Enable clang format for template plugin tests (#19942)

This commit is contained in:
Ilya Churaev 2023-09-19 18:20:30 +04:00 committed by GitHub
parent 472ad39a9d
commit b6e0706961
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
220 changed files with 41970 additions and 34041 deletions

View File

@ -20,7 +20,7 @@ ov_add_test_target(
INCLUDES
"${TEMPLATE_PLUGIN_SOURCE_DIR}/include"
"${CMAKE_CURRENT_SOURCE_DIR}/op_reference"
# ADD_CPPLINT
ADD_CLANG_FORMAT
LABELS
TEMPLATE
)

View File

@ -3,10 +3,10 @@
//
#include "functional_test_utils/core_config.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
void CoreConfiguration(LayerTestsUtils::LayerTestsCommon* test) {
}
void CoreConfiguration(LayerTestsUtils::LayerTestsCommon* test) {}
namespace ov {
namespace test {

View File

@ -2,10 +2,12 @@
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
#include "openvino/op/abs.hpp"
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
using namespace ov;
using namespace reference_tests;
@ -50,8 +52,8 @@ public:
private:
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape,
const element::Type& input_type,
const element::Type& expected_output_type) {
const element::Type& input_type,
const element::Type& expected_output_type) {
const auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
const auto log = std::make_shared<op::v0::Abs>(in);
return std::make_shared<Model>(NodeVector{log}, ParameterVector{in});
@ -66,12 +68,10 @@ template <element::Type_t IN_ET>
std::vector<AbsParams> generateParamsForAbsFloat() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<AbsParams> params{
AbsParams(ov::PartialShape{4},
IN_ET,
std::vector<T>{1.f, -2.f, 0.f, -4.75f},
std::vector<T>{1.f, 2.f, 0.f, 4.75f})
};
std::vector<AbsParams> params{AbsParams(ov::PartialShape{4},
IN_ET,
std::vector<T>{1.f, -2.f, 0.f, -4.75f},
std::vector<T>{1.f, 2.f, 0.f, 4.75f})};
return params;
}
@ -80,11 +80,7 @@ std::vector<AbsParams> generateParamsForAbsInt() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<AbsParams> params{
AbsParams(ov::PartialShape{4},
IN_ET,
std::vector<T>{1, -2, 0, -4},
std::vector<T>{1, 2, 0, 4})
};
AbsParams(ov::PartialShape{4}, IN_ET, std::vector<T>{1, -2, 0, -4}, std::vector<T>{1, 2, 0, 4})};
return params;
}
@ -93,24 +89,18 @@ std::vector<AbsParams> generateParamsForAbsUInt() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<AbsParams> params{
AbsParams(ov::PartialShape{4},
IN_ET,
std::vector<T>{1, 2, 0, 4},
std::vector<T>{1, 2, 0, 4})
};
AbsParams(ov::PartialShape{4}, IN_ET, std::vector<T>{1, 2, 0, 4}, std::vector<T>{1, 2, 0, 4})};
return params;
}
std::vector<AbsParams> generateCombinedParamsForAbs() {
const std::vector<std::vector<AbsParams>> allTypeParams{
generateParamsForAbsFloat<element::Type_t::f32>(),
generateParamsForAbsFloat<element::Type_t::f16>(),
generateParamsForAbsFloat<element::Type_t::bf16>(),
generateParamsForAbsInt<element::Type_t::i64>(),
generateParamsForAbsInt<element::Type_t::i32>(),
generateParamsForAbsUInt<element::Type_t::u64>(),
generateParamsForAbsUInt<element::Type_t::u32>()
};
const std::vector<std::vector<AbsParams>> allTypeParams{generateParamsForAbsFloat<element::Type_t::f32>(),
generateParamsForAbsFloat<element::Type_t::f16>(),
generateParamsForAbsFloat<element::Type_t::bf16>(),
generateParamsForAbsInt<element::Type_t::i64>(),
generateParamsForAbsInt<element::Type_t::i32>(),
generateParamsForAbsUInt<element::Type_t::u64>(),
generateParamsForAbsUInt<element::Type_t::u32>()};
std::vector<AbsParams> combinedParams;
@ -121,10 +111,9 @@ std::vector<AbsParams> generateCombinedParamsForAbs() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(
smoke_Abs_With_Hardcoded_Refs,
ReferenceAbsLayerTest,
::testing::ValuesIn(generateCombinedParamsForAbs()),
ReferenceAbsLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Abs_With_Hardcoded_Refs,
ReferenceAbsLayerTest,
::testing::ValuesIn(generateCombinedParamsForAbs()),
ReferenceAbsLayerTest::getTestCaseName);
} // namespace

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/acos.hpp"
#include <gtest/gtest.h>
#include "openvino/op/acos.hpp"
#include "base_reference_test.hpp"
using namespace ov;
@ -42,7 +43,7 @@ private:
static std::shared_ptr<Model> CreateFunction(const Shape& shape, const element::Type& type) {
const auto in = std::make_shared<op::v0::Parameter>(type, shape);
const auto acos = std::make_shared<op::v0::Acos>(in);
return std::make_shared<Model>(NodeVector {acos}, ParameterVector {in});
return std::make_shared<Model>(NodeVector{acos}, ParameterVector{in});
}
};
@ -53,30 +54,55 @@ TEST_P(ReferenceAcosLayerTest, AcosWithHardcodedRefs) {
} // namespace
INSTANTIATE_TEST_SUITE_P(
smoke_Acos_With_Hardcoded_Refs, ReferenceAcosLayerTest,
::testing::Values(Builder {}
.input({{11}, element::f16, std::vector<ov::float16> {-1.f, -0.75f, -0.5f, -0.25f, -0.125f,
0.f, 0.125f, 0.25f, 0.5f, 0.75f, 1.f}})
.expected({{11}, element::f16, std::vector<ov::float16> {3.14159265f, 2.41885841f, 2.09439510f, 1.82347658f, 1.69612416f,
1.57079633f, 1.44546850f, 1.31811607f, 1.04719755f, 0.72273425f,
0.00000000f}}),
Builder {}
.input({{11}, element::f32, std::vector<float> {-1.f, -0.75f, -0.5f, -0.25f, -0.125f,
0.f, 0.125f, 0.25f, 0.5f, 0.75f, 1.f}})
.expected({{11}, element::f32, std::vector<float> {3.14159265f, 2.41885841f, 2.09439510f, 1.82347658f, 1.69612416f,
1.57079633f, 1.44546850f, 1.31811607f, 1.04719755f, 0.72273425f,
0.00000000f}}),
Builder {}
.input({{3}, element::i32, std::vector<int32_t> {-1, 0, 1}})
.expected({{3}, element::i32, std::vector<int32_t> {3, 2, 0}}),
Builder {}
.input({{3}, element::i64, std::vector<int64_t> {-1, 0, 1}})
.expected({{3}, element::i64, std::vector<int64_t> {3, 2, 0}}),
Builder {}
.input({{2}, element::u32, std::vector<uint32_t> {0, 1}})
.expected({{2}, element::u32, std::vector<uint32_t> {2, 0}}),
Builder {}
.input({{2}, element::u64, std::vector<uint64_t> {0, 1}})
.expected({{2}, element::u64, std::vector<uint64_t> {2, 0}})),
smoke_Acos_With_Hardcoded_Refs,
ReferenceAcosLayerTest,
::testing::Values(
Builder{}
.input(
{{11},
element::f16,
std::vector<ov::float16>{-1.f, -0.75f, -0.5f, -0.25f, -0.125f, 0.f, 0.125f, 0.25f, 0.5f, 0.75f, 1.f}})
.expected({{11},
element::f16,
std::vector<ov::float16>{3.14159265f,
2.41885841f,
2.09439510f,
1.82347658f,
1.69612416f,
1.57079633f,
1.44546850f,
1.31811607f,
1.04719755f,
0.72273425f,
0.00000000f}}),
Builder{}
.input({{11},
element::f32,
std::vector<float>{-1.f, -0.75f, -0.5f, -0.25f, -0.125f, 0.f, 0.125f, 0.25f, 0.5f, 0.75f, 1.f}})
.expected({{11},
element::f32,
std::vector<float>{3.14159265f,
2.41885841f,
2.09439510f,
1.82347658f,
1.69612416f,
1.57079633f,
1.44546850f,
1.31811607f,
1.04719755f,
0.72273425f,
0.00000000f}}),
Builder{}
.input({{3}, element::i32, std::vector<int32_t>{-1, 0, 1}})
.expected({{3}, element::i32, std::vector<int32_t>{3, 2, 0}}),
Builder{}
.input({{3}, element::i64, std::vector<int64_t>{-1, 0, 1}})
.expected({{3}, element::i64, std::vector<int64_t>{3, 2, 0}}),
Builder{}
.input({{2}, element::u32, std::vector<uint32_t>{0, 1}})
.expected({{2}, element::u32, std::vector<uint32_t>{2, 0}}),
Builder{}
.input({{2}, element::u64, std::vector<uint64_t>{0, 1}})
.expected({{2}, element::u64, std::vector<uint64_t>{2, 0}})),
ReferenceAcosLayerTest::getTestCaseName);
} // namespace reference_tests

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/acosh.hpp"
#include <gtest/gtest.h>
#include "openvino/op/acosh.hpp"
#include "base_reference_test.hpp"
using namespace ov;
@ -42,7 +43,7 @@ private:
static std::shared_ptr<Model> CreateFunction(const Shape& shape, const element::Type& type) {
const auto in = std::make_shared<op::v0::Parameter>(type, shape);
const auto acosh = std::make_shared<op::v3::Acosh>(in);
return std::make_shared<ov::Model>(NodeVector {acosh}, ParameterVector {in});
return std::make_shared<ov::Model>(NodeVector{acosh}, ParameterVector{in});
}
};
@ -53,24 +54,27 @@ TEST_P(ReferenceAcoshLayerTest, AcoshWithHardcodedRefs) {
} // namespace
INSTANTIATE_TEST_SUITE_P(
smoke_Acosh_With_Hardcoded_Refs, ReferenceAcoshLayerTest,
::testing::Values(Builder {}
.input({{8}, element::f16, std::vector<ov::float16> {1.f, 2.f, 3.f, 4.f, 5.f, 10.f, 100.f, 1000.f}})
.expected({{8}, element::f16, std::vector<ov::float16> {0., 1.317, 1.763, 2.063, 2.292, 2.993, 5.298, 7.6012}}),
Builder {}
.input({{8}, element::f32, std::vector<float> {1.f, 2.f, 3.f, 4.f, 5.f, 10.f, 100.f, 1000.f}})
.expected({{8}, element::f32, std::vector<float> {0., 1.317, 1.763, 2.063, 2.292, 2.993, 5.298, 7.6012}}),
Builder {}
.input({{8}, element::i32, std::vector<int32_t> {1, 2, 3, 4, 5, 10, 100, 1000}})
.expected({{8}, element::i32, std::vector<int32_t> {0, 1, 2, 2, 2, 3, 5, 8}}),
Builder {}
.input({{8}, element::i64, std::vector<int64_t> {1, 2, 3, 4, 5, 10, 100, 1000}})
.expected({{8}, element::i64, std::vector<int64_t> {0, 1, 2, 2, 2, 3, 5, 8}}),
Builder {}
.input({{8}, element::u32, std::vector<uint32_t> {1, 2, 3, 4, 5, 10, 100, 1000}})
.expected({{8}, element::u32, std::vector<uint32_t> {0, 1, 2, 2, 2, 3, 5, 8}}),
Builder {}
.input({{8}, element::u64, std::vector<uint64_t> {1, 2, 3, 4, 5, 10, 100, 1000}})
.expected({{8}, element::u64, std::vector<uint64_t> {0, 1, 2, 2, 2, 3, 5, 8}})),
smoke_Acosh_With_Hardcoded_Refs,
ReferenceAcoshLayerTest,
::testing::Values(
Builder{}
.input({{8}, element::f16, std::vector<ov::float16>{1.f, 2.f, 3.f, 4.f, 5.f, 10.f, 100.f, 1000.f}})
.expected(
{{8}, element::f16, std::vector<ov::float16>{0., 1.317, 1.763, 2.063, 2.292, 2.993, 5.298, 7.6012}}),
Builder{}
.input({{8}, element::f32, std::vector<float>{1.f, 2.f, 3.f, 4.f, 5.f, 10.f, 100.f, 1000.f}})
.expected({{8}, element::f32, std::vector<float>{0., 1.317, 1.763, 2.063, 2.292, 2.993, 5.298, 7.6012}}),
Builder{}
.input({{8}, element::i32, std::vector<int32_t>{1, 2, 3, 4, 5, 10, 100, 1000}})
.expected({{8}, element::i32, std::vector<int32_t>{0, 1, 2, 2, 2, 3, 5, 8}}),
Builder{}
.input({{8}, element::i64, std::vector<int64_t>{1, 2, 3, 4, 5, 10, 100, 1000}})
.expected({{8}, element::i64, std::vector<int64_t>{0, 1, 2, 2, 2, 3, 5, 8}}),
Builder{}
.input({{8}, element::u32, std::vector<uint32_t>{1, 2, 3, 4, 5, 10, 100, 1000}})
.expected({{8}, element::u32, std::vector<uint32_t>{0, 1, 2, 2, 2, 3, 5, 8}}),
Builder{}
.input({{8}, element::u64, std::vector<uint64_t>{1, 2, 3, 4, 5, 10, 100, 1000}})
.expected({{8}, element::u64, std::vector<uint64_t>{0, 1, 2, 2, 2, 3, 5, 8}})),
ReferenceAcoshLayerTest::getTestCaseName);
} // namespace reference_tests

View File

@ -2,10 +2,11 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/adaptive_avg_pool.hpp"
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
#include "openvino/op/adaptive_avg_pool.hpp"
#include "openvino/op/constant.hpp"
using namespace ov;
@ -41,7 +42,8 @@ struct AdaptiveAvgPoolParams {
std::vector<int64_t> m_adaptive_values;
};
class ReferenceAdaptiveAvgPoolLayerTest : public testing::TestWithParam<AdaptiveAvgPoolParams>, public CommonReferenceTest {
class ReferenceAdaptiveAvgPoolLayerTest : public testing::TestWithParam<AdaptiveAvgPoolParams>,
public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
@ -65,9 +67,9 @@ public:
private:
static std::shared_ptr<Model> CreateFunction(const Shape& input_shape,
const element::Type& input_type,
const Shape& adaptive_shape,
const std::vector<int64_t> adaptive_values) {
const element::Type& input_type,
const Shape& adaptive_shape,
const std::vector<int64_t> adaptive_values) {
const auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
const auto out = op::v0::Constant::create<int64_t>(element::Type_t::i64, adaptive_shape, adaptive_values);
const auto adaptive_avg_pool = std::make_shared<op::v8::AdaptiveAvgPool>(in, out);
@ -84,49 +86,51 @@ std::vector<AdaptiveAvgPoolParams> generateParamsForAdaptiveAvgPool() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<AdaptiveAvgPoolParams> params{
AdaptiveAvgPoolParams(ov::Shape{2, 3, 7},
ov::Shape{2, 3, 3},
IN_ET,
IN_ET,
std::vector<T>{0, 4, 1, 3, -2, -5, -2, -2, 1, -3, 1, -3, -4, 0, -2, 1, -1, -2, 3, -1, -3,
-1, -2, 3, 4, -3, -4, 1, 2, 0, -4, -5, -2, -2, -3, 2, 3, 1, -5, 2, -4, -2},
std::vector<T>{1.66666663,
0.66666669,
-3.,
-1.33333337,
-1.66666663,
-2.33333325,
-0.66666669,
0.,
-0.33333334,
AdaptiveAvgPoolParams(
ov::Shape{2, 3, 7},
ov::Shape{2, 3, 3},
IN_ET,
IN_ET,
std::vector<T>{0, 4, 1, 3, -2, -5, -2, -2, 1, -3, 1, -3, -4, 0, -2, 1, -1, -2, 3, -1, -3,
-1, -2, 3, 4, -3, -4, 1, 2, 0, -4, -5, -2, -2, -3, 2, 3, 1, -5, 2, -4, -2},
std::vector<T>{1.66666663,
0.66666669,
-3.,
-1.33333337,
-1.66666663,
-2.33333325,
-0.66666669,
0.,
-0.33333334,
0.,
1.33333337,
-2.,
-0.66666669,
-3.66666675,
-2.33333325,
2.,
-0.66666669,
-1.33333337},
ov::Shape{1},
{3}),
0.,
1.33333337,
-2.,
-0.66666669,
-3.66666675,
-2.33333325,
2.,
-0.66666669,
-1.33333337},
ov::Shape{1},
{3}),
AdaptiveAvgPoolParams(
ov::Shape{1, 3, 7, 10},
ov::Shape{1, 3, 3, 3},
IN_ET,
IN_ET,
std::vector<T>{-2, -3, -4, 3, -5, 4, 0, -4, -2, -4, -5, 0, -3, 0, -2, 0, 0, -5, -4, -1, 3, -1, 0, -1,
0, -2, 0, 4, 1, 4, 0, -1, -4, 2, -2, -5, -1, -1, -2, 1, 2, -2, -1, 2, 0, -1, 0, -5,
4, 4, 3, 0, -4, -4, -4, -2, 0, 1, -2, -1, 4, -2, -4, 1, -1, -3, -4, -1, 1, -4,
std::vector<T>{
-2, -3, -4, 3, -5, 4, 0, -4, -2, -4, -5, 0, -3, 0, -2, 0, 0, -5, -4, -1, 3, -1, 0, -1,
0, -2, 0, 4, 1, 4, 0, -1, -4, 2, -2, -5, -1, -1, -2, 1, 2, -2, -1, 2, 0, -1, 0, -5,
4, 4, 3, 0, -4, -4, -4, -2, 0, 1, -2, -1, 4, -2, -4, 1, -1, -3, -4, -1, 1, -4,
-2, -4, -5, 0, -4, 3, 4, -5, -4, -2, 0, 2, -4, -3, 3, -1, 1, -4, -5, 4, 2, -5, 2, -3,
0, 4, 3, 3, 1, 2, -1, -4, 1, -3, -3, -2, 3, 4, -2, -5, 1, 4, 4, -2, 2, 1, -5, -2,
-5, 1, 1, -2, -3, -3, -1, -5, 1, -3, -5, -3, -4, -1, 4, -3, 4, -1, 4, 3, 1, 4,
-2, -4, -5, 0, -4, 3, 4, -5, -4, -2, 0, 2, -4, -3, 3, -1, 1, -4, -5, 4, 2, -5, 2, -3,
0, 4, 3, 3, 1, 2, -1, -4, 1, -3, -3, -2, 3, 4, -2, -5, 1, 4, 4, -2, 2, 1, -5, -2,
-5, 1, 1, -2, -3, -3, -1, -5, 1, -3, -5, -3, -4, -1, 4, -3, 4, -1, 4, 3, 1, 4,
-2, -4, -4, 4, -3, 4, 2, -3, -2, 4, -3, 0, 1, -4, 4, 4, 0, 3, -1, 3, 3, -5, 0, 3,
-3, 1, -2, 4, -5, -5, 1, 0, -1, 0, -3, -2, 0, -3, 3, -2, -2, 0, -3, 4, -1, 2, -2, 2,
-3, -1, -4, -2, 0, 2, 0, 2, 0, -3, 4, 3, -5, -3, -5, 1, -5, -3, -5, 4, -3, 3},
-2, -4, -4, 4, -3, 4, 2, -3, -2, 4, -3, 0, 1, -4, 4, 4, 0, 3, -1, 3, 3, -5, 0, 3,
-3, 1, -2, 4, -5, -5, 1, 0, -1, 0, -3, -2, 0, -3, 3, -2, -2, 0, -3, 4, -1, 2, -2, 2,
-3, -1, -4, -2, 0, 2, 0, 2, 0, -3, 4, 3, -5, -3, -5, 1, -5, -3, -5, 4, -3, 3},
std::vector<T>{-1.08333337, -0.25000000, -0.91666669, -0.08333334, -0.66666669,
0.75000000, -0.41666666, -1.33333337, -0.58333331,
@ -142,14 +146,14 @@ std::vector<AdaptiveAvgPoolParams> generateParamsForAdaptiveAvgPool() {
ov::Shape{2, 2, 2, 2, 2},
IN_ET,
IN_ET,
std::vector<T>{-5, 1, -3, -4, 4, -4, 3, -3, -1, 0, 0, -2, -4, 2, 0, -4, -5, -2, -4, -4, 0, -2, 3, -3, 4, -1, -4,
-1, -1, -5, 4, -1, -2, -3, 0, 4, -1, -5, -4, 1, 1, 4, -5, -5, -5, 4, -3, -3, -3, 4, 0, -3, -5, 1,
4, 2, 1, -5, -5, 1, 0, -4, -1, 2, -4, -2, 4, 3, 1, -3, -3, -2, -4, -3, -3, 3, -1, 1, 2, 2, -4,
-5, -4, 1, 3, -4, -1, 2, 4, -5, 0, 1, -2, 0, 0, -2, 3, -2, -5, -3, -5, -2, -1, 3, -2, 4, 3, -3},
std::vector<T>{-0.750, -0.250, -1.375, -1.125, -1.125, -0.500, -0.875, -1.250,
-0.375, -1.625, -1., -0.500, -0.250, -0.750, -1.875, -0.625,
0.125, -0.375, -1.625, -1.250, 0., -1., 0.875, -0.375,
-1.125, -1.375, 0.750, -1.875, -0.625, -1.125, 1.250, -1.},
std::vector<T>{-5, 1, -3, -4, 4, -4, 3, -3, -1, 0, 0, -2, -4, 2, 0, -4, -5, -2, -4, -4, 0, -2,
3, -3, 4, -1, -4, -1, -1, -5, 4, -1, -2, -3, 0, 4, -1, -5, -4, 1, 1, 4, -5, -5,
-5, 4, -3, -3, -3, 4, 0, -3, -5, 1, 4, 2, 1, -5, -5, 1, 0, -4, -1, 2, -4, -2,
4, 3, 1, -3, -3, -2, -4, -3, -3, 3, -1, 1, 2, 2, -4, -5, -4, 1, 3, -4, -1, 2,
4, -5, 0, 1, -2, 0, 0, -2, 3, -2, -5, -3, -5, -2, -1, 3, -2, 4, 3, -3},
std::vector<T>{-0.750, -0.250, -1.375, -1.125, -1.125, -0.500, -0.875, -1.250, -0.375, -1.625, -1.,
-0.500, -0.250, -0.750, -1.875, -0.625, 0.125, -0.375, -1.625, -1.250, 0., -1.,
0.875, -0.375, -1.125, -1.375, 0.750, -1.875, -0.625, -1.125, 1.250, -1.},
ov::Shape{3},
{2, 2, 2}),
};
@ -160,8 +164,7 @@ std::vector<AdaptiveAvgPoolParams> generateCombinedParamsForAdaptiveAvgPool() {
const std::vector<std::vector<AdaptiveAvgPoolParams>> allTypeParams{
generateParamsForAdaptiveAvgPool<element::Type_t::f32>(),
generateParamsForAdaptiveAvgPool<element::Type_t::f16>(),
generateParamsForAdaptiveAvgPool<element::Type_t::bf16>()
};
generateParamsForAdaptiveAvgPool<element::Type_t::bf16>()};
std::vector<AdaptiveAvgPoolParams> combinedParams;
@ -172,10 +175,9 @@ std::vector<AdaptiveAvgPoolParams> generateCombinedParamsForAdaptiveAvgPool() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(
smoke_AdaptiveAvgPool_With_Hardcoded_Refs,
ReferenceAdaptiveAvgPoolLayerTest,
::testing::ValuesIn(generateCombinedParamsForAdaptiveAvgPool()),
ReferenceAdaptiveAvgPoolLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_AdaptiveAvgPool_With_Hardcoded_Refs,
ReferenceAdaptiveAvgPoolLayerTest,
::testing::ValuesIn(generateCombinedParamsForAdaptiveAvgPool()),
ReferenceAdaptiveAvgPoolLayerTest::getTestCaseName);
} // namespace

View File

@ -2,10 +2,11 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/adaptive_max_pool.hpp"
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
#include "openvino/op/adaptive_max_pool.hpp"
#include "openvino/op/constant.hpp"
using namespace ov;
@ -44,7 +45,8 @@ struct AdaptiveMaxPoolParams {
std::vector<int64_t> m_adaptive_values;
};
class ReferenceAdaptiveMaxPoolLayerTest : public testing::TestWithParam<AdaptiveMaxPoolParams>, public CommonReferenceTest {
class ReferenceAdaptiveMaxPoolLayerTest : public testing::TestWithParam<AdaptiveMaxPoolParams>,
public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
@ -68,9 +70,9 @@ public:
private:
static std::shared_ptr<Model> CreateFunction(const Shape& input_shape,
const element::Type& input_type,
const Shape& adaptive_shape,
const std::vector<int64_t> adaptive_values) {
const element::Type& input_type,
const Shape& adaptive_shape,
const std::vector<int64_t> adaptive_values) {
const auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
const auto out = op::v0::Constant::create<int64_t>(element::Type_t::i64, adaptive_shape, adaptive_values);
const auto adaptive_max_pool = std::make_shared<op::v8::AdaptiveMaxPool>(in, out);
@ -93,7 +95,7 @@ std::vector<AdaptiveMaxPoolParams> generateParamsForAdaptiveMaxPoolWithExpectedR
IN_ET,
IN_ET,
std::vector<T>{0, 4, 1, 3, -2, -5, -2, -2, 1, -3, 1, -3, -4, 0, -2, 1, -1, -2, 3, -1, -3,
-1, -2, 3, 4, -3, -4, 1, 2, 0, -4, -5, -2, -2, -3, 2, 3, 1, -5, 2, -4, -2},
-1, -2, 3, 4, -3, -4, 1, 2, 0, -4, -5, -2, -2, -3, 2, 3, 1, -5, 2, -4, -2},
std::vector<T>{4,
3,
-2,
@ -114,77 +116,69 @@ std::vector<AdaptiveMaxPoolParams> generateParamsForAdaptiveMaxPoolWithExpectedR
2,
2},
std::vector<int64_t>{1,
3,
4,
1,
3,
6,
1,
4,
4,
3,
4,
1,
3,
6,
1,
4,
4,
2,
3,
6,
0,
4,
4,
1,
4,
4},
ov::Shape{1},
2,
3,
6,
0,
4,
4,
1,
4,
4},
ov::Shape{1},
std::vector<int64_t>{3}),
AdaptiveMaxPoolParams(
ov::Shape{1, 3, 7, 10},
ov::Shape{1, 3, 3, 3},
IN_ET,
IN_ET,
std::vector<T>{0, -2, -5, -5, 2, 3, 2, -3, 1, -2, -4, -1, -1, -1, 2, -4, 3, -5, -1, -1, 1, 2, 4, -2,
-3, -2, 0, -5, 2, -4, -1, -4, 4, 2, 1, -2, 2, -3, 0, 1, -3, 3, -1, 4, 0, 2, 0, 3,
4, -4, 1, 4, -1, -5, -2, 4, -3, 3, 2, 1, 0, 4, 2, -5, 2, -5, -2, -1, 4, 2,
std::vector<T>{
0, -2, -5, -5, 2, 3, 2, -3, 1, -2, -4, -1, -1, -1, 2, -4, 3, -5, -1, -1, 1, 2, 4, -2,
-3, -2, 0, -5, 2, -4, -1, -4, 4, 2, 1, -2, 2, -3, 0, 1, -3, 3, -1, 4, 0, 2, 0, 3,
4, -4, 1, 4, -1, -5, -2, 4, -3, 3, 2, 1, 0, 4, 2, -5, 2, -5, -2, -1, 4, 2,
0, 4, -2, 0, -5, -3, 4, -4, -2, -2, 2, 1, 4, 3, 2, -5, -4, -4, 0, 1, 4, -4, -3, 3,
3, 4, -2, -3, -4, -2, 0, 1, -1, 3, -2, 2, 0, -3, -1, -1, 0, 0, 2, 2, -2, 1, -3, 1,
2, 4, 3, -5, -4, 1, -4, 2, 0, -2, -5, 2, -3, -2, -3, -4, 2, -2, -4, 2, -4, -3,
0, 4, -2, 0, -5, -3, 4, -4, -2, -2, 2, 1, 4, 3, 2, -5, -4, -4, 0, 1, 4, -4, -3, 3,
3, 4, -2, -3, -4, -2, 0, 1, -1, 3, -2, 2, 0, -3, -1, -1, 0, 0, 2, 2, -2, 1, -3, 1,
2, 4, 3, -5, -4, 1, -4, 2, 0, -2, -5, 2, -3, -2, -3, -4, 2, -2, -4, 2, -4, -3,
1, -5, -1, -5, 2, 1, 3, 4, 3, 0, -5, 4, -3, -4, -1, 2, -4, 2, 0, -5, -3, 0, 2, -3,
-5, 3, -2, -1, -5, -4, -5, 0, -5, -1, -3, 3, 3, -4, -3, -4, -5, 4, -1, 1, -1, -4, 1, -3,
-4, -1, -2, -3, -5, 2, 2, -5, 1, 1, -5, -4, 0, 2, 4, 2, 0, 2, 4, 0, -5, 2},
std::vector<T>{4, 3, 3, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 3, 2, 4,
4, 3, 4, 4, 3, 3, 4, 4, 4},
std::vector<int64_t>{22, 5, 16, 22, 43, 48, 43, 43, 48,
1, 6, 6, 20, 25, 49, 50, 43, 49,
11, 6, 7, 41, 25, 36, 41, 66, 66},
1, -5, -1, -5, 2, 1, 3, 4, 3, 0, -5, 4, -3, -4, -1, 2, -4, 2, 0, -5, -3, 0, 2, -3,
-5, 3, -2, -1, -5, -4, -5, 0, -5, -1, -3, 3, 3, -4, -3, -4, -5, 4, -1, 1, -1, -4, 1, -3,
-4, -1, -2, -3, -5, 2, 2, -5, 1, 1, -5, -4, 0, 2, 4, 2, 0, 2, 4, 0, -5, 2},
std::vector<T>{4, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 2, 4, 4, 3, 4, 4, 3, 3, 4, 4, 4},
std::vector<int64_t>{22, 5, 16, 22, 43, 48, 43, 43, 48, 1, 6, 6, 20, 25,
49, 50, 43, 49, 11, 6, 7, 41, 25, 36, 41, 66, 66},
ov::Shape{2},
std::vector<int64_t>{3, 3}),
AdaptiveMaxPoolParams(
ov::Shape{2, 2, 3, 3, 3},
ov::Shape{2, 2, 2, 2, 2},
IN_ET,
IN_ET,
std::vector<T>{-5, 1, -3, -4, 4, -4, 3, -3, -1, 0, 0, -2, -4, 2,
0, -4, -5, -2, -4, -4, 0, -2, 3, -3, 4, -1, -4,
AdaptiveMaxPoolParams(ov::Shape{2, 2, 3, 3, 3},
ov::Shape{2, 2, 2, 2, 2},
IN_ET,
IN_ET,
std::vector<T>{-5, 1, -3, -4, 4, -4, 3, -3, -1, 0, 0, -2, -4, 2,
0, -4, -5, -2, -4, -4, 0, -2, 3, -3, 4, -1, -4,
-1, -1, -5, 4, -1, -2, -3, 0, 4, -1, -5, -4, 1, 1,
4, -5, -5, -5, 4, -3, -3, -3, 4, 0, -3, -5, 1,
-1, -1, -5, 4, -1, -2, -3, 0, 4, -1, -5, -4, 1, 1,
4, -5, -5, -5, 4, -3, -3, -3, 4, 0, -3, -5, 1,
4, 2, 1, -5, -5, 1, 0, -4, -1, 2, -4, -2, 4, 3,
1, -3, -3, -2, -4, -3, -3, 3, -1, 1, 2, 2, -4,
4, 2, 1, -5, -5, 1, 0, -4, -1, 2, -4, -2, 4, 3,
1, -3, -3, -2, -4, -3, -3, 3, -1, 1, 2, 2, -4,
-5, -4, 1, 3, -4, -1, 2, 4, -5, 0, 1, -2, 0, 0,
-2, 3, -2, -5, -3, -5, -2, -1, 3, -2, 4, 3, -3},
std::vector<T>{4, 4, 4, 4, 3, 3, 4, 3,
4, 4, 4, 4, 4, 4, 4, 4,
4, 3, 4, 3, 4, 3, 4, 3,
3, 1, 4, 4, 3, 3, 4, 3},
std::vector<int64_t>{4, 4, 4, 4, 22, 22, 24, 22,
3, 14, 3, 8, 18, 14, 22, 14,
0, 13, 12, 13, 12, 13, 12, 13,
3, 2, 7, 7, 22, 22, 24, 22},
ov::Shape{3},
std::vector<int64_t>{2, 2, 2})
};
-5, -4, 1, 3, -4, -1, 2, 4, -5, 0, 1, -2, 0, 0,
-2, 3, -2, -5, -3, -5, -2, -1, 3, -2, 4, 3, -3},
std::vector<T>{4, 4, 4, 4, 3, 3, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4,
4, 3, 4, 3, 4, 3, 4, 3, 3, 1, 4, 4, 3, 3, 4, 3},
std::vector<int64_t>{4, 4, 4, 4, 22, 22, 24, 22, 3, 14, 3, 8, 18, 14, 22, 14,
0, 13, 12, 13, 12, 13, 12, 13, 3, 2, 7, 7, 22, 22, 24, 22},
ov::Shape{3},
std::vector<int64_t>{2, 2, 2})};
return params;
}
@ -208,10 +202,9 @@ std::vector<AdaptiveMaxPoolParams> generateCombinedParamsForAdaptiveMaxPool() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(
smoke_AdaptiveMaxPool_With_Hardcoded_Refs,
ReferenceAdaptiveMaxPoolLayerTest,
::testing::ValuesIn(generateCombinedParamsForAdaptiveMaxPool()),
ReferenceAdaptiveMaxPoolLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_AdaptiveMaxPool_With_Hardcoded_Refs,
ReferenceAdaptiveMaxPoolLayerTest,
::testing::ValuesIn(generateCombinedParamsForAdaptiveMaxPool()),
ReferenceAdaptiveMaxPoolLayerTest::getTestCaseName);
} // namespace

View File

@ -2,10 +2,12 @@
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
#include "openvino/op/add.hpp"
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
using namespace ov;
using namespace reference_tests;
@ -57,9 +59,9 @@ public:
private:
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape1,
const PartialShape& input_shape2,
const element::Type& input_type,
const element::Type& expected_output_type) {
const PartialShape& input_shape2,
const element::Type& input_type,
const element::Type& expected_output_type) {
const auto in1 = std::make_shared<op::v0::Parameter>(input_type, input_shape1);
const auto in2 = std::make_shared<op::v0::Parameter>(input_type, input_shape2);
const auto add = std::make_shared<op::v1::Add>(in1, in2);
@ -88,9 +90,9 @@ public:
private:
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape1,
const PartialShape& input_shape2,
const element::Type& input_type,
const element::Type& expected_output_type) {
const PartialShape& input_shape2,
const element::Type& input_type,
const element::Type& expected_output_type) {
const auto in1 = std::make_shared<op::v0::Parameter>(input_type, input_shape1);
const auto in2 = std::make_shared<op::v0::Parameter>(input_type, input_shape2);
auto add = std::make_shared<op::v1::Add>(in1, in2);
@ -146,31 +148,27 @@ template <element::Type_t IN_ET>
std::vector<AddParams> generateParamsForAddInPlace() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<AddParams> params{
AddParams(ov::PartialShape{2, 2},
ov::PartialShape{2, 2},
IN_ET,
std::vector<T>{1, 2, 3, 4},
std::vector<T>{5, 6, 7, 8},
std::vector<T>{48, 64, 80, 96})
};
std::vector<AddParams> params{AddParams(ov::PartialShape{2, 2},
ov::PartialShape{2, 2},
IN_ET,
std::vector<T>{1, 2, 3, 4},
std::vector<T>{5, 6, 7, 8},
std::vector<T>{48, 64, 80, 96})};
return params;
}
std::vector<AddParams> generateCombinedParamsForAdd() {
const std::vector<std::vector<AddParams>> allTypeParams{
generateParamsForAdd<element::Type_t::f32>(),
generateParamsForAdd<element::Type_t::f16>(),
generateParamsForAdd<element::Type_t::bf16>(),
generateParamsForAdd<element::Type_t::i64>(),
generateParamsForAdd<element::Type_t::i32>(),
generateParamsForAdd<element::Type_t::i16>(),
generateParamsForAdd<element::Type_t::i8>(),
generateParamsForAdd<element::Type_t::u64>(),
generateParamsForAdd<element::Type_t::u32>(),
generateParamsForAdd<element::Type_t::u16>(),
generateParamsForAdd<element::Type_t::u8>()
};
const std::vector<std::vector<AddParams>> allTypeParams{generateParamsForAdd<element::Type_t::f32>(),
generateParamsForAdd<element::Type_t::f16>(),
generateParamsForAdd<element::Type_t::bf16>(),
generateParamsForAdd<element::Type_t::i64>(),
generateParamsForAdd<element::Type_t::i32>(),
generateParamsForAdd<element::Type_t::i16>(),
generateParamsForAdd<element::Type_t::i8>(),
generateParamsForAdd<element::Type_t::u64>(),
generateParamsForAdd<element::Type_t::u32>(),
generateParamsForAdd<element::Type_t::u16>(),
generateParamsForAdd<element::Type_t::u8>()};
std::vector<AddParams> combinedParams;
@ -182,19 +180,17 @@ std::vector<AddParams> generateCombinedParamsForAdd() {
}
std::vector<AddParams> generateCombinedParamsForAddInPlace() {
const std::vector<std::vector<AddParams>> allTypeParams{
generateParamsForAddInPlace<element::Type_t::f32>(),
generateParamsForAddInPlace<element::Type_t::f16>(),
generateParamsForAddInPlace<element::Type_t::bf16>(),
generateParamsForAddInPlace<element::Type_t::i64>(),
generateParamsForAddInPlace<element::Type_t::i32>(),
generateParamsForAddInPlace<element::Type_t::i16>(),
generateParamsForAddInPlace<element::Type_t::i8>(),
generateParamsForAddInPlace<element::Type_t::u64>(),
generateParamsForAddInPlace<element::Type_t::u32>(),
generateParamsForAddInPlace<element::Type_t::u16>(),
generateParamsForAddInPlace<element::Type_t::u8>()
};
const std::vector<std::vector<AddParams>> allTypeParams{generateParamsForAddInPlace<element::Type_t::f32>(),
generateParamsForAddInPlace<element::Type_t::f16>(),
generateParamsForAddInPlace<element::Type_t::bf16>(),
generateParamsForAddInPlace<element::Type_t::i64>(),
generateParamsForAddInPlace<element::Type_t::i32>(),
generateParamsForAddInPlace<element::Type_t::i16>(),
generateParamsForAddInPlace<element::Type_t::i8>(),
generateParamsForAddInPlace<element::Type_t::u64>(),
generateParamsForAddInPlace<element::Type_t::u32>(),
generateParamsForAddInPlace<element::Type_t::u16>(),
generateParamsForAddInPlace<element::Type_t::u8>()};
std::vector<AddParams> combinedParams;
@ -205,16 +201,14 @@ std::vector<AddParams> generateCombinedParamsForAddInPlace() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(
smoke_Add_With_Hardcoded_Refs,
ReferenceAddLayerTest,
::testing::ValuesIn(generateCombinedParamsForAdd()),
ReferenceAddLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Add_With_Hardcoded_Refs,
ReferenceAddLayerTest,
::testing::ValuesIn(generateCombinedParamsForAdd()),
ReferenceAddLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(
smoke_Add_In_Place_With_Hardcoded_Refs,
ReferenceAddInPlaceLayerTest,
::testing::ValuesIn(generateCombinedParamsForAddInPlace()),
ReferenceAddLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Add_In_Place_With_Hardcoded_Refs,
ReferenceAddInPlaceLayerTest,
::testing::ValuesIn(generateCombinedParamsForAddInPlace()),
ReferenceAddLayerTest::getTestCaseName);
} // namespace

View File

@ -2,11 +2,12 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/asin.hpp"
#include <gtest/gtest.h>
#include "openvino/op/asin.hpp"
#include "shared_test_classes/base/layer_test_utils.hpp"
#include "base_reference_test.hpp"
#include "shared_test_classes/base/layer_test_utils.hpp"
using namespace ov;
@ -43,7 +44,7 @@ private:
static std::shared_ptr<Model> CreateFunction(const Shape& shape, const element::Type& type) {
const auto in = std::make_shared<op::v0::Parameter>(type, shape);
const auto Asin = std::make_shared<op::v0::Asin>(in);
return std::make_shared<ov::Model>(NodeVector {Asin}, ParameterVector {in});
return std::make_shared<ov::Model>(NodeVector{Asin}, ParameterVector{in});
}
};
@ -54,46 +55,56 @@ TEST_P(ReferenceAsinLayerTest, AsinWithHardcodedRefs) {
} // namespace
INSTANTIATE_TEST_SUITE_P(
smoke_Asin_With_Hardcoded_Refs, ReferenceAsinLayerTest,
smoke_Asin_With_Hardcoded_Refs,
ReferenceAsinLayerTest,
::testing::Values(
Builder {}
.input({{11}, element::f16, std::vector<ov::float16> {-1.f, -0.75f, -0.5f, -0.25f, -0.125f, 0.f, 0.125f, 0.25f, 0.5f, 0.75f, 1.f}})
.expected({{11}, element::f16, std::vector<ov::float16> {-1.57079633f,
-0.84806208f,
-0.52359878f,
-0.25268026f,
-0.12532783f,
0.00000000f,
0.12532783f,
0.25268026f,
0.52359878f,
0.84806208f,
1.57079633f}}),
Builder {}
.input({{11}, element::f32, std::vector<float> {-1.f, -0.75f, -0.5f, -0.25f, -0.125f, 0.f, 0.125f, 0.25f, 0.5f, 0.75f, 1.f}})
.expected({{11}, element::f32, std::vector<float> {-1.57079633f,
-0.84806208f,
-0.52359878f,
-0.25268026f,
-0.12532783f,
0.00000000f,
0.12532783f,
0.25268026f,
0.52359878f,
0.84806208f,
1.57079633f}}),
Builder {}
.input({{3}, element::i32, std::vector<int32_t> {-1, 0, 1}})
.expected({{3}, element::i32, std::vector<int32_t> {-1, 0, 1}}),
Builder {}
.input({{3}, element::i64, std::vector<int64_t> {-1, 0, 1}})
.expected({{3}, element::i64, std::vector<int64_t> {-1, 0, 1}}),
Builder {}
.input({{2}, element::u32, std::vector<uint32_t> {0, 1}})
.expected({{2}, element::u32, std::vector<uint32_t> {0, 1}}),
Builder {}
.input({{2}, element::u64, std::vector<uint64_t> {0, 1}})
.expected({{2}, element::u64, std::vector<uint64_t> {0, 1}})),
Builder{}
.input(
{{11},
element::f16,
std::vector<ov::float16>{-1.f, -0.75f, -0.5f, -0.25f, -0.125f, 0.f, 0.125f, 0.25f, 0.5f, 0.75f, 1.f}})
.expected({{11},
element::f16,
std::vector<ov::float16>{-1.57079633f,
-0.84806208f,
-0.52359878f,
-0.25268026f,
-0.12532783f,
0.00000000f,
0.12532783f,
0.25268026f,
0.52359878f,
0.84806208f,
1.57079633f}}),
Builder{}
.input({{11},
element::f32,
std::vector<float>{-1.f, -0.75f, -0.5f, -0.25f, -0.125f, 0.f, 0.125f, 0.25f, 0.5f, 0.75f, 1.f}})
.expected({{11},
element::f32,
std::vector<float>{-1.57079633f,
-0.84806208f,
-0.52359878f,
-0.25268026f,
-0.12532783f,
0.00000000f,
0.12532783f,
0.25268026f,
0.52359878f,
0.84806208f,
1.57079633f}}),
Builder{}
.input({{3}, element::i32, std::vector<int32_t>{-1, 0, 1}})
.expected({{3}, element::i32, std::vector<int32_t>{-1, 0, 1}}),
Builder{}
.input({{3}, element::i64, std::vector<int64_t>{-1, 0, 1}})
.expected({{3}, element::i64, std::vector<int64_t>{-1, 0, 1}}),
Builder{}
.input({{2}, element::u32, std::vector<uint32_t>{0, 1}})
.expected({{2}, element::u32, std::vector<uint32_t>{0, 1}}),
Builder{}
.input({{2}, element::u64, std::vector<uint64_t>{0, 1}})
.expected({{2}, element::u64, std::vector<uint64_t>{0, 1}})),
ReferenceAsinLayerTest::getTestCaseName);
} // namespace reference_tests

View File

@ -2,11 +2,12 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/asinh.hpp"
#include <gtest/gtest.h>
#include "openvino/op/asinh.hpp"
#include "shared_test_classes/base/layer_test_utils.hpp"
#include "base_reference_test.hpp"
#include "shared_test_classes/base/layer_test_utils.hpp"
using namespace ov;
@ -43,7 +44,7 @@ private:
static std::shared_ptr<Model> CreateFunction(const Shape& shape, const element::Type& type) {
const auto in = std::make_shared<op::v0::Parameter>(type, shape);
const auto Asinh = std::make_shared<op::v3::Asinh>(in);
return std::make_shared<ov::Model>(NodeVector {Asinh}, ParameterVector {in});
return std::make_shared<ov::Model>(NodeVector{Asinh}, ParameterVector{in});
}
};
@ -54,46 +55,54 @@ TEST_P(ReferenceAsinhLayerTest, AsinhWithHardcodedRefs) {
} // namespace
INSTANTIATE_TEST_SUITE_P(
smoke_Asinh_With_Hardcoded_Refs, ReferenceAsinhLayerTest,
smoke_Asinh_With_Hardcoded_Refs,
ReferenceAsinhLayerTest,
::testing::Values(
Builder {}
.input({{11}, element::f16, std::vector<ov::float16> {0.f, 1.f, -1.f, 2.f, -2.f, 3.f, -3.f, 4.f, 5.f, 10.f, 100.f}})
.expected({{11}, element::f16, std::vector<ov::float16> {0.00000000f,
0.88137359f,
-0.88137359f,
1.44363548f,
-1.44363548f,
1.81844646f,
-1.81844646f,
2.09471255f,
2.31243834f,
2.99822295f,
5.29834237f}}),
Builder {}
.input({{11}, element::f32, std::vector<float> {0.f, 1.f, -1.f, 2.f, -2.f, 3.f, -3.f, 4.f, 5.f, 10.f, 100.f}})
.expected({{11}, element::f32, std::vector<float> {0.00000000f,
0.88137359f,
-0.88137359f,
1.44363548f,
-1.44363548f,
1.81844646f,
-1.81844646f,
2.09471255f,
2.31243834f,
2.99822295f,
5.29834237f}}),
Builder {}
.input({{11}, element::i32, std::vector<int32_t> {-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5}})
.expected({{11}, element::i32, std::vector<int32_t> {-2, -2, -2, -1, -1, 0, 1, 1, 2, 2, 2}}),
Builder {}
.input({{11}, element::i64, std::vector<int64_t> {-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5}})
.expected({{11}, element::i64, std::vector<int64_t> {-2, -2, -2, -1, -1, 0, 1, 1, 2, 2, 2}}),
Builder {}
.input({{6}, element::u32, std::vector<uint32_t> {0, 1, 2, 3, 4, 5}})
.expected({{6}, element::u32, std::vector<uint32_t> {0, 1, 1, 2, 2, 2}}),
Builder {}
.input({{6}, element::u64, std::vector<uint64_t> {0, 1, 2, 3, 4, 5}})
.expected({{6}, element::u64, std::vector<uint64_t> {0, 1, 1, 2, 2, 2}})),
Builder{}
.input({{11},
element::f16,
std::vector<ov::float16>{0.f, 1.f, -1.f, 2.f, -2.f, 3.f, -3.f, 4.f, 5.f, 10.f, 100.f}})
.expected({{11},
element::f16,
std::vector<ov::float16>{0.00000000f,
0.88137359f,
-0.88137359f,
1.44363548f,
-1.44363548f,
1.81844646f,
-1.81844646f,
2.09471255f,
2.31243834f,
2.99822295f,
5.29834237f}}),
Builder{}
.input(
{{11}, element::f32, std::vector<float>{0.f, 1.f, -1.f, 2.f, -2.f, 3.f, -3.f, 4.f, 5.f, 10.f, 100.f}})
.expected({{11},
element::f32,
std::vector<float>{0.00000000f,
0.88137359f,
-0.88137359f,
1.44363548f,
-1.44363548f,
1.81844646f,
-1.81844646f,
2.09471255f,
2.31243834f,
2.99822295f,
5.29834237f}}),
Builder{}
.input({{11}, element::i32, std::vector<int32_t>{-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5}})
.expected({{11}, element::i32, std::vector<int32_t>{-2, -2, -2, -1, -1, 0, 1, 1, 2, 2, 2}}),
Builder{}
.input({{11}, element::i64, std::vector<int64_t>{-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5}})
.expected({{11}, element::i64, std::vector<int64_t>{-2, -2, -2, -1, -1, 0, 1, 1, 2, 2, 2}}),
Builder{}
.input({{6}, element::u32, std::vector<uint32_t>{0, 1, 2, 3, 4, 5}})
.expected({{6}, element::u32, std::vector<uint32_t>{0, 1, 1, 2, 2, 2}}),
Builder{}
.input({{6}, element::u64, std::vector<uint64_t>{0, 1, 2, 3, 4, 5}})
.expected({{6}, element::u64, std::vector<uint64_t>{0, 1, 1, 2, 2, 2}})),
ReferenceAsinhLayerTest::getTestCaseName);
} // namespace reference_tests

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/atan.hpp"
#include <gtest/gtest.h>
#include "openvino/op/atan.hpp"
#include "base_reference_test.hpp"
using namespace ov;
@ -53,34 +54,43 @@ TEST_P(ReferenceAtanLayerTest, AtanWithHardcodedRefs) {
} // namespace
INSTANTIATE_TEST_SUITE_P(
smoke_Atan_With_Hardcoded_Refs, ReferenceAtanLayerTest,
smoke_Atan_With_Hardcoded_Refs,
ReferenceAtanLayerTest,
::testing::Values(
Builder{}
.input({{11}, element::f16, std::vector<ov::float16>{-4.f, -2.f, -1.f, -0.5f, -0.25f, 0.f, 0.25f, 0.5f, 1.f, 2.f, 4.f}})
.expected({{11}, element::f16, std::vector<ov::float16>{-1.32581766f,
-1.10714872f,
-0.78539816f,
-0.46364761f,
-0.24497866f,
0.00000000f,
0.24497866f,
0.46364761f,
0.78539816f,
1.10714872f,
1.32581766f}}),
.input({{11},
element::f16,
std::vector<ov::float16>{-4.f, -2.f, -1.f, -0.5f, -0.25f, 0.f, 0.25f, 0.5f, 1.f, 2.f, 4.f}})
.expected({{11},
element::f16,
std::vector<ov::float16>{-1.32581766f,
-1.10714872f,
-0.78539816f,
-0.46364761f,
-0.24497866f,
0.00000000f,
0.24497866f,
0.46364761f,
0.78539816f,
1.10714872f,
1.32581766f}}),
Builder{}
.input({{11}, element::f32, std::vector<float>{-4.f, -2.f, -1.f, -0.5f, -0.25f, 0.f, 0.25f, 0.5f, 1.f, 2.f, 4.f}})
.expected({{11}, element::f32, std::vector<float>{-1.32581766f,
-1.10714872f,
-0.78539816f,
-0.46364761f,
-0.24497866f,
0.00000000f,
0.24497866f,
0.46364761f,
0.78539816f,
1.10714872f,
1.32581766f}}),
.input({{11},
element::f32,
std::vector<float>{-4.f, -2.f, -1.f, -0.5f, -0.25f, 0.f, 0.25f, 0.5f, 1.f, 2.f, 4.f}})
.expected({{11},
element::f32,
std::vector<float>{-1.32581766f,
-1.10714872f,
-0.78539816f,
-0.46364761f,
-0.24497866f,
0.00000000f,
0.24497866f,
0.46364761f,
0.78539816f,
1.10714872f,
1.32581766f}}),
Builder{}
.input({{5}, element::i32, std::vector<int32_t>{-2, -1, 0, 1, 2}})
.expected({{5}, element::i32, std::vector<int32_t>{-1, -1, 0, 1, 1}}),

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "ov_ops/augru_cell.hpp"
#include <gtest/gtest.h>
#include "ov_ops/augru_cell.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
@ -12,12 +13,30 @@ using namespace ov;
namespace {
struct AUGRUCellParams {
AUGRUCellParams(
const int32_t batchSize, const int32_t inputSize, const int32_t hiddenSize, const int32_t gatesCount,
const reference_tests::Tensor& X, const reference_tests::Tensor& H_t, const reference_tests::Tensor& W, const reference_tests::Tensor& R, const reference_tests::Tensor& B, const reference_tests::Tensor& A,
const reference_tests::Tensor& Ho, const std::string& testcaseName = "") :
batchSize(batchSize), inputSize(inputSize), hiddenSize(hiddenSize), gatesCount(gatesCount),
X(X), H_t(H_t), W(W), R(R), B(B), A(A), Ho(Ho), testcaseName(testcaseName) {}
AUGRUCellParams(const int32_t batchSize,
const int32_t inputSize,
const int32_t hiddenSize,
const int32_t gatesCount,
const reference_tests::Tensor& X,
const reference_tests::Tensor& H_t,
const reference_tests::Tensor& W,
const reference_tests::Tensor& R,
const reference_tests::Tensor& B,
const reference_tests::Tensor& A,
const reference_tests::Tensor& Ho,
const std::string& testcaseName = "")
: batchSize(batchSize),
inputSize(inputSize),
hiddenSize(hiddenSize),
gatesCount(gatesCount),
X(X),
H_t(H_t),
W(W),
R(R),
B(B),
A(A),
Ho(Ho),
testcaseName(testcaseName) {}
int32_t batchSize;
int32_t inputSize;
@ -76,13 +95,7 @@ private:
const auto B = std::make_shared<op::v0::Parameter>(params.B.type, params.B.shape);
const auto A = std::make_shared<op::v0::Parameter>(params.A.type, params.A.shape);
const auto augru_cell = std::make_shared<ov::op::internal::AUGRUCell>(X,
H_t,
W,
R,
B,
A,
params.hiddenSize);
const auto augru_cell = std::make_shared<ov::op::internal::AUGRUCell>(X, H_t, W, R, B, A, params.hiddenSize);
auto function = std::make_shared<Model>(NodeVector{augru_cell}, ParameterVector{X, H_t, W, R, B, A});
return function;
@ -96,107 +109,144 @@ TEST_P(ReferenceAUGRUCellTest, CompareWithRefs) {
template <element::Type_t ET>
std::vector<AUGRUCellParams> generateParams() {
using T = typename element_type_traits<ET>::value_type;
std::vector<AUGRUCellParams> params {
std::vector<AUGRUCellParams> params{
AUGRUCellParams(
2, 3, 3, 3,
reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.52421564f, 0.78845507f, 0.9372873f, 0.59783894f, 0.18278378f, 0.2084126f}),
reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.45738035f, 0.996877f, 0.82882977f, 0.47492632f, 0.88471466f, 0.57833236f}),
reference_tests::Tensor(ET, {3 * 3, 3}, std::vector<T>{
0.5815369f, 0.16559383f, 0.08464007f, 0.843122f, 0.73968244f, 0.11359601f,
0.8295078f, 0.9240567f, 0.10007995f, 0.20573162f, 0.09002485f, 0.2839569f,
0.3096991f, 0.5638341f, 0.5787327f, 0.84552664f, 0.16263747f, 0.7243242f,
0.8049057f, 0.43966424f, 0.46294412f, 0.9833361f, 0.31369713f, 0.1719934f,
0.4937093f, 0.6353004f, 0.77982515f}),
reference_tests::Tensor(ET, {3 * 3, 3}, std::vector<T>{
0.16510165f, 0.52435565f, 0.2788478f, 0.99427545f, 0.1623331f, 0.01389796f,
0.99669236f, 0.53901845f, 0.8737506f, 0.9254788f, 0.21172932f, 0.11634306f,
0.40111724f, 0.37497616f, 0.2903471f, 0.6796794f, 0.65131867f, 0.78163475f,
0.12058706f, 0.45591718f, 0.791677f, 0.76497287f, 0.9895242f, 0.7845312f,
0.51267904f, 0.49030215f, 0.08498167f}),
reference_tests::Tensor(ET, {3 * 3}, std::vector<T>{
0.8286678f + 0.9175602f,
0.9153158f + 0.14958014f,
0.9581612f + 0.49230585f,
0.6639213f + 0.63162816f,
0.84239805f + 0.4161903f,
0.5282445f + 0.22148274f,
0.14153397f + 0.50496656f,
0.22404431f + 0.34798595f,
0.6549655f + 0.6699164f}),
2,
3,
3,
3,
reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.52421564f, 0.78845507f, 0.9372873f, 0.59783894f, 0.18278378f, 0.2084126f}),
reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.45738035f, 0.996877f, 0.82882977f, 0.47492632f, 0.88471466f, 0.57833236f}),
reference_tests::Tensor(
ET,
{3 * 3, 3},
std::vector<T>{0.5815369f, 0.16559383f, 0.08464007f, 0.843122f, 0.73968244f, 0.11359601f, 0.8295078f,
0.9240567f, 0.10007995f, 0.20573162f, 0.09002485f, 0.2839569f, 0.3096991f, 0.5638341f,
0.5787327f, 0.84552664f, 0.16263747f, 0.7243242f, 0.8049057f, 0.43966424f, 0.46294412f,
0.9833361f, 0.31369713f, 0.1719934f, 0.4937093f, 0.6353004f, 0.77982515f}),
reference_tests::Tensor(ET, {3 * 3, 3}, std::vector<T>{0.16510165f, 0.52435565f, 0.2788478f, 0.99427545f,
0.1623331f, 0.01389796f, 0.99669236f, 0.53901845f,
0.8737506f, 0.9254788f, 0.21172932f, 0.11634306f,
0.40111724f, 0.37497616f, 0.2903471f, 0.6796794f,
0.65131867f, 0.78163475f, 0.12058706f, 0.45591718f,
0.791677f, 0.76497287f, 0.9895242f, 0.7845312f,
0.51267904f, 0.49030215f, 0.08498167f}),
reference_tests::Tensor(ET,
{3 * 3},
std::vector<T>{0.8286678f + 0.9175602f,
0.9153158f + 0.14958014f,
0.9581612f + 0.49230585f,
0.6639213f + 0.63162816f,
0.84239805f + 0.4161903f,
0.5282445f + 0.22148274f,
0.14153397f + 0.50496656f,
0.22404431f + 0.34798595f,
0.6549655f + 0.6699164f}),
reference_tests::Tensor(ET, {2, 1}, std::vector<T>(2, 0)),
reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.480763f, 0.996927f, 0.830836f, 0.50231f, 0.894105f, 0.58932f}),
reference_tests::Tensor(ET,
{2, 3},
std::vector<T>{0.480763f, 0.996927f, 0.830836f, 0.50231f, 0.894105f, 0.58932f}),
"augru_zero_attentional_gate"),
AUGRUCellParams(
2, 3, 3, 3,
reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.52421564f, 0.78845507f, 0.9372873f, 0.59783894f, 0.18278378f, 0.2084126f}),
reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.45738035f, 0.996877f, 0.82882977f, 0.47492632f, 0.88471466f, 0.57833236f}),
reference_tests::Tensor(ET, {3 * 3, 3}, std::vector<T>{
0.5815369f, 0.16559383f, 0.08464007f, 0.843122f, 0.73968244f, 0.11359601f,
0.8295078f, 0.9240567f, 0.10007995f, 0.20573162f, 0.09002485f, 0.2839569f,
0.3096991f, 0.5638341f, 0.5787327f, 0.84552664f, 0.16263747f, 0.7243242f,
0.8049057f, 0.43966424f, 0.46294412f, 0.9833361f, 0.31369713f, 0.1719934f,
0.4937093f, 0.6353004f, 0.77982515f}),
reference_tests::Tensor(ET, {3 * 3, 3}, std::vector<T>{
0.16510165f, 0.52435565f, 0.2788478f, 0.99427545f, 0.1623331f, 0.01389796f,
0.99669236f, 0.53901845f, 0.8737506f, 0.9254788f, 0.21172932f, 0.11634306f,
0.40111724f, 0.37497616f, 0.2903471f, 0.6796794f, 0.65131867f, 0.78163475f,
0.12058706f, 0.45591718f, 0.791677f, 0.76497287f, 0.9895242f, 0.7845312f,
0.51267904f, 0.49030215f, 0.08498167f}),
reference_tests::Tensor(ET, {3 * 3}, std::vector<T>{
0.8286678f + 0.9175602f,
0.9153158f + 0.14958014f,
0.9581612f + 0.49230585f,
0.6639213f + 0.63162816f,
0.84239805f + 0.4161903f,
0.5282445f + 0.22148274f,
0.14153397f + 0.50496656f,
0.22404431f + 0.34798595f,
0.6549655f + 0.6699164f}),
2,
3,
3,
3,
reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.52421564f, 0.78845507f, 0.9372873f, 0.59783894f, 0.18278378f, 0.2084126f}),
reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.45738035f, 0.996877f, 0.82882977f, 0.47492632f, 0.88471466f, 0.57833236f}),
reference_tests::Tensor(
ET,
{3 * 3, 3},
std::vector<T>{0.5815369f, 0.16559383f, 0.08464007f, 0.843122f, 0.73968244f, 0.11359601f, 0.8295078f,
0.9240567f, 0.10007995f, 0.20573162f, 0.09002485f, 0.2839569f, 0.3096991f, 0.5638341f,
0.5787327f, 0.84552664f, 0.16263747f, 0.7243242f, 0.8049057f, 0.43966424f, 0.46294412f,
0.9833361f, 0.31369713f, 0.1719934f, 0.4937093f, 0.6353004f, 0.77982515f}),
reference_tests::Tensor(ET, {3 * 3, 3}, std::vector<T>{0.16510165f, 0.52435565f, 0.2788478f, 0.99427545f,
0.1623331f, 0.01389796f, 0.99669236f, 0.53901845f,
0.8737506f, 0.9254788f, 0.21172932f, 0.11634306f,
0.40111724f, 0.37497616f, 0.2903471f, 0.6796794f,
0.65131867f, 0.78163475f, 0.12058706f, 0.45591718f,
0.791677f, 0.76497287f, 0.9895242f, 0.7845312f,
0.51267904f, 0.49030215f, 0.08498167f}),
reference_tests::Tensor(ET,
{3 * 3},
std::vector<T>{0.8286678f + 0.9175602f,
0.9153158f + 0.14958014f,
0.9581612f + 0.49230585f,
0.6639213f + 0.63162816f,
0.84239805f + 0.4161903f,
0.5282445f + 0.22148274f,
0.14153397f + 0.50496656f,
0.22404431f + 0.34798595f,
0.6549655f + 0.6699164f}),
reference_tests::Tensor(ET, {2, 1}, std::vector<T>{0.4f, 0.7f}),
reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.686381f, 0.997266f, 0.897868f, 0.832165f, 0.963144f, 0.868483f}),
"augru_attentional_gate_provided"),
AUGRUCellParams(
2, 3, 4, 3,
reference_tests::Tensor(ET, {1, 3}, std::vector<T>{
0.64053001f, 0.84805253f, 0.84544252f}),
reference_tests::Tensor(ET, {1, 4}, std::vector<T>{
0.43200249f, 0.08097203f, 0.68151259f, 0.09095205f}),
reference_tests::Tensor(ET, {3 * 4, 3}, std::vector<T>{
0.23187583f, 0.66675389f, 0.01945467f, 0.60630121f, 0.18400699f, 0.16003634f,
0.04636866f, 0.75745989f, 0.96562912f, 0.56330529f, 0.20863093f, 0.93179716f,
0.99211225f, 0.73087621f, 0.21175275f, 0.03808638f, 0.63130526f, 0.76965886f,
0.67656870f, 0.57886251f, 0.94375534f, 0.88943972f, 0.96256618f, 0.38204562f,
0.76424904f, 0.30076485f, 0.60250044f, 0.40778284f, 0.70017757f, 0.00410288f,
0.97978094f, 0.73106175f, 0.22250106f, 0.44011834f, 0.11434720f, 0.62128995}),
reference_tests::Tensor(ET, {3 * 4, 4}, std::vector<T>{
0.60702709f, 0.47515485f, 0.26202747f, 0.53851601f, 0.73423241f, 0.11627945f,
0.04631785f, 0.43604361f, 0.12472080f, 0.47546322f, 0.23103632f, 0.36108585f,
0.45139418f, 0.79838954f, 0.28194170f, 0.76877929f, 0.28428253f, 0.13822001f,
0.51670576f, 0.80312243f, 0.11050813f, 0.19925340f, 0.29769184f, 0.78933459f,
0.79981487f, 0.55313454f, 0.04135296f, 0.50578146f, 0.76553680f, 0.44311704f,
0.30525652f, 0.26301583f, 0.41771479f, 0.18182059f, 0.11106816f, 0.67427757f,
0.59174944f, 0.13339960f, 0.33362533f, 0.78938375f, 0.99260256f, 0.86955733f,
0.24899024f, 0.87134874f, 0.02803802f, 0.61244129f, 0.40803782f, 0.90735816f,
0.51267904f, 0.49030215f, 0.08498167f}),
reference_tests::Tensor(ET, {3 * 4}, std::vector<T>{
0.61387895f, 0.56121052f, 0.89328753f, 0.15302506f, 0.90491122f, 0.78289335f,
0.97930211f, 0.75002178f, 0.92500923f, 0.18957983f, 0.07849785f, 0.76568159f}),
reference_tests::Tensor(ET,
{2, 3},
std::vector<T>{0.686381f, 0.997266f, 0.897868f, 0.832165f, 0.963144f, 0.868483f}),
"augru_attentional_gate_provided"),
AUGRUCellParams(
2,
3,
4,
3,
reference_tests::Tensor(ET, {1, 3}, std::vector<T>{0.64053001f, 0.84805253f, 0.84544252f}),
reference_tests::Tensor(ET, {1, 4}, std::vector<T>{0.43200249f, 0.08097203f, 0.68151259f, 0.09095205f}),
reference_tests::Tensor(
ET,
{3 * 4, 3},
std::vector<T>{0.23187583f, 0.66675389f, 0.01945467f, 0.60630121f, 0.18400699f, 0.16003634f,
0.04636866f, 0.75745989f, 0.96562912f, 0.56330529f, 0.20863093f, 0.93179716f,
0.99211225f, 0.73087621f, 0.21175275f, 0.03808638f, 0.63130526f, 0.76965886f,
0.67656870f, 0.57886251f, 0.94375534f, 0.88943972f, 0.96256618f, 0.38204562f,
0.76424904f, 0.30076485f, 0.60250044f, 0.40778284f, 0.70017757f, 0.00410288f,
0.97978094f, 0.73106175f, 0.22250106f, 0.44011834f, 0.11434720f, 0.62128995}),
reference_tests::Tensor(
ET,
{3 * 4, 4},
std::vector<T>{0.60702709f, 0.47515485f, 0.26202747f, 0.53851601f, 0.73423241f, 0.11627945f,
0.04631785f, 0.43604361f, 0.12472080f, 0.47546322f, 0.23103632f, 0.36108585f,
0.45139418f, 0.79838954f, 0.28194170f, 0.76877929f, 0.28428253f, 0.13822001f,
0.51670576f, 0.80312243f, 0.11050813f, 0.19925340f, 0.29769184f, 0.78933459f,
0.79981487f, 0.55313454f, 0.04135296f, 0.50578146f, 0.76553680f, 0.44311704f,
0.30525652f, 0.26301583f, 0.41771479f, 0.18182059f, 0.11106816f, 0.67427757f,
0.59174944f, 0.13339960f, 0.33362533f, 0.78938375f, 0.99260256f, 0.86955733f,
0.24899024f, 0.87134874f, 0.02803802f, 0.61244129f, 0.40803782f, 0.90735816f,
0.51267904f, 0.49030215f, 0.08498167f}),
reference_tests::Tensor(ET,
{3 * 4},
std::vector<T>{0.61387895f,
0.56121052f,
0.89328753f,
0.15302506f,
0.90491122f,
0.78289335f,
0.97930211f,
0.75002178f,
0.92500923f,
0.18957983f,
0.07849785f,
0.76568159f}),
reference_tests::Tensor(ET, {1, 1}, std::vector<T>{0.3333f}),
reference_tests::Tensor(ET, {2, 2}, std::vector<T>{
0.666063f, 0.451451f, 0.792762f, 0.453281f}),
"augru_different_input_and_hidden_size"),
};
reference_tests::Tensor(ET, {2, 2}, std::vector<T>{0.666063f, 0.451451f, 0.792762f, 0.453281f}),
"augru_different_input_and_hidden_size"),
};
return params;
}
std::vector<AUGRUCellParams> generateCombinedParams() {
const std::vector<std::vector<AUGRUCellParams>> generatedParams {
const std::vector<std::vector<AUGRUCellParams>> generatedParams{
generateParams<element::Type_t::bf16>(),
generateParams<element::Type_t::f16>(),
generateParams<element::Type_t::f32>(),
@ -210,7 +260,9 @@ std::vector<AUGRUCellParams> generateCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_AUGRUCell_With_Hardcoded_Refs, ReferenceAUGRUCellTest,
testing::ValuesIn(generateCombinedParams()), ReferenceAUGRUCellTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_AUGRUCell_With_Hardcoded_Refs,
ReferenceAUGRUCellTest,
testing::ValuesIn(generateCombinedParams()),
ReferenceAUGRUCellTest::getTestCaseName);
} // namespace
} // namespace

View File

@ -2,10 +2,11 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/avg_pool.hpp"
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
#include "openvino/op/avg_pool.hpp"
using namespace ov;
using namespace reference_tests;
@ -15,18 +16,18 @@ namespace {
struct AvgPoolParams {
template <class IT>
AvgPoolParams(const Shape& input_shape,
const Shape& output_shape,
const element::Type& input_type,
const element::Type& ouput_type,
const std::vector<IT>& input_values,
const std::vector<IT>& output_values,
const Strides& strides,
const Shape& pads_begin,
const Shape& pads_end,
const Shape& kernel,
const bool exclude_pad,
const op::RoundingType& rounding_type,
const op::PadType& pad_type)
const Shape& output_shape,
const element::Type& input_type,
const element::Type& ouput_type,
const std::vector<IT>& input_values,
const std::vector<IT>& output_values,
const Strides& strides,
const Shape& pads_begin,
const Shape& pads_end,
const Shape& kernel,
const bool exclude_pad,
const op::RoundingType& rounding_type,
const op::PadType& pad_type)
: m_input_shape(input_shape),
m_output_shape(output_shape),
m_input_type(input_type),
@ -88,14 +89,14 @@ public:
private:
static std::shared_ptr<Model> CreateFunction(const Shape& input_shape,
const element::Type& input_type,
const Strides& strides,
const Shape& pads_begin,
const Shape& pads_end,
const Shape& kernel,
const bool exclude_pad,
const op::RoundingType rounding_type,
const op::PadType pad_type) {
const element::Type& input_type,
const Strides& strides,
const Shape& pads_begin,
const Shape& pads_end,
const Shape& kernel,
const bool exclude_pad,
const op::RoundingType rounding_type,
const op::PadType pad_type) {
const auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
const auto avgPool = std::make_shared<op::v1::AvgPool>(in,
strides,
@ -113,8 +114,8 @@ TEST_P(ReferenceAvgPoolLayerTest, AvgPoolWithHardcodedRefs) {
Exec();
}
template<typename T>
std::vector<T> getContinuousIncreasingValue(size_t elementSize, float step) {
template <typename T>
std::vector<T> getContinuousIncreasingValue(size_t elementSize, float step) {
std::vector<T> a(elementSize);
std::iota(std::begin(a), std::end(a), step);
return a;
@ -247,11 +248,9 @@ std::vector<AvgPoolParams> generateParamsForAvgPool() {
}
std::vector<AvgPoolParams> generateCombinedParamsForAvgPool() {
const std::vector<std::vector<AvgPoolParams>> allTypeParams{
generateParamsForAvgPool<element::Type_t::f32>(),
generateParamsForAvgPool<element::Type_t::f16>(),
generateParamsForAvgPool<element::Type_t::bf16>()
};
const std::vector<std::vector<AvgPoolParams>> allTypeParams{generateParamsForAvgPool<element::Type_t::f32>(),
generateParamsForAvgPool<element::Type_t::f16>(),
generateParamsForAvgPool<element::Type_t::bf16>()};
std::vector<AvgPoolParams> combinedParams;
@ -262,10 +261,9 @@ std::vector<AvgPoolParams> generateCombinedParamsForAvgPool() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(
smoke_AvgPool_With_Hardcoded_Refs,
ReferenceAvgPoolLayerTest,
::testing::ValuesIn(generateCombinedParamsForAvgPool()),
ReferenceAvgPoolLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_With_Hardcoded_Refs,
ReferenceAvgPoolLayerTest,
::testing::ValuesIn(generateCombinedParamsForAvgPool()),
ReferenceAvgPoolLayerTest::getTestCaseName);
} // namespace

View File

@ -2,21 +2,21 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "base_reference_test.hpp"
#include "functional_test_utils/ov_plugin_cache.hpp"
#include "shared_test_classes/base/layer_test_utils.hpp"
#include <gtest/gtest.h>
#include "functional_test_utils/ov_plugin_cache.hpp"
#include "openvino/core/type/element_type.hpp"
#include "openvino/runtime/allocator.hpp"
#include "openvino/runtime/tensor.hpp"
#include "shared_test_classes/base/layer_test_utils.hpp"
#include "transformations/utils/utils.hpp"
using namespace ov;
namespace reference_tests {
CommonReferenceTest::CommonReferenceTest(): targetDevice("TEMPLATE") {
CommonReferenceTest::CommonReferenceTest() : targetDevice("TEMPLATE") {
core = test::utils::PluginCache::get().core(targetDevice);
}
@ -75,8 +75,12 @@ void CommonReferenceTest::Validate() {
}
}
void CommonReferenceTest::ValidateBlobs(const ov::Tensor& refBlob, const ov::Tensor& outBlob, const size_t blob_idx,
float threshold, float abs_threshold, size_t actual_comparision_size) {
void CommonReferenceTest::ValidateBlobs(const ov::Tensor& refBlob,
const ov::Tensor& outBlob,
const size_t blob_idx,
float threshold,
float abs_threshold,
size_t actual_comparision_size) {
ASSERT_EQ(refBlob.get_element_type(), outBlob.get_element_type())
<< "Incompatible element type for blob with index " << blob_idx;
ASSERT_EQ(refBlob.get_byte_size(), outBlob.get_byte_size())
@ -88,80 +92,110 @@ void CommonReferenceTest::ValidateBlobs(const ov::Tensor& refBlob, const ov::Ten
const auto& element_type = refBlob.get_element_type();
switch (element_type) {
case ov::element::bf16:
LayerTestsUtils::LayerTestsCommon::Compare<ov::bfloat16, ov::bfloat16>(
refBlob.data<const ov::bfloat16>(), outBlob.data<const ov::bfloat16>(),
actual_comparision_size, threshold, abs_threshold);
LayerTestsUtils::LayerTestsCommon::Compare<ov::bfloat16, ov::bfloat16>(refBlob.data<const ov::bfloat16>(),
outBlob.data<const ov::bfloat16>(),
actual_comparision_size,
threshold,
abs_threshold);
break;
case ov::element::f16:
LayerTestsUtils::LayerTestsCommon::Compare<ov::float16, ov::float16>(
refBlob.data<const ov::float16>(), outBlob.data<const ov::float16>(),
actual_comparision_size, threshold, abs_threshold);
LayerTestsUtils::LayerTestsCommon::Compare<ov::float16, ov::float16>(refBlob.data<const ov::float16>(),
outBlob.data<const ov::float16>(),
actual_comparision_size,
threshold,
abs_threshold);
break;
case ov::element::f32:
LayerTestsUtils::LayerTestsCommon::Compare<float, float>(
refBlob.data<const float>(), outBlob.data<const float>(),
actual_comparision_size, threshold, abs_threshold);
LayerTestsUtils::LayerTestsCommon::Compare<float, float>(refBlob.data<const float>(),
outBlob.data<const float>(),
actual_comparision_size,
threshold,
abs_threshold);
break;
case ov::element::f64:
LayerTestsUtils::LayerTestsCommon::Compare<double, double>(
refBlob.data<const double>(), outBlob.data<const double>(),
actual_comparision_size, threshold, abs_threshold);
LayerTestsUtils::LayerTestsCommon::Compare<double, double>(refBlob.data<const double>(),
outBlob.data<const double>(),
actual_comparision_size,
threshold,
abs_threshold);
break;
case ov::element::i8:
LayerTestsUtils::LayerTestsCommon::Compare<int8_t, int8_t>(
refBlob.data<const int8_t>(), outBlob.data<const int8_t>(),
actual_comparision_size, threshold, abs_threshold);
LayerTestsUtils::LayerTestsCommon::Compare<int8_t, int8_t>(refBlob.data<const int8_t>(),
outBlob.data<const int8_t>(),
actual_comparision_size,
threshold,
abs_threshold);
break;
case ov::element::i16:
LayerTestsUtils::LayerTestsCommon::Compare<int16_t, int16_t>(
refBlob.data<const int16_t>(), outBlob.data<const int16_t>(),
actual_comparision_size, threshold, abs_threshold);
LayerTestsUtils::LayerTestsCommon::Compare<int16_t, int16_t>(refBlob.data<const int16_t>(),
outBlob.data<const int16_t>(),
actual_comparision_size,
threshold,
abs_threshold);
break;
case ov::element::i32:
LayerTestsUtils::LayerTestsCommon::Compare<int32_t, int32_t>(
refBlob.data<const int32_t>(), outBlob.data<const int32_t>(),
actual_comparision_size, threshold, abs_threshold);
LayerTestsUtils::LayerTestsCommon::Compare<int32_t, int32_t>(refBlob.data<const int32_t>(),
outBlob.data<const int32_t>(),
actual_comparision_size,
threshold,
abs_threshold);
break;
case ov::element::i64:
LayerTestsUtils::LayerTestsCommon::Compare<int64_t, int64_t>(
refBlob.data<const int64_t>(), outBlob.data<const int64_t>(),
actual_comparision_size, threshold, abs_threshold);
LayerTestsUtils::LayerTestsCommon::Compare<int64_t, int64_t>(refBlob.data<const int64_t>(),
outBlob.data<const int64_t>(),
actual_comparision_size,
threshold,
abs_threshold);
break;
case ov::element::boolean:
LayerTestsUtils::LayerTestsCommon::Compare<bool, bool>(
refBlob.data<const bool>(), outBlob.data<const bool>(),
actual_comparision_size, threshold, abs_threshold);
LayerTestsUtils::LayerTestsCommon::Compare<bool, bool>(refBlob.data<const bool>(),
outBlob.data<const bool>(),
actual_comparision_size,
threshold,
abs_threshold);
break;
case ov::element::u8:
LayerTestsUtils::LayerTestsCommon::Compare<uint8_t, uint8_t>(
refBlob.data<const uint8_t>(), outBlob.data<const uint8_t>(),
actual_comparision_size, threshold, abs_threshold);
LayerTestsUtils::LayerTestsCommon::Compare<uint8_t, uint8_t>(refBlob.data<const uint8_t>(),
outBlob.data<const uint8_t>(),
actual_comparision_size,
threshold,
abs_threshold);
break;
case ov::element::u16:
LayerTestsUtils::LayerTestsCommon::Compare<uint16_t, uint16_t>(
refBlob.data<const uint16_t>(), outBlob.data<const uint16_t>(),
actual_comparision_size, threshold, abs_threshold);
LayerTestsUtils::LayerTestsCommon::Compare<uint16_t, uint16_t>(refBlob.data<const uint16_t>(),
outBlob.data<const uint16_t>(),
actual_comparision_size,
threshold,
abs_threshold);
break;
case ov::element::u32:
LayerTestsUtils::LayerTestsCommon::Compare<uint32_t, uint32_t>(
refBlob.data<const uint32_t>(), outBlob.data<const uint32_t>(),
actual_comparision_size, threshold, abs_threshold);
LayerTestsUtils::LayerTestsCommon::Compare<uint32_t, uint32_t>(refBlob.data<const uint32_t>(),
outBlob.data<const uint32_t>(),
actual_comparision_size,
threshold,
abs_threshold);
break;
case ov::element::u64:
LayerTestsUtils::LayerTestsCommon::Compare<uint64_t, uint64_t>(
refBlob.data<const uint64_t>(), outBlob.data<const uint64_t>(),
actual_comparision_size, threshold, abs_threshold);
LayerTestsUtils::LayerTestsCommon::Compare<uint64_t, uint64_t>(refBlob.data<const uint64_t>(),
outBlob.data<const uint64_t>(),
actual_comparision_size,
threshold,
abs_threshold);
break;
case ov::element::i4:
case ov::element::u4:
LayerTestsUtils::LayerTestsCommon::Compare<int8_t, int8_t>(
static_cast<const int8_t*>(refBlob.data()), static_cast<const int8_t*>(outBlob.data()),
actual_comparision_size / 2, threshold, abs_threshold);
LayerTestsUtils::LayerTestsCommon::Compare<int8_t, int8_t>(static_cast<const int8_t*>(refBlob.data()),
static_cast<const int8_t*>(outBlob.data()),
actual_comparision_size / 2,
threshold,
abs_threshold);
break;
case ov::element::u1:
LayerTestsUtils::LayerTestsCommon::Compare<int8_t, int8_t>(
static_cast<const int8_t*>(refBlob.data()), static_cast<const int8_t*>(outBlob.data()),
actual_comparision_size / 8, threshold, abs_threshold);
LayerTestsUtils::LayerTestsCommon::Compare<int8_t, int8_t>(static_cast<const int8_t*>(refBlob.data()),
static_cast<const int8_t*>(outBlob.data()),
actual_comparision_size / 8,
threshold,
abs_threshold);
break;
default:
FAIL() << "Comparator for " << element_type << " element type isn't supported";

View File

@ -55,9 +55,7 @@ ov::Tensor CreateTensor(const ov::element::Type& element_type, const std::vector
// Create blob with correct input shape (not 1-dimensional). Will be used in tests with dynamic input shapes
template <class T>
ov::Tensor CreateTensor(const ov::Shape& shape,
const ov::element::Type& element_type,
const std::vector<T>& values) {
ov::Tensor CreateTensor(const ov::Shape& shape, const ov::element::Type& element_type, const std::vector<T>& values) {
ov::Tensor tensor{element_type, shape};
size_t size = sizeof(T) * values.size();
if (tensor.get_byte_size() < size)

View File

@ -2,11 +2,12 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/batch_norm.hpp"
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
#include "openvino/op/constant.hpp"
#include "openvino/op/batch_norm.hpp"
using namespace reference_tests;
using namespace ov;
@ -78,8 +79,8 @@ public:
private:
static std::shared_ptr<Model> CreateFunction(const Shape& input_shape,
const element::Type_t& input_type,
const float epsilon) {
const element::Type_t& input_type,
const float epsilon) {
Shape channel_shape{input_shape.at(1)};
auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
auto gamma = std::make_shared<op::v0::Parameter>(input_type, channel_shape);
@ -103,8 +104,8 @@ public:
private:
static std::shared_ptr<Model> CreateFunction(const Shape& input_shape,
const element::Type_t& input_type,
const float epsilon) {
const element::Type_t& input_type,
const float epsilon) {
Shape channel_shape{input_shape.at(1)};
auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
auto gamma = std::make_shared<op::v0::Parameter>(input_type, channel_shape);
@ -130,7 +131,7 @@ std::vector<BatchNormParams> generateParamsForBatchNorm() {
using T = typename element_type_traits<ET>::value_type;
std::vector<BatchNormParams> params{
/*------------- 2d --------------*/
/*------------- 2d --------------*/
BatchNormParams(Shape{2, 3},
Shape{2, 3},
ET,
@ -175,7 +176,7 @@ std::vector<BatchNormParams> generateParamsForBatchNorm() {
std::vector<T>{0.0, 0.0, 0.0},
std::vector<T>{2.0, 6.0, 0.0},
0.25),
/*------------- 4d --------------*/
/*------------- 4d --------------*/
BatchNormParams(Shape{2, 2, 2, 1},
Shape{2, 2, 2, 1},
ET,
@ -201,41 +202,33 @@ std::vector<BatchNormParams> generateParamsForBatchNorm() {
std::vector<T>{1.0, 1.0},
std::vector<T>{1.0, 1.0},
0.001),
BatchNormParams(Shape{2, 2, 2, 1},
Shape{2, 2, 2, 1},
ET,
ET,
std::vector<T>{0.54881352f,
0.71518934f,
0.60276335f,
0.54488319f,
0.42365479f,
0.64589411f,
0.4375872f,
0.89177299f},
std::vector<T>{-0.30327f,
1.1561f,
-0.096382f,
-0.434702f,
-1.4011f,
0.548275f,
-1.06187f,
1.59295f},
std::vector<T>{1.0, 1.0},
std::vector<T>{0.0f, 0.0f},
std::vector<T>{0.583388f, 0.619252f},
std::vector<T>{0.0119972f, 0.0282681f},
0.001),
BatchNormParams(
Shape{2, 2, 2, 1},
Shape{2, 2, 2, 1},
ET,
ET,
std::vector<T>{0.54881352f,
0.71518934f,
0.60276335f,
0.54488319f,
0.42365479f,
0.64589411f,
0.4375872f,
0.89177299f},
std::vector<T>{-0.30327f, 1.1561f, -0.096382f, -0.434702f, -1.4011f, 0.548275f, -1.06187f, 1.59295f},
std::vector<T>{1.0, 1.0},
std::vector<T>{0.0f, 0.0f},
std::vector<T>{0.583388f, 0.619252f},
std::vector<T>{0.0119972f, 0.0282681f},
0.001),
};
return params;
}
std::vector<BatchNormParams> generateCombinedParamsForBatchNorm() {
const std::vector<std::vector<BatchNormParams>> allTypeParams{
generateParamsForBatchNorm<element::Type_t::f32>(),
generateParamsForBatchNorm<element::Type_t::f16>()
};
const std::vector<std::vector<BatchNormParams>> allTypeParams{generateParamsForBatchNorm<element::Type_t::f32>(),
generateParamsForBatchNorm<element::Type_t::f16>()};
std::vector<BatchNormParams> combinedParams;
@ -246,16 +239,14 @@ std::vector<BatchNormParams> generateCombinedParamsForBatchNorm() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(
smoke_BatchNorm_With_Hardcoded_Refs,
ReferenceBatchNormV0LayerTest,
::testing::ValuesIn(generateCombinedParamsForBatchNorm()),
ReferenceBatchNormV0LayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_BatchNorm_With_Hardcoded_Refs,
ReferenceBatchNormV0LayerTest,
::testing::ValuesIn(generateCombinedParamsForBatchNorm()),
ReferenceBatchNormV0LayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(
smoke_BatchNorm_With_Hardcoded_Refs,
ReferenceBatchNormV5LayerTest,
::testing::ValuesIn(generateCombinedParamsForBatchNorm()),
ReferenceBatchNormV5LayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_BatchNorm_With_Hardcoded_Refs,
ReferenceBatchNormV5LayerTest,
::testing::ValuesIn(generateCombinedParamsForBatchNorm()),
ReferenceBatchNormV5LayerTest::getTestCaseName);
} // namespace

View File

@ -4,21 +4,27 @@
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
#include "openvino/opsets/opset1.hpp"
#include "openvino/opsets/opset2.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
using namespace ov;
namespace {
struct BatchToSpaceParams {
BatchToSpaceParams(const reference_tests::Tensor& dataTensor, const reference_tests::Tensor& blockShapeTensor,
const reference_tests::Tensor& cropsBeginTensor, const reference_tests::Tensor& cropsEndTensor,
const reference_tests::Tensor& expectedTensor, const std::string& testcaseName = "") :
dataTensor(dataTensor), blockShapeTensor(blockShapeTensor),
cropsBeginTensor(cropsBeginTensor), cropsEndTensor(cropsEndTensor),
expectedTensor(expectedTensor), testcaseName(testcaseName) {}
BatchToSpaceParams(const reference_tests::Tensor& dataTensor,
const reference_tests::Tensor& blockShapeTensor,
const reference_tests::Tensor& cropsBeginTensor,
const reference_tests::Tensor& cropsEndTensor,
const reference_tests::Tensor& expectedTensor,
const std::string& testcaseName = "")
: dataTensor(dataTensor),
blockShapeTensor(blockShapeTensor),
cropsBeginTensor(cropsBeginTensor),
cropsEndTensor(cropsEndTensor),
expectedTensor(expectedTensor),
testcaseName(testcaseName) {}
reference_tests::Tensor dataTensor;
reference_tests::Tensor blockShapeTensor;
@ -80,7 +86,7 @@ TEST_P(ReferenceBatchToSpaceLayerTest, CompareWithRefs) {
template <element::Type_t IN_ET>
std::vector<BatchToSpaceParams> generateBatchToSpaceParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<BatchToSpaceParams> batchToSpaceParams {
std::vector<BatchToSpaceParams> batchToSpaceParams{
// input_with_shape_4x3
BatchToSpaceParams(
reference_tests::Tensor({4, 3}, IN_ET, std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}),
@ -126,89 +132,78 @@ std::vector<BatchToSpaceParams> generateBatchToSpaceParams() {
// input_with_shape_4x1x2x3
BatchToSpaceParams(
reference_tests::Tensor({4, 1, 2, 3}, IN_ET, std::vector<T>{1, 2, 3, 4, 5, 6,
7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24}),
reference_tests::Tensor({4, 1, 2, 3}, IN_ET, std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24}),
reference_tests::Tensor({4}, element::i64, std::vector<int64_t>{1, 1, 1, 2}),
reference_tests::Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 0, 0}),
reference_tests::Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 0, 0}),
reference_tests::Tensor({2, 1, 2, 6}, IN_ET, std::vector<T>{1, 13, 2, 14, 3, 15,
4, 16, 5, 17, 6, 18,
7, 19, 8, 20, 9, 21,
10, 22, 11, 23, 12, 24}),
reference_tests::Tensor({2, 1, 2, 6}, IN_ET, std::vector<T>{1, 13, 2, 14, 3, 15, 4, 16, 5, 17, 6, 18,
7, 19, 8, 20, 9, 21, 10, 22, 11, 23, 12, 24}),
"input_with_shape_4x1x2x3"),
// input_with_shape_4x1x2x3_1
BatchToSpaceParams(
reference_tests::Tensor({4, 1, 2, 3}, IN_ET, std::vector<T>{1, 2, 3, 4, 5, 6,
7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24}),
reference_tests::Tensor({4, 1, 2, 3}, IN_ET, std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24}),
reference_tests::Tensor({4}, element::i64, std::vector<int64_t>{1, 1, 2, 1}),
reference_tests::Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 0, 0}),
reference_tests::Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 0, 0}),
reference_tests::Tensor({2, 1, 4, 3}, IN_ET, std::vector<T>{1, 2, 3, 13, 14, 15,
4, 5, 6, 16, 17, 18,
7, 8, 9, 19, 20, 21,
10, 11, 12, 22, 23, 24}),
reference_tests::Tensor({2, 1, 4, 3}, IN_ET, std::vector<T>{1, 2, 3, 13, 14, 15, 4, 5, 6, 16, 17, 18,
7, 8, 9, 19, 20, 21, 10, 11, 12, 22, 23, 24}),
"input_with_shape_4x1x2x3_1"),
// input_with_shape_4x1x2x3_2
BatchToSpaceParams(
reference_tests::Tensor({4, 1, 2, 3}, IN_ET, std::vector<T>{1, 2, 3, 4, 5, 6,
7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24}),
reference_tests::Tensor({4, 1, 2, 3}, IN_ET, std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24}),
reference_tests::Tensor({4}, element::i64, std::vector<int64_t>{1, 1, 2, 2}),
reference_tests::Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 0, 0}),
reference_tests::Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 0, 0}),
reference_tests::Tensor({1, 1, 4, 6}, IN_ET, std::vector<T>{1, 7, 2, 8, 3, 9,
13, 19, 14, 20, 15, 21,
4, 10, 5, 11, 6, 12,
16, 22, 17, 23, 18, 24}),
reference_tests::Tensor({1, 1, 4, 6}, IN_ET, std::vector<T>{1, 7, 2, 8, 3, 9, 13, 19, 14, 20, 15, 21,
4, 10, 5, 11, 6, 12, 16, 22, 17, 23, 18, 24}),
"input_with_shape_4x1x2x3_2"),
// input_with_shape_with_crop_4x1x2x3
BatchToSpaceParams(
reference_tests::Tensor({4, 1, 2, 3}, IN_ET, std::vector<T>{1, 2, 3, 4, 5, 6,
7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24}),
reference_tests::Tensor({4, 1, 2, 3}, IN_ET, std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24}),
reference_tests::Tensor({4}, element::i64, std::vector<int64_t>{1, 1, 2, 2}),
reference_tests::Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 0, 0}),
reference_tests::Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 0, 2}),
reference_tests::Tensor({1, 1, 4, 4}, IN_ET, std::vector<T>{1, 7, 2, 8, 13, 19, 14, 20,
4, 10, 5, 11, 16, 22, 17, 23}),
reference_tests::Tensor({1, 1, 4, 4},
IN_ET,
std::vector<T>{1, 7, 2, 8, 13, 19, 14, 20, 4, 10, 5, 11, 16, 22, 17, 23}),
"input_with_shape_with_crop_4x1x2x3"),
// input_with_shape_with_crop_4x1x2x3_1
BatchToSpaceParams(
reference_tests::Tensor({4, 1, 2, 3}, IN_ET, std::vector<T>{1, 2, 3, 4, 5, 6,
7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24}),
reference_tests::Tensor({4, 1, 2, 3}, IN_ET, std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24}),
reference_tests::Tensor({4}, element::i64, std::vector<int64_t>{1, 1, 2, 2}),
reference_tests::Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 0, 2}),
reference_tests::Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 0, 0}),
reference_tests::Tensor({1, 1, 4, 4}, IN_ET, std::vector<T>{2, 8, 3, 9, 14, 20, 15, 21,
5, 11, 6, 12, 17, 23, 18, 24}),
reference_tests::Tensor({1, 1, 4, 4},
IN_ET,
std::vector<T>{2, 8, 3, 9, 14, 20, 15, 21, 5, 11, 6, 12, 17, 23, 18, 24}),
"input_with_shape_with_crop_4x1x2x3_1"),
// input_with_shape_with_crop_4x1x2x3_2
BatchToSpaceParams(
reference_tests::Tensor({4, 1, 2, 3}, IN_ET, std::vector<T>{1, 2, 3, 4, 5, 6,
7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24}),
reference_tests::Tensor({4, 1, 2, 3}, IN_ET, std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24}),
reference_tests::Tensor({4}, element::i64, std::vector<int64_t>{1, 1, 2, 2}),
reference_tests::Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 1, 0}),
reference_tests::Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 1, 0}),
reference_tests::Tensor({1, 1, 2, 6}, IN_ET, std::vector<T>{13, 19, 14, 20, 15, 21,
4, 10, 5, 11, 6, 12}),
reference_tests::Tensor({1, 1, 2, 6}, IN_ET, std::vector<T>{13, 19, 14, 20, 15, 21, 4, 10, 5, 11, 6, 12}),
"input_with_shape_with_crop_4x1x2x3_2"),
};
return batchToSpaceParams;
}
std::vector<BatchToSpaceParams> generateBatchToSpaceCombinedParams() {
const std::vector<std::vector<BatchToSpaceParams>> batchToSpaceTypeParams {
const std::vector<std::vector<BatchToSpaceParams>> batchToSpaceTypeParams{
generateBatchToSpaceParams<element::Type_t::i8>(),
generateBatchToSpaceParams<element::Type_t::i16>(),
generateBatchToSpaceParams<element::Type_t::i32>(),
@ -230,6 +225,8 @@ std::vector<BatchToSpaceParams> generateBatchToSpaceCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_BatchToSpace_With_Hardcoded_Refs, ReferenceBatchToSpaceLayerTest,
testing::ValuesIn(generateBatchToSpaceCombinedParams()), ReferenceBatchToSpaceLayerTest::getTestCaseName);
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_BatchToSpace_With_Hardcoded_Refs,
ReferenceBatchToSpaceLayerTest,
testing::ValuesIn(generateBatchToSpaceCombinedParams()),
ReferenceBatchToSpaceLayerTest::getTestCaseName);
} // namespace

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/binary_convolution.hpp"
#include <gtest/gtest.h>
#include "openvino/op/binary_convolution.hpp"
#include "base_reference_test.hpp"
#include "openvino/opsets/opset8.hpp"
@ -53,12 +54,14 @@ struct BinaryConvolutionParams {
ov::CoordinateDiff padBegin;
ov::CoordinateDiff padEnd;
ov::Strides dialations;
ov::op::v1::BinaryConvolution::BinaryConvolutionMode mode = ov::op::v1::BinaryConvolution::BinaryConvolutionMode::XNOR_POPCOUNT;
ov::op::v1::BinaryConvolution::BinaryConvolutionMode mode =
ov::op::v1::BinaryConvolution::BinaryConvolutionMode::XNOR_POPCOUNT;
float padValue;
std::string testcaseName;
};
class ReferenceBinaryConvolutionLayerTest : public testing::TestWithParam<BinaryConvolutionParams>, public CommonReferenceTest {
class ReferenceBinaryConvolutionLayerTest : public testing::TestWithParam<BinaryConvolutionParams>,
public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
@ -88,20 +91,21 @@ public:
}
private:
static std::shared_ptr<Model> CreateFunction(const BinaryConvolutionParams& params, const std::vector<uint8_t>& filterData) {
static std::shared_ptr<Model> CreateFunction(const BinaryConvolutionParams& params,
const std::vector<uint8_t>& filterData) {
const op::PadType auto_pad{op::PadType::EXPLICIT};
const auto in = std::make_shared<op::v0::Parameter>(params.inType, params.inputShape);
auto filter = std::make_shared<opset8::Constant>(ov::element::u1, params.filterShape, &filterData[0]);
const auto BinaryConvolution = std::make_shared<op::v1::BinaryConvolution>(in,
filter,
params.strides,
params.padBegin,
params.padEnd,
params.dialations,
params.mode,
params.padValue,
auto_pad);
return std::make_shared<ov::Model>(NodeVector {BinaryConvolution}, ParameterVector {in});
filter,
params.strides,
params.padBegin,
params.padEnd,
params.dialations,
params.mode,
params.padValue,
auto_pad);
return std::make_shared<ov::Model>(NodeVector{BinaryConvolution}, ParameterVector{in});
}
};
@ -113,194 +117,200 @@ template <element::Type_t IN_ET>
std::vector<BinaryConvolutionParams> generateBinaryConvolutionParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<BinaryConvolutionParams> binaryConvolutionParams {
// --------------------- 2D BinaryConvolution ------------------------------------------
BinaryConvolutionParams(PartialShape {1, 1, 4, 4},
Shape {1, 1, 3, 3},
PartialShape {1, 1, 2, 2},
std::vector<BinaryConvolutionParams> binaryConvolutionParams{
// --------------------- 2D BinaryConvolution ------------------------------------------
BinaryConvolutionParams(PartialShape{1, 1, 4, 4},
Shape{1, 1, 3, 3},
PartialShape{1, 1, 2, 2},
IN_ET,
std::vector<T>{1, 0, 0, 1,
1, 1, 0, 0,
0, 0, 0, 1,
1, 0, 1, 1},
std::vector<uint8_t>{0xAA, 0x80}, // 10101010 10000000
std::vector<T>{1, 1,
3, -1},
std::vector<T>{1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1},
std::vector<uint8_t>{0xAA, 0x80}, // 10101010 10000000
std::vector<T>{1, 1, 3, -1},
{1, 1},
{0, 0},
{0, 0},
{1, 1}),
BinaryConvolutionParams(PartialShape {1, 1, 4, 4},
Shape {1, 1, 3, 3},
PartialShape {1, 1, 4, 4},
BinaryConvolutionParams(PartialShape{1, 1, 4, 4},
Shape{1, 1, 3, 3},
PartialShape{1, 1, 4, 4},
IN_ET,
std::vector<T>{1, 0, 0, 1,
1, 1, 0, 0,
0, 0, 0, 1,
1, 0, 1, 1},
std::vector<uint8_t>{0xAA, 0x80}, // 10101010 10000000
std::vector<T>{1, -3, -1, 1,
-3, 1, 1, -5,
-3, 3, -1, 1,
1, -5, 1, -3},
std::vector<T>{1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1},
std::vector<uint8_t>{0xAA, 0x80}, // 10101010 10000000
std::vector<T>{1, -3, -1, 1, -3, 1, 1, -5, -3, 3, -1, 1, 1, -5, 1, -3},
{1, 1},
{1, 1},
{1, 1},
{1, 1}),
BinaryConvolutionParams(PartialShape {1, 1, 4, 4},
Shape {1, 1, 3, 3},
PartialShape {1, 1, 4, 4},
BinaryConvolutionParams(PartialShape{1, 1, 4, 4},
Shape{1, 1, 3, 3},
PartialShape{1, 1, 4, 4},
IN_ET,
std::vector<T>{1, 0, 0, 1,
1, 1, 0, 0,
0, 0, 0, 1,
1, 0, 1, 1},
std::vector<uint8_t>{0xAA, 0x80}, // 10101010 10000000
std::vector<T>{3, -1, 1, 3,
-1, 1, 1, -3,
-1, 3, -1, 3,
3, -3, 3, -1},
std::vector<T>{1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1},
std::vector<uint8_t>{0xAA, 0x80}, // 10101010 10000000
std::vector<T>{3, -1, 1, 3, -1, 1, 1, -3, -1, 3, -1, 3, 3, -3, 3, -1},
{1, 1},
{1, 1},
{1, 1},
{1, 1},
1.0f),
BinaryConvolutionParams(PartialShape {1, 1, 5, 5},
Shape {1, 1, 3, 3},
PartialShape {1, 1, 2, 2},
BinaryConvolutionParams(
PartialShape{1, 1, 5, 5},
Shape{1, 1, 3, 3},
PartialShape{1, 1, 2, 2},
IN_ET,
std::vector<T>{0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1},
std::vector<uint8_t>{0x2E, 0x00}, // 10101010 10000000
std::vector<T>{-1, 3, 1, 1},
{2, 2},
{0, 0},
{0, 0},
{1, 1}),
BinaryConvolutionParams(
PartialShape{1, 1, 7, 7},
Shape{1, 1, 3, 3},
PartialShape{1, 1, 3, 3},
IN_ET,
std::vector<T>{1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1,
1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0},
std::vector<uint8_t>{0x6B, 0x00}, // 10101010 10000000
std::vector<T>{-5, -3, -5, 5, 1, 3, -1, -1, 3},
{1, 1},
{0, 0},
{0, 0},
{2, 2}),
BinaryConvolutionParams(
PartialShape{1, 1, 7, 7},
Shape{1, 1, 3, 3},
PartialShape{1, 1, 4, 4},
IN_ET,
std::vector<T>{1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1,
1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0},
std::vector<uint8_t>{0x6B, 0x00}, // 10101010 10000000
std::vector<T>{1, 1, -1, 1, 1, -5, -5, 5, 3, -1, 3, 3, -1, -1, 3, -3},
{2, 2},
{2, 2},
{2, 2},
{2, 2}),
BinaryConvolutionParams(
PartialShape{1, 1, 7, 7},
Shape{1, 1, 3, 3},
PartialShape{1, 1, 4, 4},
IN_ET,
std::vector<T>{1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1,
1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0},
std::vector<uint8_t>{0x6B, 0x00}, // 10101010 10000000
std::vector<T>{3, 3, 1, -1, -1, -5, -5, 3, 1, -1, 3, 1, -3, 1, 5, -1},
{2, 2},
{2, 2},
{2, 2},
{2, 2},
1.0f),
BinaryConvolutionParams(PartialShape{1, 2, 4, 4},
Shape{1, 2, 3, 3},
PartialShape{1, 1, 2, 2},
IN_ET,
std::vector<T>{0, 1, 1, 0, 1,
1, 1, 0, 1, 0,
0, 0, 1, 0, 1,
1, 1, 0, 1, 0,
0, 0, 1, 1, 1},
std::vector<uint8_t>{0x2E, 0x00}, // 10101010 10000000
std::vector<T>{-1, 3,
1, 1},
{2, 2},
{0, 0},
{0, 0},
{1, 1}),
BinaryConvolutionParams(PartialShape {1, 1, 7, 7},
Shape {1, 1, 3, 3},
PartialShape {1, 1, 3, 3},
IN_ET,
std::vector<T>{1, 1, 0, 0, 0, 1, 0,
0, 0, 1, 0, 1, 0, 0,
1, 1, 1, 1, 0, 1, 1,
0, 0, 0, 1, 1, 1, 0,
0, 1, 0, 0, 1, 1, 1,
1, 0, 1, 1, 0, 0, 0,
1, 1, 1, 0, 1, 0, 0},
std::vector<uint8_t>{0x6B, 0x00}, // 10101010 10000000
std::vector<T>{-5, -3, -5,
5, 1, 3,
-1, -1, 3},
{1, 1},
{0, 0},
{0, 0},
{2, 2}),
BinaryConvolutionParams(PartialShape {1, 1, 7, 7},
Shape {1, 1, 3, 3},
PartialShape {1, 1, 4, 4},
IN_ET,
std::vector<T>{1, 1, 0, 0, 0, 1, 0,
0, 0, 1, 0, 1, 0, 0,
1, 1, 1, 1, 0, 1, 1,
0, 0, 0, 1, 1, 1, 0,
0, 1, 0, 0, 1, 1, 1,
1, 0, 1, 1, 0, 0, 0,
1, 1, 1, 0, 1, 0, 0},
std::vector<uint8_t>{0x6B, 0x00}, // 10101010 10000000
std::vector<T>{1, 1, -1, 1,
1, -5, -5, 5,
3, -1, 3, 3,
-1, -1, 3, -3},
{2, 2},
{2, 2},
{2, 2},
{2, 2}),
BinaryConvolutionParams(PartialShape {1, 1, 7, 7},
Shape {1, 1, 3, 3},
PartialShape {1, 1, 4, 4},
IN_ET,
std::vector<T>{1, 1, 0, 0, 0, 1, 0,
0, 0, 1, 0, 1, 0, 0,
1, 1, 1, 1, 0, 1, 1,
0, 0, 0, 1, 1, 1, 0,
0, 1, 0, 0, 1, 1, 1,
1, 0, 1, 1, 0, 0, 0,
1, 1, 1, 0, 1, 0, 0},
std::vector<uint8_t>{0x6B, 0x00}, // 10101010 10000000
std::vector<T>{3, 3, 1, -1,
-1, -5, -5, 3,
1, -1, 3, 1,
-3, 1, 5, -1},
{2, 2},
{2, 2},
{2, 2},
{2, 2},
1.0f),
BinaryConvolutionParams(PartialShape {1, 2, 4, 4},
Shape {1, 2, 3, 3},
PartialShape {1, 1, 2, 2},
IN_ET,
std::vector<T>{
// channel 1
1, 0, 0, 1,
1, 1, 0, 0,
0, 0, 0, 1,
1, 0, 1, 1,
// channel 2
0, 1, 1, 0,
0, 0, 1, 1,
1, 1, 1, 0,
0, 1, 0, 0},
std::vector<uint8_t>{0xAA, 0xAA, 0x80}, // 10101010 10000000
std::vector<T>{2, 2,
6, -2},
std::vector<T>{// channel 1
1,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
1,
1,
0,
1,
1,
// channel 2
0,
1,
1,
0,
0,
0,
1,
1,
1,
1,
1,
0,
0,
1,
0,
0},
std::vector<uint8_t>{0xAA, 0xAA, 0x80}, // 10101010 10000000
std::vector<T>{2, 2, 6, -2},
{1, 1},
{0, 0},
{0, 0},
{1, 1}),
BinaryConvolutionParams(PartialShape {2, 1, 4, 4},
Shape {1, 1, 3, 3},
PartialShape {2, 1, 2, 2},
BinaryConvolutionParams(PartialShape{2, 1, 4, 4},
Shape{1, 1, 3, 3},
PartialShape{2, 1, 2, 2},
IN_ET,
std::vector<T>{
// batch 1
1, 0, 0, 1,
1, 1, 0, 0,
0, 0, 0, 1,
1, 0, 1, 1,
// batch 2
0, 0, 0, 0,
1, 1, 1, 0,
1, 1, 0, 1,
1, 0, 1, 0},
std::vector<uint8_t>{0xAA, 0x80}, // 10101010 10000000
std::vector<T>{
// batch 1
1, 1,
3, -1,
// batch 2
-3, 3,
5, -7},
std::vector<T>{// batch 1
1,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
1,
1,
0,
1,
1,
// batch 2
0,
0,
0,
0,
1,
1,
1,
0,
1,
1,
0,
1,
1,
0,
1,
0},
std::vector<uint8_t>{0xAA, 0x80}, // 10101010 10000000
std::vector<T>{ // batch 1
1,
1,
3,
-1,
// batch 2
-3,
3,
5,
-7},
{1, 1},
{0, 0},
{0, 0},
{1, 1})
};
{1, 1})};
return binaryConvolutionParams;
}
std::vector<BinaryConvolutionParams> generateBinaryConvolutionCombinedParams() {
const std::vector<std::vector<BinaryConvolutionParams>> binaryConvolutionTypeParams {
const std::vector<std::vector<BinaryConvolutionParams>> binaryConvolutionTypeParams{
generateBinaryConvolutionParams<element::Type_t::f32>(),
generateBinaryConvolutionParams<element::Type_t::f16>(),
generateBinaryConvolutionParams<element::Type_t::i64>(),
generateBinaryConvolutionParams<element::Type_t::i32>()
};
generateBinaryConvolutionParams<element::Type_t::i32>()};
std::vector<BinaryConvolutionParams> combinedParams;
for (const auto& params : binaryConvolutionTypeParams) {
@ -309,7 +319,9 @@ std::vector<BinaryConvolutionParams> generateBinaryConvolutionCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_BinaryConvolution_With_Hardcoded_Refs, ReferenceBinaryConvolutionLayerTest,
testing::ValuesIn(generateBinaryConvolutionCombinedParams()), ReferenceBinaryConvolutionLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_BinaryConvolution_With_Hardcoded_Refs,
ReferenceBinaryConvolutionLayerTest,
testing::ValuesIn(generateBinaryConvolutionCombinedParams()),
ReferenceBinaryConvolutionLayerTest::getTestCaseName);
} // namespace
} // namespace

View File

@ -4,20 +4,23 @@
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
#include "openvino/opsets/opset1.hpp"
#include "openvino/opsets/opset3.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
using namespace ov;
namespace {
struct BroadcastParams {
BroadcastParams(
const reference_tests::Tensor& dataTensor, const reference_tests::Tensor& targetShapeTensor,
const reference_tests::Tensor& expectedTensor, const std::string& testcaseName = "") :
dataTensor(dataTensor), targetShapeTensor(targetShapeTensor),
expectedTensor(expectedTensor), testcaseName(testcaseName) {}
BroadcastParams(const reference_tests::Tensor& dataTensor,
const reference_tests::Tensor& targetShapeTensor,
const reference_tests::Tensor& expectedTensor,
const std::string& testcaseName = "")
: dataTensor(dataTensor),
targetShapeTensor(targetShapeTensor),
expectedTensor(expectedTensor),
testcaseName(testcaseName) {}
reference_tests::Tensor dataTensor;
reference_tests::Tensor targetShapeTensor;
@ -55,9 +58,10 @@ private:
static std::shared_ptr<Model> CreateFunction(const BroadcastParams& params) {
const auto A = std::make_shared<opset1::Parameter>(params.dataTensor.type, params.dataTensor.shape);
const auto f = std::make_shared<Model>(
std::make_shared<opset1::Broadcast>(A, opset1::Constant::create(params.targetShapeTensor.type,
params.targetShapeTensor.shape,
params.targetShapeTensor.data.data())),
std::make_shared<opset1::Broadcast>(A,
opset1::Constant::create(params.targetShapeTensor.type,
params.targetShapeTensor.shape,
params.targetShapeTensor.data.data())),
ParameterVector{A});
return f;
}
@ -72,9 +76,10 @@ private:
static std::shared_ptr<Model> CreateFunction(const BroadcastParams& params) {
const auto A = std::make_shared<opset1::Parameter>(params.dataTensor.type, params.dataTensor.shape);
const auto f = std::make_shared<Model>(
std::make_shared<opset3::Broadcast>(A, opset1::Constant::create(params.targetShapeTensor.type,
params.targetShapeTensor.shape,
params.targetShapeTensor.data.data())),
std::make_shared<opset3::Broadcast>(A,
opset1::Constant::create(params.targetShapeTensor.type,
params.targetShapeTensor.shape,
params.targetShapeTensor.data.data())),
ParameterVector{A});
return f;
}
@ -85,17 +90,19 @@ TEST_P(ReferenceBroadcastTestV3, CompareWithRefs) {
}
struct BroadcastParamsExplicitAxis : BroadcastParams {
BroadcastParamsExplicitAxis(
const reference_tests::Tensor& dataTensor, const reference_tests::Tensor& targetShapeTensor,
const reference_tests::Tensor& axesMappingTensor, const reference_tests::Tensor& expectedTensor,
const std::string& testcaseName = "") :
BroadcastParams(dataTensor, targetShapeTensor, expectedTensor, testcaseName),
axesMappingTensor(axesMappingTensor) {}
BroadcastParamsExplicitAxis(const reference_tests::Tensor& dataTensor,
const reference_tests::Tensor& targetShapeTensor,
const reference_tests::Tensor& axesMappingTensor,
const reference_tests::Tensor& expectedTensor,
const std::string& testcaseName = "")
: BroadcastParams(dataTensor, targetShapeTensor, expectedTensor, testcaseName),
axesMappingTensor(axesMappingTensor) {}
reference_tests::Tensor axesMappingTensor;
};
class ReferenceBroadcastTestExplicitAxis : public testing::TestWithParam<BroadcastParamsExplicitAxis>, public CommonReferenceTest {
class ReferenceBroadcastTestExplicitAxis : public testing::TestWithParam<BroadcastParamsExplicitAxis>,
public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
@ -144,12 +151,14 @@ TEST_P(ReferenceBroadcastTestExplicitAxis, CompareWithRefs) {
}
struct BroadcastParamsTestHelper {
BroadcastParamsTestHelper(
const Shape& shapeA,
const Shape& shapeR,
const AxisSet& axes, const std::string& testcaseName = "") :
shapeA(shapeA), shapeR(shapeR),
axes(axes), testcaseName(testcaseName) {}
BroadcastParamsTestHelper(const Shape& shapeA,
const Shape& shapeR,
const AxisSet& axes,
const std::string& testcaseName = "")
: shapeA(shapeA),
shapeR(shapeR),
axes(axes),
testcaseName(testcaseName) {}
Shape shapeA;
Shape shapeR;
@ -157,7 +166,8 @@ struct BroadcastParamsTestHelper {
std::string testcaseName;
};
class ReferenceBroadcastTestTestHelper : public testing::TestWithParam<BroadcastParamsTestHelper>, public CommonReferenceTest {
class ReferenceBroadcastTestTestHelper : public testing::TestWithParam<BroadcastParamsTestHelper>,
public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
@ -197,7 +207,8 @@ private:
const auto shape_const = opset1::Constant::create(element::u64, Shape{params.shapeR.size()}, params.shapeR);
std::shared_ptr<Node> broadcast;
if (params.axes.size() > 0) {
auto axes_const = opset1::Constant::create(element::i64, Shape{params.axes.size()}, params.axes.to_vector());
auto axes_const =
opset1::Constant::create(element::i64, Shape{params.axes.size()}, params.axes.to_vector());
broadcast = std::make_shared<opset1::Broadcast>(A, shape_const, axes_const);
} else {
broadcast = std::make_shared<opset1::Broadcast>(A, shape_const);
@ -209,7 +220,7 @@ private:
protected:
void GenerateRefOutData() {
actualOutData.clear();
for (const auto &output : executableNetwork.outputs()) {
for (const auto& output : executableNetwork.outputs()) {
actualOutData.emplace_back(inferRequest.get_tensor(output));
}
refOutData = actualOutData;
@ -229,14 +240,14 @@ class ReferenceBroadcastTestExplicitAxisReversed : public ReferenceBroadcastTest
private:
static std::shared_ptr<Model> CreateFunction(const BroadcastParamsExplicitAxis& params) {
const auto A = std::make_shared<opset1::Parameter>(params.dataTensor.type, params.dataTensor.shape);
auto broadcast = std::make_shared<opset1::Broadcast>(
A,
opset1::Constant::create(params.targetShapeTensor.type,
params.targetShapeTensor.shape,
params.targetShapeTensor.data.data()),
opset1::Constant::create(params.axesMappingTensor.type,
params.axesMappingTensor.shape,
params.axesMappingTensor.data.data()));
auto broadcast =
std::make_shared<opset1::Broadcast>(A,
opset1::Constant::create(params.targetShapeTensor.type,
params.targetShapeTensor.shape,
params.targetShapeTensor.data.data()),
opset1::Constant::create(params.axesMappingTensor.type,
params.axesMappingTensor.shape,
params.axesMappingTensor.data.data()));
auto reverse = std::make_shared<opset1::Reverse>(broadcast,
opset1::Constant::create(element::i64, {1}, {1}),
opset1::Reverse::Mode::INDEX);
@ -252,38 +263,33 @@ TEST_P(ReferenceBroadcastTestExplicitAxisReversed, CompareWithRefs) {
template <element::Type_t ET>
std::vector<BroadcastParams> generateParams() {
using T = typename element_type_traits<ET>::value_type;
std::vector<BroadcastParams> params {
BroadcastParams(
reference_tests::Tensor(ET, {}, std::vector<T>{6}),
reference_tests::Tensor(element::u64, {1}, std::vector<uint64_t>{4}),
reference_tests::Tensor(ET, {4}, std::vector<T>{6, 6, 6, 6}),
"broadcast_scalar_vector"),
BroadcastParams(
reference_tests::Tensor(ET, {}, std::vector<T>{6}),
reference_tests::Tensor(element::u64, {2}, std::vector<uint64_t>{2, 2}),
reference_tests::Tensor(ET, {2, 2}, std::vector<T>{6, 6, 6, 6}),
"broadcast_scalar_matrix"),
BroadcastParams(
reference_tests::Tensor(ET, {}, std::vector<T>{6}),
reference_tests::Tensor(element::u64, {3}, std::vector<uint64_t>{2, 2, 2}),
reference_tests::Tensor(ET, {2, 2, 2}, std::vector<T>{6, 6, 6, 6, 6, 6, 6, 6}),
"broadcast_scalar_tensor"),
BroadcastParams(
reference_tests::Tensor(ET, {2, 2, 2}, std::vector<T>{2, 4, 6, 8, 16, 32, 64, 127}),
reference_tests::Tensor(element::u64, {3}, std::vector<uint64_t>{2, 2, 2}),
reference_tests::Tensor(ET, {2, 2, 2}, std::vector<T>{2, 4, 6, 8, 16, 32, 64, 127}),
"broadcast_trivial"),
BroadcastParams(
reference_tests::Tensor(ET, {2, 2}, std::vector<T>{1, 2, 3, 4}),
reference_tests::Tensor(element::u64, {3}, std::vector<uint64_t>{2, 2, 2}),
reference_tests::Tensor(ET, {2, 2, 2}, std::vector<T>{1, 2, 3, 4, 1, 2, 3, 4}),
"broadcast_matrix_0"),
std::vector<BroadcastParams> params{
BroadcastParams(reference_tests::Tensor(ET, {}, std::vector<T>{6}),
reference_tests::Tensor(element::u64, {1}, std::vector<uint64_t>{4}),
reference_tests::Tensor(ET, {4}, std::vector<T>{6, 6, 6, 6}),
"broadcast_scalar_vector"),
BroadcastParams(reference_tests::Tensor(ET, {}, std::vector<T>{6}),
reference_tests::Tensor(element::u64, {2}, std::vector<uint64_t>{2, 2}),
reference_tests::Tensor(ET, {2, 2}, std::vector<T>{6, 6, 6, 6}),
"broadcast_scalar_matrix"),
BroadcastParams(reference_tests::Tensor(ET, {}, std::vector<T>{6}),
reference_tests::Tensor(element::u64, {3}, std::vector<uint64_t>{2, 2, 2}),
reference_tests::Tensor(ET, {2, 2, 2}, std::vector<T>{6, 6, 6, 6, 6, 6, 6, 6}),
"broadcast_scalar_tensor"),
BroadcastParams(reference_tests::Tensor(ET, {2, 2, 2}, std::vector<T>{2, 4, 6, 8, 16, 32, 64, 127}),
reference_tests::Tensor(element::u64, {3}, std::vector<uint64_t>{2, 2, 2}),
reference_tests::Tensor(ET, {2, 2, 2}, std::vector<T>{2, 4, 6, 8, 16, 32, 64, 127}),
"broadcast_trivial"),
BroadcastParams(reference_tests::Tensor(ET, {2, 2}, std::vector<T>{1, 2, 3, 4}),
reference_tests::Tensor(element::u64, {3}, std::vector<uint64_t>{2, 2, 2}),
reference_tests::Tensor(ET, {2, 2, 2}, std::vector<T>{1, 2, 3, 4, 1, 2, 3, 4}),
"broadcast_matrix_0"),
};
return params;
}
std::vector<BroadcastParams> generateCombinedParams() {
const std::vector<std::vector<BroadcastParams>> generatedParams {
const std::vector<std::vector<BroadcastParams>> generatedParams{
generateParams<element::Type_t::i8>(),
generateParams<element::Type_t::i16>(),
generateParams<element::Type_t::i32>(),
@ -305,22 +311,25 @@ std::vector<BroadcastParams> generateCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_Broadcast_With_Hardcoded_Refs, ReferenceBroadcastTest,
testing::ValuesIn(generateCombinedParams()), ReferenceBroadcastTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Broadcast_With_Hardcoded_Refs,
ReferenceBroadcastTest,
testing::ValuesIn(generateCombinedParams()),
ReferenceBroadcastTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Broadcast_With_Hardcoded_Refs, ReferenceBroadcastTestV3,
testing::ValuesIn(generateCombinedParams()), ReferenceBroadcastTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Broadcast_With_Hardcoded_Refs,
ReferenceBroadcastTestV3,
testing::ValuesIn(generateCombinedParams()),
ReferenceBroadcastTest::getTestCaseName);
template <element::Type_t ET>
std::vector<BroadcastParamsExplicitAxis> generateParamsExplicitAxis() {
using T = typename element_type_traits<ET>::value_type;
std::vector<BroadcastParamsExplicitAxis> params {
BroadcastParamsExplicitAxis(
reference_tests::Tensor(ET, {}, std::vector<T>{6}),
reference_tests::Tensor(element::u64, {2}, std::vector<uint64_t>{1, 2}),
reference_tests::Tensor(element::i64, {1}, std::vector<int64_t>{0}),
reference_tests::Tensor(ET, {1, 2}, std::vector<T>{6, 6}),
"broadcast_scalar_vector_explicit_axis_0"),
std::vector<BroadcastParamsExplicitAxis> params{
BroadcastParamsExplicitAxis(reference_tests::Tensor(ET, {}, std::vector<T>{6}),
reference_tests::Tensor(element::u64, {2}, std::vector<uint64_t>{1, 2}),
reference_tests::Tensor(element::i64, {1}, std::vector<int64_t>{0}),
reference_tests::Tensor(ET, {1, 2}, std::vector<T>{6, 6}),
"broadcast_scalar_vector_explicit_axis_0"),
BroadcastParamsExplicitAxis(
reference_tests::Tensor(ET, {3}, std::vector<T>{1, 2, 3}),
reference_tests::Tensor(element::u64, {2}, std::vector<uint64_t>{3, 4}),
@ -333,30 +342,27 @@ std::vector<BroadcastParamsExplicitAxis> generateParamsExplicitAxis() {
reference_tests::Tensor(element::i64, {1}, std::vector<int64_t>{1}),
reference_tests::Tensor(ET, {3, 4}, std::vector<T>{1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}),
"broadcast_vector_rowwise"),
BroadcastParamsExplicitAxis(
reference_tests::Tensor(ET, {1}, std::vector<T>{4}),
reference_tests::Tensor(element::u64, {2}, std::vector<uint64_t>{3, 1}),
reference_tests::Tensor(element::i64, {1}, std::vector<int64_t>{1}),
reference_tests::Tensor(ET, {3, 1}, std::vector<T>{4, 4, 4}),
"broadcast_scalar_to_matrix"),
BroadcastParamsExplicitAxis(
reference_tests::Tensor(ET, {2, 2}, std::vector<T>{1, 2, 3, 4}),
reference_tests::Tensor(element::u64, {3}, std::vector<uint64_t>{2, 2, 2}),
reference_tests::Tensor(element::i64, {2}, std::vector<int64_t>{0, 2}),
reference_tests::Tensor(ET, {2, 2, 2}, std::vector<T>{1, 2, 1, 2, 3, 4, 3, 4}),
"broadcast_matrix_1"),
BroadcastParamsExplicitAxis(
reference_tests::Tensor(ET, {2, 2}, std::vector<T>{1, 2, 3, 4}),
reference_tests::Tensor(element::u64, {3}, std::vector<uint64_t>{2, 2, 2}),
reference_tests::Tensor(element::i64, {2}, std::vector<int64_t>{0, 1}),
reference_tests::Tensor(ET, {2, 2, 2}, std::vector<T>{1, 1, 2, 2, 3, 3, 4, 4}),
"broadcast_matrix_2"),
BroadcastParamsExplicitAxis(reference_tests::Tensor(ET, {1}, std::vector<T>{4}),
reference_tests::Tensor(element::u64, {2}, std::vector<uint64_t>{3, 1}),
reference_tests::Tensor(element::i64, {1}, std::vector<int64_t>{1}),
reference_tests::Tensor(ET, {3, 1}, std::vector<T>{4, 4, 4}),
"broadcast_scalar_to_matrix"),
BroadcastParamsExplicitAxis(reference_tests::Tensor(ET, {2, 2}, std::vector<T>{1, 2, 3, 4}),
reference_tests::Tensor(element::u64, {3}, std::vector<uint64_t>{2, 2, 2}),
reference_tests::Tensor(element::i64, {2}, std::vector<int64_t>{0, 2}),
reference_tests::Tensor(ET, {2, 2, 2}, std::vector<T>{1, 2, 1, 2, 3, 4, 3, 4}),
"broadcast_matrix_1"),
BroadcastParamsExplicitAxis(reference_tests::Tensor(ET, {2, 2}, std::vector<T>{1, 2, 3, 4}),
reference_tests::Tensor(element::u64, {3}, std::vector<uint64_t>{2, 2, 2}),
reference_tests::Tensor(element::i64, {2}, std::vector<int64_t>{0, 1}),
reference_tests::Tensor(ET, {2, 2, 2}, std::vector<T>{1, 1, 2, 2, 3, 3, 4, 4}),
"broadcast_matrix_2"),
};
return params;
}
std::vector<BroadcastParamsExplicitAxis> generateCombinedParamsExplicitAxis() {
const std::vector<std::vector<BroadcastParamsExplicitAxis>> generatedParams {
const std::vector<std::vector<BroadcastParamsExplicitAxis>> generatedParams{
generateParamsExplicitAxis<element::Type_t::i8>(),
generateParamsExplicitAxis<element::Type_t::i16>(),
generateParamsExplicitAxis<element::Type_t::i32>(),
@ -378,102 +384,36 @@ std::vector<BroadcastParamsExplicitAxis> generateCombinedParamsExplicitAxis() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_Broadcast_With_Hardcoded_Refs, ReferenceBroadcastTestExplicitAxis,
testing::ValuesIn(generateCombinedParamsExplicitAxis()), ReferenceBroadcastTestExplicitAxis::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Broadcast_With_Hardcoded_Refs,
ReferenceBroadcastTestExplicitAxis,
testing::ValuesIn(generateCombinedParamsExplicitAxis()),
ReferenceBroadcastTestExplicitAxis::getTestCaseName);
std::vector<BroadcastParamsTestHelper> generateParamsTestHelper() {
std::vector<BroadcastParamsTestHelper> params {
BroadcastParamsTestHelper(
{2},
{3, 2, 4},
{1},
"broadcast_algo_vector_middle"),
BroadcastParamsTestHelper(
{2},
{3, 2},
{1},
"broadcast_algo_vector_forward_2"),
BroadcastParamsTestHelper(
{2},
{4, 3, 2},
{2},
"broadcast_algo_vector_forward_3"),
BroadcastParamsTestHelper(
{2},
{5, 4, 3, 2},
{3},
"broadcast_algo_vector_forward_4"),
BroadcastParamsTestHelper(
{},
{5, 4, 3, 2},
{},
"broadcast_algo_scalar"),
BroadcastParamsTestHelper(
{2},
{2, 3},
{0},
"broadcast_algo_vector_backward_2"),
BroadcastParamsTestHelper(
{2},
{2, 3, 4},
{0},
"broadcast_algo_vector_backward_3"),
BroadcastParamsTestHelper(
{2},
{2, 3, 4, 5},
{0},
"broadcast_algo_vector_backward_4"),
BroadcastParamsTestHelper(
{4, 5},
{2, 3, 4, 5},
{2, 3},
"broadcast_algo_matrix_backward_4"),
BroadcastParamsTestHelper(
{3, 5},
{2, 3, 4, 5},
{1, 3},
"broadcast_algo_matrix_stride_1"),
BroadcastParamsTestHelper(
{3, 4},
{2, 3, 4, 5},
{1, 2},
"broadcast_algo_matrix_stride_2"),
BroadcastParamsTestHelper(
{2, 4},
{2, 3, 4, 5},
{0, 2},
"broadcast_algo_matrix_stride_3"),
BroadcastParamsTestHelper(
{2, 3, 4},
{5, 2, 3, 4},
{1, 2, 3},
"broadcast_algo_3d_backward"),
BroadcastParamsTestHelper(
{2, 3, 4},
{2, 5, 3, 4},
{0, 2, 3},
"broadcast_algo_3d_stride_1"),
BroadcastParamsTestHelper(
{2, 3, 4},
{2, 3, 5, 4},
{0, 1, 3},
"broadcast_algo_3d_stride_2"),
BroadcastParamsTestHelper(
{3, 1},
{2, 3, 3},
{1, 2},
"broadcast_algo_3d_diffrent_rank"),
BroadcastParamsTestHelper(
{2, 3, 1, 1},
{2, 3, 4, 5},
{0, 1, 2, 3},
"broadcast_algo_4d_same_rank"),
std::vector<BroadcastParamsTestHelper> params{
BroadcastParamsTestHelper({2}, {3, 2, 4}, {1}, "broadcast_algo_vector_middle"),
BroadcastParamsTestHelper({2}, {3, 2}, {1}, "broadcast_algo_vector_forward_2"),
BroadcastParamsTestHelper({2}, {4, 3, 2}, {2}, "broadcast_algo_vector_forward_3"),
BroadcastParamsTestHelper({2}, {5, 4, 3, 2}, {3}, "broadcast_algo_vector_forward_4"),
BroadcastParamsTestHelper({}, {5, 4, 3, 2}, {}, "broadcast_algo_scalar"),
BroadcastParamsTestHelper({2}, {2, 3}, {0}, "broadcast_algo_vector_backward_2"),
BroadcastParamsTestHelper({2}, {2, 3, 4}, {0}, "broadcast_algo_vector_backward_3"),
BroadcastParamsTestHelper({2}, {2, 3, 4, 5}, {0}, "broadcast_algo_vector_backward_4"),
BroadcastParamsTestHelper({4, 5}, {2, 3, 4, 5}, {2, 3}, "broadcast_algo_matrix_backward_4"),
BroadcastParamsTestHelper({3, 5}, {2, 3, 4, 5}, {1, 3}, "broadcast_algo_matrix_stride_1"),
BroadcastParamsTestHelper({3, 4}, {2, 3, 4, 5}, {1, 2}, "broadcast_algo_matrix_stride_2"),
BroadcastParamsTestHelper({2, 4}, {2, 3, 4, 5}, {0, 2}, "broadcast_algo_matrix_stride_3"),
BroadcastParamsTestHelper({2, 3, 4}, {5, 2, 3, 4}, {1, 2, 3}, "broadcast_algo_3d_backward"),
BroadcastParamsTestHelper({2, 3, 4}, {2, 5, 3, 4}, {0, 2, 3}, "broadcast_algo_3d_stride_1"),
BroadcastParamsTestHelper({2, 3, 4}, {2, 3, 5, 4}, {0, 1, 3}, "broadcast_algo_3d_stride_2"),
BroadcastParamsTestHelper({3, 1}, {2, 3, 3}, {1, 2}, "broadcast_algo_3d_diffrent_rank"),
BroadcastParamsTestHelper({2, 3, 1, 1}, {2, 3, 4, 5}, {0, 1, 2, 3}, "broadcast_algo_4d_same_rank"),
};
return params;
}
std::vector<BroadcastParamsTestHelper> generateCombinedParamsTestHelper() {
const std::vector<std::vector<BroadcastParamsTestHelper>> generatedParams {
const std::vector<std::vector<BroadcastParamsTestHelper>> generatedParams{
generateParamsTestHelper(),
};
std::vector<BroadcastParamsTestHelper> combinedParams;
@ -484,13 +424,15 @@ std::vector<BroadcastParamsTestHelper> generateCombinedParamsTestHelper() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_Broadcast_With_Hardcoded_Refs, ReferenceBroadcastTestTestHelper,
testing::ValuesIn(generateCombinedParamsTestHelper()), ReferenceBroadcastTestTestHelper::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Broadcast_With_Hardcoded_Refs,
ReferenceBroadcastTestTestHelper,
testing::ValuesIn(generateCombinedParamsTestHelper()),
ReferenceBroadcastTestTestHelper::getTestCaseName);
template <element::Type_t ET>
std::vector<BroadcastParamsExplicitAxis> generateParamsExplicitAxisReversed() {
using T = typename element_type_traits<ET>::value_type;
std::vector<BroadcastParamsExplicitAxis> params {
std::vector<BroadcastParamsExplicitAxis> params{
BroadcastParamsExplicitAxis(
reference_tests::Tensor(ET, {4}, std::vector<T>{1, 2, 3, 4}),
reference_tests::Tensor(element::u64, {2}, std::vector<uint64_t>{3, 4}),
@ -502,7 +444,7 @@ std::vector<BroadcastParamsExplicitAxis> generateParamsExplicitAxisReversed() {
}
std::vector<BroadcastParamsExplicitAxis> generateCombinedParamsExplicitAxisReversed() {
const std::vector<std::vector<BroadcastParamsExplicitAxis>> generatedParams {
const std::vector<std::vector<BroadcastParamsExplicitAxis>> generatedParams{
generateParamsExplicitAxisReversed<element::Type_t::i8>(),
generateParamsExplicitAxisReversed<element::Type_t::i16>(),
generateParamsExplicitAxisReversed<element::Type_t::i32>(),
@ -524,6 +466,8 @@ std::vector<BroadcastParamsExplicitAxis> generateCombinedParamsExplicitAxisRever
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_Broadcast_With_Hardcoded_Refs, ReferenceBroadcastTestExplicitAxisReversed,
testing::ValuesIn(generateCombinedParamsExplicitAxisReversed()), ReferenceBroadcastTestExplicitAxis::getTestCaseName);
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_Broadcast_With_Hardcoded_Refs,
ReferenceBroadcastTestExplicitAxisReversed,
testing::ValuesIn(generateCombinedParamsExplicitAxisReversed()),
ReferenceBroadcastTestExplicitAxis::getTestCaseName);
} // namespace

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/bucketize.hpp"
#include <gtest/gtest.h>
#include "openvino/op/bucketize.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
@ -12,9 +13,15 @@ using namespace ov;
struct BucketizeParams {
template <class IT, class BT, class OT>
BucketizeParams(const element::Type& input_type, const PartialShape& input_pshape, const std::vector<IT>& input,
const element::Type& bucket_type, const PartialShape& bucket_pshape, const std::vector<BT>& buckets, bool with_right_bound,
const element::Type& output_type, const std::vector<OT>& expected_output)
BucketizeParams(const element::Type& input_type,
const PartialShape& input_pshape,
const std::vector<IT>& input,
const element::Type& bucket_type,
const PartialShape& bucket_pshape,
const std::vector<BT>& buckets,
bool with_right_bound,
const element::Type& output_type,
const std::vector<OT>& expected_output)
: input_type(input_type),
input_pshape(input_pshape),
input(CreateTensor(input_type, input)),
@ -40,8 +47,12 @@ class ReferenceBucketizeLayerTest : public testing::TestWithParam<BucketizeParam
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params.input_type, params.input_pshape, params.bucket_type, params.bucket_pshape,
params.with_right_bound, params.output_type);
function = CreateFunction(params.input_type,
params.input_pshape,
params.bucket_type,
params.bucket_pshape,
params.with_right_bound,
params.output_type);
inputData = {params.input, params.buckets};
refOutData = {params.expected_output};
}
@ -59,13 +70,17 @@ public:
}
private:
static std::shared_ptr<Model> CreateFunction(const element::Type& input_type, const PartialShape& input_pshape,
const element::Type& bucket_type, const PartialShape& bucket_pshape,
const bool with_right_bound, const element::Type& output_type) {
static std::shared_ptr<Model> CreateFunction(const element::Type& input_type,
const PartialShape& input_pshape,
const element::Type& bucket_type,
const PartialShape& bucket_pshape,
const bool with_right_bound,
const element::Type& output_type) {
auto data = std::make_shared<op::v0::Parameter>(input_type, input_pshape);
auto buckets = std::make_shared<op::v0::Parameter>(bucket_type, bucket_pshape);
return std::make_shared<Model>(std::make_shared<op::v3::Bucketize>(data, buckets, output_type, with_right_bound),
ParameterVector {data, buckets});
return std::make_shared<Model>(
std::make_shared<op::v3::Bucketize>(data, buckets, output_type, with_right_bound),
ParameterVector{data, buckets});
}
};
@ -73,26 +88,27 @@ TEST_P(ReferenceBucketizeLayerTest, CompareWithHardcodedRefs) {
Exec();
}
INSTANTIATE_TEST_SUITE_P(smoke_Bucketize_With_Hardcoded_Refs, ReferenceBucketizeLayerTest,
INSTANTIATE_TEST_SUITE_P(smoke_Bucketize_With_Hardcoded_Refs,
ReferenceBucketizeLayerTest,
::testing::Values(
// fp32, int32, with_right_bound
BucketizeParams(element::f32,
PartialShape {10, 1},
std::vector<float> {8.f, 1.f, 2.f, 1.1f, 8.f, 10.f, 1.f, 10.2f, 0.f, 20.f},
PartialShape{10, 1},
std::vector<float>{8.f, 1.f, 2.f, 1.1f, 8.f, 10.f, 1.f, 10.2f, 0.f, 20.f},
element::i32,
PartialShape {4},
std::vector<int32_t> {1, 4, 10, 20},
PartialShape{4},
std::vector<int32_t>{1, 4, 10, 20},
true,
element::i32,
std::vector<int32_t> {2, 0, 1, 1, 2, 2, 0, 3, 0, 3}),
std::vector<int32_t>{2, 0, 1, 1, 2, 2, 0, 3, 0, 3}),
// fp32, int32, with_right_bound
BucketizeParams(element::i32,
PartialShape {1, 1, 10},
std::vector<int32_t> {8, 1, 2, 1, 8, 5, 1, 5, 0, 20},
PartialShape{1, 1, 10},
std::vector<int32_t>{8, 1, 2, 1, 8, 5, 1, 5, 0, 20},
element::i32,
PartialShape {4},
std::vector<int32_t> {1, 4, 10, 20},
PartialShape{4},
std::vector<int32_t>{1, 4, 10, 20},
false,
element::i32,
std::vector<int32_t> {2, 1, 1, 1, 2, 2, 1, 2, 0, 4})),
std::vector<int32_t>{2, 1, 1, 1, 2, 2, 1, 2, 0, 4})),
ReferenceBucketizeLayerTest::getTestCaseName);

View File

@ -2,10 +2,12 @@
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
#include "openvino/op/ceiling.hpp"
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
using namespace ov;
using namespace reference_tests;
@ -14,9 +16,9 @@ namespace {
struct CeilingParams {
template <class IT>
CeilingParams(const PartialShape& shape,
const element::Type& iType,
const std::vector<IT>& iValues,
const std::vector<IT>& oValues)
const element::Type& iType,
const std::vector<IT>& iValues,
const std::vector<IT>& oValues)
: pshape(shape),
inType(iType),
outType(iType),
@ -50,11 +52,11 @@ public:
private:
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape,
const element::Type& input_type,
const element::Type& expected_output_type) {
const element::Type& input_type,
const element::Type& expected_output_type) {
const auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
const auto ceiling = std::make_shared<op::v0::Ceiling>(in);
return std::make_shared<Model>(NodeVector {ceiling}, ParameterVector {in});
return std::make_shared<Model>(NodeVector{ceiling}, ParameterVector{in});
}
};
@ -66,12 +68,10 @@ template <element::Type_t IN_ET>
std::vector<CeilingParams> generateParamsForCeilingFloat() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<CeilingParams> params{
CeilingParams(ov::PartialShape{4},
IN_ET,
std::vector<T>{-2.5f, -2.0f, 0.3f, 4.8f},
std::vector<T>{-2.0f, -2.0f, 1.0f, 5.0f})
};
std::vector<CeilingParams> params{CeilingParams(ov::PartialShape{4},
IN_ET,
std::vector<T>{-2.5f, -2.0f, 0.3f, 4.8f},
std::vector<T>{-2.0f, -2.0f, 1.0f, 5.0f})};
return params;
}
@ -79,12 +79,10 @@ template <element::Type_t IN_ET>
std::vector<CeilingParams> generateParamsForCeilingInt64() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<CeilingParams> params{
CeilingParams(ov::PartialShape{3},
IN_ET,
std::vector<T>{0, 1, 0x4000000000000001},
std::vector<T>{0, 1, 0x4000000000000001})
};
std::vector<CeilingParams> params{CeilingParams(ov::PartialShape{3},
IN_ET,
std::vector<T>{0, 1, 0x4000000000000001},
std::vector<T>{0, 1, 0x4000000000000001})};
return params;
}
@ -92,12 +90,10 @@ template <element::Type_t IN_ET>
std::vector<CeilingParams> generateParamsForCeilingInt32() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<CeilingParams> params{
CeilingParams(ov::PartialShape{4},
IN_ET,
std::vector<T>{2, 136314888, 0x40000010, 0x40000001},
std::vector<T>{2, 136314888, 0x40000010, 0x40000001})
};
std::vector<CeilingParams> params{CeilingParams(ov::PartialShape{4},
IN_ET,
std::vector<T>{2, 136314888, 0x40000010, 0x40000001},
std::vector<T>{2, 136314888, 0x40000010, 0x40000001})};
return params;
}
@ -105,28 +101,24 @@ template <element::Type_t IN_ET>
std::vector<CeilingParams> generateParamsForCeilingInt() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<CeilingParams> params{
CeilingParams(ov::PartialShape{4},
IN_ET,
std::vector<T>{2, 64, 0x40, 0x01},
std::vector<T>{2, 64, 0x40, 0x01})
};
std::vector<CeilingParams> params{CeilingParams(ov::PartialShape{4},
IN_ET,
std::vector<T>{2, 64, 0x40, 0x01},
std::vector<T>{2, 64, 0x40, 0x01})};
return params;
}
std::vector<CeilingParams> generateCombinedParamsForCeiling() {
const std::vector<std::vector<CeilingParams>> allTypeParams{
generateParamsForCeilingFloat<element::Type_t::f32>(),
generateParamsForCeilingFloat<element::Type_t::f16>(),
generateParamsForCeilingInt64<element::Type_t::i64>(),
generateParamsForCeilingInt32<element::Type_t::i32>(),
generateParamsForCeilingInt<element::Type_t::i16>(),
generateParamsForCeilingInt<element::Type_t::i8>(),
generateParamsForCeilingInt64<element::Type_t::u64>(),
generateParamsForCeilingInt32<element::Type_t::u32>(),
generateParamsForCeilingInt<element::Type_t::u16>(),
generateParamsForCeilingInt<element::Type_t::u8>()
};
const std::vector<std::vector<CeilingParams>> allTypeParams{generateParamsForCeilingFloat<element::Type_t::f32>(),
generateParamsForCeilingFloat<element::Type_t::f16>(),
generateParamsForCeilingInt64<element::Type_t::i64>(),
generateParamsForCeilingInt32<element::Type_t::i32>(),
generateParamsForCeilingInt<element::Type_t::i16>(),
generateParamsForCeilingInt<element::Type_t::i8>(),
generateParamsForCeilingInt64<element::Type_t::u64>(),
generateParamsForCeilingInt32<element::Type_t::u32>(),
generateParamsForCeilingInt<element::Type_t::u16>(),
generateParamsForCeilingInt<element::Type_t::u8>()};
std::vector<CeilingParams> combinedParams;
@ -137,10 +129,9 @@ std::vector<CeilingParams> generateCombinedParamsForCeiling() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(
smoke_Ceiling_With_Hardcoded_Refs,
ReferenceCeilingLayerTest,
::testing::ValuesIn(generateCombinedParamsForCeiling()),
ReferenceCeilingLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Ceiling_With_Hardcoded_Refs,
ReferenceCeilingLayerTest,
::testing::ValuesIn(generateCombinedParamsForCeiling()),
ReferenceCeilingLayerTest::getTestCaseName);
} // namespace

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/clamp.hpp"
#include <gtest/gtest.h>
#include "openvino/op/clamp.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
@ -13,8 +14,12 @@ using namespace ov;
namespace {
struct ClampParams {
template <class IT>
ClampParams(const ov::PartialShape& shape, const ov::element::Type& iType, const std::vector<IT>& iValues, const std::vector<IT>& oValues,
const double min, const double max)
ClampParams(const ov::PartialShape& shape,
const ov::element::Type& iType,
const std::vector<IT>& iValues,
const std::vector<IT>& oValues,
const double min,
const double max)
: min(min),
max(max),
pshape(shape),
@ -53,11 +58,14 @@ public:
}
private:
static std::shared_ptr<Model> CreateFunction(const ov::PartialShape& input_shape, const ov::element::Type& input_type,
const ov::element::Type& expected_output_type, const double min, const double max) {
static std::shared_ptr<Model> CreateFunction(const ov::PartialShape& input_shape,
const ov::element::Type& input_type,
const ov::element::Type& expected_output_type,
const double min,
const double max) {
const auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
const auto Clamp = std::make_shared<op::v0::Clamp>(in, min, max);
return std::make_shared<ov::Model>(NodeVector {Clamp}, ParameterVector {in});
return std::make_shared<ov::Model>(NodeVector{Clamp}, ParameterVector{in});
}
};
@ -72,32 +80,31 @@ std::vector<ClampParams> generateClampFloatParams() {
auto max = std::numeric_limits<T>::max();
auto pinf = std::numeric_limits<float>::infinity();
auto ninf = -std::numeric_limits<float>::infinity();
std::vector<ClampParams> clampParams {
ClampParams(ov::PartialShape {5, 2},
std::vector<ClampParams> clampParams{
ClampParams(ov::PartialShape{5, 2},
IN_ET,
std::vector<T>{-0.1, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8},
std::vector<T>{0.2, 0.2, 0.2, 0.2, 0.3, 0.4, 0.5, 0.6, 0.6, 0.6},
0.2,
0.6),
ClampParams(ov::PartialShape {5, 2},
ClampParams(ov::PartialShape{5, 2},
IN_ET,
std::vector<T>{min, max, ninf, pinf, 9.99999, 10.0, 10.000001, 19.999999, 20.0, 20.000001},
std::vector<T>{10.0, 20.0, 10.0, 20.0, 10.0, 10.0, 10.000001, 19.999999, 20.0, 20.0},
10.0,
20.0),
ClampParams(ov::PartialShape {5, 2},
ClampParams(ov::PartialShape{5, 2},
IN_ET,
std::vector<T>{min, max, ninf, pinf, 9.99999, 10.0, 10.000001, 19.999999, 20.0, 20.000001},
std::vector<T>{10.0, max, 10.0, pinf, 10.0, 10.0, 10.000001, 19.999999, 20.0, 20.000001},
10.0,
pinf),
ClampParams(ov::PartialShape {5, 2},
ClampParams(ov::PartialShape{5, 2},
IN_ET,
std::vector<T>{min, max, ninf, pinf, 9.99999, 10.0, 10.000001, 19.999999, 20.0, 20.000001},
std::vector<T>{min, 20.0, ninf, 20.0, 9.99999, 10.0, 10.000001, 19.999999, 20.0, 20.0},
ninf,
20.0)
};
20.0)};
return clampParams;
}
@ -108,38 +115,36 @@ std::vector<ClampParams> generateClampIntParams() {
auto max = std::numeric_limits<T>::max();
auto pinf = std::numeric_limits<float>::infinity();
auto ninf = -std::numeric_limits<float>::infinity();
std::vector<ClampParams> clampParams {
ClampParams(ov::PartialShape {6},
IN_ET,
std::vector<T>{-1, 3, -10, 20, 6, 2},
std::vector<T>{1, 3, 1, 5, 5, 2},
0.4,
5.6),
ClampParams(ov::PartialShape {6},
IN_ET,
std::vector<T>{-6, 1, -2, 0, -1, 2},
std::vector<T>{-5, -1, -2, -1, -1, -1},
-5.6,
-0.4),
ClampParams(ov::PartialShape {4, 2},
IN_ET,
std::vector<T>{min, max, 9, 10, 11, 19, 20, 21},
std::vector<T>{10, 20, 10, 10, 11, 19, 20, 20},
10.0,
20.0),
ClampParams(ov::PartialShape {4, 2},
IN_ET,
std::vector<T>{min, max, 9, 10, 11, 19, 20, 21},
std::vector<T>{10, max, 10, 10, 11, 19, 20, 21},
10.0,
pinf),
ClampParams(ov::PartialShape {4, 2},
IN_ET,
std::vector<T>{min, max, 9, 10, 11, 19, 20, 21},
std::vector<T>{min, 20, 9, 10, 11, 19, 20, 20},
ninf,
20.0)
};
std::vector<ClampParams> clampParams{ClampParams(ov::PartialShape{6},
IN_ET,
std::vector<T>{-1, 3, -10, 20, 6, 2},
std::vector<T>{1, 3, 1, 5, 5, 2},
0.4,
5.6),
ClampParams(ov::PartialShape{6},
IN_ET,
std::vector<T>{-6, 1, -2, 0, -1, 2},
std::vector<T>{-5, -1, -2, -1, -1, -1},
-5.6,
-0.4),
ClampParams(ov::PartialShape{4, 2},
IN_ET,
std::vector<T>{min, max, 9, 10, 11, 19, 20, 21},
std::vector<T>{10, 20, 10, 10, 11, 19, 20, 20},
10.0,
20.0),
ClampParams(ov::PartialShape{4, 2},
IN_ET,
std::vector<T>{min, max, 9, 10, 11, 19, 20, 21},
std::vector<T>{10, max, 10, 10, 11, 19, 20, 21},
10.0,
pinf),
ClampParams(ov::PartialShape{4, 2},
IN_ET,
std::vector<T>{min, max, 9, 10, 11, 19, 20, 21},
std::vector<T>{min, 20, 9, 10, 11, 19, 20, 20},
ninf,
20.0)};
return clampParams;
}
@ -150,43 +155,39 @@ std::vector<ClampParams> generateClampUintParams() {
T max = (static_cast<T>(1) << (std::numeric_limits<T>::digits - 1)) - 1;
auto pinf = static_cast<double>(max);
auto ninf = -std::numeric_limits<float>::infinity();
std::vector<ClampParams> clampParams {
ClampParams(ov::PartialShape {4, 2},
IN_ET,
std::vector<T>{min, max, 9, 10, 11, 19, 20, 21},
std::vector<T>{10, 20, 10, 10, 11, 19, 20, 20},
10.0,
20.0),
ClampParams(ov::PartialShape {4, 2},
IN_ET,
std::vector<T>{min, max, 9, 10, 11, 19, 20, 21},
std::vector<T>{10, max, 10, 10, 11, 19, 20, 21},
10.0,
pinf),
ClampParams(ov::PartialShape {4, 2},
IN_ET,
std::vector<T>{min, max, 9, 10, 11, 19, 20, 21},
std::vector<T>{min, 20, 9, 10, 11, 19, 20, 20},
ninf,
20.0)
};
std::vector<ClampParams> clampParams{ClampParams(ov::PartialShape{4, 2},
IN_ET,
std::vector<T>{min, max, 9, 10, 11, 19, 20, 21},
std::vector<T>{10, 20, 10, 10, 11, 19, 20, 20},
10.0,
20.0),
ClampParams(ov::PartialShape{4, 2},
IN_ET,
std::vector<T>{min, max, 9, 10, 11, 19, 20, 21},
std::vector<T>{10, max, 10, 10, 11, 19, 20, 21},
10.0,
pinf),
ClampParams(ov::PartialShape{4, 2},
IN_ET,
std::vector<T>{min, max, 9, 10, 11, 19, 20, 21},
std::vector<T>{min, 20, 9, 10, 11, 19, 20, 20},
ninf,
20.0)};
return clampParams;
}
std::vector<ClampParams> generateClampCombinedParams() {
const std::vector<std::vector<ClampParams>> clampTypeParams {
generateClampFloatParams<element::Type_t::f32>(),
generateClampFloatParams<element::Type_t::f16>(),
generateClampFloatParams<element::Type_t::bf16>(),
generateClampIntParams<element::Type_t::i8>(),
generateClampIntParams<element::Type_t::i16>(),
generateClampIntParams<element::Type_t::i32>(),
generateClampIntParams<element::Type_t::i64>(),
generateClampUintParams<element::Type_t::u8>(),
generateClampUintParams<element::Type_t::u16>(),
generateClampUintParams<element::Type_t::u32>(),
generateClampUintParams<element::Type_t::u64>()
};
const std::vector<std::vector<ClampParams>> clampTypeParams{generateClampFloatParams<element::Type_t::f32>(),
generateClampFloatParams<element::Type_t::f16>(),
generateClampFloatParams<element::Type_t::bf16>(),
generateClampIntParams<element::Type_t::i8>(),
generateClampIntParams<element::Type_t::i16>(),
generateClampIntParams<element::Type_t::i32>(),
generateClampIntParams<element::Type_t::i64>(),
generateClampUintParams<element::Type_t::u8>(),
generateClampUintParams<element::Type_t::u16>(),
generateClampUintParams<element::Type_t::u32>(),
generateClampUintParams<element::Type_t::u64>()};
std::vector<ClampParams> combinedParams;
for (const auto& params : clampTypeParams) {
@ -195,7 +196,9 @@ std::vector<ClampParams> generateClampCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_Clamp_With_Hardcoded_Refs, ReferenceClampLayerTest,
testing::ValuesIn(generateClampCombinedParams()), ReferenceClampLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Clamp_With_Hardcoded_Refs,
ReferenceClampLayerTest,
testing::ValuesIn(generateClampCombinedParams()),
ReferenceClampLayerTest::getTestCaseName);
} // namespace
} // namespace

View File

@ -10,6 +10,6 @@ namespace {
TEST_P(ReferenceComparisonLayerTest, CompareWithHardcodedRefs) {
Exec();
}
} // namespace
} // namespace ComparisonOpsRefTestDefinitions
} // namespace reference_tests
} // namespace
} // namespace ComparisonOpsRefTestDefinitions
} // namespace reference_tests

View File

@ -7,14 +7,14 @@
#include "base_reference_test.hpp"
#include "common_test_utils/test_enums.hpp"
#include "openvino/op/equal.hpp"
#include "openvino/op/not_equal.hpp"
#include "openvino/op/greater.hpp"
#include "openvino/op/greater_eq.hpp"
#include "openvino/op/is_finite.hpp"
#include "openvino/op/is_inf.hpp"
#include "openvino/op/is_nan.hpp"
#include "openvino/op/less.hpp"
#include "openvino/op/less_eq.hpp"
#include "openvino/op/is_inf.hpp"
#include "openvino/op/is_finite.hpp"
#include "openvino/op/is_nan.hpp"
#include "openvino/op/not_equal.hpp"
using namespace ov;
@ -41,7 +41,11 @@ class ReferenceComparisonLayerTest : public testing::TestWithParam<RefComparison
public:
void SetUp() override {
const auto& params = GetParam();
function = CreateFunction(params.compType, params.input1.shape, params.input2.shape, params.input1.type, params.expected.type);
function = CreateFunction(params.compType,
params.input1.shape,
params.input2.shape,
params.input1.type,
params.expected.type);
inputData = {params.input1.data, params.input2.data};
refOutData = {params.expected.data};
}
@ -57,54 +61,56 @@ public:
}
private:
static std::shared_ptr<ov::Model> CreateFunction(ComparisonTypes comp_op_type, const ov::PartialShape& input_shape1,
const ov::PartialShape& input_shape2, const ov::element::Type& input_type,
const ov::element::Type& expected_output_type) {
static std::shared_ptr<ov::Model> CreateFunction(ComparisonTypes comp_op_type,
const ov::PartialShape& input_shape1,
const ov::PartialShape& input_shape2,
const ov::element::Type& input_type,
const ov::element::Type& expected_output_type) {
const auto in0 = std::make_shared<op::v0::Parameter>(input_type, input_shape1);
const auto in1 = std::make_shared<op::v0::Parameter>(input_type, input_shape2);
std::shared_ptr<ov::Node> comp;
switch (comp_op_type) {
case ComparisonTypes::EQUAL: {
comp = std::make_shared<ov::op::v1::Equal>(in0, in1);
comp = std::make_shared<ov::op::v1::Equal>(in0, in1);
break;
}
case ComparisonTypes::NOT_EQUAL: {
comp = std::make_shared<ov::op::v1::NotEqual>(in0, in1);
comp = std::make_shared<ov::op::v1::NotEqual>(in0, in1);
break;
}
case ComparisonTypes::GREATER: {
comp = std::make_shared<ov::op::v1::Greater>(in0, in1);
comp = std::make_shared<ov::op::v1::Greater>(in0, in1);
break;
}
case ComparisonTypes::GREATER_EQUAL: {
comp = std::make_shared<ov::op::v1::GreaterEqual>(in0, in1);
comp = std::make_shared<ov::op::v1::GreaterEqual>(in0, in1);
break;
}
case ComparisonTypes::IS_FINITE: {
comp = std::make_shared<ov::op::v10::IsFinite>(in0);
comp = std::make_shared<ov::op::v10::IsFinite>(in0);
break;
}
case ComparisonTypes::IS_INF: {
comp = std::make_shared<ov::op::v10::IsInf>(in0);
comp = std::make_shared<ov::op::v10::IsInf>(in0);
break;
}
case ComparisonTypes::IS_NAN: {
comp = std::make_shared<ov::op::v10::IsNaN>(in0);
comp = std::make_shared<ov::op::v10::IsNaN>(in0);
break;
}
case ComparisonTypes::LESS: {
comp = std::make_shared<ov::op::v1::Less>(in0, in1);
comp = std::make_shared<ov::op::v1::Less>(in0, in1);
break;
}
case ComparisonTypes::LESS_EQUAL: {
comp = std::make_shared<ov::op::v1::LessEqual>(in0, in1);
comp = std::make_shared<ov::op::v1::LessEqual>(in0, in1);
break;
}
default: {
throw std::runtime_error("Incorrect type of Comparison operation");
}
}
return std::make_shared<ov::Model>(ov::NodeVector {comp}, ov::ParameterVector {in0, in1});
return std::make_shared<ov::Model>(ov::NodeVector{comp}, ov::ParameterVector{in0, in1});
}
};
} // namespace ComparisonOpsRefTestDefinitions

File diff suppressed because it is too large Load Diff

View File

@ -2,14 +2,16 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/constant.hpp"
#include <gtest/gtest.h>
#include <random>
#include "openvino/op/constant.hpp"
#include "openvino/op/abs.hpp"
#include "openvino/op/equal.hpp"
#include "base_reference_test.hpp"
#include "functional_test_utils/skip_tests_config.hpp"
#include "openvino/op/abs.hpp"
#include "openvino/op/equal.hpp"
using namespace reference_tests;
using namespace ov;
@ -18,8 +20,10 @@ namespace {
struct ConstantParams {
template <class IT, class OT>
ConstantParams(const PartialShape& inputShape,
const element::Type& inType, const element::Type& refType,
const std::vector<IT>& inputData, const std::vector<OT>& refData,
const element::Type& inType,
const element::Type& refType,
const std::vector<IT>& inputData,
const std::vector<OT>& refData,
const std::string& test_name = "")
: inputShape(inputShape),
inType(inType),
@ -155,9 +159,11 @@ TEST_P(ReferenceConstantLayerTest_EqualityBool, CompareWithHardcodedRefs) {
template <element::Type_t IN_ET>
std::vector<ConstantParams> generateConstantParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<ConstantParams> constantParams {
std::vector<ConstantParams> constantParams{
// tensor_constant
ConstantParams({2, 2, 2}, IN_ET, IN_ET,
ConstantParams({2, 2, 2},
IN_ET,
IN_ET,
std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8},
std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8},
"tensor_constant"),
@ -166,33 +172,41 @@ std::vector<ConstantParams> generateConstantParams() {
}
std::vector<ConstantParams> generateConstantDefinedTypeParams() {
std::vector<ConstantParams> constantParams {
std::vector<ConstantParams> constantParams{
// scalar_constant_float32
ConstantParams({}, element::Type_t::f32, element::Type_t::f32,
std::vector<float>{4.75},
std::vector<float>{4.75f},
"scalar_constant_float32"),
ConstantParams({},
element::Type_t::f32,
element::Type_t::f32,
std::vector<float>{4.75},
std::vector<float>{4.75f},
"scalar_constant_float32"),
// scalar_constant_int64
ConstantParams({}, element::Type_t::i64, element::Type_t::i64,
std::vector<int64_t>{0x4000000000000001},
std::vector<int64_t>{0x4000000000000001},
"scalar_constant_int64"),
ConstantParams({},
element::Type_t::i64,
element::Type_t::i64,
std::vector<int64_t>{0x4000000000000001},
std::vector<int64_t>{0x4000000000000001},
"scalar_constant_int64"),
// tensor_constant_float32
ConstantParams({2, 2}, element::Type_t::f32, element::Type_t::f32,
std::vector<float>{4.75, 4.5, -5.25, 0.0},
std::vector<float>{4.75f, 4.5f, -5.25f, 0.0f},
"tensor_constant_float32"),
ConstantParams({2, 2},
element::Type_t::f32,
element::Type_t::f32,
std::vector<float>{4.75, 4.5, -5.25, 0.0},
std::vector<float>{4.75f, 4.5f, -5.25f, 0.0f},
"tensor_constant_float32"),
// tensor_constant_int64
ConstantParams({2}, element::Type_t::i64, element::Type_t::i64,
std::vector<int64_t>{0x4000000000000001, 0x4000000000000002},
std::vector<int64_t>{0x4000000000000001, 0x4000000000000002},
"tensor_constant_int64"),
ConstantParams({2},
element::Type_t::i64,
element::Type_t::i64,
std::vector<int64_t>{0x4000000000000001, 0x4000000000000002},
std::vector<int64_t>{0x4000000000000001, 0x4000000000000002},
"tensor_constant_int64"),
};
return constantParams;
}
std::vector<ConstantParams> generateConstantCombinedParams() {
const std::vector<std::vector<ConstantParams>> constantTypeParams {
const std::vector<std::vector<ConstantParams>> constantTypeParams{
generateConstantParams<element::Type_t::i8>(),
generateConstantParams<element::Type_t::i16>(),
generateConstantParams<element::Type_t::i32>(),
@ -216,7 +230,7 @@ std::vector<ConstantParams> generateConstantCombinedParams() {
}
std::vector<ConstantParams> generateConstant2ConstantCombinedParams() {
const std::vector<std::vector<ConstantParams>> constantTypeParams {
const std::vector<std::vector<ConstantParams>> constantTypeParams{
generateConstantParams<element::Type_t::i8>(),
generateConstantParams<element::Type_t::i16>(),
generateConstantParams<element::Type_t::i32>(),
@ -241,9 +255,11 @@ std::vector<ConstantParams> generateConstant2ConstantCombinedParams() {
template <element::Type_t IN_ET>
std::vector<ConstantParams> generateConstantWithOpParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<ConstantParams> constantParams {
std::vector<ConstantParams> constantParams{
// tensor_constant_with_op
ConstantParams({2, 2, 2}, IN_ET, IN_ET,
ConstantParams({2, 2, 2},
IN_ET,
IN_ET,
std::vector<T>{-1, 2, 3, -4, 5, -6, -7, 8},
std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8},
"tensor_constant_with_op"),
@ -252,7 +268,7 @@ std::vector<ConstantParams> generateConstantWithOpParams() {
}
std::vector<ConstantParams> generateConstantWithOpCombinedParams() {
const std::vector<std::vector<ConstantParams>> constantTypeParams {
const std::vector<std::vector<ConstantParams>> constantTypeParams{
generateConstantWithOpParams<element::Type_t::i8>(),
generateConstantWithOpParams<element::Type_t::i16>(),
generateConstantWithOpParams<element::Type_t::i32>(),
@ -271,39 +287,53 @@ std::vector<ConstantParams> generateConstantWithOpCombinedParams() {
}
std::vector<ConstantParams> generateConstantDefinedTypeMultiUseCombinedParams() {
const std::vector<ConstantParams> combinedParams {
const std::vector<ConstantParams> combinedParams{
// constant_multi_use
ConstantParams({}, element::Type_t::i32, element::Type_t::i32,
std::vector<int32_t>{388},
std::vector<int32_t>{388},
"constant_multi_use"),
ConstantParams({},
element::Type_t::i32,
element::Type_t::i32,
std::vector<int32_t>{388},
std::vector<int32_t>{388},
"constant_multi_use"),
};
return combinedParams;
}
std::vector<ConstantParams> generateConstantDefinedTypeEqualityBoolCombinedParams() {
const std::vector<ConstantParams> combinedParams {
const std::vector<ConstantParams> combinedParams{
// constant_equality_bool
ConstantParams({4}, element::Type_t::boolean, element::Type_t::boolean,
std::vector<char>{true, false, true, false},
std::vector<char>{true, false, true, false},
"constant_equality_bool"),
ConstantParams({4},
element::Type_t::boolean,
element::Type_t::boolean,
std::vector<char>{true, false, true, false},
std::vector<char>{true, false, true, false},
"constant_equality_bool"),
};
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_Constant_With_Hardcoded_Refs, ReferenceConstantLayerTest,
testing::ValuesIn(generateConstantCombinedParams()), ReferenceConstantLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Constant_With_Hardcoded_Refs,
ReferenceConstantLayerTest,
testing::ValuesIn(generateConstantCombinedParams()),
ReferenceConstantLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Constant_With_Hardcoded_Refs, ReferenceConstantLayerTest_2Constant,
testing::ValuesIn(generateConstant2ConstantCombinedParams()), ReferenceConstantLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Constant_With_Hardcoded_Refs,
ReferenceConstantLayerTest_2Constant,
testing::ValuesIn(generateConstant2ConstantCombinedParams()),
ReferenceConstantLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Constant_With_Hardcoded_Refs, ReferenceConstantLayerTest_WithOp,
testing::ValuesIn(generateConstantWithOpCombinedParams()), ReferenceConstantLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Constant_With_Hardcoded_Refs,
ReferenceConstantLayerTest_WithOp,
testing::ValuesIn(generateConstantWithOpCombinedParams()),
ReferenceConstantLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Constant_With_Hardcoded_Refs, ReferenceConstantLayerTest_MultiUse,
testing::ValuesIn(generateConstantDefinedTypeMultiUseCombinedParams()), ReferenceConstantLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Constant_With_Hardcoded_Refs,
ReferenceConstantLayerTest_MultiUse,
testing::ValuesIn(generateConstantDefinedTypeMultiUseCombinedParams()),
ReferenceConstantLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Constant_With_Hardcoded_Refs, ReferenceConstantLayerTest_EqualityBool,
testing::ValuesIn(generateConstantDefinedTypeEqualityBoolCombinedParams()), ReferenceConstantLayerTest::getTestCaseName);
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_Constant_With_Hardcoded_Refs,
ReferenceConstantLayerTest_EqualityBool,
testing::ValuesIn(generateConstantDefinedTypeEqualityBoolCombinedParams()),
ReferenceConstantLayerTest::getTestCaseName);
} // namespace

View File

@ -10,6 +10,6 @@ namespace {
TEST_P(ReferenceConversionLayerTest, CompareWithHardcodedRefs) {
Exec();
}
} // namespace
} // namespace ConversionOpsRefTestDefinitions
} // namespace reference_tests
} // namespace
} // namespace ConversionOpsRefTestDefinitions
} // namespace reference_tests

View File

@ -17,16 +17,24 @@ namespace ConversionOpsRefTestDefinitions {
using ov::test::utils::ConversionTypes;
static std::map<ConversionTypes, std::string> conversionNames = {
{ConversionTypes::CONVERT, "Convert"},
{ConversionTypes::CONVERT_LIKE, "ConvertLike"}
};
static std::map<ConversionTypes, std::string> conversionNames = {{ConversionTypes::CONVERT, "Convert"},
{ConversionTypes::CONVERT_LIKE, "ConvertLike"}};
struct ConvertParams {
template <class IT, class OT>
ConvertParams(ConversionTypes convType, const ov::PartialShape& shape, const ov::element::Type& iType,
const ov::element::Type& oType, const std::vector<IT>& iValues, const std::vector<OT>& oValues, size_t iSize = 0, size_t oSize = 0)
: conversionType(convType), pshape(shape), inType(iType), outType(oType), inputData(CreateTensor(iType, iValues, iSize)),
ConvertParams(ConversionTypes convType,
const ov::PartialShape& shape,
const ov::element::Type& iType,
const ov::element::Type& oType,
const std::vector<IT>& iValues,
const std::vector<OT>& oValues,
size_t iSize = 0,
size_t oSize = 0)
: conversionType(convType),
pshape(shape),
inType(iType),
outType(oType),
inputData(CreateTensor(iType, iValues, iSize)),
refData(CreateTensor(oType, oValues, oSize)) {}
ConversionTypes conversionType;
ov::PartialShape pshape;
@ -56,9 +64,10 @@ public:
}
private:
static std::shared_ptr<ov::Model> CreateFunction(const ov::PartialShape& input_shape, const ov::element::Type& input_type,
const ov::element::Type& expected_output_type,
const ConversionTypes& conversion_type) {
static std::shared_ptr<ov::Model> CreateFunction(const ov::PartialShape& input_shape,
const ov::element::Type& input_type,
const ov::element::Type& expected_output_type,
const ConversionTypes& conversion_type) {
const auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
std::shared_ptr<ov::Node> convert;
if (conversion_type == ConversionTypes::CONVERT) {
@ -69,8 +78,8 @@ private:
} else {
throw std::runtime_error("Incorrect type of Conversion operation");
}
return std::make_shared<ov::Model>(ov::NodeVector {convert}, ov::ParameterVector {in});
return std::make_shared<ov::Model>(ov::NodeVector{convert}, ov::ParameterVector{in});
}
};
} // namespace ConversionOpsRefTestDefinitions
} // namespace reference_tests
} // namespace ConversionOpsRefTestDefinitions
} // namespace reference_tests

File diff suppressed because it is too large Load Diff

View File

@ -5,9 +5,9 @@
#include <gtest/gtest.h>
#include <openvino/core/model.hpp>
#include <tuple>
#include <openvino/op/i420_to_rgb.hpp>
#include <openvino/op/i420_to_bgr.hpp>
#include <openvino/op/i420_to_rgb.hpp>
#include <tuple>
#include "base_reference_test.hpp"
#include "functional_test_utils/skip_tests_config.hpp"
@ -20,8 +20,8 @@ class ReferenceConvertColorI420LayerTest : public testing::Test, public CommonRe
public:
void SetUp() override {
SKIP_IF_CURRENT_TEST_IS_DISABLED()
abs_threshold = 1.f; // allow R, G, B absolute deviation to 1 (of max 255)
threshold = 1.f; // Ignore relative comparison (100%)
abs_threshold = 1.f; // allow R, G, B absolute deviation to 1 (of max 255)
threshold = 1.f; // Ignore relative comparison (100%)
}
public:
@ -31,28 +31,28 @@ public:
std::shared_ptr<Node> conv;
conv = std::make_shared<T>(in);
auto res = std::make_shared<op::v0::Result>(conv);
return std::make_shared<Model>(ResultVector{res}, ParameterVector {in});
return std::make_shared<Model>(ResultVector{res}, ParameterVector{in});
}
template <typename T>
static std::shared_ptr<Model> CreateFunction3(const reference_tests::Tensor& input1, const reference_tests::Tensor& input2, const reference_tests::Tensor& input3) {
static std::shared_ptr<Model> CreateFunction3(const reference_tests::Tensor& input1,
const reference_tests::Tensor& input2,
const reference_tests::Tensor& input3) {
const auto in1 = std::make_shared<op::v0::Parameter>(input1.type, input1.shape);
const auto in2 = std::make_shared<op::v0::Parameter>(input2.type, input2.shape);
const auto in3 = std::make_shared<op::v0::Parameter>(input3.type, input3.shape);
std::shared_ptr<Node> conv;
conv = std::make_shared<T>(in1, in2, in3);
auto res = std::make_shared<op::v0::Result>(conv);
return std::make_shared<Model>(ResultVector{res}, ParameterVector {in1, in2, in3});
return std::make_shared<Model>(ResultVector{res}, ParameterVector{in1, in2, in3});
}
};
TEST_F(ReferenceConvertColorI420LayerTest, CompareWithHardcodedRefs_r_u8_single_rgb) {
auto input = std::vector<uint8_t> {0x51, 0x51, 0x51, 0x51,
0x51, 0x51, 0x51, 0x51,
0x5a, 0x5a, 0xf0, 0xf0};
auto input = std::vector<uint8_t>{0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x5a, 0x5a, 0xf0, 0xf0};
auto input_shape = Shape{1, 3, 4, 1};
auto exp_out = std::vector<uint8_t> {0xff, 0, 0, 0xff, 0, 0, 0xff, 0, 0, 0xff, 0, 0,
0xff, 0, 0, 0xff, 0, 0, 0xff, 0, 0, 0xff, 0, 0};
auto exp_out = std::vector<uint8_t>{0xff, 0, 0, 0xff, 0, 0, 0xff, 0, 0, 0xff, 0, 0,
0xff, 0, 0, 0xff, 0, 0, 0xff, 0, 0, 0xff, 0, 0};
auto out_shape = Shape{1, 2, 4, 3};
reference_tests::Tensor inp_tensor(input_shape, element::u8, input);
inputData = {inp_tensor.data};
@ -63,12 +63,10 @@ TEST_F(ReferenceConvertColorI420LayerTest, CompareWithHardcodedRefs_r_u8_single_
}
TEST_F(ReferenceConvertColorI420LayerTest, CompareWithHardcodedRefs_color_u8_single_bgr) {
auto input = std::vector<uint8_t> {0x51, 0xeb, 0x51, 0xeb,
0x51, 0xeb, 0x51, 0xeb,
0x6d, 0x6d, 0xb8, 0xb8};
auto input = std::vector<uint8_t>{0x51, 0xeb, 0x51, 0xeb, 0x51, 0xeb, 0x51, 0xeb, 0x6d, 0x6d, 0xb8, 0xb8};
auto input_shape = Shape{1, 6, 2, 1};
auto exp_out = std::vector<uint8_t> {37, 37, 164, 217, 216, 255, 37, 37, 164, 217, 216, 255,
37, 37, 164, 217, 216, 255, 37, 37, 164, 217, 216, 255};
auto exp_out = std::vector<uint8_t>{37, 37, 164, 217, 216, 255, 37, 37, 164, 217, 216, 255,
37, 37, 164, 217, 216, 255, 37, 37, 164, 217, 216, 255};
auto out_shape = Shape{1, 4, 2, 3};
reference_tests::Tensor inp_tensor(input_shape, element::u8, input);
@ -83,12 +81,10 @@ TEST_F(ReferenceConvertColorI420LayerTest, CompareWithHardcodedRefs_color_u8_sin
}
TEST_F(ReferenceConvertColorI420LayerTest, CompareWithHardcodedRefs_g_fp32_single_rgb) {
auto input = std::vector<float> {145.f, 145.f, 145.f, 145.f,
145.f, 145.f, 145.f, 145.f,
54.f, 54.f, 34.f, 34.f};
auto input = std::vector<float>{145.f, 145.f, 145.f, 145.f, 145.f, 145.f, 145.f, 145.f, 54.f, 54.f, 34.f, 34.f};
auto input_shape = Shape{1, 3, 4, 1};
auto exp_out = std::vector<float> {0, 255.f, 0, 0, 255.f, 0, 0, 255.f, 0, 0, 255.f, 0,
0, 255.f, 0, 0, 255.f, 0, 0, 255.f, 0, 0, 255.f, 0};
auto exp_out = std::vector<float>{0, 255.f, 0, 0, 255.f, 0, 0, 255.f, 0, 0, 255.f, 0,
0, 255.f, 0, 0, 255.f, 0, 0, 255.f, 0, 0, 255.f, 0};
auto out_shape = Shape{1, 2, 4, 3};
reference_tests::Tensor inp_tensor(input_shape, element::f32, input);
@ -103,23 +99,17 @@ TEST_F(ReferenceConvertColorI420LayerTest, CompareWithHardcodedRefs_g_fp32_singl
}
TEST_F(ReferenceConvertColorI420LayerTest, CompareWithHardcodedRefs_batch_fp32_three_bgr) {
auto input_y = std::vector<float> {81.f, 81.f, 81.f, 81.f,
145.f, 145.f, 145.f, 145.f,
41.f, 41.f, 41.f, 41.f};
auto input_y = std::vector<float>{81.f, 81.f, 81.f, 81.f, 145.f, 145.f, 145.f, 145.f, 41.f, 41.f, 41.f, 41.f};
auto input_shape_y = Shape{3, 2, 2, 1};
auto input_u = std::vector<float> {90.,
54.,
240.};
auto input_u = std::vector<float>{90., 54., 240.};
auto input_shape_u = Shape{3, 1, 1, 1};
auto input_v = std::vector<float> {240.,
34.,
110.};
auto input_v = std::vector<float>{240., 34., 110.};
auto input_shape_v = Shape{3, 1, 1, 1};
auto exp_out = std::vector<float> {0, 0, 255., 0, 0, 255., 0, 0, 255., 0, 0, 255.,
0, 255., 0, 0, 255., 0, 0, 255., 0, 0, 255., 0,
255., 0, 0, 255., 0, 0, 255., 0, 0, 255., 0, 0};
auto exp_out =
std::vector<float>{0, 0, 255., 0, 0, 255., 0, 0, 255., 0, 0, 255., 0, 255., 0, 0, 255., 0,
0, 255., 0, 0, 255., 0, 255., 0, 0, 255., 0, 0, 255., 0, 0, 255., 0, 0};
auto out_shape = Shape{3, 2, 2, 3};
reference_tests::Tensor inp_tensor_y(input_shape_y, element::f32, input_y);
@ -136,25 +126,17 @@ TEST_F(ReferenceConvertColorI420LayerTest, CompareWithHardcodedRefs_batch_fp32_t
}
TEST_F(ReferenceConvertColorI420LayerTest, CompareWithHardcodedRefs_color4x4_f32_three_rgb) {
auto input_y = std::vector<float> {81, 235,
81, 235,
81, 81,
81, 81,
145, 145,
145, 145,
41, 41,
41, 41};
auto input_y = std::vector<float>{81, 235, 81, 235, 81, 81, 81, 81, 145, 145, 145, 145, 41, 41, 41, 41};
auto input_shape_y = Shape{1, 8, 2, 1};
auto input_u = std::vector<float> {109, 90, 54, 240};
auto input_u = std::vector<float>{109, 90, 54, 240};
auto input_shape_u = Shape{1, 4, 1, 1};
auto input_v = std::vector<float> {184, 240, 34, 110};
auto input_v = std::vector<float>{184, 240, 34, 110};
auto input_shape_v = Shape{1, 4, 1, 1};
auto exp_out = std::vector<float> {165, 37, 37, 255, 216, 217, 165, 37, 37, 255, 216, 217,
255, 0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0,
0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 255, 0,
0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 255};
auto exp_out = std::vector<float>{165, 37, 37, 255, 216, 217, 165, 37, 37, 255, 216, 217, 255, 0, 0, 255,
0, 0, 255, 0, 0, 255, 0, 0, 0, 255, 0, 0, 255, 0, 0, 255,
0, 0, 255, 0, 0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 255};
auto out_shape = Shape{1, 2, 2, 3};
reference_tests::Tensor inp_tensor_y(input_shape_y, element::f32, input_y);

View File

@ -5,9 +5,9 @@
#include <gtest/gtest.h>
#include <openvino/core/model.hpp>
#include <tuple>
#include <openvino/op/nv12_to_rgb.hpp>
#include <openvino/op/nv12_to_bgr.hpp>
#include <openvino/op/nv12_to_rgb.hpp>
#include <tuple>
#include "base_reference_test.hpp"
#include "functional_test_utils/skip_tests_config.hpp"
@ -20,8 +20,8 @@ class ReferenceConvertColorNV12LayerTest : public testing::Test, public CommonRe
public:
void SetUp() override {
SKIP_IF_CURRENT_TEST_IS_DISABLED()
abs_threshold = 2.f; // allow R, G, B absolute deviation to 2 (of max 255)
threshold = 1.f; // Ignore relative comparison (100%)
abs_threshold = 2.f; // allow R, G, B absolute deviation to 2 (of max 255)
threshold = 1.f; // Ignore relative comparison (100%)
}
public:
@ -31,24 +31,25 @@ public:
std::shared_ptr<Node> conv;
conv = std::make_shared<T>(in);
auto res = std::make_shared<op::v0::Result>(conv);
return std::make_shared<Model>(ResultVector{res}, ParameterVector {in});
return std::make_shared<Model>(ResultVector{res}, ParameterVector{in});
}
template <typename T>
static std::shared_ptr<Model> CreateFunction2(const reference_tests::Tensor& input1, const reference_tests::Tensor& input2) {
static std::shared_ptr<Model> CreateFunction2(const reference_tests::Tensor& input1,
const reference_tests::Tensor& input2) {
const auto in1 = std::make_shared<op::v0::Parameter>(input1.type, input1.shape);
const auto in2 = std::make_shared<op::v0::Parameter>(input2.type, input2.shape);
std::shared_ptr<Node> conv;
conv = std::make_shared<T>(in1, in2);
auto res = std::make_shared<op::v0::Result>(conv);
return std::make_shared<Model>(ResultVector{res}, ParameterVector {in1, in2});
return std::make_shared<Model>(ResultVector{res}, ParameterVector{in1, in2});
}
};
TEST_F(ReferenceConvertColorNV12LayerTest, CompareWithHardcodedRefs_r_u8_single_rgb) {
auto input = std::vector<uint8_t> {0x51, 0x51, 0x51, 0x51, 0x5a, 0xf0};
auto input = std::vector<uint8_t>{0x51, 0x51, 0x51, 0x51, 0x5a, 0xf0};
auto input_shape = Shape{1, 3, 2, 1};
auto exp_out = std::vector<uint8_t> {0xff, 0, 0, 0xff, 0, 0, 0xff, 0, 0, 0xff, 0, 0};
auto exp_out = std::vector<uint8_t>{0xff, 0, 0, 0xff, 0, 0, 0xff, 0, 0, 0xff, 0, 0};
auto out_shape = Shape{1, 2, 2, 3};
reference_tests::Tensor inp_tensor(input_shape, element::u8, input);
inputData = {inp_tensor.data};
@ -59,9 +60,9 @@ TEST_F(ReferenceConvertColorNV12LayerTest, CompareWithHardcodedRefs_r_u8_single_
}
TEST_F(ReferenceConvertColorNV12LayerTest, CompareWithHardcodedRefs_color_u8_single_bgr) {
auto input = std::vector<uint8_t> {0x51, 0xeb, 0x51, 0xeb, 0x6d, 0xb8};
auto input = std::vector<uint8_t>{0x51, 0xeb, 0x51, 0xeb, 0x6d, 0xb8};
auto input_shape = Shape{1, 3, 2, 1};
auto exp_out = std::vector<uint8_t> {37, 37, 164, 215, 216, 255, 37, 37, 164, 215, 216, 255};
auto exp_out = std::vector<uint8_t>{37, 37, 164, 215, 216, 255, 37, 37, 164, 215, 216, 255};
auto out_shape = Shape{1, 2, 2, 3};
reference_tests::Tensor inp_tensor(input_shape, element::u8, input);
@ -76,9 +77,9 @@ TEST_F(ReferenceConvertColorNV12LayerTest, CompareWithHardcodedRefs_color_u8_sin
}
TEST_F(ReferenceConvertColorNV12LayerTest, CompareWithHardcodedRefs_g_fp32_single_rgb) {
auto input = std::vector<float> {145.f, 145.f, 145.f, 145.f, 54.f, 34.f};
auto input = std::vector<float>{145.f, 145.f, 145.f, 145.f, 54.f, 34.f};
auto input_shape = Shape{1, 3, 2, 1};
auto exp_out = std::vector<float> {0, 255.f, 0, 0, 255.f, 0, 0, 255.f, 0, 0, 255.f, 0};
auto exp_out = std::vector<float>{0, 255.f, 0, 0, 255.f, 0, 0, 255.f, 0, 0, 255.f, 0};
auto out_shape = Shape{1, 2, 2, 3};
reference_tests::Tensor inp_tensor(input_shape, element::f32, input);
@ -93,19 +94,15 @@ TEST_F(ReferenceConvertColorNV12LayerTest, CompareWithHardcodedRefs_g_fp32_singl
}
TEST_F(ReferenceConvertColorNV12LayerTest, CompareWithHardcodedRefs_batch_fp32_two_bgr) {
auto input_y = std::vector<float> {81.f, 81.f, 81.f, 81.f,
145.f, 145.f, 145.f, 145.f,
41.f, 41.f, 41.f, 41.f};
auto input_y = std::vector<float>{81.f, 81.f, 81.f, 81.f, 145.f, 145.f, 145.f, 145.f, 41.f, 41.f, 41.f, 41.f};
auto input_shape_y = Shape{3, 2, 2, 1};
auto input_uv = std::vector<float> {90., 240.,
54., 34.,
240., 110.};
auto input_uv = std::vector<float>{90., 240., 54., 34., 240., 110.};
auto input_shape_uv = Shape{3, 1, 1, 2};
auto exp_out = std::vector<float> {0, 0, 255., 0, 0, 255., 0, 0, 255., 0, 0, 255.,
0, 255., 0, 0, 255., 0, 0, 255., 0, 0, 255., 0,
255., 0, 0, 255., 0, 0, 255., 0, 0, 255., 0, 0};
auto exp_out =
std::vector<float>{0, 0, 255., 0, 0, 255., 0, 0, 255., 0, 0, 255., 0, 255., 0, 0, 255., 0,
0, 255., 0, 0, 255., 0, 255., 0, 0, 255., 0, 0, 255., 0, 0, 255., 0, 0};
auto out_shape = Shape{3, 2, 2, 3};
reference_tests::Tensor inp_tensor_y(input_shape_y, element::f32, input_y);
@ -121,13 +118,13 @@ TEST_F(ReferenceConvertColorNV12LayerTest, CompareWithHardcodedRefs_batch_fp32_t
}
TEST_F(ReferenceConvertColorNV12LayerTest, CompareWithHardcodedRefs_color2x2_f32_two_rgb) {
auto input_y = std::vector<float> {81, 235, 81, 235};
auto input_y = std::vector<float>{81, 235, 81, 235};
auto input_shape_y = Shape{1, 2, 2, 1};
auto input_uv = std::vector<float> {109, 184};
auto input_uv = std::vector<float>{109, 184};
auto input_shape_uv = Shape{1, 1, 1, 2};
auto exp_out = std::vector<float> {164, 37, 37, 255, 216, 215, 164, 37, 37, 255, 216, 215};
auto exp_out = std::vector<float>{164, 37, 37, 255, 216, 215, 164, 37, 37, 255, 216, 215};
auto out_shape = Shape{1, 2, 2, 3};
reference_tests::Tensor inp_tensor_y(input_shape_y, element::f32, input_y);

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/convolution.hpp"
#include <gtest/gtest.h>
#include "openvino/op/convolution.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
@ -13,10 +14,17 @@ using namespace ov;
namespace {
struct ConvolutionParams {
template <class IT>
ConvolutionParams(const PartialShape& inputShape, const PartialShape& filterShape, const PartialShape& outputShape,
ConvolutionParams(const PartialShape& inputShape,
const PartialShape& filterShape,
const PartialShape& outputShape,
const element::Type& iType,
const std::vector<IT>& iValues, const std::vector<IT>& filterValues, const std::vector<IT>& oValues,
const Strides& strides, const CoordinateDiff& padBegin, const CoordinateDiff& padEnd, const Strides& dialations)
const std::vector<IT>& iValues,
const std::vector<IT>& filterValues,
const std::vector<IT>& oValues,
const Strides& strides,
const CoordinateDiff& padBegin,
const CoordinateDiff& padEnd,
const Strides& dialations)
: inputShape(inputShape),
filterShape(filterShape),
outputShape(outputShape),
@ -32,10 +40,17 @@ struct ConvolutionParams {
dialations(dialations) {}
template <class IT>
ConvolutionParams(const PartialShape& inputShape, const PartialShape& filterShape, const PartialShape& outputShape,
ConvolutionParams(const PartialShape& inputShape,
const PartialShape& filterShape,
const PartialShape& outputShape,
const element::Type& iType,
const std::vector<IT>& iValues, const std::vector<IT>& filterValues, const std::vector<IT>& oValues,
const Strides& strides, const CoordinateDiff& padBegin, const CoordinateDiff& padEnd, const Strides& dialations,
const std::vector<IT>& iValues,
const std::vector<IT>& filterValues,
const std::vector<IT>& oValues,
const Strides& strides,
const CoordinateDiff& padBegin,
const CoordinateDiff& padEnd,
const Strides& dialations,
const bool convolutionOutlining)
: inputShape(inputShape),
filterShape(filterShape),
@ -109,15 +124,15 @@ private:
if (params.convolutionOutlining == true) {
const auto Convolution2 = std::make_shared<op::v1::Convolution>(Convolution,
filter,
params.strides,
params.padBegin,
params.padEnd,
params.dialations,
auto_pad);
return std::make_shared<ov::Model>(NodeVector {Convolution2}, ParameterVector {in, filter});
filter,
params.strides,
params.padBegin,
params.padEnd,
params.dialations,
auto_pad);
return std::make_shared<ov::Model>(NodeVector{Convolution2}, ParameterVector{in, filter});
} else {
return std::make_shared<ov::Model>(NodeVector {Convolution}, ParameterVector {in, filter});
return std::make_shared<ov::Model>(NodeVector{Convolution}, ParameterVector{in, filter});
}
}
};
@ -130,9 +145,9 @@ template <element::Type_t IN_ET>
std::vector<ConvolutionParams> generateConvolutionI8Params() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<ConvolutionParams> convolutionParams {
// --------------------- 1D convolution ------------------------------------------
// clang-format off
std::vector<ConvolutionParams> convolutionParams{
// --------------------- 1D convolution ------------------------------------------
// clang-format off
ConvolutionParams(PartialShape {1, 1, 6},
PartialShape {1, 1, 3},
PartialShape {1, 1, 4},
@ -1069,12 +1084,11 @@ std::vector<ConvolutionParams> generateConvolutionFloatParams() {
// clang-format on
std::vector<ConvolutionParams> generateConvolutionCombinedParams() {
const std::vector<std::vector<ConvolutionParams>> convolutionTypeParams {
const std::vector<std::vector<ConvolutionParams>> convolutionTypeParams{
generateConvolutionFloatParams<element::Type_t::f32>(),
generateConvolutionFloatParams<element::Type_t::f16>(),
generateConvolutionFloatParams<element::Type_t::bf16>(),
generateConvolutionI8Params<element::Type_t::i8>()
};
generateConvolutionI8Params<element::Type_t::i8>()};
std::vector<ConvolutionParams> combinedParams;
for (const auto& params : convolutionTypeParams) {
@ -1083,7 +1097,9 @@ std::vector<ConvolutionParams> generateConvolutionCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_Convolution_With_Hardcoded_Refs, ReferenceConvolutionLayerTest,
testing::ValuesIn(generateConvolutionCombinedParams()), ReferenceConvolutionLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Convolution_With_Hardcoded_Refs,
ReferenceConvolutionLayerTest,
testing::ValuesIn(generateConvolutionCombinedParams()),
ReferenceConvolutionLayerTest::getTestCaseName);
} // namespace
} // namespace

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/cos.hpp"
#include <gtest/gtest.h>
#include "openvino/op/cos.hpp"
#include "base_reference_test.hpp"
using namespace ov;
@ -42,7 +43,7 @@ private:
static std::shared_ptr<Model> CreateFunction(const Shape& shape, const element::Type& type) {
const auto in = std::make_shared<op::v0::Parameter>(type, shape);
const auto Cos = std::make_shared<op::v0::Cos>(in);
return std::make_shared<ov::Model>(NodeVector {Cos}, ParameterVector {in});
return std::make_shared<ov::Model>(NodeVector{Cos}, ParameterVector{in});
}
};
@ -53,11 +54,33 @@ TEST_P(ReferenceCosLayerTest, CosWithHardcodedRefs) {
} // namespace
INSTANTIATE_TEST_SUITE_P(
smoke_Cos_With_Hardcoded_Refs, ReferenceCosLayerTest,
smoke_Cos_With_Hardcoded_Refs,
ReferenceCosLayerTest,
::testing::Values(
Builder {}
.input({{11}, element::f16, std::vector<ov::float16> {0.f, 0.25f, -0.25f, 0.5f, -0.5f, 1.f, -1.f, 2.f, -2.f, 4.f, -4.f}})
.expected({{11}, element::f16, std::vector<ov::float16> {1.00000000f,
Builder{}
.input({{11},
element::f16,
std::vector<ov::float16>{0.f, 0.25f, -0.25f, 0.5f, -0.5f, 1.f, -1.f, 2.f, -2.f, 4.f, -4.f}})
.expected({{11},
element::f16,
std::vector<ov::float16>{1.00000000f,
0.96891242f,
0.96891242f,
0.87758256f,
0.87758256f,
0.54030231f,
0.54030231f,
-0.41614684f,
-0.41614684f,
-0.65364362f,
-0.65364362f}}),
Builder{}
.input({{11},
element::f32,
std::vector<float>{0.f, 0.25f, -0.25f, 0.5f, -0.5f, 1.f, -1.f, 2.f, -2.f, 4.f, -4.f}})
.expected({{11},
element::f32,
std::vector<float>{1.00000000f,
0.96891242f,
0.96891242f,
0.87758256f,
@ -68,31 +91,18 @@ INSTANTIATE_TEST_SUITE_P(
-0.41614684f,
-0.65364362f,
-0.65364362f}}),
Builder {}
.input({{11}, element::f32, std::vector<float> {0.f, 0.25f, -0.25f, 0.5f, -0.5f, 1.f, -1.f, 2.f, -2.f, 4.f, -4.f}})
.expected({{11}, element::f32, std::vector<float> {1.00000000f,
0.96891242f,
0.96891242f,
0.87758256f,
0.87758256f,
0.54030231f,
0.54030231f,
-0.41614684f,
-0.41614684f,
-0.65364362f,
-0.65364362f}}),
Builder {}
.input({{5}, element::i32, std::vector<int32_t> {1, 2, 3, 4, 5}})
.expected({{5}, element::i32, std::vector<int32_t> {1, 0, -1, -1, 0}}),
Builder {}
.input({{5}, element::i64, std::vector<int64_t> {1, 2, 3, 4, 5}})
.expected({{5}, element::i64, std::vector<int64_t> {1, 0, -1, -1, 0}}),
Builder {}
.input({{3}, element::u32, std::vector<uint32_t> {1, 2, 5}})
.expected({{3}, element::u32, std::vector<uint32_t> {1, 0, 0}}),
Builder {}
.input({{3}, element::u64, std::vector<uint64_t> {1, 2, 5}})
.expected({{3}, element::u64, std::vector<uint64_t> {1, 0, 0}})),
Builder{}
.input({{5}, element::i32, std::vector<int32_t>{1, 2, 3, 4, 5}})
.expected({{5}, element::i32, std::vector<int32_t>{1, 0, -1, -1, 0}}),
Builder{}
.input({{5}, element::i64, std::vector<int64_t>{1, 2, 3, 4, 5}})
.expected({{5}, element::i64, std::vector<int64_t>{1, 0, -1, -1, 0}}),
Builder{}
.input({{3}, element::u32, std::vector<uint32_t>{1, 2, 5}})
.expected({{3}, element::u32, std::vector<uint32_t>{1, 0, 0}}),
Builder{}
.input({{3}, element::u64, std::vector<uint64_t>{1, 2, 5}})
.expected({{3}, element::u64, std::vector<uint64_t>{1, 0, 0}})),
ReferenceCosLayerTest::getTestCaseName);
} // namespace reference_tests

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/cosh.hpp"
#include <gtest/gtest.h>
#include "openvino/op/cosh.hpp"
#include "base_reference_test.hpp"
using namespace ov;
@ -42,7 +43,7 @@ private:
static std::shared_ptr<Model> CreateFunction(const Shape& shape, const element::Type& type) {
const auto in = std::make_shared<op::v0::Parameter>(type, shape);
const auto Cosh = std::make_shared<op::v0::Cosh>(in);
return std::make_shared<ov::Model>(NodeVector {Cosh}, ParameterVector {in});
return std::make_shared<ov::Model>(NodeVector{Cosh}, ParameterVector{in});
}
};
@ -53,46 +54,55 @@ TEST_P(ReferenceCoshLayerTest, CoshWithHardcodedRefs) {
} // namespace
INSTANTIATE_TEST_SUITE_P(
smoke_Cosh_With_Hardcoded_Refs, ReferenceCoshLayerTest,
smoke_Cosh_With_Hardcoded_Refs,
ReferenceCoshLayerTest,
::testing::Values(
Builder {}
.input({{11}, element::f16, std::vector<ov::float16> {-4.f, -2.f, -1.f, -0.5f, -0.25f, 0.f, 0.25f, 0.5f, 1.f, 2.f, 4.f}})
.expected({{11}, element::f16, std::vector<ov::float16> {27.30823284f,
3.76219569f,
1.54308063f,
1.12762597f,
1.03141310f,
1.00000000f,
1.03141310f,
1.12762597f,
1.54308063f,
3.76219569f,
27.30823284f}}),
Builder {}
.input({{11}, element::f32, std::vector<float> {-4.f, -2.f, -1.f, -0.5f, -0.25f, 0.f, 0.25f, 0.5f, 1.f, 2.f, 4.f}})
.expected({{11}, element::f32, std::vector<float> {27.30823284f,
3.76219569f,
1.54308063f,
1.12762597f,
1.03141310f,
1.00000000f,
1.03141310f,
1.12762597f,
1.54308063f,
3.76219569f,
27.30823284f}}),
Builder {}
.input({{7}, element::i32, std::vector<int32_t> {-4, -2, -1, 0, 1, 2, 4}})
.expected({{7}, element::i32, std::vector<int32_t> {27, 4, 2, 1, 2, 4, 27}}),
Builder {}
.input({{7}, element::i64, std::vector<int64_t> {-4, -2, -1, 0, 1, 2, 4}})
.expected({{7}, element::i64, std::vector<int64_t> {27, 4, 2, 1, 2, 4, 27}}),
Builder {}
.input({{4}, element::u32, std::vector<uint32_t> {0, 1, 2, 4}})
.expected({{4}, element::u32, std::vector<uint32_t> {1, 2, 4, 27}}),
Builder {}
.input({{4}, element::u64, std::vector<uint64_t> {0, 1, 2, 4}})
.expected({{4}, element::u64, std::vector<uint64_t> {1, 2, 4, 27}})),
Builder{}
.input({{11},
element::f16,
std::vector<ov::float16>{-4.f, -2.f, -1.f, -0.5f, -0.25f, 0.f, 0.25f, 0.5f, 1.f, 2.f, 4.f}})
.expected({{11},
element::f16,
std::vector<ov::float16>{27.30823284f,
3.76219569f,
1.54308063f,
1.12762597f,
1.03141310f,
1.00000000f,
1.03141310f,
1.12762597f,
1.54308063f,
3.76219569f,
27.30823284f}}),
Builder{}
.input({{11},
element::f32,
std::vector<float>{-4.f, -2.f, -1.f, -0.5f, -0.25f, 0.f, 0.25f, 0.5f, 1.f, 2.f, 4.f}})
.expected({{11},
element::f32,
std::vector<float>{27.30823284f,
3.76219569f,
1.54308063f,
1.12762597f,
1.03141310f,
1.00000000f,
1.03141310f,
1.12762597f,
1.54308063f,
3.76219569f,
27.30823284f}}),
Builder{}
.input({{7}, element::i32, std::vector<int32_t>{-4, -2, -1, 0, 1, 2, 4}})
.expected({{7}, element::i32, std::vector<int32_t>{27, 4, 2, 1, 2, 4, 27}}),
Builder{}
.input({{7}, element::i64, std::vector<int64_t>{-4, -2, -1, 0, 1, 2, 4}})
.expected({{7}, element::i64, std::vector<int64_t>{27, 4, 2, 1, 2, 4, 27}}),
Builder{}
.input({{4}, element::u32, std::vector<uint32_t>{0, 1, 2, 4}})
.expected({{4}, element::u32, std::vector<uint32_t>{1, 2, 4, 27}}),
Builder{}
.input({{4}, element::u64, std::vector<uint64_t>{0, 1, 2, 4}})
.expected({{4}, element::u64, std::vector<uint64_t>{1, 2, 4, 27}})),
ReferenceCoshLayerTest::getTestCaseName);
} // namespace reference_tests

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/ctc_greedy_decoder.hpp"
#include <gtest/gtest.h>
#include "openvino/op/ctc_greedy_decoder.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
@ -12,11 +13,16 @@ using namespace ov;
namespace {
struct CTCGreedyDecoderParams {
CTCGreedyDecoderParams(
const reference_tests::Tensor& dataTensor, const reference_tests::Tensor& masksTensor, int64_t ctcMergedRepeat,
const reference_tests::Tensor& expectedTensor, const std::string& testcaseName = "") :
dataTensor(dataTensor), masksTensor(masksTensor), ctcMergedRepeat(ctcMergedRepeat),
expectedTensor(expectedTensor), testcaseName(testcaseName) {}
CTCGreedyDecoderParams(const reference_tests::Tensor& dataTensor,
const reference_tests::Tensor& masksTensor,
int64_t ctcMergedRepeat,
const reference_tests::Tensor& expectedTensor,
const std::string& testcaseName = "")
: dataTensor(dataTensor),
masksTensor(masksTensor),
ctcMergedRepeat(ctcMergedRepeat),
expectedTensor(expectedTensor),
testcaseName(testcaseName) {}
reference_tests::Tensor dataTensor;
reference_tests::Tensor masksTensor;
@ -25,7 +31,8 @@ struct CTCGreedyDecoderParams {
std::string testcaseName;
};
class ReferenceCTCGreedyDecoderTest : public testing::TestWithParam<CTCGreedyDecoderParams>, public CommonReferenceTest {
class ReferenceCTCGreedyDecoderTest : public testing::TestWithParam<CTCGreedyDecoderParams>,
public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
@ -70,40 +77,68 @@ TEST_P(ReferenceCTCGreedyDecoderTest, CompareWithRefs) {
template <element::Type_t IN_ET>
std::vector<CTCGreedyDecoderParams> generateParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<CTCGreedyDecoderParams> params {
std::vector<CTCGreedyDecoderParams> params{
CTCGreedyDecoderParams(
reference_tests::Tensor(IN_ET, {3, 1, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.4f, 0.3f, 0.f, 0.5f, 0.6f, 0.f}),
reference_tests::Tensor(IN_ET,
{3, 1, 3},
std::vector<T>{0.1f, 0.2f, 0.f, 0.4f, 0.3f, 0.f, 0.5f, 0.6f, 0.f}),
reference_tests::Tensor(IN_ET, {3, 1}, std::vector<T>{1.0f, 1.0f, 1.0f}),
false,
reference_tests::Tensor(IN_ET, {1, 3, 1, 1}, std::vector<T>{1.0f, 0.0f, 1.0f}),
"ctc_greedy_decoder"),
CTCGreedyDecoderParams(
reference_tests::Tensor(IN_ET, {3, 2, 3}, std::vector<T>{
0.1f, 0.2f, 0.f, 0.15f, 0.25f, 0.f, 0.4f, 0.3f, 0.f, 0.45f, 0.35f, 0.f, 0.5f, 0.6f, 0.f, 0.55f, 0.65f, 0.f}),
reference_tests::Tensor(IN_ET,
{3, 2, 3},
std::vector<T>{0.1f,
0.2f,
0.f,
0.15f,
0.25f,
0.f,
0.4f,
0.3f,
0.f,
0.45f,
0.35f,
0.f,
0.5f,
0.6f,
0.f,
0.55f,
0.65f,
0.f}),
reference_tests::Tensor(IN_ET, {3, 2}, std::vector<T>{1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f}),
false,
reference_tests::Tensor(IN_ET, {2, 3, 1, 1}, std::vector<T>{1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f}),
"ctc_greedy_decoder_multiple_batches"),
CTCGreedyDecoderParams(
reference_tests::Tensor(IN_ET, {3, 1, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.4f, 0.3f, 0.f, 0.5f, 0.6f, 0.f}),
reference_tests::Tensor(IN_ET,
{3, 1, 3},
std::vector<T>{0.1f, 0.2f, 0.f, 0.4f, 0.3f, 0.f, 0.5f, 0.6f, 0.f}),
reference_tests::Tensor(IN_ET, {3, 1}, std::vector<T>{1.0f, 1.0f, 0.0f}),
false,
reference_tests::Tensor(IN_ET, {1, 3, 1, 1}, std::vector<T>{1.0f, 0.0f, -1.0f}),
"ctc_greedy_decoder_single_batch_short_sequence"),
CTCGreedyDecoderParams(
reference_tests::Tensor(IN_ET, {3, 1, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.3f, 0.4f, 0.f, 0.6f, 0.5f, 0.f}),
reference_tests::Tensor(IN_ET,
{3, 1, 3},
std::vector<T>{0.1f, 0.2f, 0.f, 0.3f, 0.4f, 0.f, 0.6f, 0.5f, 0.f}),
reference_tests::Tensor(IN_ET, {3, 1}, std::vector<T>{1.0f, 1.0f, 1.0f}),
true,
reference_tests::Tensor(IN_ET, {1, 3, 1, 1}, std::vector<T>{1.0f, 0.0f, -1.0f}),
"ctc_greedy_decoder_merge"),
CTCGreedyDecoderParams(
reference_tests::Tensor(IN_ET, {3, 1, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.3f, 0.4f, 0.f, 0.6f, 0.5f, 0.f}),
reference_tests::Tensor(IN_ET,
{3, 1, 3},
std::vector<T>{0.1f, 0.2f, 0.f, 0.3f, 0.4f, 0.f, 0.6f, 0.5f, 0.f}),
reference_tests::Tensor(IN_ET, {3, 1}, std::vector<T>{1.0f, 1.0f, 1.0f}),
false,
reference_tests::Tensor(IN_ET, {1, 3, 1, 1}, std::vector<T>{1.0f, 1.0f, 0.0f}),
"ctc_greedy_decoder_single_no_merge"),
CTCGreedyDecoderParams(
reference_tests::Tensor(IN_ET, {2, 2, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.4f, 0.3f, 0.f, 0.5f, 0.6f, 0.f, 0.7f, 0.8f, 0.f}),
reference_tests::Tensor(IN_ET,
{2, 2, 3},
std::vector<T>{0.1f, 0.2f, 0.f, 0.4f, 0.3f, 0.f, 0.5f, 0.6f, 0.f, 0.7f, 0.8f, 0.f}),
reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{1.0f, 1.0f, 1.0f, 0.0f}),
false,
reference_tests::Tensor(IN_ET, {2, 2, 1, 1}, std::vector<T>{1.0f, 1.0f, 0.0f, -1.0f}),
@ -113,7 +148,7 @@ std::vector<CTCGreedyDecoderParams> generateParams() {
}
std::vector<CTCGreedyDecoderParams> generateCombinedParams() {
const std::vector<std::vector<CTCGreedyDecoderParams>> generatedParams {
const std::vector<std::vector<CTCGreedyDecoderParams>> generatedParams{
generateParams<element::Type_t::bf16>(),
generateParams<element::Type_t::f16>(),
generateParams<element::Type_t::f32>(),
@ -127,6 +162,8 @@ std::vector<CTCGreedyDecoderParams> generateCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_CTCGreedyDecoder_With_Hardcoded_Refs, ReferenceCTCGreedyDecoderTest,
testing::ValuesIn(generateCombinedParams()), ReferenceCTCGreedyDecoderTest::getTestCaseName);
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_CTCGreedyDecoder_With_Hardcoded_Refs,
ReferenceCTCGreedyDecoderTest,
testing::ValuesIn(generateCombinedParams()),
ReferenceCTCGreedyDecoderTest::getTestCaseName);
} // namespace

View File

@ -2,22 +2,32 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/ctc_greedy_decoder_seq_len.hpp"
#include <gtest/gtest.h>
#include "openvino/op/ctc_greedy_decoder_seq_len.hpp"
#include "openvino/op/constant.hpp"
#include "base_reference_test.hpp"
#include "openvino/op/constant.hpp"
using namespace reference_tests;
using namespace ov;
namespace {
struct CTCGreedyDecoderSeqLenParams {
CTCGreedyDecoderSeqLenParams(
const reference_tests::Tensor& dataTensor, const reference_tests::Tensor& seqLenTensor, const reference_tests::Tensor& blankIndexTensor, int64_t mergeRepeated,
const reference_tests::Tensor& expectedTensor, const reference_tests::Tensor& expectedTensor2, const std::string& testcaseName = "") :
dataTensor(dataTensor), seqLenTensor(seqLenTensor), blankIndexTensor(blankIndexTensor), mergeRepeated(mergeRepeated),
expectedTensor(expectedTensor), expectedTensor2(expectedTensor2), testcaseName(testcaseName) {}
CTCGreedyDecoderSeqLenParams(const reference_tests::Tensor& dataTensor,
const reference_tests::Tensor& seqLenTensor,
const reference_tests::Tensor& blankIndexTensor,
int64_t mergeRepeated,
const reference_tests::Tensor& expectedTensor,
const reference_tests::Tensor& expectedTensor2,
const std::string& testcaseName = "")
: dataTensor(dataTensor),
seqLenTensor(seqLenTensor),
blankIndexTensor(blankIndexTensor),
mergeRepeated(mergeRepeated),
expectedTensor(expectedTensor),
expectedTensor2(expectedTensor2),
testcaseName(testcaseName) {}
reference_tests::Tensor dataTensor;
reference_tests::Tensor seqLenTensor;
@ -29,11 +39,18 @@ struct CTCGreedyDecoderSeqLenParams {
};
struct CTCGreedyDecoderSeqLenParamsNoOptionalInput {
CTCGreedyDecoderSeqLenParamsNoOptionalInput(
const reference_tests::Tensor& dataTensor, const reference_tests::Tensor& seqLenTensor, int64_t mergeRepeated,
const reference_tests::Tensor& expectedTensor, const reference_tests::Tensor& expectedTensor2, const std::string& testcaseName = "") :
dataTensor(dataTensor), seqLenTensor(seqLenTensor), mergeRepeated(mergeRepeated),
expectedTensor(expectedTensor), expectedTensor2(expectedTensor2), testcaseName(testcaseName) {}
CTCGreedyDecoderSeqLenParamsNoOptionalInput(const reference_tests::Tensor& dataTensor,
const reference_tests::Tensor& seqLenTensor,
int64_t mergeRepeated,
const reference_tests::Tensor& expectedTensor,
const reference_tests::Tensor& expectedTensor2,
const std::string& testcaseName = "")
: dataTensor(dataTensor),
seqLenTensor(seqLenTensor),
mergeRepeated(mergeRepeated),
expectedTensor(expectedTensor),
expectedTensor2(expectedTensor2),
testcaseName(testcaseName) {}
reference_tests::Tensor dataTensor;
reference_tests::Tensor seqLenTensor;
@ -43,7 +60,8 @@ struct CTCGreedyDecoderSeqLenParamsNoOptionalInput {
std::string testcaseName;
};
class ReferenceCTCGreedyDecoderSeqLenTest : public testing::TestWithParam<CTCGreedyDecoderSeqLenParams>, public CommonReferenceTest {
class ReferenceCTCGreedyDecoderSeqLenTest : public testing::TestWithParam<CTCGreedyDecoderSeqLenParams>,
public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
@ -77,16 +95,19 @@ private:
std::shared_ptr<Model> function;
const auto data = std::make_shared<op::v0::Parameter>(params.dataTensor.type, params.dataTensor.shape);
const auto seq_len = std::make_shared<op::v0::Parameter>(params.seqLenTensor.type, params.seqLenTensor.shape);
auto blank_index = std::make_shared<op::v0::Constant>(params.blankIndexTensor.type, params.blankIndexTensor.shape,
auto blank_index = std::make_shared<op::v0::Constant>(params.blankIndexTensor.type,
params.blankIndexTensor.shape,
params.blankIndexTensor.data.data());
const auto decoder = std::make_shared<op::v6::CTCGreedyDecoderSeqLen>(data, seq_len, blank_index, params.mergeRepeated);
const auto decoder =
std::make_shared<op::v6::CTCGreedyDecoderSeqLen>(data, seq_len, blank_index, params.mergeRepeated);
function = std::make_shared<ov::Model>(decoder->outputs(), ParameterVector{data, seq_len});
return function;
}
};
class ReferenceCTCGreedyDecoderSeqLenTestNoOptionalInput :
public testing::TestWithParam<CTCGreedyDecoderSeqLenParamsNoOptionalInput>, public CommonReferenceTest {
class ReferenceCTCGreedyDecoderSeqLenTestNoOptionalInput
: public testing::TestWithParam<CTCGreedyDecoderSeqLenParamsNoOptionalInput>,
public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
@ -135,7 +156,7 @@ TEST_P(ReferenceCTCGreedyDecoderSeqLenTestNoOptionalInput, CompareWithRefs) {
template <element::Type_t ET>
std::vector<CTCGreedyDecoderSeqLenParams> generateParams() {
using T = typename element_type_traits<ET>::value_type;
std::vector<CTCGreedyDecoderSeqLenParams> params {
std::vector<CTCGreedyDecoderSeqLenParams> params{
CTCGreedyDecoderSeqLenParams(
reference_tests::Tensor(ET, {1, 3, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.4f, 0.3f, 0.f, 0.5f, 0.6f, 0.f}),
reference_tests::Tensor(element::i32, {1}, std::vector<int32_t>{2}),
@ -153,8 +174,26 @@ std::vector<CTCGreedyDecoderSeqLenParams> generateParams() {
reference_tests::Tensor(element::i32, {1}, std::vector<int32_t>{2}),
"evaluate_ctc_greedy_decoder_seq_len_merge"),
CTCGreedyDecoderSeqLenParams(
reference_tests::Tensor(ET, {2, 3, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.15f, 0.25f, 0.f, 0.4f, 0.3f, 0.f,
0.45f, 0.35f, 0.f, 0.5f, 0.6f, 0.f, 0.55f, 0.65f, 0.f}),
reference_tests::Tensor(ET,
{2, 3, 3},
std::vector<T>{0.1f,
0.2f,
0.f,
0.15f,
0.25f,
0.f,
0.4f,
0.3f,
0.f,
0.45f,
0.35f,
0.f,
0.5f,
0.6f,
0.f,
0.55f,
0.65f,
0.f}),
reference_tests::Tensor(element::i32, {2}, std::vector<int32_t>{1, 1}),
reference_tests::Tensor(element::i32, {}, std::vector<int32_t>{2}),
false,
@ -162,9 +201,10 @@ std::vector<CTCGreedyDecoderSeqLenParams> generateParams() {
reference_tests::Tensor(element::i32, {2}, std::vector<int32_t>{1, 1}),
"evaluate_ctc_greedy_decoder_seq_len_multiple_batches"),
CTCGreedyDecoderSeqLenParams(
reference_tests::Tensor(ET, {3, 3, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.15f, 0.25f, 0.f, 0.4f, 0.3f, 0.f,
0.45f, 0.35f, 0.f, 0.5f, 0.6f, 0.f, 0.55f, 0.65f, 0.f,
0.1f, 0.2f, 0.f, 0.15f, 0.25f, 0.f, 0.4f, 0.3f, 0.f}),
reference_tests::Tensor(ET, {3, 3, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.15f, 0.25f, 0.f, 0.4f,
0.3f, 0.f, 0.45f, 0.35f, 0.f, 0.5f, 0.6f,
0.f, 0.55f, 0.65f, 0.f, 0.1f, 0.2f, 0.f,
0.15f, 0.25f, 0.f, 0.4f, 0.3f, 0.f}),
reference_tests::Tensor(element::i32, {3}, std::vector<int32_t>{2, 3, 1}),
reference_tests::Tensor(element::i32, {}, std::vector<int32_t>{2}),
false,
@ -176,7 +216,7 @@ std::vector<CTCGreedyDecoderSeqLenParams> generateParams() {
}
std::vector<CTCGreedyDecoderSeqLenParams> generateCombinedParams() {
const std::vector<std::vector<CTCGreedyDecoderSeqLenParams>> generatedParams {
const std::vector<std::vector<CTCGreedyDecoderSeqLenParams>> generatedParams{
generateParams<element::Type_t::bf16>(),
generateParams<element::Type_t::f16>(),
generateParams<element::Type_t::f32>(),
@ -193,7 +233,7 @@ std::vector<CTCGreedyDecoderSeqLenParams> generateCombinedParams() {
template <element::Type_t ET>
std::vector<CTCGreedyDecoderSeqLenParamsNoOptionalInput> generateParamsNoOptionalInput() {
using T = typename element_type_traits<ET>::value_type;
std::vector<CTCGreedyDecoderSeqLenParamsNoOptionalInput> params {
std::vector<CTCGreedyDecoderSeqLenParamsNoOptionalInput> params{
CTCGreedyDecoderSeqLenParamsNoOptionalInput(
reference_tests::Tensor(ET, {1, 3, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.4f, 0.3f, 0.f, 0.5f, 0.6f, 0.f}),
reference_tests::Tensor(element::i32, {1}, std::vector<int32_t>{2}),
@ -206,7 +246,7 @@ std::vector<CTCGreedyDecoderSeqLenParamsNoOptionalInput> generateParamsNoOptiona
}
std::vector<CTCGreedyDecoderSeqLenParamsNoOptionalInput> generateCombinedParamsNoOptionalInput() {
const std::vector<std::vector<CTCGreedyDecoderSeqLenParamsNoOptionalInput>> generatedParams {
const std::vector<std::vector<CTCGreedyDecoderSeqLenParamsNoOptionalInput>> generatedParams{
generateParamsNoOptionalInput<element::Type_t::bf16>(),
generateParamsNoOptionalInput<element::Type_t::f16>(),
generateParamsNoOptionalInput<element::Type_t::f32>(),
@ -220,9 +260,13 @@ std::vector<CTCGreedyDecoderSeqLenParamsNoOptionalInput> generateCombinedParamsN
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_CTCGreedyDecoderSeqLen_With_Hardcoded_Refs, ReferenceCTCGreedyDecoderSeqLenTest,
testing::ValuesIn(generateCombinedParams()), ReferenceCTCGreedyDecoderSeqLenTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_CTCGreedyDecoderSeqLen_With_Hardcoded_Refs,
ReferenceCTCGreedyDecoderSeqLenTest,
testing::ValuesIn(generateCombinedParams()),
ReferenceCTCGreedyDecoderSeqLenTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_CTCGreedyDecoderSeqLen_With_Hardcoded_Refs, ReferenceCTCGreedyDecoderSeqLenTestNoOptionalInput,
testing::ValuesIn(generateCombinedParamsNoOptionalInput()), ReferenceCTCGreedyDecoderSeqLenTestNoOptionalInput::getTestCaseName);
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_CTCGreedyDecoderSeqLen_With_Hardcoded_Refs,
ReferenceCTCGreedyDecoderSeqLenTestNoOptionalInput,
testing::ValuesIn(generateCombinedParamsNoOptionalInput()),
ReferenceCTCGreedyDecoderSeqLenTestNoOptionalInput::getTestCaseName);
} // namespace

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/ctc_loss.hpp"
#include <gtest/gtest.h>
#include "openvino/op/ctc_loss.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
@ -13,8 +14,15 @@ using namespace ov;
namespace {
struct CTCLossParams {
CTCLossParams(const bool collapseRepeated, const bool mergeRepeated, const bool findUnique, const reference_tests::Tensor& logitsTensor, const reference_tests::Tensor& logitsLenTensor,
const reference_tests::Tensor& labelsTensor, const reference_tests::Tensor& labelsLenTensor, const reference_tests::Tensor& blankIdxTensor, const reference_tests::Tensor& expectedTensor)
CTCLossParams(const bool collapseRepeated,
const bool mergeRepeated,
const bool findUnique,
const reference_tests::Tensor& logitsTensor,
const reference_tests::Tensor& logitsLenTensor,
const reference_tests::Tensor& labelsTensor,
const reference_tests::Tensor& labelsLenTensor,
const reference_tests::Tensor& blankIdxTensor,
const reference_tests::Tensor& expectedTensor)
: preprocessCollapseRepeated(collapseRepeated),
ctcMergeRepeated(mergeRepeated),
unique(findUnique),
@ -41,7 +49,11 @@ public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params);
inputData = {params.logits.data, params.logitsLen.data, params.labels.data, params.labelsLen.data, params.blankIdx.data};
inputData = {params.logits.data,
params.logitsLen.data,
params.labels.data,
params.labelsLen.data,
params.blankIdx.data};
refOutData = {params.expected.data};
}
static std::string getTestCaseName(const testing::TestParamInfo<CTCLossParams>& obj) {
@ -68,8 +80,15 @@ private:
const auto D = std::make_shared<op::v0::Parameter>(params.labelsLen.type, params.labelsLen.shape); // labelsLen
const auto E = std::make_shared<op::v0::Parameter>(params.blankIdx.type, params.blankIdx.shape); // blankIdx
const auto ctcLoss = std::make_shared<op::v4::CTCLoss>(A, B, C, D, E, params.preprocessCollapseRepeated, params.ctcMergeRepeated, params.unique);
return std::make_shared<ov::Model>(NodeVector {ctcLoss}, ParameterVector {A, B, C, D, E});
const auto ctcLoss = std::make_shared<op::v4::CTCLoss>(A,
B,
C,
D,
E,
params.preprocessCollapseRepeated,
params.ctcMergeRepeated,
params.unique);
return std::make_shared<ov::Model>(NodeVector{ctcLoss}, ParameterVector{A, B, C, D, E});
}
};
@ -78,91 +97,153 @@ TEST_P(ReferenceCTCLossLayerTest, CompareWithRefs) {
}
INSTANTIATE_TEST_SUITE_P(
smoke_CTCLoss_With_Hardcoded_Refs, ReferenceCTCLossLayerTest,
::testing::Values(CTCLossParams(false, false, false, // collapse repeated, merge repeated, unique
reference_tests::Tensor({2, 3, 3}, element::f32, std::vector<float> {0, 1, 8, 5, 5, 2, 0, 7, 7, 10, 4, 5, 9, 0, 0, 5, 7, 0}), // logits
reference_tests::Tensor({2}, element::i32, std::vector<int> {3, 3}), // logitsLen
reference_tests::Tensor({2, 3}, element::i32, std::vector<int> {0, 1, 2, 1, 1, 1}), // labels
reference_tests::Tensor({2}, element::i32, std::vector<int> {2, 1}), // labelsLen
reference_tests::Tensor({}, element::i32, std::vector<int> {2}), // blankIdx
reference_tests::Tensor({2}, element::f32, std::vector<float> {1.41223f, 14.1359f})), // refOut
CTCLossParams(false, false, true, // collapse repeated, merge repeated, unique
reference_tests::Tensor({2, 3, 3}, element::f32, std::vector<float> {0, 1, 8, 5, 5, 2, 0, 7, 7, 10, 4, 5, 9, 0, 0, 5, 7, 0}), // logits
reference_tests::Tensor({2}, element::i32, std::vector<int> {3, 3}), // logitsLen
reference_tests::Tensor({2, 3}, element::i32, std::vector<int> {0, 1, 2, 1, 1, 1}), // labels
reference_tests::Tensor({2}, element::i32, std::vector<int> {2, 1}), // labelsLen
reference_tests::Tensor({}, element::i32, std::vector<int> {2}), // blankIdx
reference_tests::Tensor({2}, element::f32, std::vector<float> {1.41223f, 14.1359f})), // refOut
CTCLossParams(false, true, false, // collapse repeated, merge repeated, unique
reference_tests::Tensor({2, 3, 3}, element::f32, std::vector<float> {0, 1, 8, 5, 5, 2, 0, 7, 7, 10, 4, 5, 9, 0, 0, 5, 7, 0}), // logits
reference_tests::Tensor({2}, element::i32, std::vector<int> {3, 3}), // logitsLen
reference_tests::Tensor({2, 3}, element::i32, std::vector<int> {0, 1, 2, 1, 1, 1}), // labels
reference_tests::Tensor({2}, element::i32, std::vector<int> {2, 1}), // labelsLen
reference_tests::Tensor({}, element::i32, std::vector<int> {2}), // blankIdx
reference_tests::Tensor({2}, element::f32, std::vector<float> {1.41156f, 13.2745f})), // refOut
CTCLossParams(true, false, false, // collapse repeated, merge repeated, unique
reference_tests::Tensor({2, 3, 3}, element::f32, std::vector<float> {0, 1, 8, 5, 5, 2, 0, 7, 7, 10, 4, 5, 9, 0, 0, 5, 7, 0}), // logits
reference_tests::Tensor({2}, element::i32, std::vector<int> {3, 3}), // logitsLen
reference_tests::Tensor({2, 3}, element::i32, std::vector<int> {0, 1, 2, 1, 1, 1}), // labels
reference_tests::Tensor({2}, element::i32, std::vector<int> {2, 1}), // labelsLen
reference_tests::Tensor({}, element::i32, std::vector<int> {2}), // blankIdx
reference_tests::Tensor({2}, element::f32, std::vector<float> {1.41223f, 14.1359f})), // refOut
CTCLossParams(false, true, true, // collapse repeated, merge repeated, unique
reference_tests::Tensor({2, 3, 3}, element::f32, std::vector<float> {0, 1, 8, 5, 5, 2, 0, 7, 7, 10, 4, 5, 9, 0, 0, 5, 7, 0}), // logits
reference_tests::Tensor({2}, element::i32, std::vector<int> {3, 3}), // logitsLen
reference_tests::Tensor({2, 3}, element::i32, std::vector<int> {0, 1, 2, 1, 1, 1}), // labels
reference_tests::Tensor({2}, element::i32, std::vector<int> {2, 1}), // labelsLen
reference_tests::Tensor({}, element::i32, std::vector<int> {2}), // blankIdx
reference_tests::Tensor({2}, element::f32, std::vector<float> {1.41156f, 13.2745f})), // refOut
CTCLossParams(true, true, true, // collapse repeated, merge repeated, unique
reference_tests::Tensor({2, 3, 3}, element::f32, std::vector<float> {0, 1, 8, 5, 5, 2, 0, 7, 7, 10, 4, 5, 9, 0, 0, 5, 7, 0}), // logits
reference_tests::Tensor({2}, element::i32, std::vector<int> {3, 3}), // logitsLen
reference_tests::Tensor({2, 3}, element::i32, std::vector<int> {0, 1, 2, 1, 1, 1}), // labels
reference_tests::Tensor({2}, element::i32, std::vector<int> {2, 1}), // labelsLen
reference_tests::Tensor({}, element::i32, std::vector<int> {2}), // blankIdx
reference_tests::Tensor({2}, element::f32, std::vector<float> {1.41223f, 13.2745f})), // refOut
// floating point type - float16
CTCLossParams(false, false, false, // collapse repeated, merge repeated, unique
reference_tests::Tensor({2, 3, 3}, element::f16, std::vector<float16> {0, 1, 8, 5, 5, 2, 0, 7, 7, 10, 4, 5, 9, 0, 0, 5, 7, 0}), // logits
reference_tests::Tensor({2}, element::i32, std::vector<int> {3, 3}), // logitsLen
reference_tests::Tensor({2, 3}, element::i32, std::vector<int> {0, 1, 2, 1, 1, 1}), // labels
reference_tests::Tensor({2}, element::i32, std::vector<int> {2, 1}), // labelsLen
reference_tests::Tensor({}, element::i32, std::vector<int> {2}), // blankIdx
reference_tests::Tensor({2}, element::f16, std::vector<float16> {1.41223f, 14.1359f})), // refOut
CTCLossParams(false, false, true, // collapse repeated, merge repeated, unique
reference_tests::Tensor({2, 3, 3}, element::f16, std::vector<float16> {0, 1, 8, 5, 5, 2, 0, 7, 7, 10, 4, 5, 9, 0, 0, 5, 7, 0}), // logits
reference_tests::Tensor({2}, element::i32, std::vector<int> {3, 3}), // logitsLen
reference_tests::Tensor({2, 3}, element::i32, std::vector<int> {0, 1, 2, 1, 1, 1}), // labels
reference_tests::Tensor({2}, element::i32, std::vector<int> {2, 1}), // labelsLen
reference_tests::Tensor({}, element::i32, std::vector<int> {2}), // blankIdx
reference_tests::Tensor({2}, element::f16, std::vector<float16> {1.41223f, 14.1359f})), // refOut
CTCLossParams(false, true, false, // collapse repeated, merge repeated, unique
reference_tests::Tensor({2, 3, 3}, element::f16, std::vector<float16> {0, 1, 8, 5, 5, 2, 0, 7, 7, 10, 4, 5, 9, 0, 0, 5, 7, 0}), // logits
reference_tests::Tensor({2}, element::i32, std::vector<int> {3, 3}), // logitsLen
reference_tests::Tensor({2, 3}, element::i32, std::vector<int> {0, 1, 2, 1, 1, 1}), // labels
reference_tests::Tensor({2}, element::i32, std::vector<int> {2, 1}), // labelsLen
reference_tests::Tensor({}, element::i32, std::vector<int> {2}), // blankIdx
reference_tests::Tensor({2}, element::f16, std::vector<float16> {1.41156f, 13.2745f})), // refOut
CTCLossParams(true, false, false, // collapse repeated, merge repeated, unique
reference_tests::Tensor({2, 3, 3}, element::f16, std::vector<float16> {0, 1, 8, 5, 5, 2, 0, 7, 7, 10, 4, 5, 9, 0, 0, 5, 7, 0}), // logits
reference_tests::Tensor({2}, element::i32, std::vector<int> {3, 3}), // logitsLen
reference_tests::Tensor({2, 3}, element::i32, std::vector<int> {0, 1, 2, 1, 1, 1}), // labels
reference_tests::Tensor({2}, element::i32, std::vector<int> {2, 1}), // labelsLen
reference_tests::Tensor({}, element::i32, std::vector<int> {2}), // blankIdx
reference_tests::Tensor({2}, element::f16, std::vector<float16> {1.41223f, 14.1359f})), // refOut
CTCLossParams(false, true, true, // collapse repeated, merge repeated, unique
reference_tests::Tensor({2, 3, 3}, element::f16, std::vector<float16> {0, 1, 8, 5, 5, 2, 0, 7, 7, 10, 4, 5, 9, 0, 0, 5, 7, 0}), // logits
reference_tests::Tensor({2}, element::i32, std::vector<int> {3, 3}), // logitsLen
reference_tests::Tensor({2, 3}, element::i32, std::vector<int> {0, 1, 2, 1, 1, 1}), // labels
reference_tests::Tensor({2}, element::i32, std::vector<int> {2, 1}), // labelsLen
reference_tests::Tensor({}, element::i32, std::vector<int> {2}), // blankIdx
reference_tests::Tensor({2}, element::f16, std::vector<float16> {1.41156f, 13.2745f})), // refOut
CTCLossParams(true, true, true, // collapse repeated, merge repeated, unique
reference_tests::Tensor({2, 3, 3}, element::f16, std::vector<float16> {0, 1, 8, 5, 5, 2, 0, 7, 7, 10, 4, 5, 9, 0, 0, 5, 7, 0}), // logits
reference_tests::Tensor({2}, element::i32, std::vector<int> {3, 3}), // logitsLen
reference_tests::Tensor({2, 3}, element::i32, std::vector<int> {0, 1, 2, 1, 1, 1}), // labels
reference_tests::Tensor({2}, element::i32, std::vector<int> {2, 1}), // labelsLen
reference_tests::Tensor({}, element::i32, std::vector<int> {2}), // blankIdx
reference_tests::Tensor({2}, element::f16, std::vector<float16> {1.41223f, 13.2745f}))), // refOut
smoke_CTCLoss_With_Hardcoded_Refs,
ReferenceCTCLossLayerTest,
::testing::Values(
CTCLossParams(false,
false,
false, // collapse repeated, merge repeated, unique
reference_tests::Tensor(
{2, 3, 3},
element::f32,
std::vector<float>{0, 1, 8, 5, 5, 2, 0, 7, 7, 10, 4, 5, 9, 0, 0, 5, 7, 0}), // logits
reference_tests::Tensor({2}, element::i32, std::vector<int>{3, 3}), // logitsLen
reference_tests::Tensor({2, 3}, element::i32, std::vector<int>{0, 1, 2, 1, 1, 1}), // labels
reference_tests::Tensor({2}, element::i32, std::vector<int>{2, 1}), // labelsLen
reference_tests::Tensor({}, element::i32, std::vector<int>{2}), // blankIdx
reference_tests::Tensor({2}, element::f32, std::vector<float>{1.41223f, 14.1359f})), // refOut
CTCLossParams(false,
false,
true, // collapse repeated, merge repeated, unique
reference_tests::Tensor(
{2, 3, 3},
element::f32,
std::vector<float>{0, 1, 8, 5, 5, 2, 0, 7, 7, 10, 4, 5, 9, 0, 0, 5, 7, 0}), // logits
reference_tests::Tensor({2}, element::i32, std::vector<int>{3, 3}), // logitsLen
reference_tests::Tensor({2, 3}, element::i32, std::vector<int>{0, 1, 2, 1, 1, 1}), // labels
reference_tests::Tensor({2}, element::i32, std::vector<int>{2, 1}), // labelsLen
reference_tests::Tensor({}, element::i32, std::vector<int>{2}), // blankIdx
reference_tests::Tensor({2}, element::f32, std::vector<float>{1.41223f, 14.1359f})), // refOut
CTCLossParams(false,
true,
false, // collapse repeated, merge repeated, unique
reference_tests::Tensor(
{2, 3, 3},
element::f32,
std::vector<float>{0, 1, 8, 5, 5, 2, 0, 7, 7, 10, 4, 5, 9, 0, 0, 5, 7, 0}), // logits
reference_tests::Tensor({2}, element::i32, std::vector<int>{3, 3}), // logitsLen
reference_tests::Tensor({2, 3}, element::i32, std::vector<int>{0, 1, 2, 1, 1, 1}), // labels
reference_tests::Tensor({2}, element::i32, std::vector<int>{2, 1}), // labelsLen
reference_tests::Tensor({}, element::i32, std::vector<int>{2}), // blankIdx
reference_tests::Tensor({2}, element::f32, std::vector<float>{1.41156f, 13.2745f})), // refOut
CTCLossParams(true,
false,
false, // collapse repeated, merge repeated, unique
reference_tests::Tensor(
{2, 3, 3},
element::f32,
std::vector<float>{0, 1, 8, 5, 5, 2, 0, 7, 7, 10, 4, 5, 9, 0, 0, 5, 7, 0}), // logits
reference_tests::Tensor({2}, element::i32, std::vector<int>{3, 3}), // logitsLen
reference_tests::Tensor({2, 3}, element::i32, std::vector<int>{0, 1, 2, 1, 1, 1}), // labels
reference_tests::Tensor({2}, element::i32, std::vector<int>{2, 1}), // labelsLen
reference_tests::Tensor({}, element::i32, std::vector<int>{2}), // blankIdx
reference_tests::Tensor({2}, element::f32, std::vector<float>{1.41223f, 14.1359f})), // refOut
CTCLossParams(false,
true,
true, // collapse repeated, merge repeated, unique
reference_tests::Tensor(
{2, 3, 3},
element::f32,
std::vector<float>{0, 1, 8, 5, 5, 2, 0, 7, 7, 10, 4, 5, 9, 0, 0, 5, 7, 0}), // logits
reference_tests::Tensor({2}, element::i32, std::vector<int>{3, 3}), // logitsLen
reference_tests::Tensor({2, 3}, element::i32, std::vector<int>{0, 1, 2, 1, 1, 1}), // labels
reference_tests::Tensor({2}, element::i32, std::vector<int>{2, 1}), // labelsLen
reference_tests::Tensor({}, element::i32, std::vector<int>{2}), // blankIdx
reference_tests::Tensor({2}, element::f32, std::vector<float>{1.41156f, 13.2745f})), // refOut
CTCLossParams(true,
true,
true, // collapse repeated, merge repeated, unique
reference_tests::Tensor(
{2, 3, 3},
element::f32,
std::vector<float>{0, 1, 8, 5, 5, 2, 0, 7, 7, 10, 4, 5, 9, 0, 0, 5, 7, 0}), // logits
reference_tests::Tensor({2}, element::i32, std::vector<int>{3, 3}), // logitsLen
reference_tests::Tensor({2, 3}, element::i32, std::vector<int>{0, 1, 2, 1, 1, 1}), // labels
reference_tests::Tensor({2}, element::i32, std::vector<int>{2, 1}), // labelsLen
reference_tests::Tensor({}, element::i32, std::vector<int>{2}), // blankIdx
reference_tests::Tensor({2}, element::f32, std::vector<float>{1.41223f, 13.2745f})), // refOut
// floating point type - float16
CTCLossParams(false,
false,
false, // collapse repeated, merge repeated, unique
reference_tests::Tensor(
{2, 3, 3},
element::f16,
std::vector<float16>{0, 1, 8, 5, 5, 2, 0, 7, 7, 10, 4, 5, 9, 0, 0, 5, 7, 0}), // logits
reference_tests::Tensor({2}, element::i32, std::vector<int>{3, 3}), // logitsLen
reference_tests::Tensor({2, 3}, element::i32, std::vector<int>{0, 1, 2, 1, 1, 1}), // labels
reference_tests::Tensor({2}, element::i32, std::vector<int>{2, 1}), // labelsLen
reference_tests::Tensor({}, element::i32, std::vector<int>{2}), // blankIdx
reference_tests::Tensor({2}, element::f16, std::vector<float16>{1.41223f, 14.1359f})), // refOut
CTCLossParams(false,
false,
true, // collapse repeated, merge repeated, unique
reference_tests::Tensor(
{2, 3, 3},
element::f16,
std::vector<float16>{0, 1, 8, 5, 5, 2, 0, 7, 7, 10, 4, 5, 9, 0, 0, 5, 7, 0}), // logits
reference_tests::Tensor({2}, element::i32, std::vector<int>{3, 3}), // logitsLen
reference_tests::Tensor({2, 3}, element::i32, std::vector<int>{0, 1, 2, 1, 1, 1}), // labels
reference_tests::Tensor({2}, element::i32, std::vector<int>{2, 1}), // labelsLen
reference_tests::Tensor({}, element::i32, std::vector<int>{2}), // blankIdx
reference_tests::Tensor({2}, element::f16, std::vector<float16>{1.41223f, 14.1359f})), // refOut
CTCLossParams(false,
true,
false, // collapse repeated, merge repeated, unique
reference_tests::Tensor(
{2, 3, 3},
element::f16,
std::vector<float16>{0, 1, 8, 5, 5, 2, 0, 7, 7, 10, 4, 5, 9, 0, 0, 5, 7, 0}), // logits
reference_tests::Tensor({2}, element::i32, std::vector<int>{3, 3}), // logitsLen
reference_tests::Tensor({2, 3}, element::i32, std::vector<int>{0, 1, 2, 1, 1, 1}), // labels
reference_tests::Tensor({2}, element::i32, std::vector<int>{2, 1}), // labelsLen
reference_tests::Tensor({}, element::i32, std::vector<int>{2}), // blankIdx
reference_tests::Tensor({2}, element::f16, std::vector<float16>{1.41156f, 13.2745f})), // refOut
CTCLossParams(true,
false,
false, // collapse repeated, merge repeated, unique
reference_tests::Tensor(
{2, 3, 3},
element::f16,
std::vector<float16>{0, 1, 8, 5, 5, 2, 0, 7, 7, 10, 4, 5, 9, 0, 0, 5, 7, 0}), // logits
reference_tests::Tensor({2}, element::i32, std::vector<int>{3, 3}), // logitsLen
reference_tests::Tensor({2, 3}, element::i32, std::vector<int>{0, 1, 2, 1, 1, 1}), // labels
reference_tests::Tensor({2}, element::i32, std::vector<int>{2, 1}), // labelsLen
reference_tests::Tensor({}, element::i32, std::vector<int>{2}), // blankIdx
reference_tests::Tensor({2}, element::f16, std::vector<float16>{1.41223f, 14.1359f})), // refOut
CTCLossParams(false,
true,
true, // collapse repeated, merge repeated, unique
reference_tests::Tensor(
{2, 3, 3},
element::f16,
std::vector<float16>{0, 1, 8, 5, 5, 2, 0, 7, 7, 10, 4, 5, 9, 0, 0, 5, 7, 0}), // logits
reference_tests::Tensor({2}, element::i32, std::vector<int>{3, 3}), // logitsLen
reference_tests::Tensor({2, 3}, element::i32, std::vector<int>{0, 1, 2, 1, 1, 1}), // labels
reference_tests::Tensor({2}, element::i32, std::vector<int>{2, 1}), // labelsLen
reference_tests::Tensor({}, element::i32, std::vector<int>{2}), // blankIdx
reference_tests::Tensor({2}, element::f16, std::vector<float16>{1.41156f, 13.2745f})), // refOut
CTCLossParams(true,
true,
true, // collapse repeated, merge repeated, unique
reference_tests::Tensor(
{2, 3, 3},
element::f16,
std::vector<float16>{0, 1, 8, 5, 5, 2, 0, 7, 7, 10, 4, 5, 9, 0, 0, 5, 7, 0}), // logits
reference_tests::Tensor({2}, element::i32, std::vector<int>{3, 3}), // logitsLen
reference_tests::Tensor({2, 3}, element::i32, std::vector<int>{0, 1, 2, 1, 1, 1}), // labels
reference_tests::Tensor({2}, element::i32, std::vector<int>{2, 1}), // labelsLen
reference_tests::Tensor({}, element::i32, std::vector<int>{2}), // blankIdx
reference_tests::Tensor({2}, element::f16, std::vector<float16>{1.41223f, 13.2745f}))), // refOut
ReferenceCTCLossLayerTest::getTestCaseName);
} // namespace

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/cum_sum.hpp"
#include <gtest/gtest.h>
#include "openvino/op/cum_sum.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
@ -14,8 +15,15 @@ namespace {
struct CumSumParams {
// Custom axis input and attributes
template <class IT, class AT>
CumSumParams(const PartialShape& shape, const element::Type& iType, const std::vector<IT>& iValues, const std::vector<IT>& oValues, const bool execlusive,
const bool reverse, const element::Type& axisType, AT axisVal, const PartialShape& axisShape)
CumSumParams(const PartialShape& shape,
const element::Type& iType,
const std::vector<IT>& iValues,
const std::vector<IT>& oValues,
const bool execlusive,
const bool reverse,
const element::Type& axisType,
AT axisVal,
const PartialShape& axisShape)
: execlusive(execlusive),
reverse(reverse),
axisValue(axisVal),
@ -24,14 +32,17 @@ struct CumSumParams {
axisType(axisType),
inType(iType),
outType(iType),
axisData(CreateTensor(axisType, std::vector<AT> {axisVal})),
axisData(CreateTensor(axisType, std::vector<AT>{axisVal})),
inputData(CreateTensor(iType, iValues)),
refData(CreateTensor(iType, oValues)),
testDefaults(false) {}
// Default axis input and attributes
template <class IT>
CumSumParams(const PartialShape& shape, const element::Type& iType, const std::vector<IT>& iValues, const std::vector<IT>& oValues)
CumSumParams(const PartialShape& shape,
const element::Type& iType,
const std::vector<IT>& iValues,
const std::vector<IT>& oValues)
: inShape(shape),
axisType(element::i32),
inType(iType),
@ -65,7 +76,12 @@ public:
inputData = {params.inputData};
refOutData = {params.refData};
} else {
function = CreateFunction(params.inShape, params.inType, params.axisShape, params.axisType, params.execlusive, params.reverse);
function = CreateFunction(params.inShape,
params.inType,
params.axisShape,
params.axisType,
params.execlusive,
params.reverse);
inputData = {params.inputData, params.axisData};
refOutData = {params.refData};
}
@ -85,18 +101,22 @@ public:
}
private:
static std::shared_ptr<Model> CreateFunction(const PartialShape& data_shape, const element::Type& data_type, const PartialShape& axis_shape,
const element::Type& axis_type, const bool execlusive, const bool reverse) {
static std::shared_ptr<Model> CreateFunction(const PartialShape& data_shape,
const element::Type& data_type,
const PartialShape& axis_shape,
const element::Type& axis_type,
const bool execlusive,
const bool reverse) {
const auto data_param = std::make_shared<op::v0::Parameter>(data_type, data_shape);
const auto axis_param = std::make_shared<op::v0::Parameter>(axis_type, axis_shape);
const auto cum_sum = std::make_shared<op::v0::CumSum>(data_param, axis_param, execlusive, reverse);
return std::make_shared<ov::Model>(NodeVector {cum_sum}, ParameterVector {data_param, axis_param});
return std::make_shared<ov::Model>(NodeVector{cum_sum}, ParameterVector{data_param, axis_param});
}
static std::shared_ptr<Model> CreateFunction(const PartialShape& data_shape, const element::Type& data_type) {
const auto data_param = std::make_shared<op::v0::Parameter>(data_type, data_shape);
const auto cum_sum = std::make_shared<op::v0::CumSum>(data_param);
return std::make_shared<ov::Model>(NodeVector {cum_sum}, ParameterVector {data_param});
return std::make_shared<ov::Model>(NodeVector{cum_sum}, ParameterVector{data_param});
}
};
@ -107,73 +127,176 @@ TEST_P(ReferenceCumSumLayerTest, CompareWithHardcodedRefs) {
template <element::Type_t IN_ET>
std::vector<CumSumParams> generateCumSumParams(const element::Type& type) {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<CumSumParams> opParams {
std::vector<CumSumParams> opParams{
// Default axis input and attributes
CumSumParams(PartialShape {1}, type, std::vector<T> {3}, std::vector<T> {3}),
CumSumParams(PartialShape {6}, type, std::vector<T> {1, 2, 3, 4, 5, 6}, std::vector<T> {1, 3, 6, 10, 15, 21}),
CumSumParams(PartialShape {2, 4}, type, std::vector<T> {0, 1, 2, 3, 4, 5, 6, 7}, std::vector<T> {0, 1, 2, 3, 4, 6, 8, 10}),
CumSumParams(PartialShape{1}, type, std::vector<T>{3}, std::vector<T>{3}),
CumSumParams(PartialShape{6}, type, std::vector<T>{1, 2, 3, 4, 5, 6}, std::vector<T>{1, 3, 6, 10, 15, 21}),
CumSumParams(PartialShape{2, 4},
type,
std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7},
std::vector<T>{0, 1, 2, 3, 4, 6, 8, 10}),
// Custom axis input and attributes
CumSumParams(PartialShape {6}, type, std::vector<T> {1, 2, 3, 4, 5, 6}, std::vector<T> {1, 3, 6, 10, 15, 21}, false, false, element::i32, int32_t(0),
PartialShape {}), // axis i32
CumSumParams(PartialShape {6}, type, std::vector<T> {1, 2, 3, 4, 5, 6}, std::vector<T> {1, 3, 6, 10, 15, 21}, false, false, element::i64, int64_t(0),
PartialShape {}), // axis i64
CumSumParams(PartialShape {6}, type, std::vector<T> {1, 2, 3, 4, 5, 6}, std::vector<T> {21, 20, 18, 15, 11, 6}, false, true, element::i64, int64_t(0),
PartialShape {}),
CumSumParams(PartialShape {6}, type, std::vector<T> {1, 2, 3, 4, 5, 6}, std::vector<T> {0, 1, 3, 6, 10, 15}, true, false, element::i64, int64_t(0),
PartialShape {}),
CumSumParams(PartialShape {6}, type, std::vector<T> {1, 2, 3, 4, 5, 6}, std::vector<T> {20, 18, 15, 11, 6, 0}, true, true, element::i64, int64_t(0),
PartialShape {}),
CumSumParams(PartialShape{6},
type,
std::vector<T>{1, 2, 3, 4, 5, 6},
std::vector<T>{1, 3, 6, 10, 15, 21},
false,
false,
element::i32,
int32_t(0),
PartialShape{}), // axis i32
CumSumParams(PartialShape{6},
type,
std::vector<T>{1, 2, 3, 4, 5, 6},
std::vector<T>{1, 3, 6, 10, 15, 21},
false,
false,
element::i64,
int64_t(0),
PartialShape{}), // axis i64
CumSumParams(PartialShape{6},
type,
std::vector<T>{1, 2, 3, 4, 5, 6},
std::vector<T>{21, 20, 18, 15, 11, 6},
false,
true,
element::i64,
int64_t(0),
PartialShape{}),
CumSumParams(PartialShape{6},
type,
std::vector<T>{1, 2, 3, 4, 5, 6},
std::vector<T>{0, 1, 3, 6, 10, 15},
true,
false,
element::i64,
int64_t(0),
PartialShape{}),
CumSumParams(PartialShape{6},
type,
std::vector<T>{1, 2, 3, 4, 5, 6},
std::vector<T>{20, 18, 15, 11, 6, 0},
true,
true,
element::i64,
int64_t(0),
PartialShape{}),
CumSumParams(PartialShape {2, 4}, type, std::vector<T> {0, 1, 2, 3, 4, 5, 6, 7}, std::vector<T> {0, 1, 2, 3, 4, 6, 8, 10}, false, false, element::i32,
int32_t(0), PartialShape {}),
CumSumParams(PartialShape {2, 4}, type, std::vector<T> {0, 1, 2, 3, 4, 5, 6, 7}, std::vector<T> {4, 6, 8, 10, 4, 5, 6, 7}, false, true, element::i32,
int32_t(0), PartialShape {}),
CumSumParams(PartialShape {2, 4}, type, std::vector<T> {0, 1, 2, 3, 4, 5, 6, 7}, std::vector<T> {0, 0, 0, 0, 0, 1, 2, 3}, true, false, element::i32,
int32_t(0), PartialShape {}),
CumSumParams(PartialShape {2, 4}, type, std::vector<T> {0, 1, 2, 3, 4, 5, 6, 7}, std::vector<T> {4, 5, 6, 7, 0, 0, 0, 0}, true, true, element::i32,
int32_t(0), PartialShape {}),
CumSumParams(PartialShape {2, 4}, type, std::vector<T> {0, 1, 2, 3, 4, 5, 6, 7}, std::vector<T> {0, 1, 3, 6, 4, 9, 15, 22}, false, false, element::i32,
int32_t(1), PartialShape {}),
CumSumParams(PartialShape {2, 4}, type, std::vector<T> {0, 1, 2, 3, 4, 5, 6, 7}, std::vector<T> {0, 0, 1, 3, 0, 4, 9, 15}, true, false, element::i32,
int32_t(1), PartialShape {}),
CumSumParams(PartialShape {2, 4}, type, std::vector<T> {0, 1, 2, 3, 4, 5, 6, 7}, std::vector<T> {6, 6, 5, 3, 22, 18, 13, 7}, false, true, element::i32,
int32_t(1), PartialShape {}),
CumSumParams(PartialShape {2, 4}, type, std::vector<T> {0, 1, 2, 3, 4, 5, 6, 7}, std::vector<T> {6, 5, 3, 0, 18, 13, 7, 0}, true, true, element::i32,
int32_t(1), PartialShape {}),
CumSumParams(PartialShape{2, 4},
type,
std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7},
std::vector<T>{0, 1, 2, 3, 4, 6, 8, 10},
false,
false,
element::i32,
int32_t(0),
PartialShape{}),
CumSumParams(PartialShape{2, 4},
type,
std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7},
std::vector<T>{4, 6, 8, 10, 4, 5, 6, 7},
false,
true,
element::i32,
int32_t(0),
PartialShape{}),
CumSumParams(PartialShape{2, 4},
type,
std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7},
std::vector<T>{0, 0, 0, 0, 0, 1, 2, 3},
true,
false,
element::i32,
int32_t(0),
PartialShape{}),
CumSumParams(PartialShape{2, 4},
type,
std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7},
std::vector<T>{4, 5, 6, 7, 0, 0, 0, 0},
true,
true,
element::i32,
int32_t(0),
PartialShape{}),
CumSumParams(PartialShape{2, 4},
type,
std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7},
std::vector<T>{0, 1, 3, 6, 4, 9, 15, 22},
false,
false,
element::i32,
int32_t(1),
PartialShape{}),
CumSumParams(PartialShape{2, 4},
type,
std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7},
std::vector<T>{0, 0, 1, 3, 0, 4, 9, 15},
true,
false,
element::i32,
int32_t(1),
PartialShape{}),
CumSumParams(PartialShape{2, 4},
type,
std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7},
std::vector<T>{6, 6, 5, 3, 22, 18, 13, 7},
false,
true,
element::i32,
int32_t(1),
PartialShape{}),
CumSumParams(PartialShape{2, 4},
type,
std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7},
std::vector<T>{6, 5, 3, 0, 18, 13, 7, 0},
true,
true,
element::i32,
int32_t(1),
PartialShape{}),
CumSumParams(PartialShape {3, 2, 4}, type,
std::vector<T> {0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23},
std::vector<T> {0, 1, 2, 3, 4, 5, 6, 7,
8, 10, 12, 14, 16, 18, 20, 22,
24, 27, 30, 33, 36, 39, 42, 45},
false, false, element::i32, int32_t(0), PartialShape {}),
CumSumParams(PartialShape {3, 2, 4}, type,
std::vector<T> {0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23},
std::vector<T> {0, 1, 2, 3, 4, 6, 8, 10,
8, 9, 10, 11, 20, 22, 24, 26,
16, 17, 18, 19, 36, 38, 40, 42},
false, false, element::i32, int32_t(1), PartialShape {}),
CumSumParams(PartialShape {3, 2, 4}, type,
std::vector<T> {0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23},
std::vector<T> {0, 1, 3, 6, 4, 9, 15, 22,
8, 17, 27, 38, 12, 25, 39, 54,
16, 33, 51, 70, 20, 41, 63, 86},
false, false, element::i32, int32_t(2), PartialShape {}),
CumSumParams(
PartialShape{3, 2, 4},
type,
std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23},
std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 18, 20, 22, 24, 27, 30, 33, 36, 39, 42, 45},
false,
false,
element::i32,
int32_t(0),
PartialShape{}),
CumSumParams(
PartialShape{3, 2, 4},
type,
std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23},
std::vector<T>{0, 1, 2, 3, 4, 6, 8, 10, 8, 9, 10, 11, 20, 22, 24, 26, 16, 17, 18, 19, 36, 38, 40, 42},
false,
false,
element::i32,
int32_t(1),
PartialShape{}),
CumSumParams(
PartialShape{3, 2, 4},
type,
std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23},
std::vector<T>{0, 1, 3, 6, 4, 9, 15, 22, 8, 17, 27, 38, 12, 25, 39, 54, 16, 33, 51, 70, 20, 41, 63, 86},
false,
false,
element::i32,
int32_t(2),
PartialShape{}),
};
return opParams;
}
std::vector<CumSumParams> generateCumSumCombinedParams() {
const std::vector<std::vector<CumSumParams>> opTypeParams {
generateCumSumParams<element::Type_t::bf16>(element::bf16), generateCumSumParams<element::Type_t::f16>(element::f16),
generateCumSumParams<element::Type_t::f32>(element::f32), generateCumSumParams<element::Type_t::i32>(element::i32),
generateCumSumParams<element::Type_t::i64>(element::i64), generateCumSumParams<element::Type_t::u32>(element::u32),
const std::vector<std::vector<CumSumParams>> opTypeParams{
generateCumSumParams<element::Type_t::bf16>(element::bf16),
generateCumSumParams<element::Type_t::f16>(element::f16),
generateCumSumParams<element::Type_t::f32>(element::f32),
generateCumSumParams<element::Type_t::i32>(element::i32),
generateCumSumParams<element::Type_t::i64>(element::i64),
generateCumSumParams<element::Type_t::u32>(element::u32),
generateCumSumParams<element::Type_t::i8>(element::i8)};
std::vector<CumSumParams> combinedParams;
std::for_each(opTypeParams.begin(), opTypeParams.end(), [&](std::vector<CumSumParams> params) {
@ -182,6 +305,8 @@ std::vector<CumSumParams> generateCumSumCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_CumSum_With_Hardcoded_Refs, ReferenceCumSumLayerTest, ::testing::ValuesIn(generateCumSumCombinedParams()),
INSTANTIATE_TEST_SUITE_P(smoke_CumSum_With_Hardcoded_Refs,
ReferenceCumSumLayerTest,
::testing::ValuesIn(generateCumSumCombinedParams()),
ReferenceCumSumLayerTest::getTestCaseName);
} // namespace

View File

@ -5,8 +5,9 @@
#include <gtest/gtest.h>
#include <random>
#include "openvino/op/psroi_pooling.hpp"
#include "base_reference_test.hpp"
#include "openvino/op/psroi_pooling.hpp"
#include "openvino/opsets/opset1.hpp"
using namespace reference_tests;
@ -15,12 +16,24 @@ using namespace ov;
namespace {
struct DeformablePSROIPoolingParams {
template <class IT>
DeformablePSROIPoolingParams(const size_t batch_in, const size_t channel_in, const size_t height_in, const size_t width_in,
const float spatial_scale, const size_t group_size, const int64_t spatial_bins_x, const int64_t spatial_bins_y,
const float trans_std, const int64_t part_size, const size_t rois_dim,
const ov::element::Type& iType, const bool is_input_generation_iota, const float inputValue,
const std::vector<IT>& roisValues, const std::vector<IT>& oValues,
const std::string& test_name = "", const std::string& mode = "bilinear_deformable")
DeformablePSROIPoolingParams(const size_t batch_in,
const size_t channel_in,
const size_t height_in,
const size_t width_in,
const float spatial_scale,
const size_t group_size,
const int64_t spatial_bins_x,
const int64_t spatial_bins_y,
const float trans_std,
const int64_t part_size,
const size_t rois_dim,
const ov::element::Type& iType,
const bool is_input_generation_iota,
const float inputValue,
const std::vector<IT>& roisValues,
const std::vector<IT>& oValues,
const std::string& test_name = "",
const std::string& mode = "bilinear_deformable")
: groupSize(group_size),
spatialBinsX(spatial_bins_x),
spatialBinsY(spatial_bins_y),
@ -33,34 +46,48 @@ struct DeformablePSROIPoolingParams {
outType(iType),
roisData(CreateTensor(iType, roisValues)),
testcaseName(test_name) {
outputDim = (channel_in / (group_size * group_size)) - (static_cast<size_t>(channel_in / (group_size * group_size)) % 2);
inputShape = Shape{batch_in, channel_in, height_in, width_in};
roisShape = Shape{rois_dim, 5};
outputDim = (channel_in / (group_size * group_size)) -
(static_cast<size_t>(channel_in / (group_size * group_size)) % 2);
inputShape = Shape{batch_in, channel_in, height_in, width_in};
roisShape = Shape{rois_dim, 5};
std::vector<IT> inputValues(shape_size(inputShape.get_shape()));
if (is_input_generation_iota)
std::iota(inputValues.begin(), inputValues.end(), inputValue);
else
std::fill(inputValues.begin(), inputValues.end(), inputValue);
inputData = CreateTensor(iType, inputValues);
std::vector<IT> inputValues(shape_size(inputShape.get_shape()));
if (is_input_generation_iota)
std::iota(inputValues.begin(), inputValues.end(), inputValue);
else
std::fill(inputValues.begin(), inputValues.end(), inputValue);
inputData = CreateTensor(iType, inputValues);
if (oValues.size() > 1) {
refData = CreateTensor(iType, oValues);
} else {
Shape output_shape{rois_dim, outputDim, group_size, group_size};
std::vector<IT> expected_output_values(shape_size(output_shape));
std::fill(expected_output_values.begin(), expected_output_values.end(), oValues[0]);
refData = CreateTensor(iType, expected_output_values);
}
}
if (oValues.size() > 1) {
refData = CreateTensor(iType, oValues);
} else {
Shape output_shape{rois_dim, outputDim, group_size, group_size};
std::vector<IT> expected_output_values(shape_size(output_shape));
std::fill(expected_output_values.begin(), expected_output_values.end(), oValues[0]);
refData = CreateTensor(iType, expected_output_values);
}
}
template <class IT>
DeformablePSROIPoolingParams(const size_t batch_in, const size_t channel_in, const size_t height_in, const size_t width_in,
const float spatial_scale, const size_t group_size, const int64_t spatial_bins_x, const int64_t spatial_bins_y,
const float trans_std, const int64_t part_size, const size_t rois_dim,
const ov::element::Type& iType, const bool is_input_generation_iota, const float inputValue, const float offsetValue,
const std::vector<IT>& roisValues, const std::vector<IT>& oValues,
const std::string& test_name = "", const std::string& mode = "bilinear_deformable")
DeformablePSROIPoolingParams(const size_t batch_in,
const size_t channel_in,
const size_t height_in,
const size_t width_in,
const float spatial_scale,
const size_t group_size,
const int64_t spatial_bins_x,
const int64_t spatial_bins_y,
const float trans_std,
const int64_t part_size,
const size_t rois_dim,
const ov::element::Type& iType,
const bool is_input_generation_iota,
const float inputValue,
const float offsetValue,
const std::vector<IT>& roisValues,
const std::vector<IT>& oValues,
const std::string& test_name = "",
const std::string& mode = "bilinear_deformable")
: groupSize(group_size),
spatialBinsX(spatial_bins_x),
spatialBinsY(spatial_bins_y),
@ -74,31 +101,31 @@ struct DeformablePSROIPoolingParams {
outType(iType),
roisData(CreateTensor(iType, roisValues)),
testcaseName(test_name) {
outputDim = (channel_in / (group_size * group_size)) - ((channel_in / (group_size * group_size)) % 2);
inputShape = Shape{batch_in, channel_in, height_in, width_in};
roisShape = Shape{rois_dim, 5};
offsetsShape = Shape{rois_dim, 2, group_size, group_size};
outputDim = (channel_in / (group_size * group_size)) - ((channel_in / (group_size * group_size)) % 2);
inputShape = Shape{batch_in, channel_in, height_in, width_in};
roisShape = Shape{rois_dim, 5};
offsetsShape = Shape{rois_dim, 2, group_size, group_size};
std::vector<IT> inputValues(shape_size(inputShape.get_shape()));
if (is_input_generation_iota)
std::iota(inputValues.begin(), inputValues.end(), inputValue);
else
std::fill(inputValues.begin(), inputValues.end(), inputValue);
inputData = CreateTensor(iType, inputValues);
std::vector<IT> inputValues(shape_size(inputShape.get_shape()));
if (is_input_generation_iota)
std::iota(inputValues.begin(), inputValues.end(), inputValue);
else
std::fill(inputValues.begin(), inputValues.end(), inputValue);
inputData = CreateTensor(iType, inputValues);
std::vector<IT> offsetsValues(shape_size(offsetsShape.get_shape()));
std::fill(offsetsValues.begin(), offsetsValues.end(), offsetValue);
offsetsData = CreateTensor(iType, offsetsValues);
std::vector<IT> offsetsValues(shape_size(offsetsShape.get_shape()));
std::fill(offsetsValues.begin(), offsetsValues.end(), offsetValue);
offsetsData = CreateTensor(iType, offsetsValues);
if (oValues.size() > 1) {
refData = CreateTensor(iType, oValues);
} else {
Shape output_shape{rois_dim, outputDim, group_size, group_size};
std::vector<IT> expected_output_values(shape_size(output_shape));
std::fill(expected_output_values.begin(), expected_output_values.end(), oValues[0]);
refData = CreateTensor(iType, expected_output_values);
}
}
if (oValues.size() > 1) {
refData = CreateTensor(iType, oValues);
} else {
Shape output_shape{rois_dim, outputDim, group_size, group_size};
std::vector<IT> expected_output_values(shape_size(output_shape));
std::fill(expected_output_values.begin(), expected_output_values.end(), oValues[0]);
refData = CreateTensor(iType, expected_output_values);
}
}
size_t groupSize;
int64_t spatialBinsX;
@ -123,7 +150,8 @@ struct DeformablePSROIPoolingParams {
std::string testcaseName;
};
class ReferenceDeformablePSROIPoolingLayerTest : public testing::TestWithParam<DeformablePSROIPoolingParams>, public CommonReferenceTest {
class ReferenceDeformablePSROIPoolingLayerTest : public testing::TestWithParam<DeformablePSROIPoolingParams>,
public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
@ -159,29 +187,30 @@ private:
if (params.offsetsShape.size() != 0) {
const auto offsets = std::make_shared<op::v0::Parameter>(params.offsetsType, params.offsetsShape);
const auto DeformablePSROIPooling = std::make_shared<opset1::DeformablePSROIPooling>(input,
rois,
offsets,
params.outputDim,
params.spatialScale,
params.groupSize,
params.mode,
params.spatialBinsX,
params.spatialBinsY,
params.transStd,
params.partSize);
return std::make_shared<ov::Model>(NodeVector {DeformablePSROIPooling}, ParameterVector {input, rois, offsets});
rois,
offsets,
params.outputDim,
params.spatialScale,
params.groupSize,
params.mode,
params.spatialBinsX,
params.spatialBinsY,
params.transStd,
params.partSize);
return std::make_shared<ov::Model>(NodeVector{DeformablePSROIPooling},
ParameterVector{input, rois, offsets});
} else {
const auto DeformablePSROIPooling = std::make_shared<opset1::DeformablePSROIPooling>(input,
rois,
params.outputDim,
params.spatialScale,
params.groupSize,
params.mode,
params.spatialBinsX,
params.spatialBinsY,
params.transStd,
params.partSize);
return std::make_shared<ov::Model>(NodeVector {DeformablePSROIPooling}, ParameterVector {input, rois});
rois,
params.outputDim,
params.spatialScale,
params.groupSize,
params.mode,
params.spatialBinsX,
params.spatialBinsY,
params.transStd,
params.partSize);
return std::make_shared<ov::Model>(NodeVector{DeformablePSROIPooling}, ParameterVector{input, rois});
}
}
};
@ -194,152 +223,403 @@ template <element::Type_t IN_ET>
std::vector<DeformablePSROIPoolingParams> generateDeformablePSROIPoolingFloatParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<DeformablePSROIPoolingParams> deformablePSROIPoolingParams {
DeformablePSROIPoolingParams(1, 16, 2, 2, // batch_in, channel_in, height_in, width_in
0.0625, 2, 1, 1, //spatial_scale, group_size, spatial_bins_x, spatial_bins_y
1, 1, 2, // trans_std, part_size, rois_dim
IN_ET, true, 0, 0.0, //inputType, is_input_generation_iota, inputValue, offsetValue
std::vector<T>{
// input_batch_id, x1, y1, x2, y2
0, 1, 2, 4, 6,
0, 0, 3, 10, 4},
std::vector<T>{
// First ROI
0, 4, 8, 12,
16, 20, 24, 28,
32, 36, 40, 44,
48, 52, 56, 60,
std::vector<DeformablePSROIPoolingParams> deformablePSROIPoolingParams{
DeformablePSROIPoolingParams(1,
16,
2,
2, // batch_in, channel_in, height_in, width_in
0.0625,
2,
1,
1, // spatial_scale, group_size, spatial_bins_x, spatial_bins_y
1,
1,
2, // trans_std, part_size, rois_dim
IN_ET,
true,
0,
0.0, // inputType, is_input_generation_iota, inputValue, offsetValue
std::vector<T>{// input_batch_id, x1, y1, x2, y2
0,
1,
2,
4,
6,
0,
0,
3,
10,
4},
std::vector<T>{// First ROI
0,
4,
8,
12,
16,
20,
24,
28,
32,
36,
40,
44,
48,
52,
56,
60,
// Second ROI
0, 4, 8, 12,
16, 20, 24, 28,
32, 36, 40, 44,
48, 52, 56, 60},
"offset_00"),
DeformablePSROIPoolingParams(1, 16, 2, 2, // batch_in, channel_in, height_in, width_in
0.0625, 2, 1, 1, //spatial_scale, group_size, spatial_bins_x, spatial_bins_y
1, 1, 2, // trans_std, part_size, rois_dim
IN_ET, true, 0, 0.2, //inputType, is_input_generation_iota, inputValue, offsetValue
std::vector<T>{
// input_batch_id, x1, y1, x2, y2
0, 1, 2, 4, 6,
0, 0, 3, 10, 4},
std::vector<T>{
// First ROI
0, 4, 8, 12,
16, 20, 24, 28,
32, 36, 40, 44,
48, 52, 56, 60,
0,
4,
8,
12,
16,
20,
24,
28,
32,
36,
40,
44,
48,
52,
56,
60},
"offset_00"),
DeformablePSROIPoolingParams(1,
16,
2,
2, // batch_in, channel_in, height_in, width_in
0.0625,
2,
1,
1, // spatial_scale, group_size, spatial_bins_x, spatial_bins_y
1,
1,
2, // trans_std, part_size, rois_dim
IN_ET,
true,
0,
0.2, // inputType, is_input_generation_iota, inputValue, offsetValue
std::vector<T>{// input_batch_id, x1, y1, x2, y2
0,
1,
2,
4,
6,
0,
0,
3,
10,
4},
std::vector<T>{// First ROI
0,
4,
8,
12,
16,
20,
24,
28,
32,
36,
40,
44,
48,
52,
56,
60,
// Second ROI
0, 4, 8, 12,
16, 20, 24, 28,
32, 36, 40, 44,
48, 52, 56, 60},
"offset_0p2"),
DeformablePSROIPoolingParams(1, 16, 2, 2, // batch_in, channel_in, height_in, width_in
0.0625, 2, 1, 1, //spatial_scale, group_size, spatial_bins_x, spatial_bins_y
1, 1, 2, // trans_std, part_size, rois_dim
IN_ET, true, 0, 0.5, //inputType, is_input_generation_iota, inputValue, offsetValue
std::vector<T>{
// input_batch_id, x1, y1, x2, y2
0, 1, 2, 4, 6,
0, 5, 3, 10, 4},
std::vector<T>{
// First ROI
0, 4, 8, 12,
16, 20, 24, 28,
32, 36, 40, 44,
48, 52, 56, 60,
0,
4,
8,
12,
16,
20,
24,
28,
32,
36,
40,
44,
48,
52,
56,
60},
"offset_0p2"),
DeformablePSROIPoolingParams(1,
16,
2,
2, // batch_in, channel_in, height_in, width_in
0.0625,
2,
1,
1, // spatial_scale, group_size, spatial_bins_x, spatial_bins_y
1,
1,
2, // trans_std, part_size, rois_dim
IN_ET,
true,
0,
0.5, // inputType, is_input_generation_iota, inputValue, offsetValue
std::vector<T>{// input_batch_id, x1, y1, x2, y2
0,
1,
2,
4,
6,
0,
5,
3,
10,
4},
std::vector<T>{// First ROI
0,
4,
8,
12,
16,
20,
24,
28,
32,
36,
40,
44,
48,
52,
56,
60,
// Second ROI
0, 4.1875, 8, 12.1875,
16, 20.1875, 24, 28.1875,
32, 36.1875, 40, 44.1875,
48, 52.1875, 56, 60.1875},
"offset_0p5"),
DeformablePSROIPoolingParams(1, 16, 2, 2, // batch_in, channel_in, height_in, width_in
0.0625, 2, 1, 1, //spatial_scale, group_size, spatial_bins_x, spatial_bins_y
1, 1, 2, // trans_std, part_size, rois_dim
IN_ET, true, 0, 0, //inputType, is_input_generation_iota, inputValue, offsetValue
std::vector<T>{
// input_batch_id, x1, y1, x2, y2
0, 10, 10, 20, 20,
0, 100, 100, 200, 200},
std::vector<T>{
// First ROI
0.375, 4.71875, 9.0625, 13.40625, 16.375, 20.71875, 25.0625, 29.40625,
32.375, 36.71875, 41.0625, 45.40625, 48.375, 52.71875, 57.0625, 61.40625,
0,
4.1875,
8,
12.1875,
16,
20.1875,
24,
28.1875,
32,
36.1875,
40,
44.1875,
48,
52.1875,
56,
60.1875},
"offset_0p5"),
DeformablePSROIPoolingParams(1,
16,
2,
2, // batch_in, channel_in, height_in, width_in
0.0625,
2,
1,
1, // spatial_scale, group_size, spatial_bins_x, spatial_bins_y
1,
1,
2, // trans_std, part_size, rois_dim
IN_ET,
true,
0,
0, // inputType, is_input_generation_iota, inputValue, offsetValue
std::vector<T>{// input_batch_id, x1, y1, x2, y2
0,
10,
10,
20,
20,
0,
100,
100,
200,
200},
std::vector<T>{// First ROI
0.375,
4.71875,
9.0625,
13.40625,
16.375,
20.71875,
25.0625,
29.40625,
32.375,
36.71875,
41.0625,
45.40625,
48.375,
52.71875,
57.0625,
61.40625,
// Second ROI
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0},
"roi_oversize"),
DeformablePSROIPoolingParams(1, 8, 3, 3, // batch_in, channel_in, height_in, width_in
1, 2, 1, 1, //spatial_scale, group_size, spatial_bins_x, spatial_bins_y
1, 2, 1, // trans_std, part_size, rois_dim
IN_ET, true, 0, //inputType, is_input_generation_iota, inputValue, offsetValue
std::vector<T>{
// input_batch_id, x1, y1, x2, y2
0, 1, 1, 2, 2},
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0},
"roi_oversize"),
DeformablePSROIPoolingParams(1,
8,
3,
3, // batch_in, channel_in, height_in, width_in
1,
2,
1,
1, // spatial_scale, group_size, spatial_bins_x, spatial_bins_y
1,
2,
1, // trans_std, part_size, rois_dim
IN_ET,
true,
0, // inputType, is_input_generation_iota, inputValue, offsetValue
std::vector<T>{// input_batch_id, x1, y1, x2, y2
0,
1,
1,
2,
2},
std::vector<T>{2.0, 12.0, 23.0, 33.0, 38.0, 48.0, 59.0, 69.0},
"no_offset_input"),
DeformablePSROIPoolingParams(1, 8, 3, 3, // batch_in, channel_in, height_in, width_in
1, 2, 1, 1, //spatial_scale, group_size, spatial_bins_x, spatial_bins_y
1, 2, 1, // trans_std, part_size, rois_dim,
IN_ET, true, 0, 0, //inputType, is_input_generation_iota, inputValue, offsetValue
std::vector<T>{
// input_batch_id, x1, y1, x2, y2
0, 1, 1, 2, 2},
"no_offset_input"),
DeformablePSROIPoolingParams(1,
8,
3,
3, // batch_in, channel_in, height_in, width_in
1,
2,
1,
1, // spatial_scale, group_size, spatial_bins_x, spatial_bins_y
1,
2,
1, // trans_std, part_size, rois_dim,
IN_ET,
true,
0,
0, // inputType, is_input_generation_iota, inputValue, offsetValue
std::vector<T>{// input_batch_id, x1, y1, x2, y2
0,
1,
1,
2,
2},
std::vector<T>{2.0, 12.0, 23.0, 33.0, 38.0, 48.0, 59.0, 69.0},
"offset_zero"),
DeformablePSROIPoolingParams(1, 8, 3, 3, // batch_in, channel_in, height_in, width_in
1, 2, 1, 1, //spatial_scale, group_size, spatial_bins_x, spatial_bins_y
1, 2, 1, // trans_std, part_size, rois_dim,
IN_ET, true, 0, 0.1, //inputType, is_input_generation_iota, inputValue, offsetValue
std::vector<T>{
// input_batch_id, x1, y1, x2, y2
0, 1, 1, 2, 2},
"offset_zero"),
DeformablePSROIPoolingParams(1,
8,
3,
3, // batch_in, channel_in, height_in, width_in
1,
2,
1,
1, // spatial_scale, group_size, spatial_bins_x, spatial_bins_y
1,
2,
1, // trans_std, part_size, rois_dim,
IN_ET,
true,
0,
0.1, // inputType, is_input_generation_iota, inputValue, offsetValue
std::vector<T>{// input_batch_id, x1, y1, x2, y2
0,
1,
1,
2,
2},
std::vector<T>{2.8, 12.8, 23.8, 33.8, 38.8, 48.8, 59.8, 69.8},
"offset_01"),
DeformablePSROIPoolingParams(1, 8, 3, 3, // batch_in, channel_in, height_in, width_in
1, 2, 1, 1, //spatial_scale, group_size, spatial_bins_x, spatial_bins_y
1, 2, 1, // trans_std, part_size, rois_dim,
IN_ET, true, 0, 0.5, //inputType, is_input_generation_iota, inputValue, offsetValue
std::vector<T>{
// input_batch_id, x1, y1, x2, y2
0, 1, 1, 2, 2},
"offset_01"),
DeformablePSROIPoolingParams(1,
8,
3,
3, // batch_in, channel_in, height_in, width_in
1,
2,
1,
1, // spatial_scale, group_size, spatial_bins_x, spatial_bins_y
1,
2,
1, // trans_std, part_size, rois_dim,
IN_ET,
true,
0,
0.5, // inputType, is_input_generation_iota, inputValue, offsetValue
std::vector<T>{// input_batch_id, x1, y1, x2, y2
0,
1,
1,
2,
2},
std::vector<T>{6., 15.5, 25.5, 35., 42., 51.5, 61.5, 71.},
"offset_05"),
DeformablePSROIPoolingParams(1, 16, 2, 2, // batch_in, channel_in, height_in, width_in
0.0625, 2, 1, 1, //spatial_scale, group_size, spatial_bins_x, spatial_bins_y
1, 1, 1, // trans_std, part_size, rois_dim,
IN_ET, false, 0.1, 0.1, //inputType, is_input_generation_iota, inputValue, offsetValue
std::vector<T>{
// input_batch_id, x1, y1, x2, y2
0, 10, 10, 10, 10},
std::vector<T>{0.1, 0.1, 0.1, 0.1,
0.1, 0.1, 0.1, 0.1,
0.1, 0.1, 0.1, 0.1,
0.1, 0.1, 0.1, 0.1},
"single_value"),
DeformablePSROIPoolingParams(1, 1024, 63, 38, // batch_in, channel_in, height_in, width_in
0.0625, 3, 1, 1, //spatial_scale, group_size, spatial_bins_x, spatial_bins_y
1, 1, 2, // trans_std, part_size, rois_dim,
IN_ET, false, 0.1, 0.0, //inputType, is_input_generation_iota, inputValue, offsetValue
std::vector<T>{
// input_batch_id, x1, y1, x2, y2
0, 1, 2, 4, 6,
0, 0, 3, 10, 4},
"offset_05"),
DeformablePSROIPoolingParams(
1,
16,
2,
2, // batch_in, channel_in, height_in, width_in
0.0625,
2,
1,
1, // spatial_scale, group_size, spatial_bins_x, spatial_bins_y
1,
1,
1, // trans_std, part_size, rois_dim,
IN_ET,
false,
0.1,
0.1, // inputType, is_input_generation_iota, inputValue, offsetValue
std::vector<T>{// input_batch_id, x1, y1, x2, y2
0,
10,
10,
10,
10},
std::vector<T>{0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1},
"single_value"),
DeformablePSROIPoolingParams(1,
1024,
63,
38, // batch_in, channel_in, height_in, width_in
0.0625,
3,
1,
1, // spatial_scale, group_size, spatial_bins_x, spatial_bins_y
1,
1,
2, // trans_std, part_size, rois_dim,
IN_ET,
false,
0.1,
0.0, // inputType, is_input_generation_iota, inputValue, offsetValue
std::vector<T>{// input_batch_id, x1, y1, x2, y2
0,
1,
2,
4,
6,
0,
0,
3,
10,
4},
std::vector<T>{0.1},
"single_value_big_shape")
};
"single_value_big_shape")};
return deformablePSROIPoolingParams;
}
std::vector<DeformablePSROIPoolingParams> generateDeformablePSROIPoolingCombinedParams() {
const std::vector<std::vector<DeformablePSROIPoolingParams>> deformablePSROIPoolingTypeParams {
const std::vector<std::vector<DeformablePSROIPoolingParams>> deformablePSROIPoolingTypeParams{
generateDeformablePSROIPoolingFloatParams<element::Type_t::f64>(),
generateDeformablePSROIPoolingFloatParams<element::Type_t::f32>(),
generateDeformablePSROIPoolingFloatParams<element::Type_t::f16>(),
generateDeformablePSROIPoolingFloatParams<element::Type_t::bf16>()
};
generateDeformablePSROIPoolingFloatParams<element::Type_t::bf16>()};
std::vector<DeformablePSROIPoolingParams> combinedParams;
for (const auto& params : deformablePSROIPoolingTypeParams) {
@ -348,7 +628,9 @@ std::vector<DeformablePSROIPoolingParams> generateDeformablePSROIPoolingCombined
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_DeformablePSROIPooling_With_Hardcoded_Refs, ReferenceDeformablePSROIPoolingLayerTest,
testing::ValuesIn(generateDeformablePSROIPoolingCombinedParams()), ReferenceDeformablePSROIPoolingLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_DeformablePSROIPooling_With_Hardcoded_Refs,
ReferenceDeformablePSROIPoolingLayerTest,
testing::ValuesIn(generateDeformablePSROIPoolingCombinedParams()),
ReferenceDeformablePSROIPoolingLayerTest::getTestCaseName);
} // namespace
} // namespace

View File

@ -4,18 +4,24 @@
#include <gtest/gtest.h>
#include "openvino/opsets/opset1.hpp"
#include "base_reference_test.hpp"
#include "openvino/opsets/opset1.hpp"
using namespace reference_tests;
using namespace ov;
namespace {
struct DepthToSpaceParams {
DepthToSpaceParams(const reference_tests::Tensor& dataTensor, const std::string mode, const int32_t blockSize,
const reference_tests::Tensor& expectedTensor, const std::string& testcaseName = "") :
dataTensor(dataTensor), mode(mode), blockSize(blockSize), expectedTensor(expectedTensor),
testcaseName(testcaseName) {}
DepthToSpaceParams(const reference_tests::Tensor& dataTensor,
const std::string mode,
const int32_t blockSize,
const reference_tests::Tensor& expectedTensor,
const std::string& testcaseName = "")
: dataTensor(dataTensor),
mode(mode),
blockSize(blockSize),
expectedTensor(expectedTensor),
testcaseName(testcaseName) {}
reference_tests::Tensor dataTensor;
std::string mode;
@ -50,11 +56,12 @@ public:
private:
static std::shared_ptr<Model> CreateFunction(const DepthToSpaceParams& params) {
opset1::DepthToSpace::DepthToSpaceMode mode = params.mode == "DEPTH_FIRST" ?
opset1::DepthToSpace::DepthToSpaceMode::DEPTH_FIRST : opset1::DepthToSpace::DepthToSpaceMode::BLOCKS_FIRST;
opset1::DepthToSpace::DepthToSpaceMode mode = params.mode == "DEPTH_FIRST"
? opset1::DepthToSpace::DepthToSpaceMode::DEPTH_FIRST
: opset1::DepthToSpace::DepthToSpaceMode::BLOCKS_FIRST;
const auto data = std::make_shared<opset1::Parameter>(params.dataTensor.type, params.dataTensor.shape);
const auto depthToSpace = std::make_shared<opset1::DepthToSpace>(data, mode, params.blockSize);
return std::make_shared<Model>(NodeVector {depthToSpace}, ParameterVector {data});
return std::make_shared<Model>(NodeVector{depthToSpace}, ParameterVector{data});
}
};
@ -65,72 +72,84 @@ TEST_P(ReferenceDepthToSpaceLayerTest, CompareWithRefs) {
template <element::Type_t IN_ET>
std::vector<DepthToSpaceParams> generateDepthToSpaceParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<DepthToSpaceParams> depthToSpaceParams {
std::vector<DepthToSpaceParams> depthToSpaceParams{
// depth_to_space_block_first_K1_BS2
DepthToSpaceParams(
reference_tests::Tensor({1, 8, 2}, IN_ET, std::vector<T>{0, 2, 8, 10, 16, 18, 24, 26, 1, 3, 9, 11, 17, 19, 25, 27}),
reference_tests::Tensor({1, 8, 2},
IN_ET,
std::vector<T>{0, 2, 8, 10, 16, 18, 24, 26, 1, 3, 9, 11, 17, 19, 25, 27}),
"BLOCKS_FIRST",
2,
reference_tests::Tensor({1, 4, 4}, IN_ET, std::vector<T>{0, 1, 2, 3, 8, 9, 10, 11, 16, 17, 18, 19, 24, 25, 26, 27}),
reference_tests::Tensor({1, 4, 4},
IN_ET,
std::vector<T>{0, 1, 2, 3, 8, 9, 10, 11, 16, 17, 18, 19, 24, 25, 26, 27}),
"depth_to_space_block_first_K1_BS2"),
// depth_to_space_block_first_K2_BS2
DepthToSpaceParams(
reference_tests::Tensor({1, 8, 2, 2}, IN_ET, std::vector<T>{0, 2, 8, 10, 16, 18, 24, 26, 1, 3, 9,
11, 17, 19, 25, 27, 4, 6, 12, 14, 20, 22,
28, 30, 5, 7, 13, 15, 21, 23, 29, 31}),
11, 17, 19, 25, 27, 4, 6, 12, 14, 20, 22,
28, 30, 5, 7, 13, 15, 21, 23, 29, 31}),
"BLOCKS_FIRST",
2,
reference_tests::Tensor({1, 2, 4, 4}, IN_ET, std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}),
reference_tests::Tensor({1, 2, 4, 4}, IN_ET, std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
22, 23, 24, 25, 26, 27, 28, 29, 30, 31}),
"depth_to_space_block_first_K2_BS2"),
// depth_to_space_block_first_K2_BS4
DepthToSpaceParams(
reference_tests::Tensor({1, 16, 2, 1}, IN_ET, std::vector<T>{0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5,
21, 6, 22, 7, 23, 8, 24, 9, 25, 10, 26,
11, 27, 12, 28, 13, 29, 14, 30, 15, 31}),
21, 6, 22, 7, 23, 8, 24, 9, 25, 10, 26,
11, 27, 12, 28, 13, 29, 14, 30, 15, 31}),
"BLOCKS_FIRST",
4,
reference_tests::Tensor({1, 1, 8, 4}, IN_ET, std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}),
reference_tests::Tensor({1, 1, 8, 4}, IN_ET, std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
22, 23, 24, 25, 26, 27, 28, 29, 30, 31}),
"depth_to_space_block_first_K2_BS4"),
// depth_to_space_depth_first_1K_BS2
DepthToSpaceParams(
reference_tests::Tensor({1, 8, 2}, IN_ET, std::vector<T>{0, 2, 1, 3, 4, 6, 5, 7, 8, 10, 9, 11, 12, 14, 13, 15}),
reference_tests::Tensor({1, 8, 2},
IN_ET,
std::vector<T>{0, 2, 1, 3, 4, 6, 5, 7, 8, 10, 9, 11, 12, 14, 13, 15}),
"DEPTH_FIRST",
2,
reference_tests::Tensor({1, 4, 4}, IN_ET, std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}),
reference_tests::Tensor({1, 4, 4},
IN_ET,
std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}),
"depth_to_space_depth_first_1K_BS2"),
// depth_to_space_depth_first_2K_BS2
DepthToSpaceParams(
reference_tests::Tensor({1, 8, 2, 2}, IN_ET, std::vector<T>{0, 2, 8, 10, 16, 18, 24, 26, 1, 3, 9,
11, 17, 19, 25, 27, 4, 6, 12, 14, 20, 22,
28, 30, 5, 7, 13, 15, 21, 23, 29, 31}),
11, 17, 19, 25, 27, 4, 6, 12, 14, 20, 22,
28, 30, 5, 7, 13, 15, 21, 23, 29, 31}),
"DEPTH_FIRST",
2,
reference_tests::Tensor({1, 2, 4, 4}, IN_ET, std::vector<T>{0, 16, 2, 18, 1, 17, 3, 19, 8, 24, 10, 26, 9, 25, 11, 27,
4, 20, 6, 22, 5, 21, 7, 23, 12, 28, 14, 30, 13, 29, 15, 31}),
reference_tests::Tensor({1, 2, 4, 4}, IN_ET, std::vector<T>{0, 16, 2, 18, 1, 17, 3, 19, 8, 24, 10,
26, 9, 25, 11, 27, 4, 20, 6, 22, 5, 21,
7, 23, 12, 28, 14, 30, 13, 29, 15, 31}),
"depth_to_space_depth_first_2K_BS2"),
// depth_to_space_depth_first_2K_BS4
DepthToSpaceParams(
reference_tests::Tensor({1, 16, 2, 1}, IN_ET, std::vector<T>{0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5,
21, 6, 22, 7, 23, 8, 24, 9, 25, 10, 26,
11, 27, 12, 28, 13, 29, 14, 30, 15, 31}),
21, 6, 22, 7, 23, 8, 24, 9, 25, 10, 26,
11, 27, 12, 28, 13, 29, 14, 30, 15, 31}),
"DEPTH_FIRST",
4,
reference_tests::Tensor({1, 1, 8, 4}, IN_ET, std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}),
reference_tests::Tensor({1, 1, 8, 4}, IN_ET, std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
22, 23, 24, 25, 26, 27, 28, 29, 30, 31}),
"depth_to_space_depth_first_2K_BS4"),
};
return depthToSpaceParams;
}
std::vector<DepthToSpaceParams> generateDepthToSpaceCombinedParams() {
const std::vector<std::vector<DepthToSpaceParams>> depthToSpaceTypeParams {
const std::vector<std::vector<DepthToSpaceParams>> depthToSpaceTypeParams{
generateDepthToSpaceParams<element::Type_t::i8>(),
generateDepthToSpaceParams<element::Type_t::i16>(),
generateDepthToSpaceParams<element::Type_t::i32>(),
@ -152,6 +171,8 @@ std::vector<DepthToSpaceParams> generateDepthToSpaceCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_DepthToSpace_With_Hardcoded_Refs, ReferenceDepthToSpaceLayerTest,
testing::ValuesIn(generateDepthToSpaceCombinedParams()), ReferenceDepthToSpaceLayerTest::getTestCaseName);
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_DepthToSpace_With_Hardcoded_Refs,
ReferenceDepthToSpaceLayerTest,
testing::ValuesIn(generateDepthToSpaceCombinedParams()),
ReferenceDepthToSpaceLayerTest::getTestCaseName);
} // namespace

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/detection_output.hpp"
#include <gtest/gtest.h>
#include "openvino/op/detection_output.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
@ -44,33 +45,34 @@ struct DetectionOutputParams {
priorBoxesData(CreateTensor(iType, priorBoxesValues)),
refData(CreateTensor(iType, oValues)),
testcaseName(test_name) {
attrs.num_classes = num_classes;
attrs_v8.background_label_id = attrs.background_label_id = background_label_id;
attrs_v8.top_k = attrs.top_k = top_k;
attrs_v8.variance_encoded_in_target = attrs.variance_encoded_in_target = variance_encoded_in_target;
attrs_v8.keep_top_k = attrs.keep_top_k = keep_top_k;
attrs_v8.code_type = attrs.code_type = code_type;
attrs_v8.share_location = attrs.share_location = share_location;
attrs_v8.nms_threshold = attrs.nms_threshold = nms_threshold;
attrs_v8.confidence_threshold = attrs.confidence_threshold = confidence_threshold;
attrs_v8.clip_after_nms = attrs.clip_after_nms = clip_after_nms;
attrs_v8.clip_before_nms = attrs.clip_before_nms = clip_before_nms;
attrs_v8.decrease_label_id = attrs.decrease_label_id = decrease_label_id;
attrs_v8.normalized = attrs.normalized = normalized;
attrs_v8.input_height = attrs.input_height = input_height;
attrs_v8.input_width = attrs.input_width = input_width;
attrs_v8.objectness_score = attrs.objectness_score = objectness_score;
attrs.num_classes = num_classes;
attrs_v8.background_label_id = attrs.background_label_id = background_label_id;
attrs_v8.top_k = attrs.top_k = top_k;
attrs_v8.variance_encoded_in_target = attrs.variance_encoded_in_target = variance_encoded_in_target;
attrs_v8.keep_top_k = attrs.keep_top_k = keep_top_k;
attrs_v8.code_type = attrs.code_type = code_type;
attrs_v8.share_location = attrs.share_location = share_location;
attrs_v8.nms_threshold = attrs.nms_threshold = nms_threshold;
attrs_v8.confidence_threshold = attrs.confidence_threshold = confidence_threshold;
attrs_v8.clip_after_nms = attrs.clip_after_nms = clip_after_nms;
attrs_v8.clip_before_nms = attrs.clip_before_nms = clip_before_nms;
attrs_v8.decrease_label_id = attrs.decrease_label_id = decrease_label_id;
attrs_v8.normalized = attrs.normalized = normalized;
attrs_v8.input_height = attrs.input_height = input_height;
attrs_v8.input_width = attrs.input_width = input_width;
attrs_v8.objectness_score = attrs.objectness_score = objectness_score;
size_t num_loc_classes = attrs.share_location ? 1 : attrs.num_classes;
size_t prior_box_size = attrs.normalized ? 4 : 5;
size_t num_loc_classes = attrs.share_location ? 1 : attrs.num_classes;
size_t prior_box_size = attrs.normalized ? 4 : 5;
locShape = ov::Shape{num_images, num_prior_boxes * num_loc_classes * prior_box_size};
confShape = ov::Shape{num_images, num_prior_boxes * attrs.num_classes};
priorBoxesShape =
ov::Shape{is_priors_patch_size_1 ? 1UL : num_images, attrs.variance_encoded_in_target ? 1UL : 2UL, num_prior_boxes * prior_box_size};
}
locShape = ov::Shape{num_images, num_prior_boxes * num_loc_classes * prior_box_size};
confShape = ov::Shape{num_images, num_prior_boxes * attrs.num_classes};
priorBoxesShape = ov::Shape{is_priors_patch_size_1 ? 1UL : num_images,
attrs.variance_encoded_in_target ? 1UL : 2UL,
num_prior_boxes * prior_box_size};
}
template <class IT>
template <class IT>
DetectionOutputParams(const int num_classes,
const int background_label_id,
const int top_k,
@ -106,33 +108,34 @@ template <class IT>
auxLocData(CreateTensor(iType, auxLocValues)),
auxConfData(CreateTensor(iType, auxConfValues)),
testcaseName(test_name) {
attrs.num_classes = num_classes;
attrs_v8.background_label_id = attrs.background_label_id = background_label_id;
attrs_v8.top_k = attrs.top_k = top_k;
attrs_v8.variance_encoded_in_target = attrs.variance_encoded_in_target = variance_encoded_in_target;
attrs_v8.keep_top_k = attrs.keep_top_k = keep_top_k;
attrs_v8.code_type = attrs.code_type = code_type;
attrs_v8.share_location = attrs.share_location = share_location;
attrs_v8.nms_threshold = attrs.nms_threshold = nms_threshold;
attrs_v8.confidence_threshold = attrs.confidence_threshold = confidence_threshold;
attrs_v8.clip_after_nms = attrs.clip_after_nms = clip_after_nms;
attrs_v8.clip_before_nms = attrs.clip_before_nms = clip_before_nms;
attrs_v8.decrease_label_id = attrs.decrease_label_id = decrease_label_id;
attrs_v8.normalized = attrs.normalized = normalized;
attrs_v8.input_height = attrs.input_height = input_height;
attrs_v8.input_width = attrs.input_width = input_width;
attrs_v8.objectness_score = attrs.objectness_score = objectness_score;
attrs.num_classes = num_classes;
attrs_v8.background_label_id = attrs.background_label_id = background_label_id;
attrs_v8.top_k = attrs.top_k = top_k;
attrs_v8.variance_encoded_in_target = attrs.variance_encoded_in_target = variance_encoded_in_target;
attrs_v8.keep_top_k = attrs.keep_top_k = keep_top_k;
attrs_v8.code_type = attrs.code_type = code_type;
attrs_v8.share_location = attrs.share_location = share_location;
attrs_v8.nms_threshold = attrs.nms_threshold = nms_threshold;
attrs_v8.confidence_threshold = attrs.confidence_threshold = confidence_threshold;
attrs_v8.clip_after_nms = attrs.clip_after_nms = clip_after_nms;
attrs_v8.clip_before_nms = attrs.clip_before_nms = clip_before_nms;
attrs_v8.decrease_label_id = attrs.decrease_label_id = decrease_label_id;
attrs_v8.normalized = attrs.normalized = normalized;
attrs_v8.input_height = attrs.input_height = input_height;
attrs_v8.input_width = attrs.input_width = input_width;
attrs_v8.objectness_score = attrs.objectness_score = objectness_score;
size_t num_loc_classes = attrs.share_location ? 1 : attrs.num_classes;
size_t prior_box_size = attrs.normalized ? 4 : 5;
size_t num_loc_classes = attrs.share_location ? 1 : attrs.num_classes;
size_t prior_box_size = attrs.normalized ? 4 : 5;
locShape = ov::Shape{num_images, num_prior_boxes * num_loc_classes * prior_box_size};
confShape = ov::Shape{num_images, num_prior_boxes * attrs.num_classes};
priorBoxesShape =
ov::Shape{is_priors_patch_size_1 ? 1UL : num_images, attrs.variance_encoded_in_target ? 1UL : 2UL, num_prior_boxes * prior_box_size};
auxLocShape = locShape;
auxConfShape = confShape;
}
locShape = ov::Shape{num_images, num_prior_boxes * num_loc_classes * prior_box_size};
confShape = ov::Shape{num_images, num_prior_boxes * attrs.num_classes};
priorBoxesShape = ov::Shape{is_priors_patch_size_1 ? 1UL : num_images,
attrs.variance_encoded_in_target ? 1UL : 2UL,
num_prior_boxes * prior_box_size};
auxLocShape = locShape;
auxConfShape = confShape;
}
ov::op::v0::DetectionOutput::Attributes attrs;
ov::op::v8::DetectionOutput::Attributes attrs_v8;
@ -151,7 +154,8 @@ template <class IT>
std::string testcaseName;
};
class ReferenceDetectionOutputLayerTest : public testing::TestWithParam<DetectionOutputParams>, public CommonReferenceTest {
class ReferenceDetectionOutputLayerTest : public testing::TestWithParam<DetectionOutputParams>,
public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
@ -186,17 +190,19 @@ private:
if ((params.auxLocShape.size() != 0) && (params.auxConfShape.size() != 0)) {
const auto auxConf = std::make_shared<op::v0::Parameter>(params.inType, params.auxConfShape);
const auto auxLoc = std::make_shared<op::v0::Parameter>(params.inType, params.auxLocShape);
const auto DetectionOutput = std::make_shared<op::v0::DetectionOutput>(loc, conf, priorBoxes, auxConf, auxLoc, params.attrs);
return std::make_shared<ov::Model>(NodeVector {DetectionOutput}, ParameterVector {loc, conf, priorBoxes, auxConf, auxLoc});
const auto DetectionOutput =
std::make_shared<op::v0::DetectionOutput>(loc, conf, priorBoxes, auxConf, auxLoc, params.attrs);
return std::make_shared<ov::Model>(NodeVector{DetectionOutput},
ParameterVector{loc, conf, priorBoxes, auxConf, auxLoc});
} else {
const auto DetectionOutput = std::make_shared<op::v0::DetectionOutput>(loc, conf, priorBoxes, params.attrs);
return std::make_shared<ov::Model>(NodeVector {DetectionOutput}, ParameterVector {loc, conf, priorBoxes});
return std::make_shared<ov::Model>(NodeVector{DetectionOutput}, ParameterVector{loc, conf, priorBoxes});
}
}
};
class ReferenceDetectionOutputV8LayerTest : public testing::TestWithParam<DetectionOutputParams>,
public CommonReferenceTest {
public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
@ -234,9 +240,10 @@ private:
const auto DetectionOutput =
std::make_shared<op::v8::DetectionOutput>(loc, conf, priorBoxes, auxConf, auxLoc, params.attrs_v8);
return std::make_shared<ov::Model>(NodeVector{DetectionOutput},
ParameterVector{loc, conf, priorBoxes, auxConf, auxLoc});
ParameterVector{loc, conf, priorBoxes, auxConf, auxLoc});
} else {
const auto DetectionOutput = std::make_shared<op::v8::DetectionOutput>(loc, conf, priorBoxes, params.attrs_v8);
const auto DetectionOutput =
std::make_shared<op::v8::DetectionOutput>(loc, conf, priorBoxes, params.attrs_v8);
return std::make_shared<ov::Model>(NodeVector{DetectionOutput}, ParameterVector{loc, conf, priorBoxes});
}
}
@ -254,7 +261,7 @@ template <element::Type_t IN_ET>
std::vector<DetectionOutputParams> generateDetectionOutputFloatParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<DetectionOutputParams> detectionOutputParams {
std::vector<DetectionOutputParams> detectionOutputParams{
DetectionOutputParams(3,
-1,
-1,
@ -275,33 +282,87 @@ std::vector<DetectionOutputParams> generateDetectionOutputFloatParams() {
2,
true,
IN_ET,
std::vector<T>{
// batch 0, class 0
0.1, 0.1, 0.2, 0.2, 0.0, 0.1, 0.2, 0.15,
// batch 0, class 1
0.3, 0.2, 0.5, 0.3, 0.2, 0.1, 0.42, 0.66,
// batch 0, class 2
0.05, 0.1, 0.2, 0.3, 0.2, 0.1, 0.33, 0.44,
// batch 1, class 0
0.2, 0.1, 0.4, 0.2, 0.1, 0.05, 0.2, 0.25,
// batch 1, class 1
0.1, 0.2, 0.5, 0.3, 0.1, 0.1, 0.12, 0.34,
// batch 1, class 2
0.25, 0.11, 0.4, 0.32, 0.2, 0.12, 0.38, 0.24},
std::vector<T>{
// batch 0
0.1, 0.9, 0.4, 0.7, 0, 0.2,
// batch 1
0.7, 0.8, 0.42, 0.33, 0.81, 0.2},
std::vector<T>{
// prior box 0
0.0, 0.5, 0.1, 0.2,
// prior box 1
0.0, 0.3, 0.1, 0.35},
std::vector<T>{
0, 0, 0.7, 0.2, 0.4, 0.52, 1, 0, 1, 0.9, 0, 0.6, 0.3, 0.35,
1, 1, 0.81, 0.25, 0.41, 0.5, 0.67, 1, 1, 0.8, 0.1, 0.55, 0.3, 0.45},
"3_inputs"),
std::vector<T>{// batch 0, class 0
0.1,
0.1,
0.2,
0.2,
0.0,
0.1,
0.2,
0.15,
// batch 0, class 1
0.3,
0.2,
0.5,
0.3,
0.2,
0.1,
0.42,
0.66,
// batch 0, class 2
0.05,
0.1,
0.2,
0.3,
0.2,
0.1,
0.33,
0.44,
// batch 1, class 0
0.2,
0.1,
0.4,
0.2,
0.1,
0.05,
0.2,
0.25,
// batch 1, class 1
0.1,
0.2,
0.5,
0.3,
0.1,
0.1,
0.12,
0.34,
// batch 1, class 2
0.25,
0.11,
0.4,
0.32,
0.2,
0.12,
0.38,
0.24},
std::vector<T>{// batch 0
0.1,
0.9,
0.4,
0.7,
0,
0.2,
// batch 1
0.7,
0.8,
0.42,
0.33,
0.81,
0.2},
std::vector<T>{// prior box 0
0.0,
0.5,
0.1,
0.2,
// prior box 1
0.0,
0.3,
0.1,
0.35},
std::vector<T>{0, 0, 0.7, 0.2, 0.4, 0.52, 1, 0, 1, 0.9, 0, 0.6, 0.3, 0.35,
1, 1, 0.81, 0.25, 0.41, 0.5, 0.67, 1, 1, 0.8, 0.1, 0.55, 0.3, 0.45},
"3_inputs"),
DetectionOutputParams(3,
-1,
-1,
@ -322,25 +383,59 @@ std::vector<DetectionOutputParams> generateDetectionOutputFloatParams() {
2,
false,
IN_ET,
std::vector<T>{
// batch 0
0.1, 0.1, 0.2, 0.2, 0.0, 0.1, 0.2, 0.15,
// batch 1
0.2, 0.1, 0.4, 0.2, 0.1, 0.05, 0.2, 0.25},
std::vector<T>{
// batch 0
0.1, 0.9, 0.4, 0.7, 0, 0.2,
// batch 1
0.7, 0.8, 0.42, 0.33, 0.81, 0.2},
std::vector<T>{
// batch 0
0.0, 0.5, 0.1, 0.2, 0.0, 0.3, 0.1, 0.35,
// batch 1
0.33, 0.2, 0.52, 0.37, 0.22, 0.1, 0.32, 0.36},
std::vector<T>{
0, 0, 0.7, 0, 0.4, 0.3, 0.5, 0, 1, 0.9, 0.1, 0.6, 0.3, 0.4,
1, 1, 0.81, 0.32, 0.15, 0.52, 0.61, 1, 1, 0.8, 0.53, 0.3, 0.92, 0.57},
"3_inputs_share_location"),
std::vector<T>{// batch 0
0.1,
0.1,
0.2,
0.2,
0.0,
0.1,
0.2,
0.15,
// batch 1
0.2,
0.1,
0.4,
0.2,
0.1,
0.05,
0.2,
0.25},
std::vector<T>{// batch 0
0.1,
0.9,
0.4,
0.7,
0,
0.2,
// batch 1
0.7,
0.8,
0.42,
0.33,
0.81,
0.2},
std::vector<T>{// batch 0
0.0,
0.5,
0.1,
0.2,
0.0,
0.3,
0.1,
0.35,
// batch 1
0.33,
0.2,
0.52,
0.37,
0.22,
0.1,
0.32,
0.36},
std::vector<T>{0, 0, 0.7, 0, 0.4, 0.3, 0.5, 0, 1, 0.9, 0.1, 0.6, 0.3, 0.4,
1, 1, 0.81, 0.32, 0.15, 0.52, 0.61, 1, 1, 0.8, 0.53, 0.3, 0.92, 0.57},
"3_inputs_share_location"),
DetectionOutputParams(3,
-1,
-1,
@ -361,86 +456,210 @@ std::vector<DetectionOutputParams> generateDetectionOutputFloatParams() {
2,
false,
IN_ET,
std::vector<T>{
// batch 0
0.1, 0.1, 0.2, 0.2, 0.0, 0.1, 0.2, 0.15,
// batch 1
0.2, 0.1, 0.4, 0.2, 0.1, 0.05, 0.2, 0.25},
std::vector<T>{
// batch 0
0.1, 0.9, 0.4, 0.7, 0, 0.2,
// batch 1
0.7, 0.8, 0.42, 0.33, 0.81, 0.2},
std::vector<T>{
// batch 0
0.0, 0.5, 0.1, 0.2, 0.0, 0.3, 0.1, 0.35,
// batch 1
0.33, 0.2, 0.52, 0.37, 0.22, 0.1, 0.32, 0.36},
std::vector<T>{
0, 0, 0.7, 0, 0.4, 0.3, 0.5, 0, 1, 0.9, 0.1, 0.6, 0.3, 0.4,
1, 1, 0.81, 0.32, 0.15, 0.52, 0.61, 1, 1, 0.8, 0.53, 0.3, 0.92, 0.57},
"3_inputs_normalized"),
DetectionOutputParams(2,
-1,
-1,
false,
{-1},
"caffe.PriorBoxParameter.CORNER",
false,
0.5,
0.3,
false,
true,
false,
true,
0,
0,
0,
2,
3,
false,
IN_ET,
std::vector<T>{
// batch 0, class 0
0.1, 0.1, 0.2, 0.2, 0.0, 0.1, 0.2, 0.15,
// batch 0, class 1
0.3, 0.2, 0.5, 0.3, 0.2, 0.1, 0.42, 0.66,
// batch 1, class 0
0.05, 0.1, 0.2, 0.3, 0.2, 0.1, 0.33, 0.44,
// batch 1, class 1
0.2, 0.1, 0.4, 0.2, 0.1, 0.05, 0.2, 0.25,
// batch 2, class 0
0.1, 0.2, 0.5, 0.3, 0.1, 0.1, 0.12, 0.34,
// batch 2, class 1
0.25, 0.11, 0.4, 0.32, 0.2, 0.12, 0.38, 0.24},
std::vector<T>{
// batch 0
0.1, 0.9, 0.4, 0.7,
// batch 1
0.7, 0.8, 0.42, 0.33,
// batch 1
0.1, 0.2, 0.32, 0.43},
std::vector<T>{
// batch 0 priors
0.0, 0.5, 0.1, 0.2, 0.0, 0.3, 0.1, 0.35,
// batch 0 variances
0.12, 0.11, 0.32, 0.02, 0.02, 0.20, 0.09, 0.71,
// batch 1 priors
0.33, 0.2, 0.52, 0.37, 0.22, 0.1, 0.32, 0.36,
// batch 1 variances
0.01, 0.07, 0.12, 0.13, 0.41, 0.33, 0.2, 0.1,
// batch 2 priors
0.0, 0.3, 0.1, 0.35, 0.22, 0.1, 0.32, 0.36,
// batch 2 variances
0.32, 0.02, 0.13, 0.41, 0.33, 0.2, 0.02, 0.20},
std::vector<T>{
0, 0, 0.4, 0.006, 0.34, 0.145, 0.563, 0, 1, 0.9, 0, 0.511, 0.164, 0.203,
0, 1, 0.7, 0.004, 0.32, 0.1378, 0.8186, 1, 0, 0.7, 0.3305, 0.207, 0.544, 0.409,
1, 0, 0.42, 0.302, 0.133, 0.4, 0.38, 1, 1, 0.8, 0.332, 0.207, 0.5596, 0.4272,
1, 1, 0.33, 0.261, 0.1165, 0.36, 0.385, 2, 0, 0.32, 0.3025, 0.122, 0.328, 0.424,
2, 1, 0.43, 0.286, 0.124, 0.3276, 0.408, -1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
"3_inputs_keep_all_bboxes"),
std::vector<T>{// batch 0
0.1,
0.1,
0.2,
0.2,
0.0,
0.1,
0.2,
0.15,
// batch 1
0.2,
0.1,
0.4,
0.2,
0.1,
0.05,
0.2,
0.25},
std::vector<T>{// batch 0
0.1,
0.9,
0.4,
0.7,
0,
0.2,
// batch 1
0.7,
0.8,
0.42,
0.33,
0.81,
0.2},
std::vector<T>{// batch 0
0.0,
0.5,
0.1,
0.2,
0.0,
0.3,
0.1,
0.35,
// batch 1
0.33,
0.2,
0.52,
0.37,
0.22,
0.1,
0.32,
0.36},
std::vector<T>{0, 0, 0.7, 0, 0.4, 0.3, 0.5, 0, 1, 0.9, 0.1, 0.6, 0.3, 0.4,
1, 1, 0.81, 0.32, 0.15, 0.52, 0.61, 1, 1, 0.8, 0.53, 0.3, 0.92, 0.57},
"3_inputs_normalized"),
DetectionOutputParams(
2,
-1,
-1,
false,
{-1},
"caffe.PriorBoxParameter.CORNER",
false,
0.5,
0.3,
false,
true,
false,
true,
0,
0,
0,
2,
3,
false,
IN_ET,
std::vector<T>{// batch 0, class 0
0.1,
0.1,
0.2,
0.2,
0.0,
0.1,
0.2,
0.15,
// batch 0, class 1
0.3,
0.2,
0.5,
0.3,
0.2,
0.1,
0.42,
0.66,
// batch 1, class 0
0.05,
0.1,
0.2,
0.3,
0.2,
0.1,
0.33,
0.44,
// batch 1, class 1
0.2,
0.1,
0.4,
0.2,
0.1,
0.05,
0.2,
0.25,
// batch 2, class 0
0.1,
0.2,
0.5,
0.3,
0.1,
0.1,
0.12,
0.34,
// batch 2, class 1
0.25,
0.11,
0.4,
0.32,
0.2,
0.12,
0.38,
0.24},
std::vector<T>{// batch 0
0.1,
0.9,
0.4,
0.7,
// batch 1
0.7,
0.8,
0.42,
0.33,
// batch 1
0.1,
0.2,
0.32,
0.43},
std::vector<T>{// batch 0 priors
0.0,
0.5,
0.1,
0.2,
0.0,
0.3,
0.1,
0.35,
// batch 0 variances
0.12,
0.11,
0.32,
0.02,
0.02,
0.20,
0.09,
0.71,
// batch 1 priors
0.33,
0.2,
0.52,
0.37,
0.22,
0.1,
0.32,
0.36,
// batch 1 variances
0.01,
0.07,
0.12,
0.13,
0.41,
0.33,
0.2,
0.1,
// batch 2 priors
0.0,
0.3,
0.1,
0.35,
0.22,
0.1,
0.32,
0.36,
// batch 2 variances
0.32,
0.02,
0.13,
0.41,
0.33,
0.2,
0.02,
0.20},
std::vector<T>{0, 0, 0.4, 0.006, 0.34, 0.145, 0.563, 0, 1, 0.9, 0, 0.511, 0.164, 0.203,
0, 1, 0.7, 0.004, 0.32, 0.1378, 0.8186, 1, 0, 0.7, 0.3305, 0.207, 0.544, 0.409,
1, 0, 0.42, 0.302, 0.133, 0.4, 0.38, 1, 1, 0.8, 0.332, 0.207, 0.5596, 0.4272,
1, 1, 0.33, 0.261, 0.1165, 0.36, 0.385, 2, 0, 0.32, 0.3025, 0.122, 0.328, 0.424,
2, 1, 0.43, 0.286, 0.124, 0.3276, 0.408, -1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
"3_inputs_keep_all_bboxes"),
DetectionOutputParams(3,
-1,
-1,
@ -461,35 +680,97 @@ std::vector<DetectionOutputParams> generateDetectionOutputFloatParams() {
2,
false,
IN_ET,
std::vector<T>{
// batch 0, class 0
0.1, 0.1, 0.2, 0.2, 0.0, 0.1, 0.2, 0.15,
// batch 0, class 1
0.3, 0.2, 0.5, 0.3, 0.2, 0.1, 0.42, 0.66,
// batch 0, class 2
0.05, 0.1, 0.2, 0.3, 0.2, 0.1, 0.33, 0.44,
// batch 1, class 0
0.2, 0.1, 0.4, 0.2, 0.1, 0.05, 0.2, 0.25,
// batch 1, class 1
0.1, 0.2, 0.5, 0.3, 0.1, 0.1, 0.12, 0.34,
// batch 1, class 2
0.25, 0.11, 0.4, 0.32, 0.2, 0.12, 0.38, 0.24},
std::vector<T>{
// batch 0
0.1, 0.9, 0.4, 0.7, 0, 0.2,
// batch 1
0.7, 0.8, 0.42, 0.33, 0.81, 0.2},
std::vector<T>{
// batch 0
0.0, 0.5, 0.1, 0.2, 0.0, 0.3, 0.1, 0.35,
// batch 1
0.33, 0.2, 0.52, 0.37, 0.22, 0.1, 0.32, 0.36},
std::vector<T>{
0, 0, 0.7, 0, 0.28163019, 0.14609808, 0.37836978,
0, 1, 0.9, 0, 0.49427515, 0.11107014, 0.14572485,
1, 1, 0.81, 0.22040875, 0.079573378, 0.36959124, 0.4376266,
1, 1, 0.8, 0.32796675, 0.18435785, 0.56003326, 0.40264216},
"3_inputs_center_size"),
std::vector<T>{// batch 0, class 0
0.1,
0.1,
0.2,
0.2,
0.0,
0.1,
0.2,
0.15,
// batch 0, class 1
0.3,
0.2,
0.5,
0.3,
0.2,
0.1,
0.42,
0.66,
// batch 0, class 2
0.05,
0.1,
0.2,
0.3,
0.2,
0.1,
0.33,
0.44,
// batch 1, class 0
0.2,
0.1,
0.4,
0.2,
0.1,
0.05,
0.2,
0.25,
// batch 1, class 1
0.1,
0.2,
0.5,
0.3,
0.1,
0.1,
0.12,
0.34,
// batch 1, class 2
0.25,
0.11,
0.4,
0.32,
0.2,
0.12,
0.38,
0.24},
std::vector<T>{// batch 0
0.1,
0.9,
0.4,
0.7,
0,
0.2,
// batch 1
0.7,
0.8,
0.42,
0.33,
0.81,
0.2},
std::vector<T>{// batch 0
0.0,
0.5,
0.1,
0.2,
0.0,
0.3,
0.1,
0.35,
// batch 1
0.33,
0.2,
0.52,
0.37,
0.22,
0.1,
0.32,
0.36},
std::vector<T>{0, 0, 0.7, 0, 0.28163019, 0.14609808, 0.37836978,
0, 1, 0.9, 0, 0.49427515, 0.11107014, 0.14572485,
1, 1, 0.81, 0.22040875, 0.079573378, 0.36959124, 0.4376266,
1, 1, 0.8, 0.32796675, 0.18435785, 0.56003326, 0.40264216},
"3_inputs_center_size"),
DetectionOutputParams(2,
-1,
-1,
@ -510,54 +791,130 @@ std::vector<DetectionOutputParams> generateDetectionOutputFloatParams() {
2,
false,
IN_ET,
std::vector<T>{
// batch 0, class 0
0.1, 0.1, 0.2, 0.2, 0.0, 0.1, 0.2, 0.15,
// batch 0, class 1
0.3, 0.2, 0.5, 0.3, 0.2, 0.1, 0.42, 0.66,
// batch 1, class 0
0.2, 0.1, 0.4, 0.2, 0.1, 0.05, 0.2, 0.25,
// batch 1, class 1
0.1, 0.2, 0.5, 0.3, 0.1, 0.1, 0.12, 0.34},
std::vector<T>{
// batch 0
0.1, 0.9, 0.4, 0.7,
// batch 1
0.42, 0.33, 0.81, 0.2},
std::vector<T>{
// batch 0
0.0, 0.5, 0.1, 0.2, 0.0, 0.3, 0.1, 0.35,
// batch 1
0.33, 0.2, 0.52, 0.37, 0.22, 0.1, 0.32, 0.36},
std::vector<T>{
0, 0, 0.4, 0.55, 0.61, 1, 0.97, 0, 1, 0.7, 0.4, 0.52, 0.9, 1,
1, 0, 0.42, 0.83, 0.5, 1, 0.87, 1, 1, 0.33, 0.63, 0.35, 1, 1},
std::vector<T>{
// batch 0, class 0
0.1, 0.2, 0.5, 0.3, 0.1, 0.1, 0.12, 0.34,
// batch 0, class 1
0.25, 0.11, 0.4, 0.32, 0.2, 0.12, 0.38, 0.24,
// batch 1, class 0
0.3, 0.2, 0.5, 0.3, 0.2, 0.1, 0.42, 0.66,
// batch 1, class 1
0.05, 0.1, 0.2, 0.3, 0.2, 0.1, 0.33, 0.44},
std::vector<T>{
// batch 0
0.1, 0.3, 0.5, 0.8,
// batch 1
0.5, 0.8, 0.01, 0.1},
"5_inputs"),
std::vector<T>{// batch 0, class 0
0.1,
0.1,
0.2,
0.2,
0.0,
0.1,
0.2,
0.15,
// batch 0, class 1
0.3,
0.2,
0.5,
0.3,
0.2,
0.1,
0.42,
0.66,
// batch 1, class 0
0.2,
0.1,
0.4,
0.2,
0.1,
0.05,
0.2,
0.25,
// batch 1, class 1
0.1,
0.2,
0.5,
0.3,
0.1,
0.1,
0.12,
0.34},
std::vector<T>{// batch 0
0.1,
0.9,
0.4,
0.7,
// batch 1
0.42,
0.33,
0.81,
0.2},
std::vector<T>{// batch 0
0.0,
0.5,
0.1,
0.2,
0.0,
0.3,
0.1,
0.35,
// batch 1
0.33,
0.2,
0.52,
0.37,
0.22,
0.1,
0.32,
0.36},
std::vector<T>{0, 0, 0.4, 0.55, 0.61, 1, 0.97, 0, 1, 0.7, 0.4, 0.52, 0.9, 1,
1, 0, 0.42, 0.83, 0.5, 1, 0.87, 1, 1, 0.33, 0.63, 0.35, 1, 1},
std::vector<T>{// batch 0, class 0
0.1,
0.2,
0.5,
0.3,
0.1,
0.1,
0.12,
0.34,
// batch 0, class 1
0.25,
0.11,
0.4,
0.32,
0.2,
0.12,
0.38,
0.24,
// batch 1, class 0
0.3,
0.2,
0.5,
0.3,
0.2,
0.1,
0.42,
0.66,
// batch 1, class 1
0.05,
0.1,
0.2,
0.3,
0.2,
0.1,
0.33,
0.44},
std::vector<T>{// batch 0
0.1,
0.3,
0.5,
0.8,
// batch 1
0.5,
0.8,
0.01,
0.1},
"5_inputs"),
};
return detectionOutputParams;
}
std::vector<DetectionOutputParams> generateDetectionOutputCombinedParams() {
const std::vector<std::vector<DetectionOutputParams>> detectionOutputTypeParams {
const std::vector<std::vector<DetectionOutputParams>> detectionOutputTypeParams{
generateDetectionOutputFloatParams<element::Type_t::f64>(),
generateDetectionOutputFloatParams<element::Type_t::f32>(),
generateDetectionOutputFloatParams<element::Type_t::f16>(),
generateDetectionOutputFloatParams<element::Type_t::bf16>(),
};
};
std::vector<DetectionOutputParams> combinedParams;
for (const auto& params : detectionOutputTypeParams) {
@ -566,12 +923,14 @@ std::vector<DetectionOutputParams> generateDetectionOutputCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_DetectionOutput_With_Hardcoded_Refs, ReferenceDetectionOutputLayerTest,
testing::ValuesIn(generateDetectionOutputCombinedParams()), ReferenceDetectionOutputLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_DetectionOutput_With_Hardcoded_Refs,
ReferenceDetectionOutputLayerTest,
testing::ValuesIn(generateDetectionOutputCombinedParams()),
ReferenceDetectionOutputLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_DetectionOutput_With_Hardcoded_Refs,
ReferenceDetectionOutputV8LayerTest,
testing::ValuesIn(generateDetectionOutputCombinedParams()),
ReferenceDetectionOutputV8LayerTest::getTestCaseName);
} // namespace
} // namespace

View File

@ -2,11 +2,12 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/dft.hpp"
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
#include "openvino/op/constant.hpp"
#include "openvino/op/dft.hpp"
using namespace reference_tests;
using namespace ov;
@ -16,13 +17,13 @@ namespace {
struct DFTParams {
template <class T>
DFTParams(const Shape& input_shape,
const Shape& expected_shape,
const element::Type_t& input_type,
const element::Type_t& expected_type,
const std::vector<T>& input_value,
const std::vector<T>& expected_value,
const std::shared_ptr<op::v0::Constant>& axes,
const std::shared_ptr<op::v0::Constant>& signal) {
const Shape& expected_shape,
const element::Type_t& input_type,
const element::Type_t& expected_type,
const std::vector<T>& input_value,
const std::vector<T>& expected_value,
const std::shared_ptr<op::v0::Constant>& axes,
const std::shared_ptr<op::v0::Constant>& signal) {
m_input_shape = input_shape;
m_expected_shape = expected_shape;
m_input_type = input_type;
@ -1118,7 +1119,7 @@ static const std::vector<float> expected_dft3d_signal_size_results = {
1.1392056, -4.696983, 0.45275614, 1.9134089, -3.8572056, -2.009159, 1.6307822, -0.9646755,
-1.2407924, 2.6003554};
template<class T>
template <class T>
static std::vector<T> convert(const std::vector<float>& v) {
if (v.empty()) {
return std::vector<T>();
@ -1402,10 +1403,9 @@ std::vector<DFTParams> generateCombinedParamsForDFT() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(
smoke_DFT_With_Hardcoded_Refs,
ReferenceDFTLayerTest,
::testing::ValuesIn(generateCombinedParamsForDFT()),
ReferenceDFTLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_DFT_With_Hardcoded_Refs,
ReferenceDFTLayerTest,
::testing::ValuesIn(generateCombinedParamsForDFT()),
ReferenceDFTLayerTest::getTestCaseName);
} // namespace

View File

@ -2,10 +2,12 @@
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
#include "openvino/op/divide.hpp"
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
using namespace ov;
using namespace reference_tests;
@ -14,11 +16,11 @@ namespace {
struct DivideParams {
template <class IT>
DivideParams(const PartialShape& iShape1,
const PartialShape& iShape2,
const element::Type& iType,
const std::vector<IT>& iValues1,
const std::vector<IT>& iValues2,
const std::vector<IT>& oValues)
const PartialShape& iShape2,
const element::Type& iType,
const std::vector<IT>& iValues1,
const std::vector<IT>& iValues2,
const std::vector<IT>& oValues)
: pshape1(iShape1),
pshape2(iShape2),
inType(iType),
@ -45,7 +47,8 @@ struct DivideRoundingParams : public DivideParams {
const std::vector<IT>& iValues2,
const std::vector<IT>& oValues,
const bool pythondiv)
: DivideParams(iShape1, iShape2, iType, iValues1, iValues2, oValues), pythonDivision(pythondiv) {}
: DivideParams(iShape1, iShape2, iType, iValues1, iValues2, oValues),
pythonDivision(pythondiv) {}
bool pythonDivision;
};
@ -71,9 +74,9 @@ public:
private:
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape1,
const PartialShape& input_shape2,
const element::Type& input_type,
const element::Type& expected_output_type) {
const PartialShape& input_shape2,
const element::Type& input_type,
const element::Type& expected_output_type) {
const auto in1 = std::make_shared<op::v0::Parameter>(input_type, input_shape1);
const auto in2 = std::make_shared<op::v0::Parameter>(input_type, input_shape2);
const auto divide = std::make_shared<op::v1::Divide>(in1, in2);
@ -81,7 +84,8 @@ private:
}
};
class ReferenceDivideRoundingLayerTest : public testing::TestWithParam<DivideRoundingParams>, public CommonReferenceTest {
class ReferenceDivideRoundingLayerTest : public testing::TestWithParam<DivideRoundingParams>,
public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
@ -102,14 +106,14 @@ public:
private:
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape1,
const PartialShape& input_shape2,
const element::Type& input_type,
const element::Type& expected_output_type,
const bool pythondiv) {
const PartialShape& input_shape2,
const element::Type& input_type,
const element::Type& expected_output_type,
const bool pythondiv) {
const auto in1 = std::make_shared<op::v0::Parameter>(input_type, input_shape1);
const auto in2 = std::make_shared<op::v0::Parameter>(input_type, input_shape2);
const auto divide = std::make_shared<op::v1::Divide>(in1, in2, pythondiv);
return std::make_shared<Model>(NodeVector{divide}, ParameterVector{in1, in2});
return std::make_shared<Model>(NodeVector{divide}, ParameterVector{in1, in2});
}
};
@ -125,14 +129,12 @@ template <element::Type_t IN_ET>
std::vector<DivideParams> generateParamsForDivide() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<DivideParams> params{
DivideParams(ov::PartialShape{2, 2},
ov::PartialShape{2, 2},
IN_ET,
std::vector<T>{2, 4, 8, 16},
std::vector<T>{1, 2, 4, 8},
std::vector<T>{2, 2, 2, 2})
};
std::vector<DivideParams> params{DivideParams(ov::PartialShape{2, 2},
ov::PartialShape{2, 2},
IN_ET,
std::vector<T>{2, 4, 8, 16},
std::vector<T>{1, 2, 4, 8},
std::vector<T>{2, 2, 2, 2})};
return params;
}
@ -140,23 +142,21 @@ template <element::Type_t IN_ET>
std::vector<DivideParams> generateParamsForDivideFloat32() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<DivideParams> params{
DivideParams(ov::PartialShape{1},
ov::PartialShape{1},
IN_ET,
std::vector<T>{18},
std::vector<T>{8},
std::vector<T>{2.25}),
DivideParams(ov::PartialShape{2, 2},
ov::PartialShape{2, 2},
IN_ET,
std::vector<T>{2, 4, 8, 16},
std::vector<T>{0, 0, 0, 0},
std::vector<T>{std::numeric_limits<float>::infinity(),
std::numeric_limits<float>::infinity(),
std::numeric_limits<float>::infinity(),
std::numeric_limits<float>::infinity()})
};
std::vector<DivideParams> params{DivideParams(ov::PartialShape{1},
ov::PartialShape{1},
IN_ET,
std::vector<T>{18},
std::vector<T>{8},
std::vector<T>{2.25}),
DivideParams(ov::PartialShape{2, 2},
ov::PartialShape{2, 2},
IN_ET,
std::vector<T>{2, 4, 8, 16},
std::vector<T>{0, 0, 0, 0},
std::vector<T>{std::numeric_limits<float>::infinity(),
std::numeric_limits<float>::infinity(),
std::numeric_limits<float>::infinity(),
std::numeric_limits<float>::infinity()})};
return params;
}
@ -164,20 +164,18 @@ template <element::Type_t IN_ET>
std::vector<DivideParams> generateParamsForDivideInt32() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<DivideParams> params{
DivideParams(ov::PartialShape{2, 2},
ov::PartialShape{2, 2},
IN_ET,
std::vector<T>{0x40000140, 0x40000001, 8, 16},
std::vector<T>{2, 5, 4, 8},
std::vector<T>{536871072, 214748365, 2, 2}),
DivideParams(ov::PartialShape{1},
ov::PartialShape{1},
IN_ET,
std::vector<T>{18},
std::vector<T>{8},
std::vector<T>{2})
};
std::vector<DivideParams> params{DivideParams(ov::PartialShape{2, 2},
ov::PartialShape{2, 2},
IN_ET,
std::vector<T>{0x40000140, 0x40000001, 8, 16},
std::vector<T>{2, 5, 4, 8},
std::vector<T>{536871072, 214748365, 2, 2}),
DivideParams(ov::PartialShape{1},
ov::PartialShape{1},
IN_ET,
std::vector<T>{18},
std::vector<T>{8},
std::vector<T>{2})};
return params;
}
@ -191,13 +189,8 @@ std::vector<DivideParams> generateParamsForDivideBroadcast() {
IN_ET,
std::vector<T>{12, 24, 36, 48, 60, 72},
std::vector<T>{1, 2, 3, 4, 6, 1},
std::vector<T>{12, 6, 4, 3, 2, 12,
24, 12, 8, 6, 4, 24,
36, 18, 12, 9, 6, 36,
48, 24, 16, 12, 8, 48,
60, 30, 20, 15, 10, 60,
72, 36, 24, 18, 12, 72})
};
std::vector<T>{12, 6, 4, 3, 2, 12, 24, 12, 8, 6, 4, 24, 36, 18, 12, 9, 6, 36,
48, 24, 16, 12, 8, 48, 60, 30, 20, 15, 10, 60, 72, 36, 24, 18, 12, 72})};
return params;
}
@ -205,14 +198,12 @@ template <element::Type_t IN_ET>
std::vector<DivideParams> generateParamsForDividePythonRoundingInt32() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<DivideParams> params{
DivideParams(ov::PartialShape{2, 2},
ov::PartialShape{2, 2},
IN_ET,
std::vector<T>{-10, -10, 10, 10},
std::vector<T>{-3, 3, -3, 3},
std::vector<T>{3, -4, -4, 3})
};
std::vector<DivideParams> params{DivideParams(ov::PartialShape{2, 2},
ov::PartialShape{2, 2},
IN_ET,
std::vector<T>{-10, -10, 10, 10},
std::vector<T>{-3, 3, -3, 3},
std::vector<T>{3, -4, -4, 3})};
return params;
}
@ -220,28 +211,24 @@ template <element::Type_t IN_ET>
std::vector<DivideRoundingParams> generateParamsForDivideCppRoundingInt32() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<DivideRoundingParams> params{
DivideRoundingParams(ov::PartialShape{2, 2},
ov::PartialShape{2, 2},
IN_ET,
std::vector<T>{-10, -10, 10, 10},
std::vector<T>{-3, 3, -3, 3},
std::vector<T>{3, -3, -3, 3},
false)
};
std::vector<DivideRoundingParams> params{DivideRoundingParams(ov::PartialShape{2, 2},
ov::PartialShape{2, 2},
IN_ET,
std::vector<T>{-10, -10, 10, 10},
std::vector<T>{-3, 3, -3, 3},
std::vector<T>{3, -3, -3, 3},
false)};
return params;
}
std::vector<DivideParams> generateCombinedParamsForDivide() {
const std::vector<std::vector<DivideParams>> allTypeParams{
generateParamsForDivide<element::Type_t::f32>(),
generateParamsForDivide<element::Type_t::f16>(),
generateParamsForDivide<element::Type_t::bf16>(),
generateParamsForDivide<element::Type_t::i64>(),
generateParamsForDivide<element::Type_t::i32>(),
generateParamsForDivide<element::Type_t::u64>(),
generateParamsForDivide<element::Type_t::u32>()
};
const std::vector<std::vector<DivideParams>> allTypeParams{generateParamsForDivide<element::Type_t::f32>(),
generateParamsForDivide<element::Type_t::f16>(),
generateParamsForDivide<element::Type_t::bf16>(),
generateParamsForDivide<element::Type_t::i64>(),
generateParamsForDivide<element::Type_t::i32>(),
generateParamsForDivide<element::Type_t::u64>(),
generateParamsForDivide<element::Type_t::u32>()};
std::vector<DivideParams> combinedParams;
@ -253,9 +240,7 @@ std::vector<DivideParams> generateCombinedParamsForDivide() {
}
std::vector<DivideParams> generateCombinedParamsForDivideFloat32() {
const std::vector<std::vector<DivideParams>> allTypeParams{
generateParamsForDivideFloat32<element::Type_t::f32>()
};
const std::vector<std::vector<DivideParams>> allTypeParams{generateParamsForDivideFloat32<element::Type_t::f32>()};
std::vector<DivideParams> combinedParams;
@ -267,9 +252,7 @@ std::vector<DivideParams> generateCombinedParamsForDivideFloat32() {
}
std::vector<DivideParams> generateCombinedParamsForDivideInt32() {
const std::vector<std::vector<DivideParams>> allTypeParams{
generateParamsForDivideInt32<element::Type_t::i32>()
};
const std::vector<std::vector<DivideParams>> allTypeParams{generateParamsForDivideInt32<element::Type_t::i32>()};
std::vector<DivideParams> combinedParams;
@ -283,8 +266,7 @@ std::vector<DivideParams> generateCombinedParamsForDivideInt32() {
std::vector<DivideParams> generateCombinedParamsForDivideBroadcast() {
const std::vector<std::vector<DivideParams>> allTypeParams{
generateParamsForDivideBroadcast<element::Type_t::f32>(),
generateParamsForDivideBroadcast<element::Type_t::i32>()
};
generateParamsForDivideBroadcast<element::Type_t::i32>()};
std::vector<DivideParams> combinedParams;
@ -297,8 +279,7 @@ std::vector<DivideParams> generateCombinedParamsForDivideBroadcast() {
std::vector<DivideParams> generateCombinedParamsForDividePythonRoundingInt32() {
const std::vector<std::vector<DivideParams>> allTypeParams{
generateParamsForDividePythonRoundingInt32<element::Type_t::i32>()
};
generateParamsForDividePythonRoundingInt32<element::Type_t::i32>()};
std::vector<DivideParams> combinedParams;
@ -311,8 +292,7 @@ std::vector<DivideParams> generateCombinedParamsForDividePythonRoundingInt32() {
std::vector<DivideRoundingParams> generateCombinedParamsForDivideCppRoundingInt32() {
const std::vector<std::vector<DivideRoundingParams>> allTypeParams{
generateParamsForDivideCppRoundingInt32<element::Type_t::i32>()
};
generateParamsForDivideCppRoundingInt32<element::Type_t::i32>()};
std::vector<DivideRoundingParams> combinedParams;
@ -323,40 +303,34 @@ std::vector<DivideRoundingParams> generateCombinedParamsForDivideCppRoundingInt3
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(
smoke_Divide_With_Hardcoded_Refs,
ReferenceDivideLayerTest,
::testing::ValuesIn(generateCombinedParamsForDivide()),
ReferenceDivideLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Divide_With_Hardcoded_Refs,
ReferenceDivideLayerTest,
::testing::ValuesIn(generateCombinedParamsForDivide()),
ReferenceDivideLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(
smoke_Divide_Float32_With_Hardcoded_Refs,
ReferenceDivideLayerTest,
::testing::ValuesIn(generateCombinedParamsForDivideFloat32()),
ReferenceDivideLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Divide_Float32_With_Hardcoded_Refs,
ReferenceDivideLayerTest,
::testing::ValuesIn(generateCombinedParamsForDivideFloat32()),
ReferenceDivideLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(
smoke_Divide_Int32_With_Hardcoded_Refs,
ReferenceDivideLayerTest,
::testing::ValuesIn(generateCombinedParamsForDivideInt32()),
ReferenceDivideLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Divide_Int32_With_Hardcoded_Refs,
ReferenceDivideLayerTest,
::testing::ValuesIn(generateCombinedParamsForDivideInt32()),
ReferenceDivideLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(
smoke_Divide_Broadcast_With_Hardcoded_Refs,
ReferenceDivideLayerTest,
::testing::ValuesIn(generateCombinedParamsForDivideBroadcast()),
ReferenceDivideLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Divide_Broadcast_With_Hardcoded_Refs,
ReferenceDivideLayerTest,
::testing::ValuesIn(generateCombinedParamsForDivideBroadcast()),
ReferenceDivideLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(
smoke_Divide_Python_Rounding_Int32_With_Hardcoded_Refs,
ReferenceDivideLayerTest,
::testing::ValuesIn(generateCombinedParamsForDividePythonRoundingInt32()),
ReferenceDivideLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Divide_Python_Rounding_Int32_With_Hardcoded_Refs,
ReferenceDivideLayerTest,
::testing::ValuesIn(generateCombinedParamsForDividePythonRoundingInt32()),
ReferenceDivideLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(
smoke_Divide_Cpp_Rounding_Int32_With_Hardcoded_Refs,
ReferenceDivideRoundingLayerTest,
::testing::ValuesIn(generateCombinedParamsForDivideCppRoundingInt32()),
ReferenceDivideRoundingLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Divide_Cpp_Rounding_Int32_With_Hardcoded_Refs,
ReferenceDivideRoundingLayerTest,
::testing::ValuesIn(generateCombinedParamsForDivideCppRoundingInt32()),
ReferenceDivideRoundingLayerTest::getTestCaseName);
} // namespace

View File

@ -4,9 +4,9 @@
#include <gtest/gtest.h>
#include "openvino/opsets/opset7.hpp"
#include "openvino/opsets/opset1.hpp"
#include "base_reference_test.hpp"
#include "openvino/opsets/opset1.hpp"
#include "openvino/opsets/opset7.hpp"
using namespace reference_tests;
using namespace ov;
@ -73,37 +73,33 @@ TEST_P(ReferenceEinsumTest, CompareWithRefs) {
template <element::Type_t ET>
std::vector<EinsumParams> generateParams() {
using T = typename element_type_traits<ET>::value_type;
std::vector<EinsumParams> params {
Builder {}
std::vector<EinsumParams> params{
Builder{}
.inputs({{ET, {1, 2}, std::vector<T>{1, 2}},
{ET, {3, 4}, std::vector<T>{3, 4, 5, 6,
7, 8, 9, 10,
11, 12, 13, 14}}})
{ET, {3, 4}, std::vector<T>{3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}}})
.equation("ab,cd->abcd")
.expectedResult({ET, {1, 2, 3, 4}, std::vector<T>{3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 6, 8, 10, 12,
14, 16, 18, 20, 22, 24, 26, 28}})
.expectedResult({ET, {1, 2, 3, 4}, std::vector<T>{3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28}})
.testcaseName("einsum_no_reduction"),
Builder {}
Builder{}
.inputs({{ET, {1, 2, 3}, std::vector<T>{1, 2, 3, 4, 5, 6}}})
.equation("ijk->kij")
.expectedResult({ET, {3, 1, 2}, std::vector<T>{1, 4, 2, 5, 3, 6}})
.testcaseName("einsum_transpose"),
Builder {}
Builder{}
.inputs({{ET, {2, 3}, std::vector<T>{1, 2, 3, 4, 5, 6}}})
.equation("ab->a")
.expectedResult({ET, {2}, std::vector<T>{6, 15}})
.testcaseName("einsum_reduce"),
Builder {}
.inputs({{ET, {2, 3}, std::vector<T>{1, 2, 3, 4, 5, 6}},
{ET, {3, 2}, std::vector<T>{1, 2, 3, 4, 5, 6}}})
Builder{}
.inputs({{ET, {2, 3}, std::vector<T>{1, 2, 3, 4, 5, 6}}, {ET, {3, 2}, std::vector<T>{1, 2, 3, 4, 5, 6}}})
.equation("ab,bc->ac")
.expectedResult({ET, {2, 2}, std::vector<T>{22, 28, 49, 64}})
.testcaseName("einsum_matrix_multiplication"),
Builder {}
Builder{}
.inputs({{ET, {2, 4}, std::vector<T>{1, 3, 2, 7, 5, 6, 0, 1}},
{ET, {4, 3, 1}, std::vector<T>{1, 2, 3, 4, 5, 6, 5, 7, 3, 7, 9, 1}},
{ET, {4, 3}, std::vector<T>{4, 3, 1, 6, 4, 2, 2, 5, 3, 1, 9, 4}}})
@ -111,50 +107,47 @@ std::vector<EinsumParams> generateParams() {
.expectedResult({ET, {3, 2}, std::vector<T>{145, 171, 703, 231, 85, 91}})
.testcaseName("einsum_multiple_multiplication"),
Builder {}
Builder{}
.inputs({{ET, {2, 2, 3}, std::vector<T>{1, 3, 2, 7, 5, 6, 3, 5, 2, 1, 0, 7}}})
.equation("a...->...")
.expectedResult({ET, {2, 3}, std::vector<T>{4, 8, 4, 8, 5, 13}})
.testcaseName("einsum_ellipsis_one_input_reduction"),
Builder {}
Builder{}
.inputs({{ET, {2, 2, 3}, std::vector<T>{1, 3, 2, 7, 5, 6, 3, 5, 2, 1, 0, 7}}})
.equation("a...->...a")
.expectedResult({ET, {2, 3, 2}, std::vector<T>{1, 3, 3, 5, 2, 2, 7, 1, 5, 0, 6, 7}})
.testcaseName("einsum_ellipsis_one_input_transpose"),
Builder {}
.inputs({{ET, {2, 2, 3}, std::vector<T>{1, 3, 2, 7, 5, 6, 3, 5, 2, 1, 0, 7}},
{ET, {1}, std::vector<T>{2}}})
Builder{}
.inputs({{ET, {2, 2, 3}, std::vector<T>{1, 3, 2, 7, 5, 6, 3, 5, 2, 1, 0, 7}}, {ET, {1}, std::vector<T>{2}}})
.equation("ab...,...->ab...")
.expectedResult({ET, {2, 2, 3}, std::vector<T>{2, 6, 4, 14, 10, 12, 6, 10, 4, 2, 0, 14}})
.testcaseName("einsum_ellipsis_mul_by_1dscalar"),
Builder {}
Builder{}
.inputs({{ET, {1, 1, 4, 3}, std::vector<T>{1, 3, 2, 7, 5, 6, 3, 5, 2, 1, 0, 7}},
{ET, {3, 4, 2, 1}, std::vector<T>{3, 1, 6, 2, 3, 10, 9, 8, 2, 9, 3, 2,
4, 2, 3, 1, 9, 1, 11, 4, 7, 2, 3, 1}}})
.equation("a...j,j...->a...")
.expectedResult({ET, {1, 4, 2, 4}, std::vector<T>{27, 85, 37, 66, 30, 58, 50, 8,
37, 123, 55, 83, 16, 48, 24, 30,
29, 83, 43, 52, 20, 92, 44, 24,
24, 96, 48, 30, 13, 67, 31, 15}})
.expectedResult(
{ET, {1, 4, 2, 4}, std::vector<T>{27, 85, 37, 66, 30, 58, 50, 8, 37, 123, 55, 83, 16, 48, 24, 30,
29, 83, 43, 52, 20, 92, 44, 24, 24, 96, 48, 30, 13, 67, 31, 15}})
.testcaseName("einsum_ellipsis_complex_mul"),
Builder {}
Builder{}
.inputs({{ET, {1, 3, 3}, std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9}}})
.equation("kii->ki")
.expectedResult({ET, {1, 3}, std::vector<T>{1, 5, 9}})
.testcaseName("einsum_diagonal"),
Builder {}
.inputs({{ET, {2, 3, 3, 2, 4}, std::vector<T>{4, 2, 5, 4, 5, 5, 1, 1, 3, 3, 1, 1, 2, 2, 4, 1, 3, 4,
4, 5, 1, 3, 1, 3, 1, 4, 3, 5, 4, 4, 5, 4, 4, 5, 4, 2,
2, 2, 3, 3, 1, 1, 4, 3, 4, 2, 2, 1, 1, 2, 3, 1, 1, 4,
2, 3, 1, 3, 4, 2, 5, 5, 3, 4, 3, 4, 5, 4, 4, 5, 1, 3,
4, 4, 5, 3, 1, 3, 2, 5, 3, 2, 5, 4, 4, 2, 4, 4, 1, 4,
4, 5, 4, 4, 4, 2, 3, 3, 4, 2, 4, 2, 5, 1, 3, 2, 4, 3,
5, 1, 2, 3, 1, 1, 2, 5, 1, 1, 2, 1, 4, 5, 3, 4, 1, 3,
Builder{}
.inputs({{ET, {2, 3, 3, 2, 4}, std::vector<T>{4, 2, 5, 4, 5, 5, 1, 1, 3, 3, 1, 1, 2, 2, 4, 1, 3, 4, 4, 5, 1,
3, 1, 3, 1, 4, 3, 5, 4, 4, 5, 4, 4, 5, 4, 2, 2, 2, 3, 3, 1, 1,
4, 3, 4, 2, 2, 1, 1, 2, 3, 1, 1, 4, 2, 3, 1, 3, 4, 2, 5, 5, 3,
4, 3, 4, 5, 4, 4, 5, 1, 3, 4, 4, 5, 3, 1, 3, 2, 5, 3, 2, 5, 4,
4, 2, 4, 4, 1, 4, 4, 5, 4, 4, 4, 2, 3, 3, 4, 2, 4, 2, 5, 1, 3,
2, 4, 3, 5, 1, 2, 3, 1, 1, 2, 5, 1, 1, 2, 1, 4, 5, 3, 4, 1, 3,
3, 1, 3, 2, 4, 5, 1, 1, 5, 4, 5, 2, 2, 3, 3, 1, 2, 4}},
{ET, {3, 2, 1}, std::vector<T>{1, 4, 4, 5, 3, 3}}})
.equation("abbac,bad->ad")
@ -165,7 +158,7 @@ std::vector<EinsumParams> generateParams() {
}
std::vector<EinsumParams> generateCombinedParams() {
const std::vector<std::vector<EinsumParams>> generatedParams {
const std::vector<std::vector<EinsumParams>> generatedParams{
generateParams<element::Type_t::i32>(),
generateParams<element::Type_t::f32>(),
};
@ -177,6 +170,8 @@ std::vector<EinsumParams> generateCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_Einsum_With_Hardcoded_Refs, ReferenceEinsumTest,
testing::ValuesIn(generateCombinedParams()), ReferenceEinsumTest::getTestCaseName);
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_Einsum_With_Hardcoded_Refs,
ReferenceEinsumTest,
testing::ValuesIn(generateCombinedParams()),
ReferenceEinsumTest::getTestCaseName);
} // namespace

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/elu.hpp"
#include <gtest/gtest.h>
#include "openvino/op/elu.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
@ -13,8 +14,11 @@ using namespace ov;
namespace {
struct EluParams {
template <class IT>
EluParams(const ov::PartialShape& shape, const ov::element::Type& iType, const std::vector<IT>& iValues, const std::vector<IT>& oValues,
const double alpha)
EluParams(const ov::PartialShape& shape,
const ov::element::Type& iType,
const std::vector<IT>& iValues,
const std::vector<IT>& oValues,
const double alpha)
: alpha(alpha),
pshape(shape),
inType(iType),
@ -50,11 +54,13 @@ public:
}
private:
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape, const element::Type& input_type,
const element::Type& expected_output_type, const double alpha) {
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape,
const element::Type& input_type,
const element::Type& expected_output_type,
const double alpha) {
const auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
const auto Elu = std::make_shared<op::v0::Elu>(in, alpha);
return std::make_shared<ov::Model>(NodeVector {Elu}, ParameterVector {in});
return std::make_shared<ov::Model>(NodeVector{Elu}, ParameterVector{in});
}
};
@ -66,18 +72,17 @@ template <element::Type_t IN_ET>
std::vector<EluParams> generateEluFloatParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<EluParams> eluParams {
EluParams(ov::PartialShape {3, 2},
IN_ET,
std::vector<T>{-2.f, 3.f, -2.f, 1.f, -1.f, 0.f},
std::vector<T>{-0.432332358f, 3.f, -0.432332358f, 1.f, -0.316060279f, 0.f},
0.5f),
EluParams(ov::PartialShape {3, 2},
IN_ET,
std::vector<T>{-2.f, 3.f, -2.f, 1.f, -1.f, 0.f},
std::vector<T>{0.864664717f, 3.f, 0.864664717f, 1.f, 0.632120559f, 0.f},
-1.f)
};
std::vector<EluParams> eluParams{
EluParams(ov::PartialShape{3, 2},
IN_ET,
std::vector<T>{-2.f, 3.f, -2.f, 1.f, -1.f, 0.f},
std::vector<T>{-0.432332358f, 3.f, -0.432332358f, 1.f, -0.316060279f, 0.f},
0.5f),
EluParams(ov::PartialShape{3, 2},
IN_ET,
std::vector<T>{-2.f, 3.f, -2.f, 1.f, -1.f, 0.f},
std::vector<T>{0.864664717f, 3.f, 0.864664717f, 1.f, 0.632120559f, 0.f},
-1.f)};
return eluParams;
}
@ -85,18 +90,16 @@ template <element::Type_t IN_ET>
std::vector<EluParams> generateEluIntParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<EluParams> eluParams {
EluParams(ov::PartialShape {3, 2},
IN_ET,
std::vector<T>{-2, 3, -2, 1, -1, 0},
std::vector<T>{0, 3, 0, 1, 0, 0},
0.5f),
EluParams(ov::PartialShape {3, 2},
IN_ET,
std::vector<T>{-2, 3, -2, 1, -1, 0},
std::vector<T>{0, 3, 0, 1, 0, 0},
-1.f)
};
std::vector<EluParams> eluParams{EluParams(ov::PartialShape{3, 2},
IN_ET,
std::vector<T>{-2, 3, -2, 1, -1, 0},
std::vector<T>{0, 3, 0, 1, 0, 0},
0.5f),
EluParams(ov::PartialShape{3, 2},
IN_ET,
std::vector<T>{-2, 3, -2, 1, -1, 0},
std::vector<T>{0, 3, 0, 1, 0, 0},
-1.f)};
return eluParams;
}
@ -104,34 +107,30 @@ template <element::Type_t IN_ET>
std::vector<EluParams> generateEluUintParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<EluParams> eluParams {
EluParams(ov::PartialShape {3, 2},
IN_ET,
std::vector<T>{5, 4, 3, 2, 1, 0},
std::vector<T>{5, 4, 3, 2, 1, 0},
0.5f),
EluParams(ov::PartialShape {3, 2},
IN_ET,
std::vector<T>{5, 4, 3, 2, 1, 0},
std::vector<T>{5, 4, 3, 2, 1, 0},
-1.f)
};
std::vector<EluParams> eluParams{EluParams(ov::PartialShape{3, 2},
IN_ET,
std::vector<T>{5, 4, 3, 2, 1, 0},
std::vector<T>{5, 4, 3, 2, 1, 0},
0.5f),
EluParams(ov::PartialShape{3, 2},
IN_ET,
std::vector<T>{5, 4, 3, 2, 1, 0},
std::vector<T>{5, 4, 3, 2, 1, 0},
-1.f)};
return eluParams;
}
std::vector<EluParams> generateEluCombinedParams() {
const std::vector<std::vector<EluParams>> eluTypeParams {
generateEluFloatParams<element::Type_t::f32>(),
generateEluFloatParams<element::Type_t::f16>(),
generateEluFloatParams<element::Type_t::bf16>(),
generateEluIntParams<element::Type_t::i8>(),
generateEluIntParams<element::Type_t::i16>(),
generateEluIntParams<element::Type_t::i32>(),
generateEluIntParams<element::Type_t::i64>(),
generateEluUintParams<element::Type_t::u8>(),
generateEluUintParams<element::Type_t::u16>(),
generateEluUintParams<element::Type_t::u32>(),
generateEluUintParams<element::Type_t::u64>()
};
const std::vector<std::vector<EluParams>> eluTypeParams{generateEluFloatParams<element::Type_t::f32>(),
generateEluFloatParams<element::Type_t::f16>(),
generateEluFloatParams<element::Type_t::bf16>(),
generateEluIntParams<element::Type_t::i8>(),
generateEluIntParams<element::Type_t::i16>(),
generateEluIntParams<element::Type_t::i32>(),
generateEluIntParams<element::Type_t::i64>(),
generateEluUintParams<element::Type_t::u8>(),
generateEluUintParams<element::Type_t::u16>(),
generateEluUintParams<element::Type_t::u32>(),
generateEluUintParams<element::Type_t::u64>()};
std::vector<EluParams> combinedParams;
for (const auto& params : eluTypeParams) {
@ -140,7 +139,9 @@ std::vector<EluParams> generateEluCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_Elu_With_Hardcoded_Refs, ReferenceEluLayerTest,
testing::ValuesIn(generateEluCombinedParams()), ReferenceEluLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Elu_With_Hardcoded_Refs,
ReferenceEluLayerTest,
testing::ValuesIn(generateEluCombinedParams()),
ReferenceEluLayerTest::getTestCaseName);
} // namespace
} // namespace

View File

@ -79,14 +79,13 @@ public:
}
private:
static std::shared_ptr<Model> CreateFunction(
const PartialShape& input_shape,
const element::Type& input_type,
const std::shared_ptr<ov::op::v0::Constant> indices,
const std::shared_ptr<ov::op::v0::Constant> segment_ids,
const std::shared_ptr<ov::op::v0::Constant> num_segments,
const std::shared_ptr<ov::op::v0::Constant> default_index,
const std::shared_ptr<ov::op::v0::Constant> per_sample_weights) {
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape,
const element::Type& input_type,
const std::shared_ptr<ov::op::v0::Constant> indices,
const std::shared_ptr<ov::op::v0::Constant> segment_ids,
const std::shared_ptr<ov::op::v0::Constant> num_segments,
const std::shared_ptr<ov::op::v0::Constant> default_index,
const std::shared_ptr<ov::op::v0::Constant> per_sample_weights) {
const auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
if (default_index) {
@ -133,8 +132,8 @@ INSTANTIATE_TEST_SUITE_P(
std::make_shared<ov::op::v0::Constant>(element::i32, ov::Shape(), std::vector<int32_t>{3}),
std::make_shared<ov::op::v0::Constant>(element::i32, ov::Shape(), std::vector<int32_t>{0}),
std::make_shared<ov::op::v0::Constant>(element::f32,
ov::Shape({4}),
std::vector<float>{0.5, 0.5, 0.5, 0.5})),
ov::Shape({4}),
std::vector<float>{0.5, 0.5, 0.5, 0.5})),
EmbeddingSegmentsSumParams(
ov::PartialShape{5, 2},
ov::element::f64,

View File

@ -74,13 +74,12 @@ public:
}
private:
static std::shared_ptr<ov::Model> CreateFunction(
const PartialShape& input_shape,
const element::Type& input_type,
const std::shared_ptr<ov::op::v0::Constant> indices,
const std::shared_ptr<ov::op::v0::Constant> offsets,
const std::shared_ptr<ov::op::v0::Constant> default_index,
const std::shared_ptr<ov::op::v0::Constant> per_sample_weights) {
static std::shared_ptr<ov::Model> CreateFunction(const PartialShape& input_shape,
const element::Type& input_type,
const std::shared_ptr<ov::op::v0::Constant> indices,
const std::shared_ptr<ov::op::v0::Constant> offsets,
const std::shared_ptr<ov::op::v0::Constant> default_index,
const std::shared_ptr<ov::op::v0::Constant> per_sample_weights) {
const auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
if (default_index) {
@ -121,8 +120,8 @@ INSTANTIATE_TEST_SUITE_P(
std::make_shared<ov::op::v0::Constant>(element::i32, ov::Shape({3}), std::vector<int32_t>{0, 2, 2}),
std::make_shared<ov::op::v0::Constant>(element::i32, ov::Shape(), std::vector<int32_t>{0}),
std::make_shared<ov::op::v0::Constant>(element::f32,
ov::Shape({4}),
std::vector<float>{0.5, 0.5, 0.5, 0.5})),
ov::Shape({4}),
std::vector<float>{0.5, 0.5, 0.5, 0.5})),
EmbeddingBagOffsetsSumParams(
ov::PartialShape{5, 2},
ov::element::f64,

View File

@ -63,11 +63,10 @@ public:
}
private:
static std::shared_ptr<Model> CreateFunction(
const PartialShape& input_shape,
const element::Type& input_type,
const std::shared_ptr<ov::op::v0::Constant> indices,
const std::shared_ptr<ov::op::v0::Constant> per_sample_weights) {
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape,
const element::Type& input_type,
const std::shared_ptr<ov::op::v0::Constant> indices,
const std::shared_ptr<ov::op::v0::Constant> per_sample_weights) {
const auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
if (per_sample_weights) {
@ -86,7 +85,7 @@ TEST_P(ReferenceEmbeddingBagPackedSumLayerTest, CompareWithRefs) {
template <class T>
inline std::shared_ptr<ov::op::v0::Constant> CreateConstant(const std::vector<std::vector<T>>& val,
const ov::element::Type& element_type) {
const ov::element::Type& element_type) {
if (val.size() > 0) {
ov::Shape i_shape({val.size(), val[0].size()});

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/equal.hpp"
#include <gtest/gtest.h>
#include "openvino/op/equal.hpp"
#include "comparison.hpp"
using namespace ov;
@ -16,43 +17,43 @@ namespace {
template <element::Type_t IN_ET>
std::vector<RefComparisonParams> generateComparisonParams(const element::Type& type) {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<RefComparisonParams> compParams {
std::vector<RefComparisonParams> compParams{
// 1D // 2D // 3D // 4D
Builder {}
Builder{}
.compType(ComparisonTypes::EQUAL)
.input1({{2, 2}, type, std::vector<T> {0, 12, 23, 0}})
.input2({{2, 2}, type, std::vector<T> {0, 12, 23, 0}})
.expected({{2, 2}, element::boolean, std::vector<char> {1, 1, 1, 1}}),
Builder {}
.input1({{2, 2}, type, std::vector<T>{0, 12, 23, 0}})
.input2({{2, 2}, type, std::vector<T>{0, 12, 23, 0}})
.expected({{2, 2}, element::boolean, std::vector<char>{1, 1, 1, 1}}),
Builder{}
.compType(ComparisonTypes::EQUAL)
.input1({{2, 3}, type, std::vector<T> {0, 6, 45, 1, 21, 21}})
.input2({{2, 3}, type, std::vector<T> {1, 18, 23, 1, 19, 21}})
.expected({{2, 3}, element::boolean, std::vector<char> {0, 0, 0, 1, 0, 1}}),
Builder {}
.input1({{2, 3}, type, std::vector<T>{0, 6, 45, 1, 21, 21}})
.input2({{2, 3}, type, std::vector<T>{1, 18, 23, 1, 19, 21}})
.expected({{2, 3}, element::boolean, std::vector<char>{0, 0, 0, 1, 0, 1}}),
Builder{}
.compType(ComparisonTypes::EQUAL)
.input1({{1}, type, std::vector<T> {53}})
.input2({{1}, type, std::vector<T> {53}})
.expected({{1}, element::boolean, std::vector<char> {1}}),
Builder {}
.input1({{1}, type, std::vector<T>{53}})
.input2({{1}, type, std::vector<T>{53}})
.expected({{1}, element::boolean, std::vector<char>{1}}),
Builder{}
.compType(ComparisonTypes::EQUAL)
.input1({{2, 4}, type, std::vector<T> {0, 12, 23, 0, 1, 5, 11, 8}})
.input2({{2, 4}, type, std::vector<T> {0, 12, 23, 0, 10, 5, 11, 8}})
.expected({{2, 4}, element::boolean, std::vector<char> {1, 1, 1, 1, 0, 1, 1, 1}}),
Builder {}
.input1({{2, 4}, type, std::vector<T>{0, 12, 23, 0, 1, 5, 11, 8}})
.input2({{2, 4}, type, std::vector<T>{0, 12, 23, 0, 10, 5, 11, 8}})
.expected({{2, 4}, element::boolean, std::vector<char>{1, 1, 1, 1, 0, 1, 1, 1}}),
Builder{}
.compType(ComparisonTypes::EQUAL)
.input1({{3, 1, 2}, type, std::vector<T> {2, 1, 4, 1, 3, 1}})
.input2({{1, 2, 1}, type, std::vector<T> {1, 1}})
.expected({{3, 2, 2}, element::boolean, std::vector<char> {0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}}),
Builder {}
.input1({{3, 1, 2}, type, std::vector<T>{2, 1, 4, 1, 3, 1}})
.input2({{1, 2, 1}, type, std::vector<T>{1, 1}})
.expected({{3, 2, 2}, element::boolean, std::vector<char>{0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}}),
Builder{}
.compType(ComparisonTypes::EQUAL)
.input1({{2, 1, 2, 1}, type, std::vector<T> {2, 1, 4, 1}})
.input2({{1, 2, 1}, type, std::vector<T> {1, 1}})
.expected({{2, 1, 2, 1}, element::boolean, std::vector<char> {0, 1, 0, 1}})};
.input1({{2, 1, 2, 1}, type, std::vector<T>{2, 1, 4, 1}})
.input2({{1, 2, 1}, type, std::vector<T>{1, 1}})
.expected({{2, 1, 2, 1}, element::boolean, std::vector<char>{0, 1, 0, 1}})};
return compParams;
}
std::vector<RefComparisonParams> generateComparisonCombinedParams() {
const std::vector<std::vector<RefComparisonParams>> compTypeParams {
const std::vector<std::vector<RefComparisonParams>> compTypeParams{
generateComparisonParams<element::Type_t::f32>(element::f32),
generateComparisonParams<element::Type_t::f16>(element::f16),
generateComparisonParams<element::Type_t::i32>(element::i32),
@ -66,38 +67,47 @@ std::vector<RefComparisonParams> generateComparisonCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_Comparison_With_Hardcoded_Refs, ReferenceComparisonLayerTest, ::testing::ValuesIn(generateComparisonCombinedParams()),
INSTANTIATE_TEST_SUITE_P(smoke_Comparison_With_Hardcoded_Refs,
ReferenceComparisonLayerTest,
::testing::ValuesIn(generateComparisonCombinedParams()),
ReferenceComparisonLayerTest::getTestCaseName);
template <element::Type_t IN_ET>
std::vector<RefComparisonParams> generateNumericParams(const element::Type& type) {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<RefComparisonParams> compParams {
Builder {}
std::vector<RefComparisonParams> compParams{
Builder{}
.compType(ComparisonTypes::EQUAL)
.input1({{4}, type, std::vector<T> {-2.5f, 25.5f, 2.25f, NAN}})
.input2({{4}, type, std::vector<T> {10.0f, 5.0f, 2.25f, 10.0f}})
.expected({{4}, element::boolean, std::vector<char> {0, 0, 1, 0, }}),
Builder {}
.input1({{4}, type, std::vector<T>{-2.5f, 25.5f, 2.25f, NAN}})
.input2({{4}, type, std::vector<T>{10.0f, 5.0f, 2.25f, 10.0f}})
.expected({{4},
element::boolean,
std::vector<char>{
0,
0,
1,
0,
}}),
Builder{}
.compType(ComparisonTypes::EQUAL)
.input1({{2, 3}, type, std::vector<T> {0.0f, NAN, NAN, 1.0f, 21.0f, -INFINITY}})
.input2({{2, 3}, type, std::vector<T> {1.0f, NAN, 23.0f, 1.0f, 19.0f, 21.0f}})
.expected({{2, 3}, element::boolean, std::vector<char> {0, 0, 0, 1, 0, 0}}),
Builder {}
.input1({{2, 3}, type, std::vector<T>{0.0f, NAN, NAN, 1.0f, 21.0f, -INFINITY}})
.input2({{2, 3}, type, std::vector<T>{1.0f, NAN, 23.0f, 1.0f, 19.0f, 21.0f}})
.expected({{2, 3}, element::boolean, std::vector<char>{0, 0, 0, 1, 0, 0}}),
Builder{}
.compType(ComparisonTypes::EQUAL)
.input1({{1}, type, std::vector<T> {INFINITY}})
.input2({{1}, type, std::vector<T> {INFINITY}})
.expected({{1}, element::boolean, std::vector<char> {1}}),
Builder {}
.input1({{1}, type, std::vector<T>{INFINITY}})
.input2({{1}, type, std::vector<T>{INFINITY}})
.expected({{1}, element::boolean, std::vector<char>{1}}),
Builder{}
.compType(ComparisonTypes::EQUAL)
.input1({{5}, type, std::vector<T> {-2.5f, 25.5f, 2.25f, INFINITY, 6.0f}})
.input2({{5}, type, std::vector<T> {10.0f, 5.0f, 2.25f, 10.0f, -INFINITY}})
.expected({{5}, element::boolean, std::vector<char> {0, 0, 1, 0, 0}})};
.input1({{5}, type, std::vector<T>{-2.5f, 25.5f, 2.25f, INFINITY, 6.0f}})
.input2({{5}, type, std::vector<T>{10.0f, 5.0f, 2.25f, 10.0f, -INFINITY}})
.expected({{5}, element::boolean, std::vector<char>{0, 0, 1, 0, 0}})};
return compParams;
}
std::vector<RefComparisonParams> generateNumericCombinedParams() {
const std::vector<std::vector<RefComparisonParams>> compTypeParams {
const std::vector<std::vector<RefComparisonParams>> compTypeParams{
generateNumericParams<element::Type_t::f16>(element::f16),
generateNumericParams<element::Type_t::f32>(element::f32)};
std::vector<RefComparisonParams> combinedParams;
@ -108,8 +118,10 @@ std::vector<RefComparisonParams> generateNumericCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_Numeric_With_Hardcoded_Refs, ReferenceComparisonLayerTest, ::testing::ValuesIn(generateNumericCombinedParams()),
INSTANTIATE_TEST_SUITE_P(smoke_Numeric_With_Hardcoded_Refs,
ReferenceComparisonLayerTest,
::testing::ValuesIn(generateNumericCombinedParams()),
ReferenceComparisonLayerTest::getTestCaseName);
} // namespace
} // namespace ComparisonOpsRefTestDefinitions
} // namespace reference_tests
} // namespace
} // namespace ComparisonOpsRefTestDefinitions
} // namespace reference_tests

View File

@ -2,11 +2,12 @@
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "functional_test_utils/skip_tests_config.hpp"
#include "openvino/op/erf.hpp"
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
#include "functional_test_utils/skip_tests_config.hpp"
using namespace reference_tests;
using namespace ov;
@ -14,7 +15,10 @@ using namespace ov;
struct ErfParams {
template <class IT>
ErfParams(const ov::PartialShape& shape, const ov::element::Type& iType, const std::vector<IT>& iValues)
: pshape(shape), inType(iType), outType(iType), inputData(CreateTensor(iType, iValues)) {
: pshape(shape),
inType(iType),
outType(iType),
inputData(CreateTensor(iType, iValues)) {
std::vector<IT> oValues;
std::vector<double> output;
for (auto element : iValues)
@ -60,11 +64,12 @@ public:
}
private:
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape, const element::Type& input_type,
const element::Type& expected_output_type) {
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape,
const element::Type& input_type,
const element::Type& expected_output_type) {
const auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
const auto erf = std::make_shared<op::v0::Erf>(in);
return std::make_shared<ov::Model>(NodeVector {erf}, ParameterVector {in});
return std::make_shared<ov::Model>(NodeVector{erf}, ParameterVector{in});
}
};
@ -73,17 +78,37 @@ TEST_P(ReferenceErfLayerTest, CompareWithRefs) {
}
INSTANTIATE_TEST_SUITE_P(
smoke_Erf_With_Hardcoded_Refs, ReferenceErfLayerTest,
::testing::Values(ErfParams(ov::PartialShape {2, 5}, ov::element::f32,
std::vector<float> {-INFINITY, -4.0f, -3.0f, -2.0f, -1.0f, 0.0f, 1.0f, 2.0f, 3.0f, INFINITY}),
ErfParams(ov::PartialShape {2, 5}, ov::element::f16,
std::vector<float16> {-INFINITY, -4.0f, -3.0f, -2.0f, -1.0f, 0.0f, 1.0f, 2.0f, 3.0f, INFINITY}),
ErfParams(ov::PartialShape {2, 3}, ov::element::i32,
std::vector<int32_t> {std::numeric_limits<int32_t>::min(), -2, -1, 1, 2, std::numeric_limits<int32_t>::max()}),
ErfParams(ov::PartialShape {2, 3}, ov::element::u32,
std::vector<uint32_t> {std::numeric_limits<uint32_t>::min(), 0, 1, 2, 3, std::numeric_limits<uint32_t>::max()}),
ErfParams(ov::PartialShape {2, 3}, ov::element::i64,
std::vector<int64_t> {std::numeric_limits<int64_t>::min(), -2, -1, 1, 2, std::numeric_limits<int64_t>::max()}),
ErfParams(ov::PartialShape {2, 3}, ov::element::u64,
std::vector<uint64_t> {std::numeric_limits<uint64_t>::min(), 0, 1, 2, 3, std::numeric_limits<uint64_t>::max()})),
smoke_Erf_With_Hardcoded_Refs,
ReferenceErfLayerTest,
::testing::Values(
ErfParams(ov::PartialShape{2, 5},
ov::element::f32,
std::vector<float>{-INFINITY, -4.0f, -3.0f, -2.0f, -1.0f, 0.0f, 1.0f, 2.0f, 3.0f, INFINITY}),
ErfParams(ov::PartialShape{2, 5},
ov::element::f16,
std::vector<float16>{-INFINITY, -4.0f, -3.0f, -2.0f, -1.0f, 0.0f, 1.0f, 2.0f, 3.0f, INFINITY}),
ErfParams(ov::PartialShape{2, 3},
ov::element::i32,
std::vector<
int32_t>{std::numeric_limits<int32_t>::min(), -2, -1, 1, 2, std::numeric_limits<int32_t>::max()}),
ErfParams(ov::PartialShape{2, 3},
ov::element::u32,
std::vector<uint32_t>{std::numeric_limits<uint32_t>::min(),
0,
1,
2,
3,
std::numeric_limits<uint32_t>::max()}),
ErfParams(ov::PartialShape{2, 3},
ov::element::i64,
std::vector<
int64_t>{std::numeric_limits<int64_t>::min(), -2, -1, 1, 2, std::numeric_limits<int64_t>::max()}),
ErfParams(ov::PartialShape{2, 3},
ov::element::u64,
std::vector<uint64_t>{std::numeric_limits<uint64_t>::min(),
0,
1,
2,
3,
std::numeric_limits<uint64_t>::max()})),
ReferenceErfLayerTest::getTestCaseName);

View File

@ -2,11 +2,11 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/exp.hpp"
#include <gtest/gtest.h>
#include "openvino/op/exp.hpp"
#include "base_reference_test.hpp"
#include "functional_test_utils/skip_tests_config.hpp"
using namespace reference_tests;
@ -16,7 +16,10 @@ using namespace InferenceEngine;
namespace {
struct ExpParams {
template <class IT>
ExpParams(const ov::PartialShape& shape, const ov::element::Type& iType, const std::vector<IT>& iValues, const std::vector<IT>& oValues)
ExpParams(const ov::PartialShape& shape,
const ov::element::Type& iType,
const std::vector<IT>& iValues,
const std::vector<IT>& oValues)
: pshape(shape),
inType(iType),
outType(iType),
@ -49,11 +52,12 @@ public:
}
private:
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape, const element::Type& input_type,
const element::Type& expected_output_type) {
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape,
const element::Type& input_type,
const element::Type& expected_output_type) {
const auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
const auto Exp = std::make_shared<op::v0::Exp>(in);
return std::make_shared<ov::Model>(NodeVector {Exp}, ParameterVector {in});
return std::make_shared<ov::Model>(NodeVector{Exp}, ParameterVector{in});
}
};
@ -75,12 +79,13 @@ public:
}
private:
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape, const element::Type& input_type,
const element::Type& expected_output_type) {
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape,
const element::Type& input_type,
const element::Type& expected_output_type) {
const auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
const auto Exp = std::make_shared<op::v0::Exp>(in);
const auto ExpInPlace = std::make_shared<op::v0::Exp>(Exp);
return std::make_shared<ov::Model>(NodeVector {ExpInPlace}, ParameterVector {in});
return std::make_shared<ov::Model>(NodeVector{ExpInPlace}, ParameterVector{in});
}
};
@ -96,16 +101,12 @@ template <element::Type_t IN_ET>
std::vector<ExpParams> generateExpFloatParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<ExpParams> expParams {
ExpParams(ov::PartialShape {8},
IN_ET,
std::vector<T>{-4, -3, -2, -1, 0, 1, 2, 3},
std::vector<T>{expf(-4), expf(-3), expf(-2), expf(-1), expf(0), expf(1), expf(2), expf(3)}),
ExpParams(ov::PartialShape {1},
IN_ET,
std::vector<T>{13},
std::vector<T>{expf(13)})
};
std::vector<ExpParams> expParams{
ExpParams(ov::PartialShape{8},
IN_ET,
std::vector<T>{-4, -3, -2, -1, 0, 1, 2, 3},
std::vector<T>{expf(-4), expf(-3), expf(-2), expf(-1), expf(0), expf(1), expf(2), expf(3)}),
ExpParams(ov::PartialShape{1}, IN_ET, std::vector<T>{13}, std::vector<T>{expf(13)})};
return expParams;
}
@ -113,17 +114,19 @@ template <element::Type_t IN_ET>
std::vector<ExpParams> generateExpIntParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<ExpParams> expParams {
ExpParams(ov::PartialShape {8},
IN_ET,
std::vector<T>{-4, -3, -2, -1, 0, 1, 2, 3},
std::vector<T>{static_cast<T>(expf(-4)), static_cast<T>(expf(-3)), static_cast<T>(expf(-2)), static_cast<T>(expf(-1)),
static_cast<T>(expf(0)), static_cast<T>(expf(1)), static_cast<T>(expf(2)), static_cast<T>(expf(3))}),
ExpParams(ov::PartialShape {1},
IN_ET,
std::vector<T>{13},
std::vector<T>{static_cast<T>(expf(13))})
};
std::vector<ExpParams> expParams{
ExpParams(ov::PartialShape{8},
IN_ET,
std::vector<T>{-4, -3, -2, -1, 0, 1, 2, 3},
std::vector<T>{static_cast<T>(expf(-4)),
static_cast<T>(expf(-3)),
static_cast<T>(expf(-2)),
static_cast<T>(expf(-1)),
static_cast<T>(expf(0)),
static_cast<T>(expf(1)),
static_cast<T>(expf(2)),
static_cast<T>(expf(3))}),
ExpParams(ov::PartialShape{1}, IN_ET, std::vector<T>{13}, std::vector<T>{static_cast<T>(expf(13))})};
return expParams;
}
@ -131,17 +134,19 @@ template <element::Type_t IN_ET>
std::vector<ExpParams> generateExpUintParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<ExpParams> expParams {
ExpParams(ov::PartialShape {8},
IN_ET,
std::vector<T>{0, 1, 2, 3, 4, 5, 10, 100},
std::vector<T>{static_cast<T>(expf(0)), static_cast<T>(expf(1)), static_cast<T>(expf(2)), static_cast<T>(expf(3)),
static_cast<T>(expf(4)), static_cast<T>(expf(5)), static_cast<T>(expf(10)), static_cast<T>(expf(100))}),
ExpParams(ov::PartialShape {1},
IN_ET,
std::vector<T>{13},
std::vector<T>{static_cast<T>(expf(13))})
};
std::vector<ExpParams> expParams{
ExpParams(ov::PartialShape{8},
IN_ET,
std::vector<T>{0, 1, 2, 3, 4, 5, 10, 100},
std::vector<T>{static_cast<T>(expf(0)),
static_cast<T>(expf(1)),
static_cast<T>(expf(2)),
static_cast<T>(expf(3)),
static_cast<T>(expf(4)),
static_cast<T>(expf(5)),
static_cast<T>(expf(10)),
static_cast<T>(expf(100))}),
ExpParams(ov::PartialShape{1}, IN_ET, std::vector<T>{13}, std::vector<T>{static_cast<T>(expf(13))})};
return expParams;
}
@ -149,22 +154,16 @@ template <element::Type_t IN_ET>
std::vector<ExpParams> generateExpInPlaceFloatParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<ExpParams> expParams {
ExpParams(ov::PartialShape {2},
IN_ET,
std::vector<T>{1, 3},
std::vector<T>{expf(expf(1)), expf(expf(3))})
};
std::vector<ExpParams> expParams{
ExpParams(ov::PartialShape{2}, IN_ET, std::vector<T>{1, 3}, std::vector<T>{expf(expf(1)), expf(expf(3))})};
return expParams;
}
std::vector<ExpParams> generateExpCombinedParams() {
const std::vector<std::vector<ExpParams>> expTypeParams {
generateExpFloatParams<element::Type_t::f32>(),
generateExpFloatParams<element::Type_t::f16>(),
generateExpIntParams<element::Type_t::i32>(),
generateExpIntParams<element::Type_t::i64>()
};
const std::vector<std::vector<ExpParams>> expTypeParams{generateExpFloatParams<element::Type_t::f32>(),
generateExpFloatParams<element::Type_t::f16>(),
generateExpIntParams<element::Type_t::i32>(),
generateExpIntParams<element::Type_t::i64>()};
std::vector<ExpParams> combinedParams;
for (const auto& params : expTypeParams) {
@ -174,10 +173,8 @@ std::vector<ExpParams> generateExpCombinedParams() {
}
std::vector<ExpParams> generateExpInPlaceCombinedParams() {
const std::vector<std::vector<ExpParams>> expTypeParams {
generateExpInPlaceFloatParams<element::Type_t::f16>(),
generateExpInPlaceFloatParams<element::Type_t::f32>()
};
const std::vector<std::vector<ExpParams>> expTypeParams{generateExpInPlaceFloatParams<element::Type_t::f16>(),
generateExpInPlaceFloatParams<element::Type_t::f32>()};
std::vector<ExpParams> combinedParams;
for (const auto& params : expTypeParams) {
@ -186,10 +183,14 @@ std::vector<ExpParams> generateExpInPlaceCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_Exp_With_Hardcoded_Refs, ReferenceExpLayerTest,
testing::ValuesIn(generateExpCombinedParams()), ReferenceExpLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Exp_With_Hardcoded_Refs,
ReferenceExpLayerTest,
testing::ValuesIn(generateExpCombinedParams()),
ReferenceExpLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Exp_In_Place_With_Hardcoded_Refs, ReferenceExpInPlaceLayerTest,
testing::ValuesIn(generateExpInPlaceCombinedParams()), ReferenceExpInPlaceLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Exp_In_Place_With_Hardcoded_Refs,
ReferenceExpInPlaceLayerTest,
testing::ValuesIn(generateExpInPlaceCombinedParams()),
ReferenceExpInPlaceLayerTest::getTestCaseName);
} // namespace
} // namespace

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/experimental_detectron_detection_output.hpp"
#include <gtest/gtest.h>
#include "openvino/op/experimental_detectron_detection_output.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
@ -18,9 +19,13 @@ struct ExperimentalDOParams {
ExperimentalDOParams(const Attrs& attrs,
const size_t num_rois,
const element::Type& iType,
const std::vector<IT>& roisValues, const std::vector<IT>& deltasValues,
const std::vector<IT>& scoresValues, const std::vector<IT>& imageSizeInfoValues,
const std::vector<IT>& refBoxesValues, const std::vector<int32_t>& refClassesValues, const std::vector<IT>& refScoresValues,
const std::vector<IT>& roisValues,
const std::vector<IT>& deltasValues,
const std::vector<IT>& scoresValues,
const std::vector<IT>& imageSizeInfoValues,
const std::vector<IT>& refBoxesValues,
const std::vector<int32_t>& refClassesValues,
const std::vector<IT>& refScoresValues,
const std::string& testcaseName = "")
: attrs(attrs),
inType(iType),
@ -33,11 +38,11 @@ struct ExperimentalDOParams {
refClassesData(CreateTensor(ov::element::i32, refClassesValues)),
refScoresData(CreateTensor(iType, refScoresValues)),
testcaseName(testcaseName) {
roisShape = Shape{num_rois, 4};
deltasShape = Shape{num_rois, static_cast<size_t>(attrs.num_classes * 4)};
scoresShape = Shape{num_rois, static_cast<size_t>(attrs.num_classes)};
imageSizeInfoShape = Shape{1, 3};
}
roisShape = Shape{num_rois, 4};
deltasShape = Shape{num_rois, static_cast<size_t>(attrs.num_classes * 4)};
scoresShape = Shape{num_rois, static_cast<size_t>(attrs.num_classes)};
imageSizeInfoShape = Shape{1, 3};
}
Attrs attrs;
PartialShape roisShape;
@ -56,7 +61,8 @@ struct ExperimentalDOParams {
std::string testcaseName;
};
class ReferenceExperimentalDOLayerTest : public testing::TestWithParam<ExperimentalDOParams>, public CommonReferenceTest {
class ReferenceExperimentalDOLayerTest : public testing::TestWithParam<ExperimentalDOParams>,
public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
@ -84,12 +90,9 @@ private:
const auto deltas = std::make_shared<op::v0::Parameter>(params.inType, params.deltasShape);
const auto scores = std::make_shared<op::v0::Parameter>(params.inType, params.scoresShape);
const auto im_info = std::make_shared<op::v0::Parameter>(params.inType, params.imageSizeInfoShape);
const auto ExperimentalDO = std::make_shared<op::v6::ExperimentalDetectronDetectionOutput>(rois,
deltas,
scores,
im_info,
params.attrs);
return std::make_shared<ov::Model>(ExperimentalDO->outputs(), ParameterVector {rois, deltas, scores, im_info});
const auto ExperimentalDO =
std::make_shared<op::v6::ExperimentalDetectronDetectionOutput>(rois, deltas, scores, im_info, params.attrs);
return std::make_shared<ov::Model>(ExperimentalDO->outputs(), ParameterVector{rois, deltas, scores, im_info});
}
};
@ -101,68 +104,71 @@ template <element::Type_t IN_ET>
std::vector<ExperimentalDOParams> generateExperimentalDOFloatParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<ExperimentalDOParams> experimentalDOParams {
ExperimentalDOParams(Attrs{0.01000000074505806f, // score_threshold
0.2f, // nms_threshold
2.0f, // max_delta_log_wh
2, // num_classes
500, // post_nms_count
5, // max_detections_per_image
true, // class_agnostic_box_regression
{10.0f, 10.0f, 5.0f, 5.0f} // deltas_weights
},
16,
IN_ET,
std::vector<T>{1.0f, 1.0f, 10.0f, 10.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 4.0f, 1.0f, 8.0f, 5.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f},
std::vector<T>{5.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 4.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 8.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
std::vector<ExperimentalDOParams> experimentalDOParams{
ExperimentalDOParams(
Attrs{
0.01000000074505806f, // score_threshold
0.2f, // nms_threshold
2.0f, // max_delta_log_wh
2, // num_classes
500, // post_nms_count
5, // max_detections_per_image
true, // class_agnostic_box_regression
{10.0f, 10.0f, 5.0f, 5.0f} // deltas_weights
},
16,
IN_ET,
std::vector<T>{1.0f, 1.0f, 10.0f, 10.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 4.0f, 1.0f, 8.0f, 5.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f},
std::vector<T>{
5.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 4.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 8.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f},
std::vector<T>{1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f},
std::vector<T>{1.0f, 1.0f, 1.0f},
std::vector<T>{0.8929862f,
0.892986297607421875,
12.10701370239257812,
12.10701370239257812,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0},
std::vector<int32_t>{1, 0, 0, 0, 0},
std::vector<T>{1.0f, 0.0f, 0.0f, 0.0f, 0.0f}),
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f},
std::vector<T>{1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f},
std::vector<T>{1.0f, 1.0f, 1.0f},
std::vector<T>{0.8929862f,
0.892986297607421875,
12.10701370239257812,
12.10701370239257812,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0f,
0.0},
std::vector<int32_t>{1, 0, 0, 0, 0},
std::vector<T>{1.0f, 0.0f, 0.0f, 0.0f, 0.0f}),
};
return experimentalDOParams;
}
std::vector<ExperimentalDOParams> generateExperimentalDOCombinedParams() {
const std::vector<std::vector<ExperimentalDOParams>> ExperimentalDOTypeParams {
const std::vector<std::vector<ExperimentalDOParams>> ExperimentalDOTypeParams{
generateExperimentalDOFloatParams<element::Type_t::f32>(),
generateExperimentalDOFloatParams<element::Type_t::f16>(),
generateExperimentalDOFloatParams<element::Type_t::bf16>(),
};
};
std::vector<ExperimentalDOParams> combinedParams;
for (const auto& params : ExperimentalDOTypeParams) {
@ -171,6 +177,8 @@ std::vector<ExperimentalDOParams> generateExperimentalDOCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_ExperimentalDetectronDetectionOutput_With_Hardcoded_Refs, ReferenceExperimentalDOLayerTest,
testing::ValuesIn(generateExperimentalDOCombinedParams()), ReferenceExperimentalDOLayerTest::getTestCaseName);
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_ExperimentalDetectronDetectionOutput_With_Hardcoded_Refs,
ReferenceExperimentalDOLayerTest,
testing::ValuesIn(generateExperimentalDOCombinedParams()),
ReferenceExperimentalDOLayerTest::getTestCaseName);
} // namespace

View File

@ -4,8 +4,8 @@
#include <gtest/gtest.h>
#include "openvino/op/experimental_detectron_prior_grid_generator.hpp"
#include "base_reference_test.hpp"
#include "openvino/op/experimental_detectron_prior_grid_generator.hpp"
using namespace reference_tests;
using namespace ov;
@ -16,14 +16,14 @@ namespace {
struct ExperimentalPGGParams {
template <class IT>
ExperimentalPGGParams(const Attrs& attrs,
const PartialShape& priorsShape,
const PartialShape& featureMapShape,
const PartialShape& imageSizeInfoShape,
const Shape& outRefShape,
const element::Type& iType,
const std::vector<IT>& priorsValues,
const std::vector<IT>& refValues,
const std::string& testcaseName = "")
const PartialShape& priorsShape,
const PartialShape& featureMapShape,
const PartialShape& imageSizeInfoShape,
const Shape& outRefShape,
const element::Type& iType,
const std::vector<IT>& priorsValues,
const std::vector<IT>& refValues,
const std::string& testcaseName = "")
: attrs(attrs),
priorsShape(priorsShape),
featureMapShape(featureMapShape),
@ -34,19 +34,19 @@ struct ExperimentalPGGParams {
priorsData(CreateTensor(iType, priorsValues)),
refData(CreateTensor(outRefShape, iType, refValues)),
testcaseName(testcaseName) {
std::vector<IT> featureMapValues(shape_size(featureMapShape.get_shape()));
std::iota(featureMapValues.begin(), featureMapValues.end(), 0.f);
featureMapData = CreateTensor(iType, featureMapValues);
std::vector<IT> featureMapValues(shape_size(featureMapShape.get_shape()));
std::iota(featureMapValues.begin(), featureMapValues.end(), 0.f);
featureMapData = CreateTensor(iType, featureMapValues);
std::vector<IT> imageSizeInfoValues(shape_size(imageSizeInfoShape.get_shape()));
std::iota(imageSizeInfoValues.begin(), imageSizeInfoValues.end(), 0.f);
imageSizeInfoData = CreateTensor(iType, imageSizeInfoValues);
std::vector<IT> imageSizeInfoValues(shape_size(imageSizeInfoShape.get_shape()));
std::iota(imageSizeInfoValues.begin(), imageSizeInfoValues.end(), 0.f);
imageSizeInfoData = CreateTensor(iType, imageSizeInfoValues);
if (shape_size(outRefShape) > refValues.size())
actualComparisonSize = refValues.size();
else
actualComparisonSize = 0;
}
if (shape_size(outRefShape) > refValues.size())
actualComparisonSize = refValues.size();
else
actualComparisonSize = 0;
}
Attrs attrs;
PartialShape priorsShape;
@ -63,7 +63,8 @@ struct ExperimentalPGGParams {
std::string testcaseName;
};
class ReferenceExperimentalPGGLayerTest : public testing::TestWithParam<ExperimentalPGGParams>, public CommonReferenceTest {
class ReferenceExperimentalPGGLayerTest : public testing::TestWithParam<ExperimentalPGGParams>,
public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
@ -98,10 +99,10 @@ private:
const auto featureMap = std::make_shared<op::v0::Parameter>(params.inType, params.featureMapShape);
const auto im_info = std::make_shared<op::v0::Parameter>(params.inType, params.imageSizeInfoShape);
const auto ExperimentalPGG = std::make_shared<op::v6::ExperimentalDetectronPriorGridGenerator>(priors,
featureMap,
im_info,
params.attrs);
return std::make_shared<ov::Model>(NodeVector {ExperimentalPGG}, ParameterVector {priors, featureMap, im_info});
featureMap,
im_info,
params.attrs);
return std::make_shared<ov::Model>(NodeVector{ExperimentalPGG}, ParameterVector{priors, featureMap, im_info});
}
};
@ -113,106 +114,119 @@ template <element::Type_t IN_ET>
std::vector<ExperimentalPGGParams> generateExperimentalPGGFloatParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<ExperimentalPGGParams> experimentalPGGParams {
ExperimentalPGGParams(Attrs{true, 0, 0, 4.0f, 4.0f},
{3, 4},
{1, 16, 4, 5},
{1, 3, 100, 200},
{60, 4},
IN_ET,
std::vector<T>{-24.5, -12.5, 24.5, 12.5, -16.5, -16.5, 16.5, 16.5, -12.5, -24.5, 12.5, 24.5},
std::vector<T>{-22.5, -10.5, 26.5, 14.5, -14.5, -14.5, 18.5, 18.5, -10.5, -22.5, 14.5, 26.5, -18.5, -10.5, 30.5, 14.5,
-10.5, -14.5, 22.5, 18.5, -6.5, -22.5, 18.5, 26.5, -14.5, -10.5, 34.5, 14.5, -6.5, -14.5, 26.5, 18.5,
-2.5, -22.5, 22.5, 26.5, -10.5, -10.5, 38.5, 14.5, -2.5, -14.5, 30.5, 18.5, 1.5, -22.5, 26.5, 26.5,
-6.5, -10.5, 42.5, 14.5, 1.5, -14.5, 34.5, 18.5, 5.5, -22.5, 30.5, 26.5, -22.5, -6.5, 26.5, 18.5,
-14.5, -10.5, 18.5, 22.5, -10.5, -18.5, 14.5, 30.5, -18.5, -6.5, 30.5, 18.5, -10.5, -10.5, 22.5, 22.5,
-6.5, -18.5, 18.5, 30.5, -14.5, -6.5, 34.5, 18.5, -6.5, -10.5, 26.5, 22.5, -2.5, -18.5, 22.5, 30.5,
-10.5, -6.5, 38.5, 18.5, -2.5, -10.5, 30.5, 22.5, 1.5, -18.5, 26.5, 30.5, -6.5, -6.5, 42.5, 18.5,
1.5, -10.5, 34.5, 22.5, 5.5, -18.5, 30.5, 30.5, -22.5, -2.5, 26.5, 22.5, -14.5, -6.5, 18.5, 26.5,
-10.5, -14.5, 14.5, 34.5, -18.5, -2.5, 30.5, 22.5, -10.5, -6.5, 22.5, 26.5, -6.5, -14.5, 18.5, 34.5,
-14.5, -2.5, 34.5, 22.5, -6.5, -6.5, 26.5, 26.5, -2.5, -14.5, 22.5, 34.5, -10.5, -2.5, 38.5, 22.5,
-2.5, -6.5, 30.5, 26.5, 1.5, -14.5, 26.5, 34.5, -6.5, -2.5, 42.5, 22.5, 1.5, -6.5, 34.5, 26.5,
5.5, -14.5, 30.5, 34.5, -22.5, 1.5, 26.5, 26.5, -14.5, -2.5, 18.5, 30.5, -10.5, -10.5, 14.5, 38.5,
-18.5, 1.5, 30.5, 26.5, -10.5, -2.5, 22.5, 30.5, -6.5, -10.5, 18.5, 38.5, -14.5, 1.5, 34.5, 26.5,
-6.5, -2.5, 26.5, 30.5, -2.5, -10.5, 22.5, 38.5, -10.5, 1.5, 38.5, 26.5, -2.5, -2.5, 30.5, 30.5,
1.5, -10.5, 26.5, 38.5, -6.5, 1.5, 42.5, 26.5, 1.5, -2.5, 34.5, 30.5, 5.5, -10.5, 30.5, 38.5}),
ExperimentalPGGParams(Attrs{false, 0, 0, 8.0f, 8.0f},
{3, 4},
{1, 16, 3, 7},
{1, 3, 100, 200},
{3, 7, 3, 4},
IN_ET,
std::vector<T>{-44.5, -24.5, 44.5, 24.5, -32.5, -32.5, 32.5, 32.5, -24.5, -44.5, 24.5, 44.5},
std::vector<T>{-40.5, -20.5, 48.5, 28.5, -28.5, -28.5, 36.5, 36.5, -20.5, -40.5, 28.5, 48.5, -32.5, -20.5, 56.5, 28.5,
-20.5, -28.5, 44.5, 36.5, -12.5, -40.5, 36.5, 48.5, -24.5, -20.5, 64.5, 28.5, -12.5, -28.5, 52.5, 36.5,
-4.5, -40.5, 44.5, 48.5, -16.5, -20.5, 72.5, 28.5, -4.5, -28.5, 60.5, 36.5, 3.5, -40.5, 52.5, 48.5,
-8.5, -20.5, 80.5, 28.5, 3.5, -28.5, 68.5, 36.5, 11.5, -40.5, 60.5, 48.5, -0.5, -20.5, 88.5, 28.5,
11.5, -28.5, 76.5, 36.5, 19.5, -40.5, 68.5, 48.5, 7.5, -20.5, 96.5, 28.5, 19.5, -28.5, 84.5, 36.5,
27.5, -40.5, 76.5, 48.5, -40.5, -12.5, 48.5, 36.5, -28.5, -20.5, 36.5, 44.5, -20.5, -32.5, 28.5, 56.5,
-32.5, -12.5, 56.5, 36.5, -20.5, -20.5, 44.5, 44.5, -12.5, -32.5, 36.5, 56.5, -24.5, -12.5, 64.5, 36.5,
-12.5, -20.5, 52.5, 44.5, -4.5, -32.5, 44.5, 56.5, -16.5, -12.5, 72.5, 36.5, -4.5, -20.5, 60.5, 44.5,
3.5, -32.5, 52.5, 56.5, -8.5, -12.5, 80.5, 36.5, 3.5, -20.5, 68.5, 44.5, 11.5, -32.5, 60.5, 56.5,
-0.5, -12.5, 88.5, 36.5, 11.5, -20.5, 76.5, 44.5, 19.5, -32.5, 68.5, 56.5, 7.5, -12.5, 96.5, 36.5,
19.5, -20.5, 84.5, 44.5, 27.5, -32.5, 76.5, 56.5, -40.5, -4.5, 48.5, 44.5, -28.5, -12.5, 36.5, 52.5,
-20.5, -24.5, 28.5, 64.5, -32.5, -4.5, 56.5, 44.5, -20.5, -12.5, 44.5, 52.5, -12.5, -24.5, 36.5, 64.5,
-24.5, -4.5, 64.5, 44.5, -12.5, -12.5, 52.5, 52.5, -4.5, -24.5, 44.5, 64.5, -16.5, -4.5, 72.5, 44.5,
-4.5, -12.5, 60.5, 52.5, 3.5, -24.5, 52.5, 64.5, -8.5, -4.5, 80.5, 44.5, 3.5, -12.5, 68.5, 52.5,
11.5, -24.5, 60.5, 64.5, -0.5, -4.5, 88.5, 44.5, 11.5, -12.5, 76.5, 52.5, 19.5, -24.5, 68.5, 64.5,
7.5, -4.5, 96.5, 44.5, 19.5, -12.5, 84.5, 52.5, 27.5, -24.5, 76.5, 64.5}),
ExperimentalPGGParams(Attrs{true, 3, 6, 64.0f, 64.0f},
{3, 4},
{1, 16, 100, 100},
{1, 3, 100, 200},
{30000, 4},
IN_ET,
std::vector<T>{-364.5, -184.5, 364.5, 184.5, -256.5, -256.5, 256.5, 256.5, -180.5, -360.5, 180.5, 360.5},
std::vector<T>{-332.5, -152.5, 396.5, 216.5, -224.5, -224.5, 288.5, 288.5, -148.5, -328.5, 212.5, 392.5, -268.5, -152.5,
460.5, 216.5, -160.5, -224.5, 352.5, 288.5, -84.5, -328.5, 276.5, 392.5, -204.5, -152.5, 524.5, 216.5,
-96.5, -224.5, 416.5, 288.5, -20.5, -328.5, 340.5, 392.5, -140.5, -152.5, 588.5, 216.5, -32.5, -224.5,
480.5, 288.5, 43.5, -328.5, 404.5, 392.5, -76.5, -152.5, 652.5, 216.5, 31.5, -224.5, 544.5, 288.5,
107.5, -328.5, 468.5, 392.5, -12.5, -152.5, 716.5, 216.5, 95.5, -224.5, 608.5, 288.5, 171.5, -328.5,
532.5, 392.5, -332.5, -88.5, 396.5, 280.5, -224.5, -160.5, 288.5, 352.5, -148.5, -264.5, 212.5, 456.5,
-268.5, -88.5, 460.5, 280.5, -160.5, -160.5, 352.5, 352.5, -84.5, -264.5, 276.5, 456.5, -204.5, -88.5,
524.5, 280.5, -96.5, -160.5, 416.5, 352.5, -20.5, -264.5, 340.5, 456.5, -140.5, -88.5, 588.5, 280.5,
-32.5, -160.5, 480.5, 352.5, 43.5, -264.5, 404.5, 456.5, -76.5, -88.5, 652.5, 280.5, 31.5, -160.5,
544.5, 352.5, 107.5, -264.5, 468.5, 456.5, -12.5, -88.5, 716.5, 280.5, 95.5, -160.5, 608.5, 352.5,
171.5, -264.5, 532.5, 456.5, -332.5, -24.5, 396.5, 344.5, -224.5, -96.5, 288.5, 416.5, -148.5, -200.5,
212.5, 520.5, -268.5, -24.5, 460.5, 344.5, -160.5, -96.5, 352.5, 416.5, -84.5, -200.5, 276.5, 520.5,
-204.5, -24.5, 524.5, 344.5, -96.5, -96.5, 416.5, 416.5, -20.5, -200.5, 340.5, 520.5, -140.5, -24.5,
588.5, 344.5, -32.5, -96.5, 480.5, 416.5, 43.5, -200.5, 404.5, 520.5, -76.5, -24.5, 652.5, 344.5,
31.5, -96.5, 544.5, 416.5, 107.5, -200.5, 468.5, 520.5, -12.5, -24.5, 716.5, 344.5, 95.5, -96.5,
608.5, 416.5, 171.5, -200.5, 532.5, 520.5}),
ExperimentalPGGParams(Attrs{false, 5, 3, 32.0f, 32.0f},
{3, 4},
{1, 16, 100, 100},
{1, 3, 100, 200},
{100, 100, 3, 4},
IN_ET,
std::vector<T>{-180.5, -88.5, 180.5, 88.5, -128.5, -128.5, 128.5, 128.5, -92.5, -184.5, 92.5, 184.5},
std::vector<T>{-164.5, -72.5, 196.5, 104.5, -112.5, -112.5, 144.5, 144.5, -76.5, -168.5, 108.5, 200.5, -132.5, -72.5,
228.5, 104.5, -80.5, -112.5, 176.5, 144.5, -44.5, -168.5, 140.5, 200.5, -100.5, -72.5, 260.5, 104.5,
-48.5, -112.5, 208.5, 144.5, -12.5, -168.5, 172.5, 200.5, -164.5, -40.5, 196.5, 136.5, -112.5, -80.5,
144.5, 176.5, -76.5, -136.5, 108.5, 232.5, -132.5, -40.5, 228.5, 136.5, -80.5, -80.5, 176.5, 176.5,
-44.5, -136.5, 140.5, 232.5, -100.5, -40.5, 260.5, 136.5, -48.5, -80.5, 208.5, 176.5, -12.5, -136.5,
172.5, 232.5, -164.5, -8.5, 196.5, 168.5, -112.5, -48.5, 144.5, 208.5, -76.5, -104.5, 108.5, 264.5,
-132.5, -8.5, 228.5, 168.5, -80.5, -48.5, 176.5, 208.5, -44.5, -104.5, 140.5, 264.5, -100.5, -8.5,
260.5, 168.5, -48.5, -48.5, 208.5, 208.5, -12.5, -104.5, 172.5, 264.5, -164.5, 23.5, 196.5, 200.5,
-112.5, -16.5, 144.5, 240.5, -76.5, -72.5, 108.5, 296.5, -132.5, 23.5, 228.5, 200.5, -80.5, -16.5,
176.5, 240.5, -44.5, -72.5, 140.5, 296.5, -100.5, 23.5, 260.5, 200.5, -48.5, -16.5, 208.5, 240.5,
-12.5, -72.5, 172.5, 296.5, -164.5, 55.5, 196.5, 232.5, -112.5, 15.5, 144.5, 272.5, -76.5, -40.5,
108.5, 328.5, -132.5, 55.5, 228.5, 232.5, -80.5, 15.5, 176.5, 272.5, -44.5, -40.5, 140.5, 328.5,
-100.5, 55.5, 260.5, 232.5, -48.5, 15.5, 208.5, 272.5, -12.5, -40.5, 172.5, 328.5}),
std::vector<ExperimentalPGGParams> experimentalPGGParams{
ExperimentalPGGParams(
Attrs{true, 0, 0, 4.0f, 4.0f},
{3, 4},
{1, 16, 4, 5},
{1, 3, 100, 200},
{60, 4},
IN_ET,
std::vector<T>{-24.5, -12.5, 24.5, 12.5, -16.5, -16.5, 16.5, 16.5, -12.5, -24.5, 12.5, 24.5},
std::vector<T>{-22.5, -10.5, 26.5, 14.5, -14.5, -14.5, 18.5, 18.5, -10.5, -22.5, 14.5, 26.5, -18.5,
-10.5, 30.5, 14.5, -10.5, -14.5, 22.5, 18.5, -6.5, -22.5, 18.5, 26.5, -14.5, -10.5,
34.5, 14.5, -6.5, -14.5, 26.5, 18.5, -2.5, -22.5, 22.5, 26.5, -10.5, -10.5, 38.5,
14.5, -2.5, -14.5, 30.5, 18.5, 1.5, -22.5, 26.5, 26.5, -6.5, -10.5, 42.5, 14.5,
1.5, -14.5, 34.5, 18.5, 5.5, -22.5, 30.5, 26.5, -22.5, -6.5, 26.5, 18.5, -14.5,
-10.5, 18.5, 22.5, -10.5, -18.5, 14.5, 30.5, -18.5, -6.5, 30.5, 18.5, -10.5, -10.5,
22.5, 22.5, -6.5, -18.5, 18.5, 30.5, -14.5, -6.5, 34.5, 18.5, -6.5, -10.5, 26.5,
22.5, -2.5, -18.5, 22.5, 30.5, -10.5, -6.5, 38.5, 18.5, -2.5, -10.5, 30.5, 22.5,
1.5, -18.5, 26.5, 30.5, -6.5, -6.5, 42.5, 18.5, 1.5, -10.5, 34.5, 22.5, 5.5,
-18.5, 30.5, 30.5, -22.5, -2.5, 26.5, 22.5, -14.5, -6.5, 18.5, 26.5, -10.5, -14.5,
14.5, 34.5, -18.5, -2.5, 30.5, 22.5, -10.5, -6.5, 22.5, 26.5, -6.5, -14.5, 18.5,
34.5, -14.5, -2.5, 34.5, 22.5, -6.5, -6.5, 26.5, 26.5, -2.5, -14.5, 22.5, 34.5,
-10.5, -2.5, 38.5, 22.5, -2.5, -6.5, 30.5, 26.5, 1.5, -14.5, 26.5, 34.5, -6.5,
-2.5, 42.5, 22.5, 1.5, -6.5, 34.5, 26.5, 5.5, -14.5, 30.5, 34.5, -22.5, 1.5,
26.5, 26.5, -14.5, -2.5, 18.5, 30.5, -10.5, -10.5, 14.5, 38.5, -18.5, 1.5, 30.5,
26.5, -10.5, -2.5, 22.5, 30.5, -6.5, -10.5, 18.5, 38.5, -14.5, 1.5, 34.5, 26.5,
-6.5, -2.5, 26.5, 30.5, -2.5, -10.5, 22.5, 38.5, -10.5, 1.5, 38.5, 26.5, -2.5,
-2.5, 30.5, 30.5, 1.5, -10.5, 26.5, 38.5, -6.5, 1.5, 42.5, 26.5, 1.5, -2.5,
34.5, 30.5, 5.5, -10.5, 30.5, 38.5}),
ExperimentalPGGParams(
Attrs{false, 0, 0, 8.0f, 8.0f},
{3, 4},
{1, 16, 3, 7},
{1, 3, 100, 200},
{3, 7, 3, 4},
IN_ET,
std::vector<T>{-44.5, -24.5, 44.5, 24.5, -32.5, -32.5, 32.5, 32.5, -24.5, -44.5, 24.5, 44.5},
std::vector<T>{
-40.5, -20.5, 48.5, 28.5, -28.5, -28.5, 36.5, 36.5, -20.5, -40.5, 28.5, 48.5, -32.5, -20.5, 56.5, 28.5,
-20.5, -28.5, 44.5, 36.5, -12.5, -40.5, 36.5, 48.5, -24.5, -20.5, 64.5, 28.5, -12.5, -28.5, 52.5, 36.5,
-4.5, -40.5, 44.5, 48.5, -16.5, -20.5, 72.5, 28.5, -4.5, -28.5, 60.5, 36.5, 3.5, -40.5, 52.5, 48.5,
-8.5, -20.5, 80.5, 28.5, 3.5, -28.5, 68.5, 36.5, 11.5, -40.5, 60.5, 48.5, -0.5, -20.5, 88.5, 28.5,
11.5, -28.5, 76.5, 36.5, 19.5, -40.5, 68.5, 48.5, 7.5, -20.5, 96.5, 28.5, 19.5, -28.5, 84.5, 36.5,
27.5, -40.5, 76.5, 48.5, -40.5, -12.5, 48.5, 36.5, -28.5, -20.5, 36.5, 44.5, -20.5, -32.5, 28.5, 56.5,
-32.5, -12.5, 56.5, 36.5, -20.5, -20.5, 44.5, 44.5, -12.5, -32.5, 36.5, 56.5, -24.5, -12.5, 64.5, 36.5,
-12.5, -20.5, 52.5, 44.5, -4.5, -32.5, 44.5, 56.5, -16.5, -12.5, 72.5, 36.5, -4.5, -20.5, 60.5, 44.5,
3.5, -32.5, 52.5, 56.5, -8.5, -12.5, 80.5, 36.5, 3.5, -20.5, 68.5, 44.5, 11.5, -32.5, 60.5, 56.5,
-0.5, -12.5, 88.5, 36.5, 11.5, -20.5, 76.5, 44.5, 19.5, -32.5, 68.5, 56.5, 7.5, -12.5, 96.5, 36.5,
19.5, -20.5, 84.5, 44.5, 27.5, -32.5, 76.5, 56.5, -40.5, -4.5, 48.5, 44.5, -28.5, -12.5, 36.5, 52.5,
-20.5, -24.5, 28.5, 64.5, -32.5, -4.5, 56.5, 44.5, -20.5, -12.5, 44.5, 52.5, -12.5, -24.5, 36.5, 64.5,
-24.5, -4.5, 64.5, 44.5, -12.5, -12.5, 52.5, 52.5, -4.5, -24.5, 44.5, 64.5, -16.5, -4.5, 72.5, 44.5,
-4.5, -12.5, 60.5, 52.5, 3.5, -24.5, 52.5, 64.5, -8.5, -4.5, 80.5, 44.5, 3.5, -12.5, 68.5, 52.5,
11.5, -24.5, 60.5, 64.5, -0.5, -4.5, 88.5, 44.5, 11.5, -12.5, 76.5, 52.5, 19.5, -24.5, 68.5, 64.5,
7.5, -4.5, 96.5, 44.5, 19.5, -12.5, 84.5, 52.5, 27.5, -24.5, 76.5, 64.5}),
ExperimentalPGGParams(
Attrs{true, 3, 6, 64.0f, 64.0f},
{3, 4},
{1, 16, 100, 100},
{1, 3, 100, 200},
{30000, 4},
IN_ET,
std::vector<T>{-364.5, -184.5, 364.5, 184.5, -256.5, -256.5, 256.5, 256.5, -180.5, -360.5, 180.5, 360.5},
std::vector<T>{-332.5, -152.5, 396.5, 216.5, -224.5, -224.5, 288.5, 288.5, -148.5, -328.5, 212.5, 392.5,
-268.5, -152.5, 460.5, 216.5, -160.5, -224.5, 352.5, 288.5, -84.5, -328.5, 276.5, 392.5,
-204.5, -152.5, 524.5, 216.5, -96.5, -224.5, 416.5, 288.5, -20.5, -328.5, 340.5, 392.5,
-140.5, -152.5, 588.5, 216.5, -32.5, -224.5, 480.5, 288.5, 43.5, -328.5, 404.5, 392.5,
-76.5, -152.5, 652.5, 216.5, 31.5, -224.5, 544.5, 288.5, 107.5, -328.5, 468.5, 392.5,
-12.5, -152.5, 716.5, 216.5, 95.5, -224.5, 608.5, 288.5, 171.5, -328.5, 532.5, 392.5,
-332.5, -88.5, 396.5, 280.5, -224.5, -160.5, 288.5, 352.5, -148.5, -264.5, 212.5, 456.5,
-268.5, -88.5, 460.5, 280.5, -160.5, -160.5, 352.5, 352.5, -84.5, -264.5, 276.5, 456.5,
-204.5, -88.5, 524.5, 280.5, -96.5, -160.5, 416.5, 352.5, -20.5, -264.5, 340.5, 456.5,
-140.5, -88.5, 588.5, 280.5, -32.5, -160.5, 480.5, 352.5, 43.5, -264.5, 404.5, 456.5,
-76.5, -88.5, 652.5, 280.5, 31.5, -160.5, 544.5, 352.5, 107.5, -264.5, 468.5, 456.5,
-12.5, -88.5, 716.5, 280.5, 95.5, -160.5, 608.5, 352.5, 171.5, -264.5, 532.5, 456.5,
-332.5, -24.5, 396.5, 344.5, -224.5, -96.5, 288.5, 416.5, -148.5, -200.5, 212.5, 520.5,
-268.5, -24.5, 460.5, 344.5, -160.5, -96.5, 352.5, 416.5, -84.5, -200.5, 276.5, 520.5,
-204.5, -24.5, 524.5, 344.5, -96.5, -96.5, 416.5, 416.5, -20.5, -200.5, 340.5, 520.5,
-140.5, -24.5, 588.5, 344.5, -32.5, -96.5, 480.5, 416.5, 43.5, -200.5, 404.5, 520.5,
-76.5, -24.5, 652.5, 344.5, 31.5, -96.5, 544.5, 416.5, 107.5, -200.5, 468.5, 520.5,
-12.5, -24.5, 716.5, 344.5, 95.5, -96.5, 608.5, 416.5, 171.5, -200.5, 532.5, 520.5}),
ExperimentalPGGParams(
Attrs{false, 5, 3, 32.0f, 32.0f},
{3, 4},
{1, 16, 100, 100},
{1, 3, 100, 200},
{100, 100, 3, 4},
IN_ET,
std::vector<T>{-180.5, -88.5, 180.5, 88.5, -128.5, -128.5, 128.5, 128.5, -92.5, -184.5, 92.5, 184.5},
std::vector<T>{-164.5, -72.5, 196.5, 104.5, -112.5, -112.5, 144.5, 144.5, -76.5, -168.5, 108.5, 200.5,
-132.5, -72.5, 228.5, 104.5, -80.5, -112.5, 176.5, 144.5, -44.5, -168.5, 140.5, 200.5,
-100.5, -72.5, 260.5, 104.5, -48.5, -112.5, 208.5, 144.5, -12.5, -168.5, 172.5, 200.5,
-164.5, -40.5, 196.5, 136.5, -112.5, -80.5, 144.5, 176.5, -76.5, -136.5, 108.5, 232.5,
-132.5, -40.5, 228.5, 136.5, -80.5, -80.5, 176.5, 176.5, -44.5, -136.5, 140.5, 232.5,
-100.5, -40.5, 260.5, 136.5, -48.5, -80.5, 208.5, 176.5, -12.5, -136.5, 172.5, 232.5,
-164.5, -8.5, 196.5, 168.5, -112.5, -48.5, 144.5, 208.5, -76.5, -104.5, 108.5, 264.5,
-132.5, -8.5, 228.5, 168.5, -80.5, -48.5, 176.5, 208.5, -44.5, -104.5, 140.5, 264.5,
-100.5, -8.5, 260.5, 168.5, -48.5, -48.5, 208.5, 208.5, -12.5, -104.5, 172.5, 264.5,
-164.5, 23.5, 196.5, 200.5, -112.5, -16.5, 144.5, 240.5, -76.5, -72.5, 108.5, 296.5,
-132.5, 23.5, 228.5, 200.5, -80.5, -16.5, 176.5, 240.5, -44.5, -72.5, 140.5, 296.5,
-100.5, 23.5, 260.5, 200.5, -48.5, -16.5, 208.5, 240.5, -12.5, -72.5, 172.5, 296.5,
-164.5, 55.5, 196.5, 232.5, -112.5, 15.5, 144.5, 272.5, -76.5, -40.5, 108.5, 328.5,
-132.5, 55.5, 228.5, 232.5, -80.5, 15.5, 176.5, 272.5, -44.5, -40.5, 140.5, 328.5,
-100.5, 55.5, 260.5, 232.5, -48.5, 15.5, 208.5, 272.5, -12.5, -40.5, 172.5, 328.5}),
};
return experimentalPGGParams;
}
std::vector<ExperimentalPGGParams> generateExperimentalPGGCombinedParams() {
const std::vector<std::vector<ExperimentalPGGParams>> experimentalPGGTypeParams {
const std::vector<std::vector<ExperimentalPGGParams>> experimentalPGGTypeParams{
generateExperimentalPGGFloatParams<element::Type_t::f64>(),
generateExperimentalPGGFloatParams<element::Type_t::f32>(),
generateExperimentalPGGFloatParams<element::Type_t::f16>(),
generateExperimentalPGGFloatParams<element::Type_t::bf16>(),
};
};
std::vector<ExperimentalPGGParams> combinedParams;
for (const auto& params : experimentalPGGTypeParams) {
@ -221,6 +235,8 @@ std::vector<ExperimentalPGGParams> generateExperimentalPGGCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_ExperimentalDetectronPriorGridGenerator_With_Hardcoded_Refs, ReferenceExperimentalPGGLayerTest,
testing::ValuesIn(generateExperimentalPGGCombinedParams()), ReferenceExperimentalPGGLayerTest::getTestCaseName);
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_ExperimentalDetectronPriorGridGenerator_With_Hardcoded_Refs,
ReferenceExperimentalPGGLayerTest,
testing::ValuesIn(generateExperimentalPGGCombinedParams()),
ReferenceExperimentalPGGLayerTest::getTestCaseName);
} // namespace

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/experimental_detectron_generate_proposals.hpp"
#include <gtest/gtest.h>
#include "openvino/op/experimental_detectron_generate_proposals.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
@ -16,11 +17,16 @@ namespace {
struct ExperimentalGPParams {
template <class IT>
ExperimentalGPParams(const Attrs& attrs,
const size_t number_of_channels, const size_t height, const size_t width,
const size_t number_of_channels,
const size_t height,
const size_t width,
const element::Type& iType,
const std::vector<IT>& imageSizeInfoValues, const std::vector<IT>& anchorsValues,
const std::vector<IT>& deltasValues, const std::vector<IT>& scoresValues,
const std::vector<IT>& refRoisValues, const std::vector<IT>& refScoresValues,
const std::vector<IT>& imageSizeInfoValues,
const std::vector<IT>& anchorsValues,
const std::vector<IT>& deltasValues,
const std::vector<IT>& scoresValues,
const std::vector<IT>& refRoisValues,
const std::vector<IT>& refScoresValues,
const std::string& testcaseName = "")
: attrs(attrs),
inType(iType),
@ -32,11 +38,11 @@ struct ExperimentalGPParams {
refRoisData(CreateTensor(iType, refRoisValues)),
refScoresData(CreateTensor(iType, refScoresValues)),
testcaseName(testcaseName) {
imageSizeInfoShape = Shape{3};
anchorsShape = Shape{height * width * number_of_channels, 4};
deltasShape = Shape{number_of_channels * 4, height, width};
scoresShape = Shape{number_of_channels, height, width};
}
imageSizeInfoShape = Shape{3};
anchorsShape = Shape{height * width * number_of_channels, 4};
deltasShape = Shape{number_of_channels * 4, height, width};
scoresShape = Shape{number_of_channels, height, width};
}
Attrs attrs;
PartialShape imageSizeInfoShape;
@ -54,7 +60,8 @@ struct ExperimentalGPParams {
std::string testcaseName;
};
class ReferenceExperimentalGPLayerTest : public testing::TestWithParam<ExperimentalGPParams>, public CommonReferenceTest {
class ReferenceExperimentalGPLayerTest : public testing::TestWithParam<ExperimentalGPParams>,
public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
@ -82,12 +89,14 @@ private:
const auto anchors = std::make_shared<op::v0::Parameter>(params.inType, params.anchorsShape);
const auto deltas = std::make_shared<op::v0::Parameter>(params.inType, params.deltasShape);
const auto scores = std::make_shared<op::v0::Parameter>(params.inType, params.scoresShape);
const auto ExperimentalGP = std::make_shared<op::v6::ExperimentalDetectronGenerateProposalsSingleImage>(im_info,
anchors,
deltas,
scores,
params.attrs);
return std::make_shared<ov::Model>(ExperimentalGP->outputs(), ParameterVector {im_info, anchors, deltas, scores});
const auto ExperimentalGP =
std::make_shared<op::v6::ExperimentalDetectronGenerateProposalsSingleImage>(im_info,
anchors,
deltas,
scores,
params.attrs);
return std::make_shared<ov::Model>(ExperimentalGP->outputs(),
ParameterVector{im_info, anchors, deltas, scores});
}
};
@ -99,104 +108,118 @@ template <element::Type_t IN_ET>
std::vector<ExperimentalGPParams> generateExperimentalGPFloatParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<ExperimentalGPParams> experimentalGPParams {
ExperimentalGPParams(Attrs{0, // min_size
0.699999988079071, // nms_threshold
6, // post_nms_count
1000 // pre_nms_count
},
3,
2,
6,
IN_ET,
std::vector<T>{1.0f, 1.0f, 1.0f},
std::vector<T>{1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
std::vector<ExperimentalGPParams> experimentalGPParams{
ExperimentalGPParams(
Attrs{
0, // min_size
0.699999988079071, // nms_threshold
6, // post_nms_count
1000 // pre_nms_count
},
3,
2,
6,
IN_ET,
std::vector<T>{1.0f, 1.0f, 1.0f},
std::vector<T>{
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f},
std::vector<T>{1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f},
std::vector<T>{
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f},
std::vector<T>{5.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 4.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 8.0f, 1.0f},
std::vector<T>{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
std::vector<T>{8.0f, 5.0f, 4.0f, 1.0f, 1.0f, 1.0f},
"eval"),
ExperimentalGPParams(Attrs{0, // min_size
0.699999988079071, // nms_threshold
6, // post_nms_count
1000 // pre_nms_count
},
3,
2,
6,
IN_ET,
std::vector<T>{150.0, 150.0, 1.0},
std::vector<T>{12.0, 68.0, 102.0, 123.0, 46.0, 80.0, 79.0, 128.0, 33.0, 71.0, 127.0, 86.0, 33.0, 56.0, 150.0, 73.0,
5.0, 41.0, 93.0, 150.0, 74.0, 66.0, 106.0, 115.0, 17.0, 37.0, 87.0, 150.0, 31.0, 27.0, 150.0, 39.0,
29.0, 23.0, 112.0, 123.0, 41.0, 37.0, 103.0, 150.0, 8.0, 46.0, 98.0, 111.0, 7.0, 69.0, 114.0, 150.0,
70.0, 21.0, 150.0, 125.0, 54.0, 19.0, 132.0, 68.0, 62.0, 8.0, 150.0, 101.0, 57.0, 81.0, 150.0, 97.0,
79.0, 29.0, 109.0, 130.0, 12.0, 63.0, 100.0, 150.0, 17.0, 33.0, 113.0, 150.0, 90.0, 78.0, 150.0, 111.0,
47.0, 68.0, 150.0, 71.0, 66.0, 103.0, 111.0, 150.0, 4.0, 17.0, 112.0, 94.0, 12.0, 8.0, 119.0, 98.0,
54.0, 56.0, 120.0, 150.0, 56.0, 29.0, 150.0, 31.0, 42.0, 3.0, 139.0, 92.0, 41.0, 65.0, 150.0, 130.0,
49.0, 13.0, 143.0, 30.0, 40.0, 60.0, 150.0, 150.0, 23.0, 73.0, 24.0, 115.0, 56.0, 84.0, 107.0, 108.0,
63.0, 8.0, 142.0, 125.0, 78.0, 37.0, 93.0, 144.0, 40.0, 34.0, 150.0, 46.0, 30.0, 21.0, 150.0, 120.0},
std::vector<T>{9.062256, 10.883133, 9.8441105, 12.694285, 0.41781136, 8.749107, 14.990341, 6.587644, 1.4206103,
13.299262, 12.432549, 2.736371, 0.22732796, 6.3361835, 12.268727, 2.1009045, 4.771589, 2.5131326,
5.610736, 9.3604145, 4.27379, 8.317948, 0.60510135, 6.7446275, 1.0207708, 1.1352817, 1.5785321,
1.718335, 1.8093798, 0.99247587, 1.3233583, 1.7432803, 1.8534478, 1.2593061, 1.7394226, 1.7686696,
1.647999, 1.7611449, 1.3119122, 0.03007332, 1.1106564, 0.55669737, 0.2546148, 1.9181818, 0.7134989,
2.0407224, 1.7211134, 1.8565536, 14.562747, 2.8786168, 0.5927796, 0.2064463, 7.6794515, 8.672126,
10.139171, 8.002429, 7.002932, 12.6314945, 10.550842, 0.15784842, 0.3194304, 10.752157, 3.709805,
11.628928, 0.7136225, 14.619964, 15.177284, 2.2824087, 15.381494, 0.16618137, 7.507227, 11.173228,
0.4923559, 1.8227729, 1.4749299, 1.7833921, 1.2363617, -0.23659119, 1.5737582, 1.779316, 1.9828427,
1.0482665, 1.4900246, 1.3563544, 1.5341306, 0.7634312, 4.6216766e-05, 1.6161222, 1.7512476, 1.9363779,
0.9195784, 1.4906164, -0.03244795, 0.681073, 0.6192401, 1.8033613, 14.146055, 3.4043705, 15.292292,
3.5295358, 11.138999, 9.952057, 5.633434, 12.114562, 9.427372, 12.384038, 9.583308, 8.427233,
15.293704, 3.288159, 11.64898, 9.350885, 2.0037227, 13.523184, 4.4176426, 6.1057625, 14.400079,
8.248259, 11.815807, 15.713364, 1.0023532, 1.3203261, 1.7100681, 0.7407832, 1.09448, 1.7188418,
1.4412547, 1.4862992, 0.74790007, 0.31571656, 0.6398838, 2.0236106, 1.1869069, 1.7265586, 1.2624544,
0.09934269, 1.3508598, 0.85212964, -0.38968498, 1.7059708, 1.6533034, 1.7400402, 1.8123854, -0.43063712},
std::vector<T>{0.7719922, 0.35906568, 0.29054508, 0.18124384, 0.5604661, 0.84750974, 0.98948747, 0.009793862, 0.7184191,
0.5560748, 0.6952493, 0.6732593, 0.3306898, 0.6790913, 0.41128764, 0.34593266, 0.94296855, 0.7348507,
0.24478768, 0.94024557, 0.05405676, 0.06466125, 0.36244348, 0.07942984, 0.10619422, 0.09412837, 0.9053611,
0.22870538, 0.9237487, 0.20986171, 0.5067282, 0.29709867, 0.53138554, 0.189101, 0.4786443, 0.88421875},
std::vector<T>{149, 149, 149, 149, 149, 0, 149, 149, 149, 60.87443542480469, 149, 149, 149, 61.89498901367188, 149,
149, 149, 149, 149, 149, 149, 149, 149, 149},
std::vector<T>{0.9894874691963196,
0.9429685473442078,
0.9402455687522888,
0.9237486720085144,
0.9053611159324646,
0.8842187523841858},
"eval_2"),
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f},
std::vector<T>{5.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 4.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 8.0f, 1.0f},
std::vector<T>{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
std::vector<T>{8.0f, 5.0f, 4.0f, 1.0f, 1.0f, 1.0f},
"eval"),
ExperimentalGPParams(
Attrs{
0, // min_size
0.699999988079071, // nms_threshold
6, // post_nms_count
1000 // pre_nms_count
},
3,
2,
6,
IN_ET,
std::vector<T>{150.0, 150.0, 1.0},
std::vector<T>{
12.0, 68.0, 102.0, 123.0, 46.0, 80.0, 79.0, 128.0, 33.0, 71.0, 127.0, 86.0, 33.0, 56.0, 150.0,
73.0, 5.0, 41.0, 93.0, 150.0, 74.0, 66.0, 106.0, 115.0, 17.0, 37.0, 87.0, 150.0, 31.0, 27.0,
150.0, 39.0, 29.0, 23.0, 112.0, 123.0, 41.0, 37.0, 103.0, 150.0, 8.0, 46.0, 98.0, 111.0, 7.0,
69.0, 114.0, 150.0, 70.0, 21.0, 150.0, 125.0, 54.0, 19.0, 132.0, 68.0, 62.0, 8.0, 150.0, 101.0,
57.0, 81.0, 150.0, 97.0, 79.0, 29.0, 109.0, 130.0, 12.0, 63.0, 100.0, 150.0, 17.0, 33.0, 113.0,
150.0, 90.0, 78.0, 150.0, 111.0, 47.0, 68.0, 150.0, 71.0, 66.0, 103.0, 111.0, 150.0, 4.0, 17.0,
112.0, 94.0, 12.0, 8.0, 119.0, 98.0, 54.0, 56.0, 120.0, 150.0, 56.0, 29.0, 150.0, 31.0, 42.0,
3.0, 139.0, 92.0, 41.0, 65.0, 150.0, 130.0, 49.0, 13.0, 143.0, 30.0, 40.0, 60.0, 150.0, 150.0,
23.0, 73.0, 24.0, 115.0, 56.0, 84.0, 107.0, 108.0, 63.0, 8.0, 142.0, 125.0, 78.0, 37.0, 93.0,
144.0, 40.0, 34.0, 150.0, 46.0, 30.0, 21.0, 150.0, 120.0},
std::vector<T>{
9.062256, 10.883133, 9.8441105, 12.694285, 0.41781136, 8.749107, 14.990341, 6.587644,
1.4206103, 13.299262, 12.432549, 2.736371, 0.22732796, 6.3361835, 12.268727, 2.1009045,
4.771589, 2.5131326, 5.610736, 9.3604145, 4.27379, 8.317948, 0.60510135, 6.7446275,
1.0207708, 1.1352817, 1.5785321, 1.718335, 1.8093798, 0.99247587, 1.3233583, 1.7432803,
1.8534478, 1.2593061, 1.7394226, 1.7686696, 1.647999, 1.7611449, 1.3119122, 0.03007332,
1.1106564, 0.55669737, 0.2546148, 1.9181818, 0.7134989, 2.0407224, 1.7211134, 1.8565536,
14.562747, 2.8786168, 0.5927796, 0.2064463, 7.6794515, 8.672126, 10.139171, 8.002429,
7.002932, 12.6314945, 10.550842, 0.15784842, 0.3194304, 10.752157, 3.709805, 11.628928,
0.7136225, 14.619964, 15.177284, 2.2824087, 15.381494, 0.16618137, 7.507227, 11.173228,
0.4923559, 1.8227729, 1.4749299, 1.7833921, 1.2363617, -0.23659119, 1.5737582, 1.779316,
1.9828427, 1.0482665, 1.4900246, 1.3563544, 1.5341306, 0.7634312, 4.6216766e-05, 1.6161222,
1.7512476, 1.9363779, 0.9195784, 1.4906164, -0.03244795, 0.681073, 0.6192401, 1.8033613,
14.146055, 3.4043705, 15.292292, 3.5295358, 11.138999, 9.952057, 5.633434, 12.114562,
9.427372, 12.384038, 9.583308, 8.427233, 15.293704, 3.288159, 11.64898, 9.350885,
2.0037227, 13.523184, 4.4176426, 6.1057625, 14.400079, 8.248259, 11.815807, 15.713364,
1.0023532, 1.3203261, 1.7100681, 0.7407832, 1.09448, 1.7188418, 1.4412547, 1.4862992,
0.74790007, 0.31571656, 0.6398838, 2.0236106, 1.1869069, 1.7265586, 1.2624544, 0.09934269,
1.3508598, 0.85212964, -0.38968498, 1.7059708, 1.6533034, 1.7400402, 1.8123854, -0.43063712},
std::vector<T>{0.7719922, 0.35906568, 0.29054508, 0.18124384, 0.5604661, 0.84750974,
0.98948747, 0.009793862, 0.7184191, 0.5560748, 0.6952493, 0.6732593,
0.3306898, 0.6790913, 0.41128764, 0.34593266, 0.94296855, 0.7348507,
0.24478768, 0.94024557, 0.05405676, 0.06466125, 0.36244348, 0.07942984,
0.10619422, 0.09412837, 0.9053611, 0.22870538, 0.9237487, 0.20986171,
0.5067282, 0.29709867, 0.53138554, 0.189101, 0.4786443, 0.88421875},
std::vector<T>{
149, 149, 149, 149, 149, 0, 149, 149, 149, 60.87443542480469, 149, 149, 149, 61.89498901367188, 149,
149, 149, 149, 149, 149, 149, 149, 149, 149},
std::vector<T>{0.9894874691963196,
0.9429685473442078,
0.9402455687522888,
0.9237486720085144,
0.9053611159324646,
0.8842187523841858},
"eval_2"),
};
return experimentalGPParams;
}
std::vector<ExperimentalGPParams> generateExperimentalGPCombinedParams() {
const std::vector<std::vector<ExperimentalGPParams>> experimentalGPTypeParams {
const std::vector<std::vector<ExperimentalGPParams>> experimentalGPTypeParams{
generateExperimentalGPFloatParams<element::Type_t::f32>(),
generateExperimentalGPFloatParams<element::Type_t::f16>(),
generateExperimentalGPFloatParams<element::Type_t::bf16>(),
};
};
std::vector<ExperimentalGPParams> combinedParams;
for (const auto& params : experimentalGPTypeParams) {
@ -205,6 +228,8 @@ std::vector<ExperimentalGPParams> generateExperimentalGPCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_ExperimentalDetectronGenerateProposalsSingleImage_With_Hardcoded_Refs, ReferenceExperimentalGPLayerTest,
testing::ValuesIn(generateExperimentalGPCombinedParams()), ReferenceExperimentalGPLayerTest::getTestCaseName);
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_ExperimentalDetectronGenerateProposalsSingleImage_With_Hardcoded_Refs,
ReferenceExperimentalGPLayerTest,
testing::ValuesIn(generateExperimentalGPCombinedParams()),
ReferenceExperimentalGPLayerTest::getTestCaseName);
} // namespace

View File

@ -4,8 +4,8 @@
#include <gtest/gtest.h>
#include "openvino/op/experimental_detectron_roi_feature.hpp"
#include "base_reference_test.hpp"
#include "openvino/op/experimental_detectron_roi_feature.hpp"
using namespace ov;
using namespace reference_tests;
@ -23,7 +23,8 @@ struct ExperimentalROIParams {
std::string test_case_name;
};
class ReferenceExperimentalROILayerTest : public testing::TestWithParam<ExperimentalROIParams>, public CommonReferenceTest {
class ReferenceExperimentalROILayerTest : public testing::TestWithParam<ExperimentalROIParams>,
public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
@ -76,149 +77,67 @@ INSTANTIATE_TEST_SUITE_P(
ReferenceExperimentalROILayerTest,
::testing::Values(
ExperimentalROIParams(
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{2, 4},
ov::element::f32,
std::vector<float>{0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0}),
reference_tests::Tensor(Shape{1, 2, 2, 3},
ov::element::f32,
std::vector<float>{0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0})},
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{2, 2, 3, 3},
ov::element::f32,
std::vector<float>{1.416667,
1.75,
2.083333,
2.416667,
2.75,
3.083333,
3.166667,
3.5,
3.833333,
7.416667,
7.75,
8.083333,
8.416667,
8.75,
9.083334,
9.166666,
9.5,
9.833334,
4.166667,
4.5,
4.833333,
4.166667,
4.5,
4.833333,
2.083333,
2.25,
2.416667,
10.16667,
10.5,
10.83333,
10.16667,
10.5,
10.83333,
5.083333,
5.25,
5.416667}),
reference_tests::Tensor(Shape{2, 4},
ov::element::f32,
std::vector<float>{0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0})},
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(Shape{2, 4},
ov::element::f32,
std::vector<float>{0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0}),
reference_tests::Tensor(
Shape{1, 2, 2, 3},
ov::element::f32,
std::vector<float>{0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0})},
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(
Shape{2, 2, 3, 3},
ov::element::f32,
std::vector<float>{1.416667, 1.75, 2.083333, 2.416667, 2.75, 3.083333, 3.166667, 3.5, 3.833333,
7.416667, 7.75, 8.083333, 8.416667, 8.75, 9.083334, 9.166666, 9.5, 9.833334,
4.166667, 4.5, 4.833333, 4.166667, 4.5, 4.833333, 2.083333, 2.25, 2.416667,
10.16667, 10.5, 10.83333, 10.16667, 10.5, 10.83333, 5.083333, 5.25, 5.416667}),
reference_tests::Tensor(Shape{2, 4},
ov::element::f32,
std::vector<float>{0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0})},
"experimental_detectron_roi_feature_eval_f32"),
ExperimentalROIParams(
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{2, 4},
ov::element::f16,
std::vector<ov::float16>{0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0}),
reference_tests::Tensor(Shape{1, 2, 2, 3},
ov::element::f16,
std::vector<ov::float16>{0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0})},
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{2, 2, 3, 3},
ov::element::f16,
std::vector<ov::float16>{1.416667,
1.75,
2.083333,
2.416667,
2.75,
3.083333,
3.166667,
3.5,
3.833333,
7.416667,
7.75,
8.083333,
8.416667,
8.75,
9.083334,
9.166666,
9.5,
9.833334,
4.166667,
4.5,
4.833333,
4.166667,
4.5,
4.833333,
2.083333,
2.25,
2.416667,
10.16667,
10.5,
10.83333,
10.16667,
10.5,
10.83333,
5.083333,
5.25,
5.416667}),
reference_tests::Tensor(Shape{2, 4},
ov::element::f16,
std::vector<ov::float16>{0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0})},
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(Shape{2, 4},
ov::element::f16,
std::vector<ov::float16>{0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0}),
reference_tests::Tensor(
Shape{1, 2, 2, 3},
ov::element::f16,
std::vector<ov::float16>{0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0})},
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(Shape{2, 2, 3, 3},
ov::element::f16,
std::vector<ov::float16>{1.416667, 1.75, 2.083333, 2.416667, 2.75, 3.083333,
3.166667, 3.5, 3.833333, 7.416667, 7.75, 8.083333,
8.416667, 8.75, 9.083334, 9.166666, 9.5, 9.833334,
4.166667, 4.5, 4.833333, 4.166667, 4.5, 4.833333,
2.083333, 2.25, 2.416667, 10.16667, 10.5, 10.83333,
10.16667, 10.5, 10.83333, 5.083333, 5.25, 5.416667}),
reference_tests::Tensor(Shape{2, 4},
ov::element::f16,
std::vector<ov::float16>{0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0})},
"experimental_detectron_roi_feature_eval_f16"),
ExperimentalROIParams(
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{2, 4},
ov::element::bf16,
std::vector<ov::bfloat16>{0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0}),
reference_tests::Tensor(Shape{1, 2, 2, 3},
ov::element::bf16,
std::vector<ov::bfloat16>{0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0})},
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{2, 2, 3, 3},
ov::element::bf16,
std::vector<ov::bfloat16>{1.416667,
1.75,
2.083333,
2.416667,
2.75,
3.083333,
3.166667,
3.5,
3.833333,
7.416667,
7.75,
8.083333,
8.416667,
8.75,
9.083334,
9.166666,
9.5,
9.833334,
4.166667,
4.5,
4.833333,
4.166667,
4.5,
4.833333,
2.083333,
2.25,
2.416667,
10.16667,
10.5,
10.83333,
10.16667,
10.5,
10.83333,
5.083333,
5.25,
5.416667}),
reference_tests::Tensor(Shape{2, 4},
ov::element::bf16,
std::vector<ov::bfloat16>{0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0})},
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(Shape{2, 4},
ov::element::bf16,
std::vector<ov::bfloat16>{0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0}),
reference_tests::Tensor(
Shape{1, 2, 2, 3},
ov::element::bf16,
std::vector<ov::bfloat16>{0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0})},
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(Shape{2, 2, 3, 3},
ov::element::bf16,
std::vector<ov::bfloat16>{1.416667, 1.75, 2.083333, 2.416667, 2.75, 3.083333,
3.166667, 3.5, 3.833333, 7.416667, 7.75, 8.083333,
8.416667, 8.75, 9.083334, 9.166666, 9.5, 9.833334,
4.166667, 4.5, 4.833333, 4.166667, 4.5, 4.833333,
2.083333, 2.25, 2.416667, 10.16667, 10.5, 10.83333,
10.16667, 10.5, 10.83333, 5.083333, 5.25, 5.416667}),
reference_tests::Tensor(Shape{2, 4},
ov::element::bf16,
std::vector<ov::bfloat16>{0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0})},
"experimental_detectron_roi_feature_eval_bf16")));

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/experimental_detectron_topkrois.hpp"
#include <gtest/gtest.h>
#include "openvino/op/experimental_detectron_topkrois.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
@ -12,11 +13,16 @@ using namespace ov;
namespace {
struct ExperimentalDetectronTopKROIsParams {
ExperimentalDetectronTopKROIsParams(
const reference_tests::Tensor& dataTensor, const reference_tests::Tensor& probsTensor, const int32_t numRois,
const reference_tests::Tensor& expectedTensor, const std::string& testcaseName = "") :
dataTensor(dataTensor), probsTensor(probsTensor), numRois(numRois),
expectedTensor(expectedTensor), testcaseName(testcaseName) {}
ExperimentalDetectronTopKROIsParams(const reference_tests::Tensor& dataTensor,
const reference_tests::Tensor& probsTensor,
const int32_t numRois,
const reference_tests::Tensor& expectedTensor,
const std::string& testcaseName = "")
: dataTensor(dataTensor),
probsTensor(probsTensor),
numRois(numRois),
expectedTensor(expectedTensor),
testcaseName(testcaseName) {}
reference_tests::Tensor dataTensor;
reference_tests::Tensor probsTensor;
@ -25,7 +31,8 @@ struct ExperimentalDetectronTopKROIsParams {
std::string testcaseName;
};
class ReferenceExperimentalDetectronTopKROIsTest : public testing::TestWithParam<ExperimentalDetectronTopKROIsParams>, public CommonReferenceTest {
class ReferenceExperimentalDetectronTopKROIsTest : public testing::TestWithParam<ExperimentalDetectronTopKROIsParams>,
public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
@ -70,7 +77,7 @@ TEST_P(ReferenceExperimentalDetectronTopKROIsTest, CompareWithRefs) {
template <element::Type_t ET>
std::vector<ExperimentalDetectronTopKROIsParams> generateParams() {
using T = typename element_type_traits<ET>::value_type;
std::vector<ExperimentalDetectronTopKROIsParams> params {
std::vector<ExperimentalDetectronTopKROIsParams> params{
ExperimentalDetectronTopKROIsParams(
reference_tests::Tensor(ET, {2, 4}, std::vector<T>{1.0f, 1.0f, 3.0f, 4.0f, 2.0f, 1.0f, 5.0f, 7.0f}),
reference_tests::Tensor(ET, {2}, std::vector<T>{0.5f, 0.3f}),
@ -78,8 +85,24 @@ std::vector<ExperimentalDetectronTopKROIsParams> generateParams() {
reference_tests::Tensor(ET, {1, 4}, std::vector<T>{1.0, 1.0, 3.0, 4.0}),
"experimental_detectron_topk_rois_eval"),
ExperimentalDetectronTopKROIsParams(
reference_tests::Tensor(ET, {4, 4}, std::vector<T>{1.0f, 1.0f, 4.0f, 5.0f, 3.0f, 2.0f, 7.0f, 9.0f,
10.0f, 15.0f, 13.0f, 17.0f, 13.0f, 10.0f, 18.0f, 15.0f}),
reference_tests::Tensor(ET,
{4, 4},
std::vector<T>{1.0f,
1.0f,
4.0f,
5.0f,
3.0f,
2.0f,
7.0f,
9.0f,
10.0f,
15.0f,
13.0f,
17.0f,
13.0f,
10.0f,
18.0f,
15.0f}),
reference_tests::Tensor(ET, {4}, std::vector<T>{0.1f, 0.7f, 0.5f, 0.9f}),
2,
reference_tests::Tensor(ET, {2, 4}, std::vector<T>{13.0f, 10.0f, 18.0f, 15.0f, 3.0f, 2.0f, 7.0f, 9.0f}),
@ -89,7 +112,7 @@ std::vector<ExperimentalDetectronTopKROIsParams> generateParams() {
}
std::vector<ExperimentalDetectronTopKROIsParams> generateCombinedParams() {
const std::vector<std::vector<ExperimentalDetectronTopKROIsParams>> generatedParams {
const std::vector<std::vector<ExperimentalDetectronTopKROIsParams>> generatedParams{
generateParams<element::Type_t::bf16>(),
generateParams<element::Type_t::f16>(),
generateParams<element::Type_t::f32>(),
@ -103,6 +126,8 @@ std::vector<ExperimentalDetectronTopKROIsParams> generateCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_ExperimentalDetectronTopKROIs_With_Hardcoded_Refs, ReferenceExperimentalDetectronTopKROIsTest,
testing::ValuesIn(generateCombinedParams()), ReferenceExperimentalDetectronTopKROIsTest::getTestCaseName);
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_ExperimentalDetectronTopKROIs_With_Hardcoded_Refs,
ReferenceExperimentalDetectronTopKROIsTest,
testing::ValuesIn(generateCombinedParams()),
ReferenceExperimentalDetectronTopKROIsTest::getTestCaseName);
} // namespace

View File

@ -4,9 +4,9 @@
#include <gtest/gtest.h>
#include "openvino/opsets/opset3.hpp"
#include "openvino/opsets/opset1.hpp"
#include "base_reference_test.hpp"
#include "openvino/opsets/opset1.hpp"
#include "openvino/opsets/opset3.hpp"
using namespace reference_tests;
using namespace ov;
@ -32,7 +32,8 @@ struct Builder : ParamsBuilder<ExtractImagePatchesParams> {
REFERENCE_TESTS_ADD_SET_PARAM(Builder, testcaseName);
};
class ReferenceExtractImagePatchesTest : public testing::TestWithParam<ExtractImagePatchesParams>, public CommonReferenceTest {
class ReferenceExtractImagePatchesTest : public testing::TestWithParam<ExtractImagePatchesParams>,
public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
@ -78,148 +79,89 @@ TEST_P(ReferenceExtractImagePatchesTest, CompareWithRefs) {
template <element::Type_t ET>
std::vector<ExtractImagePatchesParams> generateParams() {
using T = typename element_type_traits<ET>::value_type;
std::vector<ExtractImagePatchesParams> params {
Builder {}
.data({ET, {1, 1, 10, 10}, std::vector<T>{
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
91, 92, 93, 94, 95, 96, 97, 98, 99, 100}})
std::vector<ExtractImagePatchesParams> params{
Builder{}
.data({ET,
{1, 1, 10, 10},
std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100}})
.sizes({3, 3})
.strides({5, 5})
.rates({1, 1})
.autoPad(op::PadType::VALID)
.expectedResult({ET, {1, 9, 2, 2}, std::vector<T>{
1, 6, 51, 56,
2, 7, 52, 57,
3, 8, 53, 58,
11, 16, 61, 66,
12, 17, 62, 67,
13, 18, 63, 68,
21, 26, 71, 76,
22, 27, 72, 77,
23, 28, 73, 78}}),
.expectedResult({ET, {1, 9, 2, 2}, std::vector<T>{1, 6, 51, 56, 2, 7, 52, 57, 3, 8, 53, 58,
11, 16, 61, 66, 12, 17, 62, 67, 13, 18, 63, 68,
21, 26, 71, 76, 22, 27, 72, 77, 23, 28, 73, 78}}),
Builder {}
.data({ET, {1, 1, 10, 10}, std::vector<T>{
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
91, 92, 93, 94, 95, 96, 97, 98, 99, 100}})
Builder{}
.data({ET,
{1, 1, 10, 10},
std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100}})
.sizes({4, 4})
.strides({8, 8})
.rates({1, 1})
.autoPad(op::PadType::VALID)
.expectedResult({ET, {1, 16, 1, 1}, std::vector<T>{
1, 2, 3, 4,
11, 12, 13, 14,
21, 22, 23, 24,
31, 32, 33, 34}}),
.expectedResult(
{ET, {1, 16, 1, 1}, std::vector<T>{1, 2, 3, 4, 11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34}}),
Builder {}
.data({ET, {1, 1, 10, 10}, std::vector<T>{
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
91, 92, 93, 94, 95, 96, 97, 98, 99, 100}})
Builder{}
.data({ET,
{1, 1, 10, 10},
std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100}})
.sizes({4, 4})
.strides({9, 9})
.rates({1, 1})
.autoPad(op::PadType::SAME_UPPER)
.expectedResult({ET, {1, 16, 2, 2}, std::vector<T>{
0, 0, 0, 89,
0, 0, 81, 90,
0, 0, 82, 0,
0, 0, 83, 0,
0, 9, 0, 99,
1, 10, 91, 100,
2, 0, 92, 0,
3, 0, 93, 0,
0, 19, 0, 0,
11, 20, 0, 0,
12, 0, 0, 0,
13, 0, 0, 0,
0, 29, 0, 0,
21, 30, 0, 0,
22, 0, 0, 0,
23, 0, 0, 0}}),
.expectedResult(
{ET, {1, 16, 2, 2}, std::vector<T>{0, 0, 0, 89, 0, 0, 81, 90, 0, 0, 82, 0, 0, 0, 83, 0,
0, 9, 0, 99, 1, 10, 91, 100, 2, 0, 92, 0, 3, 0, 93, 0,
0, 19, 0, 0, 11, 20, 0, 0, 12, 0, 0, 0, 13, 0, 0, 0,
0, 29, 0, 0, 21, 30, 0, 0, 22, 0, 0, 0, 23, 0, 0, 0}}),
Builder {}
.data({ET, {1, 1, 10, 10}, std::vector<T>{
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
91, 92, 93, 94, 95, 96, 97, 98, 99, 100}})
Builder{}
.data({ET,
{1, 1, 10, 10},
std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100}})
.sizes({3, 3})
.strides({5, 5})
.rates({2, 2})
.autoPad(op::PadType::VALID)
.expectedResult({ET, {1, 9, 2, 2}, std::vector<T>{
1, 6, 51, 56,
3, 8, 53, 58,
5, 10, 55, 60,
21, 26, 71, 76,
23, 28, 73, 78,
25, 30, 75, 80,
41, 46, 91, 96,
43, 48, 93, 98,
45, 50, 95, 100}}),
.expectedResult({ET, {1, 9, 2, 2}, std::vector<T>{1, 6, 51, 56, 3, 8, 53, 58, 5, 10, 55, 60,
21, 26, 71, 76, 23, 28, 73, 78, 25, 30, 75, 80,
41, 46, 91, 96, 43, 48, 93, 98, 45, 50, 95, 100}}),
Builder {}
.data({ET, {1, 2, 5, 5}, std::vector<T>{
1, 2, 3, 4, 5,
6, 7, 8, 9, 10,
11, 12, 13, 14, 15,
16, 17, 18, 19, 20,
21, 22, 23, 24, 25,
26, 27, 28, 29, 30,
31, 32, 33, 34, 35,
36, 37, 38, 39, 40,
41, 42, 43, 44, 45,
46, 47, 48, 49, 50}})
Builder{}
.data({ET, {1, 2, 5, 5}, std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50}})
.sizes({2, 2})
.strides({3, 3})
.rates({1, 1})
.autoPad(op::PadType::VALID)
.expectedResult({ET, {1, 8, 2, 2}, std::vector<T>{
1, 4, 16, 19,
26, 29, 41, 44,
2, 5, 17, 20,
27, 30, 42, 45,
6, 9, 21, 24,
31, 34, 46, 49,
7, 10, 22, 25,
32, 35, 47, 50}}),
.expectedResult(
{ET, {1, 8, 2, 2}, std::vector<T>{1, 4, 16, 19, 26, 29, 41, 44, 2, 5, 17, 20, 27, 30, 42, 45,
6, 9, 21, 24, 31, 34, 46, 49, 7, 10, 22, 25, 32, 35, 47, 50}}),
};
return params;
}
std::vector<ExtractImagePatchesParams> generateCombinedParams() {
const std::vector<std::vector<ExtractImagePatchesParams>> generatedParams {
const std::vector<std::vector<ExtractImagePatchesParams>> generatedParams{
generateParams<element::Type_t::i8>(),
generateParams<element::Type_t::i16>(),
generateParams<element::Type_t::i32>(),
@ -241,6 +183,8 @@ std::vector<ExtractImagePatchesParams> generateCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_ExtractImagePatches_With_Hardcoded_Refs, ReferenceExtractImagePatchesTest,
testing::ValuesIn(generateCombinedParams()), ReferenceExtractImagePatchesTest::getTestCaseName);
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_ExtractImagePatches_With_Hardcoded_Refs,
ReferenceExtractImagePatchesTest,
testing::ValuesIn(generateCombinedParams()),
ReferenceExtractImagePatchesTest::getTestCaseName);
} // namespace

View File

@ -2,10 +2,12 @@
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
#include "openvino/op/eye.hpp"
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
using namespace ov;
using namespace reference_tests;
@ -20,13 +22,13 @@ struct EyeParams {
const reference_tests::Tensor& expected_tensor,
const std::string& test_case_name,
bool is_dyn_shape_test = false)
: num_rows(num_rows),
num_columns(num_columns),
diagonal_index(diagonal_index),
output_type(output_type),
expected_tensor(expected_tensor),
test_case_name(test_case_name),
set_dynamic_shape(is_dyn_shape_test) {}
: num_rows(num_rows),
num_columns(num_columns),
diagonal_index(diagonal_index),
output_type(output_type),
expected_tensor(expected_tensor),
test_case_name(test_case_name),
set_dynamic_shape(is_dyn_shape_test) {}
reference_tests::Tensor num_rows;
reference_tests::Tensor num_columns;
@ -46,14 +48,14 @@ struct EyeBatchShapeParams {
const reference_tests::Tensor& expected_tensor,
const std::string& test_case_name,
bool is_dyn_shape_test = false)
: num_rows(num_rows),
num_columns(num_columns),
diagonal_index(diagonal_index),
batch_shape(batch_shape),
output_type(output_type),
expected_tensor(expected_tensor),
test_case_name(test_case_name),
set_dynamic_shape(is_dyn_shape_test) {}
: num_rows(num_rows),
num_columns(num_columns),
diagonal_index(diagonal_index),
batch_shape(batch_shape),
output_type(output_type),
expected_tensor(expected_tensor),
test_case_name(test_case_name),
set_dynamic_shape(is_dyn_shape_test) {}
reference_tests::Tensor num_rows;
reference_tests::Tensor num_columns;
@ -88,9 +90,15 @@ private:
const reference_tests::Tensor& diagonal_index,
const element::Type& output_type,
bool set_dynamic_shape = false) {
const auto in1 = std::make_shared<op::v0::Parameter>(num_rows.type, set_dynamic_shape ? PartialShape::dynamic() : num_rows.shape);
const auto in2 = std::make_shared<op::v0::Parameter>(num_columns.type, set_dynamic_shape ? PartialShape::dynamic() : num_columns.shape);
const auto in3 = std::make_shared<op::v0::Parameter>(diagonal_index.type, set_dynamic_shape ? PartialShape::dynamic() : diagonal_index.shape);
const auto in1 =
std::make_shared<op::v0::Parameter>(num_rows.type,
set_dynamic_shape ? PartialShape::dynamic() : num_rows.shape);
const auto in2 =
std::make_shared<op::v0::Parameter>(num_columns.type,
set_dynamic_shape ? PartialShape::dynamic() : num_columns.shape);
const auto in3 =
std::make_shared<op::v0::Parameter>(diagonal_index.type,
set_dynamic_shape ? PartialShape::dynamic() : diagonal_index.shape);
const auto Eye = std::make_shared<op::v9::Eye>(in1, in2, in3, output_type);
return std::make_shared<Model>(NodeVector{Eye}, ParameterVector{in1, in2, in3});
}
@ -106,7 +114,10 @@ public:
params.batch_shape,
params.output_type,
params.set_dynamic_shape);
inputData = {params.num_rows.data, params.num_columns.data, params.diagonal_index.data, params.batch_shape.data};
inputData = {params.num_rows.data,
params.num_columns.data,
params.diagonal_index.data,
params.batch_shape.data};
refOutData = {params.expected_tensor.data};
}
@ -121,252 +132,213 @@ private:
const reference_tests::Tensor& batch_shape,
const element::Type& output_type,
bool set_dynamic_shape = false) {
const auto in1 = std::make_shared<op::v0::Parameter>(num_rows.type, set_dynamic_shape ? PartialShape::dynamic() : num_rows.shape);
const auto in2 = std::make_shared<op::v0::Parameter>(num_columns.type, set_dynamic_shape ? PartialShape::dynamic() : num_columns.shape);
const auto in3 = std::make_shared<op::v0::Parameter>(diagonal_index.type, set_dynamic_shape ? PartialShape::dynamic() : diagonal_index.shape);
const auto in4 = std::make_shared<op::v0::Parameter>(batch_shape.type, set_dynamic_shape ? PartialShape::dynamic() : batch_shape.shape);
const auto in1 =
std::make_shared<op::v0::Parameter>(num_rows.type,
set_dynamic_shape ? PartialShape::dynamic() : num_rows.shape);
const auto in2 =
std::make_shared<op::v0::Parameter>(num_columns.type,
set_dynamic_shape ? PartialShape::dynamic() : num_columns.shape);
const auto in3 =
std::make_shared<op::v0::Parameter>(diagonal_index.type,
set_dynamic_shape ? PartialShape::dynamic() : diagonal_index.shape);
const auto in4 =
std::make_shared<op::v0::Parameter>(batch_shape.type,
set_dynamic_shape ? PartialShape::dynamic() : batch_shape.shape);
const auto Eye = std::make_shared<op::v9::Eye>(in1, in2, in3, in4, output_type);
return std::make_shared<Model>(NodeVector{Eye}, ParameterVector{in1, in2, in3, in4});
}
};
std::vector<EyeParams> generateEyeParams(bool is_dyn_shape_test = false) {
std::vector<EyeParams> test_params {
std::vector<EyeParams> test_params{
EyeParams(reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{3}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{0}},
element::Type_t::f32,
reference_tests::Tensor{{3, 2}, element::f32, std::vector<float>{1, 0,
0, 1,
0, 0}},
"float32_default_3x2", is_dyn_shape_test),
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{0}},
element::Type_t::f32,
reference_tests::Tensor{{3, 2}, element::f32, std::vector<float>{1, 0, 0, 1, 0, 0}},
"float32_default_3x2",
is_dyn_shape_test),
EyeParams(reference_tests::Tensor{{}, element::i32, std::vector<int32_t>{2}},
reference_tests::Tensor{{}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{}, element::i32, std::vector<int32_t>{2}},
element::Type_t::i8,
reference_tests::Tensor{{2, 4}, element::i8, std::vector<int8_t>{0, 0, 1, 0,
0, 0, 0, 1}},
"int8_diag=2_2x4", is_dyn_shape_test),
reference_tests::Tensor{{}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{}, element::i32, std::vector<int32_t>{2}},
element::Type_t::i8,
reference_tests::Tensor{{2, 4}, element::i8, std::vector<int8_t>{0, 0, 1, 0, 0, 0, 0, 1}},
"int8_diag=2_2x4",
is_dyn_shape_test),
EyeParams(reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
reference_tests::Tensor{{}, element::i32, std::vector<int32_t>{-3}},
element::Type_t::i64,
reference_tests::Tensor{{4, 2}, element::i64, std::vector<int64_t>{0, 0,
0, 0,
0, 0,
1, 0}},
"int64_diag=-3_4x2", is_dyn_shape_test),
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
reference_tests::Tensor{{}, element::i32, std::vector<int32_t>{-3}},
element::Type_t::i64,
reference_tests::Tensor{{4, 2}, element::i64, std::vector<int64_t>{0, 0, 0, 0, 0, 0, 1, 0}},
"int64_diag=-3_4x2",
is_dyn_shape_test),
EyeParams(reference_tests::Tensor{{}, element::i32, std::vector<int32_t>{1}},
reference_tests::Tensor{{}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{}, element::i32, std::vector<int32_t>{10}},
element::Type_t::i8,
reference_tests::Tensor{{1, 4}, element::i8, std::vector<int8_t>{0, 0, 0, 0}},
"int8_empty_1x4", is_dyn_shape_test)};
reference_tests::Tensor{{}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{}, element::i32, std::vector<int32_t>{10}},
element::Type_t::i8,
reference_tests::Tensor{{1, 4}, element::i8, std::vector<int8_t>{0, 0, 0, 0}},
"int8_empty_1x4",
is_dyn_shape_test)};
return test_params;
}
std::vector<EyeBatchShapeParams> generateEyeBatchShapeParams(bool is_dyn_shape_test = false) {
std::vector<EyeBatchShapeParams> test_params {
EyeBatchShapeParams(reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{3}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{3}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{0}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
element::Type_t::f32,
reference_tests::Tensor{{2, 3, 3}, element::f32, std::vector<float>{1, 0, 0,
0, 1, 0,
0, 0, 1,
1, 0, 0,
0, 1, 0,
0, 0, 1}},
"f32_2x3x3_diag0", is_dyn_shape_test),
EyeBatchShapeParams(reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{0}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
element::Type_t::f32,
reference_tests::Tensor{{2, 3, 3}, element::f32, std::vector<float>{1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1,
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1}},
"f32_2x4x4_diag0", is_dyn_shape_test),
EyeBatchShapeParams(reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{3}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{0}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
element::Type_t::f32,
reference_tests::Tensor{{2, 3, 4}, element::f32, std::vector<float>{1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0}},
"f32_2x3x4_diag0", is_dyn_shape_test),
EyeBatchShapeParams(reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{3}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{0}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
element::Type_t::i8,
reference_tests::Tensor{{2, 4, 3}, element::i8, std::vector<int8_t>{1, 0, 0,
0, 1, 0,
0, 0, 1,
0, 0, 0,
1, 0, 0,
0, 1, 0,
0, 0, 1,
0, 0, 0}},
"f32_2x4x3_diag0", is_dyn_shape_test),
EyeBatchShapeParams(reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{3}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{1}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
element::Type_t::f32,
reference_tests::Tensor{{2, 3, 4}, element::f32, std::vector<float>{0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1}},
"f32_2x3x4_diag1", is_dyn_shape_test),
EyeBatchShapeParams(reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{3}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{1}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
element::Type_t::f32,
reference_tests::Tensor{{2, 4, 3}, element::f32, std::vector<float>{0, 1, 0,
0, 0, 1,
0, 0, 0,
0, 0, 0,
0, 1, 0,
0, 0, 1,
0, 0, 0,
0, 0, 0}},
"f32_2x4x3_diag1", is_dyn_shape_test),
EyeBatchShapeParams(reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{3}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
element::Type_t::i8,
reference_tests::Tensor{{2, 3, 4}, element::i8, std::vector<int8_t>{0, 0, 1, 0,
0, 0, 0, 1,
0, 0, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1,
0, 0, 0, 0}},
"i8_2x3x4_diag2", is_dyn_shape_test),
EyeBatchShapeParams(reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{3}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
element::Type_t::i8,
reference_tests::Tensor{{2, 4, 3}, element::i8, std::vector<int8_t>{0, 0, 1,
0, 0, 0,
0, 0, 0,
0, 0, 0,
0, 0, 1,
0, 0, 0,
0, 0, 0,
0, 0, 0}},
"i8_2x4x3_diag2", is_dyn_shape_test),
EyeBatchShapeParams(reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{3}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{-1}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
element::Type_t::i8,
reference_tests::Tensor{{2, 3, 4}, element::i8, std::vector<int8_t>{0, 0, 0, 0,
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 0, 0,
1, 0, 0, 0,
0, 1, 0, 0}},
"i8_2x3x4_diag-1", is_dyn_shape_test),
EyeBatchShapeParams(reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{3}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{-1}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
element::Type_t::i8,
reference_tests::Tensor{{2, 4, 3}, element::i8, std::vector<int8_t>{0, 0, 0,
1, 0, 0,
0, 1, 0,
0, 0, 1,
0, 0, 0,
1, 0, 0,
0, 1, 0,
0, 0, 1}},
"i8_2x4x3_diag-1", is_dyn_shape_test),
EyeBatchShapeParams(reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{3}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{-2}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
element::Type_t::i8,
reference_tests::Tensor{{2, 3, 4}, element::i8, std::vector<int8_t>{0, 0, 0, 0,
0, 0, 0, 0,
1, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
1, 0, 0, 0}},
"i8_2x3x4_diag-2", is_dyn_shape_test),
EyeBatchShapeParams(reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{3}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{-2}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
element::Type_t::i8,
reference_tests::Tensor{{2, 4, 3}, element::i8, std::vector<int8_t>{0, 0, 0,
0, 0, 0,
1, 0, 0,
0, 1, 0,
0, 0, 0,
0, 0, 0,
1, 0, 0,
0, 1, 0}},
"i8_2x4x3_diag-2", is_dyn_shape_test),
EyeBatchShapeParams(reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{6}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{5}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{1}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
element::Type_t::i32,
reference_tests::Tensor{{2, 6, 5}, element::i32, std::vector<int32_t>{0, 1, 0, 0, 0,
0, 0, 1, 0, 0,
0, 0, 0, 1, 0,
0, 0, 0, 0, 1,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 1, 0, 0, 0,
0, 0, 1, 0, 0,
0, 0, 0, 1, 0,
0, 0, 0, 0, 1,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0}},
"int32_2x6x5_diag1", is_dyn_shape_test),
EyeBatchShapeParams(reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
reference_tests::Tensor{{2}, element::i32, std::vector<int32_t>{2, 2}},
element::Type_t::i64,
reference_tests::Tensor{{2, 2, 4, 2}, element::i64, std::vector<int64_t>{0, 0, 1, 0,
0, 0, 0, 1,
0, 0, 1, 0,
0, 0, 0, 1,
0, 0, 1, 0,
0, 0, 0, 1,
0, 0, 1, 0,
0, 0, 0, 1}},
"int64_2x2x3x3", is_dyn_shape_test),
EyeBatchShapeParams(reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{3}},
reference_tests::Tensor{{2}, element::i32, std::vector<int32_t>{1, 3}},
element::Type_t::u8,
reference_tests::Tensor{{2, 3, 3}, element::u8, std::vector<uint8_t>{0, 0,
0, 0,
0, 0,
0, 0,
0, 0,
0, 0}},
"uint8_1x3x2x2", is_dyn_shape_test)};
std::vector<EyeBatchShapeParams> test_params{
EyeBatchShapeParams(
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{3}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{3}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{0}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
element::Type_t::f32,
reference_tests::Tensor{{2, 3, 3},
element::f32,
std::vector<float>{1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1}},
"f32_2x3x3_diag0",
is_dyn_shape_test),
EyeBatchShapeParams(
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{0}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
element::Type_t::f32,
reference_tests::Tensor{{2, 3, 3}, element::f32, std::vector<float>{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1,
0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1,
0, 0, 0, 0, 1, 0, 0, 0, 0, 1}},
"f32_2x4x4_diag0",
is_dyn_shape_test),
EyeBatchShapeParams(
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{3}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{0}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
element::Type_t::f32,
reference_tests::Tensor{{2, 3, 4}, element::f32, std::vector<float>{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0,
1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0}},
"f32_2x3x4_diag0",
is_dyn_shape_test),
EyeBatchShapeParams(
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{3}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{0}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
element::Type_t::i8,
reference_tests::Tensor{{2, 4, 3}, element::i8, std::vector<int8_t>{1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,
1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}},
"f32_2x4x3_diag0",
is_dyn_shape_test),
EyeBatchShapeParams(
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{3}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{1}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
element::Type_t::f32,
reference_tests::Tensor{{2, 3, 4}, element::f32, std::vector<float>{0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1,
0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}},
"f32_2x3x4_diag1",
is_dyn_shape_test),
EyeBatchShapeParams(
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{3}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{1}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
element::Type_t::f32,
reference_tests::Tensor{{2, 4, 3}, element::f32, std::vector<float>{0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0}},
"f32_2x4x3_diag1",
is_dyn_shape_test),
EyeBatchShapeParams(
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{3}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
element::Type_t::i8,
reference_tests::Tensor{{2, 3, 4}, element::i8, std::vector<int8_t>{0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0}},
"i8_2x3x4_diag2",
is_dyn_shape_test),
EyeBatchShapeParams(
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{3}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
element::Type_t::i8,
reference_tests::Tensor{{2, 4, 3}, element::i8, std::vector<int8_t>{0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
"i8_2x4x3_diag2",
is_dyn_shape_test),
EyeBatchShapeParams(
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{3}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{-1}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
element::Type_t::i8,
reference_tests::Tensor{{2, 3, 4}, element::i8, std::vector<int8_t>{0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0}},
"i8_2x3x4_diag-1",
is_dyn_shape_test),
EyeBatchShapeParams(
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{3}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{-1}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
element::Type_t::i8,
reference_tests::Tensor{{2, 4, 3}, element::i8, std::vector<int8_t>{0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1,
0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1}},
"i8_2x4x3_diag-1",
is_dyn_shape_test),
EyeBatchShapeParams(
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{3}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{-2}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
element::Type_t::i8,
reference_tests::Tensor{{2, 3, 4}, element::i8, std::vector<int8_t>{0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0}},
"i8_2x3x4_diag-2",
is_dyn_shape_test),
EyeBatchShapeParams(
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{3}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{-2}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
element::Type_t::i8,
reference_tests::Tensor{{2, 4, 3}, element::i8, std::vector<int8_t>{0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0}},
"i8_2x4x3_diag-2",
is_dyn_shape_test),
EyeBatchShapeParams(
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{6}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{5}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{1}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
element::Type_t::i32,
reference_tests::Tensor{{2, 6, 5},
element::i32,
std::vector<int32_t>{0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
"int32_2x6x5_diag1",
is_dyn_shape_test),
EyeBatchShapeParams(
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{4}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
reference_tests::Tensor{{2}, element::i32, std::vector<int32_t>{2, 2}},
element::Type_t::i64,
reference_tests::Tensor{{2, 2, 4, 2}, element::i64, std::vector<int64_t>{0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1,
0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0,
0, 1, 0, 0, 1, 0, 0, 0, 0, 1}},
"int64_2x2x3x3",
is_dyn_shape_test),
EyeBatchShapeParams(
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{2}},
reference_tests::Tensor{{1}, element::i32, std::vector<int32_t>{3}},
reference_tests::Tensor{{2}, element::i32, std::vector<int32_t>{1, 3}},
element::Type_t::u8,
reference_tests::Tensor{{2, 3, 3}, element::u8, std::vector<uint8_t>{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
"uint8_1x3x2x2",
is_dyn_shape_test)};
return test_params;
}
@ -394,18 +366,16 @@ TEST_P(ReferenceEyeBatchShapeLayerTest, EyeRectangleBatchShapeWithHardcodedRefs)
} // namespace
INSTANTIATE_TEST_SUITE_P(
smoke_Eye_With_Hardcoded_Refs,
ReferenceEyeLayerTest,
// Generate params (3 inputs) with static and dynamic shapes
::testing::ValuesIn(generateEyeCombinedParams()),
ReferenceEyeLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Eye_With_Hardcoded_Refs,
ReferenceEyeLayerTest,
// Generate params (3 inputs) with static and dynamic shapes
::testing::ValuesIn(generateEyeCombinedParams()),
ReferenceEyeLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(
smoke_EyeBatchShape_With_Hardcoded_Refs,
ReferenceEyeBatchShapeLayerTest,
// Generate params (4 inputs) with static and dynamic shapes
::testing::ValuesIn(generateEyeBatchShapeCombinedParams()),
ReferenceEyeBatchShapeLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_EyeBatchShape_With_Hardcoded_Refs,
ReferenceEyeBatchShapeLayerTest,
// Generate params (4 inputs) with static and dynamic shapes
::testing::ValuesIn(generateEyeBatchShapeCombinedParams()),
ReferenceEyeBatchShapeLayerTest::getTestCaseName);
} // namespace reference_tests

View File

@ -2,11 +2,12 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/fake_quantize.hpp"
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
#include "openvino/op/constant.hpp"
#include "openvino/op/fake_quantize.hpp"
using namespace ov;
using namespace reference_tests;
@ -16,17 +17,17 @@ namespace {
struct FakeQuantizeParams {
template <class IT>
FakeQuantizeParams(const Shape& input_shape,
const Shape& expected_shape,
const element::Type& input_type,
const element::Type& expected_type,
const std::vector<IT>& input_data,
const std::vector<IT>& expected_data,
const std::shared_ptr<op::v0::Constant>& input_low,
const std::shared_ptr<op::v0::Constant>& input_high,
const std::shared_ptr<op::v0::Constant>& output_low,
const std::shared_ptr<op::v0::Constant>& output_high,
const std::size_t& levels,
const op::AutoBroadcastSpec& broadcast = op::AutoBroadcastType::NONE)
const Shape& expected_shape,
const element::Type& input_type,
const element::Type& expected_type,
const std::vector<IT>& input_data,
const std::vector<IT>& expected_data,
const std::shared_ptr<op::v0::Constant>& input_low,
const std::shared_ptr<op::v0::Constant>& input_high,
const std::shared_ptr<op::v0::Constant>& output_low,
const std::shared_ptr<op::v0::Constant>& output_high,
const std::size_t& levels,
const op::AutoBroadcastSpec& broadcast = op::AutoBroadcastType::NONE)
: m_input_shape(input_shape),
m_expected_shape(expected_shape),
m_input_type(input_type),
@ -90,24 +91,26 @@ public:
private:
static std::shared_ptr<Model> CreateFunction(const Shape& input_shape,
const Shape& expected_shape,
const element::Type& input_type,
const element::Type& expected_type,
const std::shared_ptr<op::v0::Constant>& input_low,
const std::shared_ptr<op::v0::Constant>& input_high,
const std::shared_ptr<op::v0::Constant>& output_low,
const std::shared_ptr<op::v0::Constant>& output_high,
const std::size_t& levels,
const op::AutoBroadcastSpec& broadcast) {
const Shape& expected_shape,
const element::Type& input_type,
const element::Type& expected_type,
const std::shared_ptr<op::v0::Constant>& input_low,
const std::shared_ptr<op::v0::Constant>& input_high,
const std::shared_ptr<op::v0::Constant>& output_low,
const std::shared_ptr<op::v0::Constant>& output_high,
const std::size_t& levels,
const op::AutoBroadcastSpec& broadcast) {
auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
if (broadcast == op::AutoBroadcastType::NONE) {
return std::make_shared<Model>(
NodeVector{std::make_shared<op::v0::FakeQuantize>(in, input_low, input_high, output_low, output_high, levels)},
NodeVector{
std::make_shared<op::v0::FakeQuantize>(in, input_low, input_high, output_low, output_high, levels)},
ParameterVector{in});
} else {
return std::make_shared<Model>(
NodeVector{std::make_shared<op::v0::FakeQuantize>(in, input_low, input_high, output_low, output_high, levels, broadcast)},
NodeVector{std::make_shared<
op::v0::FakeQuantize>(in, input_low, input_high, output_low, output_high, levels, broadcast)},
ParameterVector{in});
}
}
@ -128,21 +131,22 @@ template <element::Type_t IN_ET>
std::vector<FakeQuantizeParams> generateParamsForFakeQuantize() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<FakeQuantizeParams> params {
FakeQuantizeParams(ov::Shape{1, 2, 3, 4},
ov::Shape{1, 2, 3, 4},
IN_ET,
IN_ET,
iota_vector<T>(shape_size(ov::Shape{1, 2, 3, 4})),
std::vector<T>{2.f, 2.f, 2.f, 2.f, 6.6666669f, 6.6666669f,
6.6666669f, 6.6666669f, 6.6666669f, 6.6666669f, 6.6666669f, 6.6666669f,
11.33333301f, 11.33333301f, 11.33333301f, 11.33333301f, 11.33333301f, 11.33333301f,
11.33333301f, 11.33333301f, 16.f, 16.f, 16.f, 16.f},
op::v0::Constant::create(IN_ET, Shape{}, {0.f}),
op::v0::Constant::create(IN_ET, Shape{}, {23.f}),
op::v0::Constant::create(IN_ET, Shape{}, {2.f}),
op::v0::Constant::create(IN_ET, Shape{}, {16.f}),
4),
std::vector<FakeQuantizeParams> params{
FakeQuantizeParams(
ov::Shape{1, 2, 3, 4},
ov::Shape{1, 2, 3, 4},
IN_ET,
IN_ET,
iota_vector<T>(shape_size(ov::Shape{1, 2, 3, 4})),
std::vector<T>{2.f, 2.f, 2.f, 2.f, 6.6666669f, 6.6666669f,
6.6666669f, 6.6666669f, 6.6666669f, 6.6666669f, 6.6666669f, 6.6666669f,
11.33333301f, 11.33333301f, 11.33333301f, 11.33333301f, 11.33333301f, 11.33333301f,
11.33333301f, 11.33333301f, 16.f, 16.f, 16.f, 16.f},
op::v0::Constant::create(IN_ET, Shape{}, {0.f}),
op::v0::Constant::create(IN_ET, Shape{}, {23.f}),
op::v0::Constant::create(IN_ET, Shape{}, {2.f}),
op::v0::Constant::create(IN_ET, Shape{}, {16.f}),
4),
FakeQuantizeParams(ov::Shape{1, 2, 3, 4},
ov::Shape{1, 2, 3, 4},
IN_ET,
@ -155,61 +159,98 @@ std::vector<FakeQuantizeParams> generateParamsForFakeQuantize() {
op::v0::Constant::create(IN_ET, Shape{}, {2.f}),
op::v0::Constant::create(IN_ET, Shape{}, {16.f}),
5),
FakeQuantizeParams(ov::Shape{1, 2, 5, 5},
ov::Shape{1, 2, 5, 5},
IN_ET,
IN_ET,
iota_vector<T>(shape_size(Shape{1, 2, 5, 5})),
std::vector<T>{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 5.0f, 10.0f, 10.0f, 15.0f, 20.0f, 20.0f, 20.0f,
20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 50.0f,
50.0f, 50.0f, 50.0f, 50.0f, 50.0f, 50.0f, 55.0f, 55.0f, 60.0f, 60.0f, 60.0f, 65.0f, 65.0f,
70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f},
op::v0::Constant::create(IN_ET, Shape{2, 1, 1}, {5.f, 30.f}),
op::v0::Constant::create(IN_ET, Shape{2, 1, 1}, {10.f, 40.f}),
op::v0::Constant::create(IN_ET, Shape{2, 1, 1}, {0.f, 50.f}),
op::v0::Constant::create(IN_ET, Shape{2, 1, 1}, {20.f, 70.f}),
5),
FakeQuantizeParams(ov::Shape{1, 2, 5, 5},
ov::Shape{1, 2, 5, 5},
IN_ET,
IN_ET,
iota_vector<T>(shape_size(Shape{1, 2, 5, 5})),
std::vector<T>{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 5.0f, 10.0f, 10.0f, 15.0f, 20.0f, 20.0f, 20.0f,
20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 50.0f,
50.0f, 50.0f, 50.0f, 50.0f, 50.0f, 50.0f, 55.0f, 55.0f, 60.0f, 60.0f, 60.0f, 65.0f, 65.0f,
70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f},
op::v0::Constant::create(IN_ET, Shape{2, 1, 1}, {5.f, 30.f}),
op::v0::Constant::create(IN_ET, Shape{2, 1, 1}, {10.f, 40.f}),
op::v0::Constant::create(IN_ET, Shape{2, 1, 1}, {0.f, 50.f}),
op::v0::Constant::create(IN_ET, Shape{2, 1, 1}, {20.f, 70.f}),
5,
op::AutoBroadcastSpec(op::AutoBroadcastType::PDPD, 1)),
FakeQuantizeParams(ov::Shape{1, 2, 5, 5},
ov::Shape{1, 2, 5, 5},
IN_ET,
IN_ET,
iota_vector<T>(shape_size(Shape{1, 2, 5, 5})),
std::vector<T>{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 5.0f, 10.0f, 10.0f, 15.0f, 20.0f, 20.0f, 20.0f,
20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 50.0f,
50.0f, 50.0f, 50.0f, 50.0f, 50.0f, 50.0f, 55.0f, 55.0f, 60.0f, 60.0f, 60.0f, 65.0f, 65.0f,
70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f},
op::v0::Constant::create(IN_ET, Shape{2, 1, 1}, {5.f, 30.f}),
op::v0::Constant::create(IN_ET, Shape{2, 1, 1}, {10.f, 40.f}),
op::v0::Constant::create(IN_ET, Shape{2, 1, 1}, {0.f, 50.f}),
op::v0::Constant::create(IN_ET, Shape{2, 1, 1}, {20.f, 70.f}),
5,
op::AutoBroadcastSpec(op::AutoBroadcastType::PDPD, -1)),
FakeQuantizeParams(
ov::Shape{1, 2, 5, 5},
ov::Shape{1, 2, 5, 5},
IN_ET,
IN_ET,
iota_vector<T>(shape_size(Shape{1, 2, 5, 5})),
std::vector<T>{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 5.0f, 10.0f, 10.0f, 15.0f, 20.0f, 20.0f, 20.0f,
20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 50.0f,
50.0f, 50.0f, 50.0f, 50.0f, 50.0f, 50.0f, 55.0f, 55.0f, 60.0f, 60.0f, 60.0f, 65.0f, 65.0f,
70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f},
op::v0::Constant::create(IN_ET, Shape{2, 1, 1}, {5.f, 30.f}),
op::v0::Constant::create(IN_ET, Shape{2, 1, 1}, {10.f, 40.f}),
op::v0::Constant::create(IN_ET, Shape{2, 1, 1}, {0.f, 50.f}),
op::v0::Constant::create(IN_ET, Shape{2, 1, 1}, {20.f, 70.f}),
5),
FakeQuantizeParams(
ov::Shape{1, 2, 5, 5},
ov::Shape{1, 2, 5, 5},
IN_ET,
IN_ET,
iota_vector<T>(shape_size(Shape{1, 2, 5, 5})),
std::vector<T>{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 5.0f, 10.0f, 10.0f, 15.0f, 20.0f, 20.0f, 20.0f,
20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 50.0f,
50.0f, 50.0f, 50.0f, 50.0f, 50.0f, 50.0f, 55.0f, 55.0f, 60.0f, 60.0f, 60.0f, 65.0f, 65.0f,
70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f},
op::v0::Constant::create(IN_ET, Shape{2, 1, 1}, {5.f, 30.f}),
op::v0::Constant::create(IN_ET, Shape{2, 1, 1}, {10.f, 40.f}),
op::v0::Constant::create(IN_ET, Shape{2, 1, 1}, {0.f, 50.f}),
op::v0::Constant::create(IN_ET, Shape{2, 1, 1}, {20.f, 70.f}),
5,
op::AutoBroadcastSpec(op::AutoBroadcastType::PDPD, 1)),
FakeQuantizeParams(
ov::Shape{1, 2, 5, 5},
ov::Shape{1, 2, 5, 5},
IN_ET,
IN_ET,
iota_vector<T>(shape_size(Shape{1, 2, 5, 5})),
std::vector<T>{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 5.0f, 10.0f, 10.0f, 15.0f, 20.0f, 20.0f, 20.0f,
20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 50.0f,
50.0f, 50.0f, 50.0f, 50.0f, 50.0f, 50.0f, 55.0f, 55.0f, 60.0f, 60.0f, 60.0f, 65.0f, 65.0f,
70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f, 70.0f},
op::v0::Constant::create(IN_ET, Shape{2, 1, 1}, {5.f, 30.f}),
op::v0::Constant::create(IN_ET, Shape{2, 1, 1}, {10.f, 40.f}),
op::v0::Constant::create(IN_ET, Shape{2, 1, 1}, {0.f, 50.f}),
op::v0::Constant::create(IN_ET, Shape{2, 1, 1}, {20.f, 70.f}),
5,
op::AutoBroadcastSpec(op::AutoBroadcastType::PDPD, -1)),
FakeQuantizeParams(ov::Shape{1, 2, 3, 3},
ov::Shape{1, 2, 3, 3},
IN_ET,
IN_ET,
iota_vector<T>(shape_size(Shape{1, 2, 3, 3})),
std::vector<T>{5.0f, 9.0f, 13.0f, 17.0f, 21.0f, 25.0f, 25.0f, 25.0f, 25.0f,
25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f, 25.0f,},
op::v0::Constant::create(IN_ET, Shape{1, 1, 3, 3}, {0.f,}),
op::v0::Constant::create(IN_ET, Shape{1, 1, 3, 3}, {5.f,}),
op::v0::Constant::create(IN_ET, Shape{1, 2, 3, 1}, {5.f,}),
op::v0::Constant::create(IN_ET, Shape{1, 2, 1, 3}, {25.f,}),
std::vector<T>{
5.0f,
9.0f,
13.0f,
17.0f,
21.0f,
25.0f,
25.0f,
25.0f,
25.0f,
25.0f,
25.0f,
25.0f,
25.0f,
25.0f,
25.0f,
25.0f,
25.0f,
25.0f,
},
op::v0::Constant::create(IN_ET,
Shape{1, 1, 3, 3},
{
0.f,
}),
op::v0::Constant::create(IN_ET,
Shape{1, 1, 3, 3},
{
5.f,
}),
op::v0::Constant::create(IN_ET,
Shape{1, 2, 3, 1},
{
5.f,
}),
op::v0::Constant::create(IN_ET,
Shape{1, 2, 1, 3},
{
25.f,
}),
16,
op::AutoBroadcastSpec(op::AutoBroadcastType::NUMPY)),
};
@ -219,8 +260,7 @@ std::vector<FakeQuantizeParams> generateParamsForFakeQuantize() {
std::vector<FakeQuantizeParams> generateCombinedParamsForFakeQuantize() {
const std::vector<std::vector<FakeQuantizeParams>> allTypeParams{
generateParamsForFakeQuantize<element::Type_t::f32>(),
generateParamsForFakeQuantize<element::Type_t::f16>()
};
generateParamsForFakeQuantize<element::Type_t::f16>()};
std::vector<FakeQuantizeParams> combinedParams;
@ -231,10 +271,9 @@ std::vector<FakeQuantizeParams> generateCombinedParamsForFakeQuantize() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(
smoke_FakeQuantize_With_Hardcoded_Refs,
ReferenceFakeQuantizeLayerTest,
::testing::ValuesIn(generateCombinedParamsForFakeQuantize()),
ReferenceFakeQuantizeLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantize_With_Hardcoded_Refs,
ReferenceFakeQuantizeLayerTest,
::testing::ValuesIn(generateCombinedParamsForFakeQuantize()),
ReferenceFakeQuantizeLayerTest::getTestCaseName);
} // namespace

View File

@ -2,10 +2,12 @@
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
#include "openvino/op/floor.hpp"
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
using namespace ov;
using namespace reference_tests;
@ -14,9 +16,9 @@ namespace {
struct FloorParams {
template <class IT>
FloorParams(const PartialShape& shape,
const element::Type& iType,
const std::vector<IT>& iValues,
const std::vector<IT>& oValues)
const element::Type& iType,
const std::vector<IT>& iValues,
const std::vector<IT>& oValues)
: pshape(shape),
inType(iType),
outType(iType),
@ -50,8 +52,8 @@ public:
private:
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape,
const element::Type& input_type,
const element::Type& expected_output_type) {
const element::Type& input_type,
const element::Type& expected_output_type) {
const auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
const auto floor = std::make_shared<op::v0::Floor>(in);
return std::make_shared<Model>(NodeVector{floor}, ParameterVector{in});
@ -66,12 +68,10 @@ template <element::Type_t IN_ET>
std::vector<FloorParams> generateParamsForFloorFloat() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<FloorParams> params{
FloorParams(ov::PartialShape{4},
IN_ET,
std::vector<T>{-2.5f, -2.0f, 0.3f, 4.8f},
std::vector<T>{-3.0f, -2.0f, 0.0f, 4.0f})
};
std::vector<FloorParams> params{FloorParams(ov::PartialShape{4},
IN_ET,
std::vector<T>{-2.5f, -2.0f, 0.3f, 4.8f},
std::vector<T>{-3.0f, -2.0f, 0.0f, 4.0f})};
return params;
}
@ -79,26 +79,21 @@ template <element::Type_t IN_ET>
std::vector<FloorParams> generateParamsForFloorInt64() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<FloorParams> params{
FloorParams(ov::PartialShape{3},
IN_ET,
std::vector<T>{0, 1, 0x4000000000000001},
std::vector<T>{0, 1, 0x4000000000000001})
};
std::vector<FloorParams> params{FloorParams(ov::PartialShape{3},
IN_ET,
std::vector<T>{0, 1, 0x4000000000000001},
std::vector<T>{0, 1, 0x4000000000000001})};
return params;
}
template <element::Type_t IN_ET>
std::vector<FloorParams> generateParamsForFloorInt32() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<FloorParams> params{
FloorParams(ov::PartialShape{4},
IN_ET,
std::vector<T>{2, 136314888, 0x40000010, 0x40000001},
std::vector<T>{2, 136314888, 0x40000010, 0x40000001})
};
std::vector<FloorParams> params{FloorParams(ov::PartialShape{4},
IN_ET,
std::vector<T>{2, 136314888, 0x40000010, 0x40000001},
std::vector<T>{2, 136314888, 0x40000010, 0x40000001})};
return params;
}
@ -107,27 +102,21 @@ std::vector<FloorParams> generateParamsForFloorInt() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<FloorParams> params{
FloorParams(ov::PartialShape{4},
IN_ET,
std::vector<T>{2, 64, 0x40, 0x01},
std::vector<T>{2, 64, 0x40, 0x01})
};
FloorParams(ov::PartialShape{4}, IN_ET, std::vector<T>{2, 64, 0x40, 0x01}, std::vector<T>{2, 64, 0x40, 0x01})};
return params;
}
std::vector<FloorParams> generateCombinedParamsForFloor() {
const std::vector<std::vector<FloorParams>> allTypeParams{
generateParamsForFloorFloat<element::Type_t::f32>(),
generateParamsForFloorFloat<element::Type_t::f16>(),
generateParamsForFloorInt64<element::Type_t::i64>(),
generateParamsForFloorInt32<element::Type_t::i32>(),
generateParamsForFloorInt<element::Type_t::i16>(),
generateParamsForFloorInt<element::Type_t::i8>(),
generateParamsForFloorInt<element::Type_t::u64>(),
generateParamsForFloorInt<element::Type_t::u32>(),
generateParamsForFloorInt<element::Type_t::u16>(),
generateParamsForFloorInt<element::Type_t::u8>()
};
const std::vector<std::vector<FloorParams>> allTypeParams{generateParamsForFloorFloat<element::Type_t::f32>(),
generateParamsForFloorFloat<element::Type_t::f16>(),
generateParamsForFloorInt64<element::Type_t::i64>(),
generateParamsForFloorInt32<element::Type_t::i32>(),
generateParamsForFloorInt<element::Type_t::i16>(),
generateParamsForFloorInt<element::Type_t::i8>(),
generateParamsForFloorInt<element::Type_t::u64>(),
generateParamsForFloorInt<element::Type_t::u32>(),
generateParamsForFloorInt<element::Type_t::u16>(),
generateParamsForFloorInt<element::Type_t::u8>()};
std::vector<FloorParams> combinedParams;
@ -138,11 +127,9 @@ std::vector<FloorParams> generateCombinedParamsForFloor() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(
smoke_Floor_With_Hardcoded_Refs,
ReferenceFloorLayerTest,
::testing::ValuesIn(generateCombinedParamsForFloor()),
ReferenceFloorLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Floor_With_Hardcoded_Refs,
ReferenceFloorLayerTest,
::testing::ValuesIn(generateCombinedParamsForFloor()),
ReferenceFloorLayerTest::getTestCaseName);
} // namespace

View File

@ -2,10 +2,12 @@
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
#include "openvino/op/floor_mod.hpp"
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
using namespace ov;
using namespace reference_tests;
@ -14,11 +16,11 @@ namespace {
struct FloorModParams {
template <class IT>
FloorModParams(const PartialShape& iShape1,
const PartialShape& iShape2,
const element::Type& iType,
const std::vector<IT>& iValues1,
const std::vector<IT>& iValues2,
const std::vector<IT>& oValues)
const PartialShape& iShape2,
const element::Type& iType,
const std::vector<IT>& iValues1,
const std::vector<IT>& iValues2,
const std::vector<IT>& oValues)
: pshape1(iShape1),
pshape2(iShape2),
inType(iType),
@ -57,9 +59,9 @@ public:
private:
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape1,
const PartialShape& input_shape2,
const element::Type& input_type,
const element::Type& expected_output_type) {
const PartialShape& input_shape2,
const element::Type& input_type,
const element::Type& expected_output_type) {
const auto in1 = std::make_shared<op::v0::Parameter>(input_type, input_shape1);
const auto in2 = std::make_shared<op::v0::Parameter>(input_type, input_shape2);
const auto floormod = std::make_shared<op::v1::FloorMod>(in1, in2);
@ -76,14 +78,12 @@ template <element::Type_t IN_ET>
std::vector<FloorModParams> generateParamsForFloorMod() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<FloorModParams> params{
FloorModParams(ov::PartialShape{4},
ov::PartialShape{4},
IN_ET,
std::vector<T>{7, -7, 7, -7},
std::vector<T>{3, 3, -3, -3},
std::vector<T>{1, 2, -2, -1})
};
std::vector<FloorModParams> params{FloorModParams(ov::PartialShape{4},
ov::PartialShape{4},
IN_ET,
std::vector<T>{7, -7, 7, -7},
std::vector<T>{3, 3, -3, -3},
std::vector<T>{1, 2, -2, -1})};
return params;
}
@ -129,14 +129,12 @@ std::vector<FloorModParams> generateParamsForFloorModNonIntegerDivisor() {
}
std::vector<FloorModParams> generateCombinedParamsForFloorMod() {
const std::vector<std::vector<FloorModParams>> allTypeParams{
generateParamsForFloorMod<element::Type_t::f32>(),
generateParamsForFloorMod<element::Type_t::f16>(),
generateParamsForFloorMod<element::Type_t::bf16>(),
generateParamsForFloorMod<element::Type_t::i64>(),
generateParamsForFloorMod<element::Type_t::i32>(),
generateParamsForFloorMod<element::Type_t::i8>()
};
const std::vector<std::vector<FloorModParams>> allTypeParams{generateParamsForFloorMod<element::Type_t::f32>(),
generateParamsForFloorMod<element::Type_t::f16>(),
generateParamsForFloorMod<element::Type_t::bf16>(),
generateParamsForFloorMod<element::Type_t::i64>(),
generateParamsForFloorMod<element::Type_t::i32>(),
generateParamsForFloorMod<element::Type_t::i8>()};
std::vector<FloorModParams> combinedParams;
@ -150,8 +148,7 @@ std::vector<FloorModParams> generateCombinedParamsForFloorMod() {
std::vector<FloorModParams> generateCombinedParamsForFloorModBroadcast() {
const std::vector<std::vector<FloorModParams>> allTypeParams{
generateParamsForFloorModBroadcast<element::Type_t::f32>(),
generateParamsForFloorModBroadcast<element::Type_t::f16>()
};
generateParamsForFloorModBroadcast<element::Type_t::f16>()};
std::vector<FloorModParams> combinedParams;
@ -172,8 +169,7 @@ std::vector<FloorModParams> generateCombinedParamsForFloorModScalar() {
generateParamsForFloorModScalar<element::Type_t::i8>(),
generateParamsForFloorModScalar<element::Type_t::u64>(),
generateParamsForFloorModScalar<element::Type_t::u32>(),
generateParamsForFloorModScalar<element::Type_t::u8>()
};
generateParamsForFloorModScalar<element::Type_t::u8>()};
std::vector<FloorModParams> combinedParams;
@ -188,28 +184,24 @@ std::vector<FloorModParams> generateCombinedParamsForFloorModNonIntegerDivisor()
return generateParamsForFloorModNonIntegerDivisor<element::Type_t::f32>();
}
INSTANTIATE_TEST_SUITE_P(
smoke_FloorMod_With_Hardcoded_Refs,
ReferenceFloorModLayerTest,
::testing::ValuesIn(generateCombinedParamsForFloorMod()),
ReferenceFloorModLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_FloorMod_With_Hardcoded_Refs,
ReferenceFloorModLayerTest,
::testing::ValuesIn(generateCombinedParamsForFloorMod()),
ReferenceFloorModLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(
smoke_FloorMod_Broadcast_With_Hardcoded_Refs,
ReferenceFloorModLayerTest,
::testing::ValuesIn(generateCombinedParamsForFloorModBroadcast()),
ReferenceFloorModLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_FloorMod_Broadcast_With_Hardcoded_Refs,
ReferenceFloorModLayerTest,
::testing::ValuesIn(generateCombinedParamsForFloorModBroadcast()),
ReferenceFloorModLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(
smoke_FloorMod_Scalar_With_Hardcoded_Refs,
ReferenceFloorModLayerTest,
::testing::ValuesIn(generateCombinedParamsForFloorModScalar()),
ReferenceFloorModLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_FloorMod_Scalar_With_Hardcoded_Refs,
ReferenceFloorModLayerTest,
::testing::ValuesIn(generateCombinedParamsForFloorModScalar()),
ReferenceFloorModLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(
smoke_FloorMod_NonInteger_Divisor,
ReferenceFloorModLayerTest,
::testing::ValuesIn(generateCombinedParamsForFloorModNonIntegerDivisor()),
ReferenceFloorModLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_FloorMod_NonInteger_Divisor,
ReferenceFloorModLayerTest,
::testing::ValuesIn(generateCombinedParamsForFloorModNonIntegerDivisor()),
ReferenceFloorModLayerTest::getTestCaseName);
} // namespace

File diff suppressed because it is too large Load Diff

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/gather_elements.hpp"
#include <gtest/gtest.h>
#include "openvino/op/gather_elements.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
@ -12,11 +13,16 @@ using namespace ov;
namespace {
struct GatherElementsParams {
GatherElementsParams(
const reference_tests::Tensor& dataTensor, const reference_tests::Tensor& indicesTensor, int64_t axis,
const reference_tests::Tensor& expectedTensor, const std::string& testcaseName = "") :
dataTensor(dataTensor), indicesTensor(indicesTensor), axis(axis),
expectedTensor(expectedTensor), testcaseName(testcaseName) {}
GatherElementsParams(const reference_tests::Tensor& dataTensor,
const reference_tests::Tensor& indicesTensor,
int64_t axis,
const reference_tests::Tensor& expectedTensor,
const std::string& testcaseName = "")
: dataTensor(dataTensor),
indicesTensor(indicesTensor),
axis(axis),
expectedTensor(expectedTensor),
testcaseName(testcaseName) {}
reference_tests::Tensor dataTensor;
reference_tests::Tensor indicesTensor;
@ -55,18 +61,17 @@ public:
private:
static std::shared_ptr<Model> CreateFunction(const GatherElementsParams& params) {
std::shared_ptr<Model> function;
const auto data = std::make_shared<op::v0::Parameter>(params.dataTensor.type,
PartialShape{params.dataTensor.shape});
const auto indices = std::make_shared<op::v0::Parameter>(params.indicesTensor.type,
PartialShape{params.indicesTensor.shape});
const auto data =
std::make_shared<op::v0::Parameter>(params.dataTensor.type, PartialShape{params.dataTensor.shape});
const auto indices =
std::make_shared<op::v0::Parameter>(params.indicesTensor.type, PartialShape{params.indicesTensor.shape});
const auto gatherElement = std::make_shared<op::v6::GatherElements>(data, indices, params.axis);
function = std::make_shared<ov::Model>(NodeVector {gatherElement}, ParameterVector {data, indices});
function = std::make_shared<ov::Model>(NodeVector{gatherElement}, ParameterVector{data, indices});
return function;
}
};
class ReferenceGatherElementsTestNegative : public ReferenceGatherElementsTest {
};
class ReferenceGatherElementsTestNegative : public ReferenceGatherElementsTest {};
TEST_P(ReferenceGatherElementsTest, CompareWithRefs) {
Exec();
@ -85,37 +90,32 @@ TEST_P(ReferenceGatherElementsTestNegative, CompareWithRefs) {
template <element::Type_t IN_ET>
std::vector<GatherElementsParams> generateParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<GatherElementsParams> params {
GatherElementsParams(
reference_tests::Tensor(IN_ET, {3}, std::vector<T>{1, 2, 3}),
reference_tests::Tensor(element::i32, {7}, std::vector<int32_t>{1, 2, 0, 2, 0, 0, 2}),
0,
reference_tests::Tensor(IN_ET, {7}, std::vector<T>{2, 3, 1, 3, 1, 1, 3}),
"evaluate_1D_gather_elements_3_indices_int32"),
GatherElementsParams(
reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{1, 2, 3, 4}),
reference_tests::Tensor(element::i32, {2, 2}, std::vector<int32_t>{0, 1, 0, 0}),
0,
reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{1, 4, 1, 2}),
"evaluate_2D_gather_elements_2x2_indices_int32_axis_0"),
GatherElementsParams(
reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{1, 2, 3, 4}),
reference_tests::Tensor(element::i32, {2, 2}, std::vector<int32_t>{0, 1, 0, 0}),
1,
reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{1, 2, 3, 3}),
"evaluate_2D_gather_elements_2x2_indices_int32_axis_1"),
GatherElementsParams(
reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{1, 2, 3, 4}),
reference_tests::Tensor(element::i32, {2, 2}, std::vector<int32_t>{0, 1, 0, 0}),
-1,
reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{1, 2, 3, 3}),
"evaluate_2D_gather_elements_2x2_indices_int32_axis_minus_1"),
GatherElementsParams(
reference_tests::Tensor(IN_ET, {3, 3}, std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9}),
reference_tests::Tensor(element::i32, {2, 3}, std::vector<int32_t>{1, 2, 0, 2, 0, 0}),
0,
reference_tests::Tensor(IN_ET, {2, 3}, std::vector<T>{4, 8, 3, 7, 2, 3}),
"evaluate_2D_gather_elements_2x3_indices_int32"),
std::vector<GatherElementsParams> params{
GatherElementsParams(reference_tests::Tensor(IN_ET, {3}, std::vector<T>{1, 2, 3}),
reference_tests::Tensor(element::i32, {7}, std::vector<int32_t>{1, 2, 0, 2, 0, 0, 2}),
0,
reference_tests::Tensor(IN_ET, {7}, std::vector<T>{2, 3, 1, 3, 1, 1, 3}),
"evaluate_1D_gather_elements_3_indices_int32"),
GatherElementsParams(reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{1, 2, 3, 4}),
reference_tests::Tensor(element::i32, {2, 2}, std::vector<int32_t>{0, 1, 0, 0}),
0,
reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{1, 4, 1, 2}),
"evaluate_2D_gather_elements_2x2_indices_int32_axis_0"),
GatherElementsParams(reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{1, 2, 3, 4}),
reference_tests::Tensor(element::i32, {2, 2}, std::vector<int32_t>{0, 1, 0, 0}),
1,
reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{1, 2, 3, 3}),
"evaluate_2D_gather_elements_2x2_indices_int32_axis_1"),
GatherElementsParams(reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{1, 2, 3, 4}),
reference_tests::Tensor(element::i32, {2, 2}, std::vector<int32_t>{0, 1, 0, 0}),
-1,
reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{1, 2, 3, 3}),
"evaluate_2D_gather_elements_2x2_indices_int32_axis_minus_1"),
GatherElementsParams(reference_tests::Tensor(IN_ET, {3, 3}, std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9}),
reference_tests::Tensor(element::i32, {2, 3}, std::vector<int32_t>{1, 2, 0, 2, 0, 0}),
0,
reference_tests::Tensor(IN_ET, {2, 3}, std::vector<T>{4, 8, 3, 7, 2, 3}),
"evaluate_2D_gather_elements_2x3_indices_int32"),
GatherElementsParams(
reference_tests::Tensor(IN_ET, {3, 2, 2}, std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}),
reference_tests::Tensor(element::i32, {3, 2, 2}, std::vector<int32_t>{1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1}),
@ -124,34 +124,31 @@ std::vector<GatherElementsParams> generateParams() {
"evaluate_3D_gather_elements_3x2x2_indices_int32"),
GatherElementsParams(
reference_tests::Tensor(IN_ET, {3, 2, 2, 2}, std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24}),
reference_tests::Tensor(element::i32, {3, 2, 2, 4}, std::vector<int32_t>{1, 0, 0, 0, 0, 1, 1, 0,
1, 1, 1, 1, 1, 0, 0, 1,
0, 0, 0, 1, 1, 1, 1, 0,
0, 0, 0, 0, 1, 0, 1, 0,
1, 1, 1, 1, 1, 0, 1, 0,
1, 0, 0, 1, 0, 0, 0, 0}),
9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24}),
reference_tests::Tensor(
element::i32,
{3, 2, 2, 4},
std::vector<int32_t>{1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0,
0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0}),
-1,
reference_tests::Tensor(IN_ET, {3, 2, 2, 4}, std::vector<T>{2, 1, 1, 1, 3, 4, 4, 3,
6, 6, 6, 6, 8, 7, 7, 8,
9, 9, 9, 10, 12, 12, 12, 11,
13, 13, 13, 13, 16, 15, 16, 15,
18, 18, 18, 18, 20, 19, 20, 19,
22, 21, 21, 22, 23, 23, 23, 23}),
reference_tests::Tensor(IN_ET,
{3, 2, 2, 4},
std::vector<T>{2, 1, 1, 1, 3, 4, 4, 3, 6, 6, 6, 6, 8, 7, 7, 8,
9, 9, 9, 10, 12, 12, 12, 11, 13, 13, 13, 13, 16, 15, 16, 15,
18, 18, 18, 18, 20, 19, 20, 19, 22, 21, 21, 22, 23, 23, 23, 23}),
"evaluate_4D_gather_elements_3x2x2x2_indices_int64"),
GatherElementsParams(
reference_tests::Tensor(IN_ET, {3, 2, 2}, std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}),
reference_tests::Tensor(IN_ET, {3, 2, 2}, std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}),
reference_tests::Tensor(element::i32, {3, 2, 2}, std::vector<int32_t>{1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1}),
-1,
reference_tests::Tensor(IN_ET, {3, 2, 2}, std::vector<T>{2, 1, 3, 4, 6, 6, 8, 7, 9, 9, 12, 12}),
"evaluate_3D_gather_elements_3x2x2_indices_int64"),
GatherElementsParams(
reference_tests::Tensor(IN_ET, {3, 3}, std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9}),
reference_tests::Tensor(element::i32, {2, 3}, std::vector<int32_t>{1, 2, 0, 2, 0, 0}),
0,
reference_tests::Tensor(IN_ET, {2, 3}, std::vector<T>{4, 8, 3, 7, 2, 3}),
"evaluate_2D_gather_elements_2x3_data_float32"),
GatherElementsParams(reference_tests::Tensor(IN_ET, {3, 3}, std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9}),
reference_tests::Tensor(element::i32, {2, 3}, std::vector<int32_t>{1, 2, 0, 2, 0, 0}),
0,
reference_tests::Tensor(IN_ET, {2, 3}, std::vector<T>{4, 8, 3, 7, 2, 3}),
"evaluate_2D_gather_elements_2x3_data_float32"),
GatherElementsParams(
reference_tests::Tensor(IN_ET, {2, 2, 1}, std::vector<T>{5, 4, 1, 4}),
reference_tests::Tensor(element::i32, {4, 2, 1}, std::vector<int32_t>{0, 0, 1, 1, 1, 1, 0, 1}),
@ -164,7 +161,7 @@ std::vector<GatherElementsParams> generateParams() {
template <>
std::vector<GatherElementsParams> generateParams<element::Type_t::boolean>() {
std::vector<GatherElementsParams> params {
std::vector<GatherElementsParams> params{
GatherElementsParams(
reference_tests::Tensor(element::boolean, {3, 2}, std::vector<char>{true, false, true, true, false, false}),
reference_tests::Tensor(element::i32, {2, 2}, std::vector<int32_t>{0, 1, 0, 2}),
@ -176,13 +173,12 @@ std::vector<GatherElementsParams> generateParams<element::Type_t::boolean>() {
}
std::vector<GatherElementsParams> generateParamsNegative() {
std::vector<GatherElementsParams> params {
GatherElementsParams(
reference_tests::Tensor(element::i32, {3}, std::vector<int32_t>{1, 2, 3}),
reference_tests::Tensor(element::i32, {7}, std::vector<int32_t>{1, 2, 0, 2, 0, 0, 8}),
0,
reference_tests::Tensor(element::i32, {7}, std::vector<int32_t>{2, 3, 1, 3, 1, 1, 3}),
"evaluate_1D_gather_elements_negative_test"),
std::vector<GatherElementsParams> params{
GatherElementsParams(reference_tests::Tensor(element::i32, {3}, std::vector<int32_t>{1, 2, 3}),
reference_tests::Tensor(element::i32, {7}, std::vector<int32_t>{1, 2, 0, 2, 0, 0, 8}),
0,
reference_tests::Tensor(element::i32, {7}, std::vector<int32_t>{2, 3, 1, 3, 1, 1, 3}),
"evaluate_1D_gather_elements_negative_test"),
GatherElementsParams(
reference_tests::Tensor(element::i32, {3, 3}, std::vector<int32_t>{1, 2, 3, 4, 5, 6, 7, 8, 9}),
reference_tests::Tensor(element::i32, {2, 3}, std::vector<int32_t>{1, 3, 0, 2, 0, 0}),
@ -194,7 +190,7 @@ std::vector<GatherElementsParams> generateParamsNegative() {
}
std::vector<GatherElementsParams> generateCombinedParams() {
const std::vector<std::vector<GatherElementsParams>> generatedParams {
const std::vector<std::vector<GatherElementsParams>> generatedParams{
generateParams<element::Type_t::boolean>(),
generateParams<element::Type_t::i8>(),
generateParams<element::Type_t::i16>(),
@ -217,9 +213,13 @@ std::vector<GatherElementsParams> generateCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_GatherElements_With_Hardcoded_Refs, ReferenceGatherElementsTest,
testing::ValuesIn(generateCombinedParams()), ReferenceGatherElementsTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_GatherElements_With_Hardcoded_Refs,
ReferenceGatherElementsTest,
testing::ValuesIn(generateCombinedParams()),
ReferenceGatherElementsTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_GatherElements_With_Hardcoded_Refs, ReferenceGatherElementsTestNegative,
testing::ValuesIn(generateParamsNegative()), ReferenceGatherElementsTest::getTestCaseName);
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_GatherElements_With_Hardcoded_Refs,
ReferenceGatherElementsTestNegative,
testing::ValuesIn(generateParamsNegative()),
ReferenceGatherElementsTest::getTestCaseName);
} // namespace

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/gather_nd.hpp"
#include <gtest/gtest.h>
#include "openvino/op/gather_nd.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
@ -12,11 +13,16 @@ using namespace ov;
namespace {
struct GatherNDParams {
GatherNDParams(
const reference_tests::Tensor& dataTensor, const reference_tests::Tensor& indicesTensor, int64_t batchDims,
const reference_tests::Tensor& expectedTensor, const std::string& testcaseName = "") :
dataTensor(dataTensor), indicesTensor(indicesTensor), batchDims(static_cast<int32_t>(batchDims)),
expectedTensor(expectedTensor), testcaseName(testcaseName) {}
GatherNDParams(const reference_tests::Tensor& dataTensor,
const reference_tests::Tensor& indicesTensor,
int64_t batchDims,
const reference_tests::Tensor& expectedTensor,
const std::string& testcaseName = "")
: dataTensor(dataTensor),
indicesTensor(indicesTensor),
batchDims(static_cast<int32_t>(batchDims)),
expectedTensor(expectedTensor),
testcaseName(testcaseName) {}
reference_tests::Tensor dataTensor;
reference_tests::Tensor indicesTensor;
@ -55,17 +61,17 @@ public:
private:
static std::shared_ptr<Model> CreateFunction(const GatherNDParams& params) {
std::shared_ptr<Model> function;
const auto data = std::make_shared<op::v0::Parameter>(params.dataTensor.type,
PartialShape{params.dataTensor.shape});
const auto indices = std::make_shared<op::v0::Parameter>(params.indicesTensor.type,
PartialShape{params.indicesTensor.shape});
const auto data =
std::make_shared<op::v0::Parameter>(params.dataTensor.type, PartialShape{params.dataTensor.shape});
const auto indices =
std::make_shared<op::v0::Parameter>(params.indicesTensor.type, PartialShape{params.indicesTensor.shape});
std::shared_ptr<op::v5::GatherND> gatherND;
if (params.batchDims == 0) {
gatherND = std::make_shared<op::v5::GatherND>(data, indices);
} else {
gatherND = std::make_shared<op::v5::GatherND>(data, indices, params.batchDims);
}
function = std::make_shared<ov::Model>(NodeVector {gatherND}, ParameterVector {data, indices});
function = std::make_shared<ov::Model>(NodeVector{gatherND}, ParameterVector{data, indices});
return function;
}
};
@ -77,101 +83,94 @@ TEST_P(ReferenceGatherND5Test, CompareWithRefs) {
template <element::Type_t IN_ET>
std::vector<GatherNDParams> generateParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<GatherNDParams> params {
GatherNDParams(
reference_tests::Tensor(IN_ET, {3, 3}, std::vector<T>{10, 11, 12, 13, 14, 15, 16, 17, 18}),
reference_tests::Tensor(element::i32, {2}, std::vector<int32_t>{1, 2}),
0,
reference_tests::Tensor(IN_ET, {}, std::vector<T>{15}),
"gather_nd_single_indices"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{10, 11, 12, 13}),
reference_tests::Tensor(element::i32, {2, 2}, std::vector<int32_t>{0, 0, 1, 1}),
0,
reference_tests::Tensor(IN_ET, {2}, std::vector<T>{10, 13}),
"gather_nd_scalar_from_2d"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{10, 11, 12, 13}),
reference_tests::Tensor(element::i32, {2, 1}, std::vector<int32_t>{1, 0}),
0,
reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{12, 13, 10, 11}),
"gather_nd_1d_from_2d"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
reference_tests::Tensor(element::i32, {2, 3}, std::vector<int32_t>{0, 0, 1, 1, 0, 1}),
0,
reference_tests::Tensor(IN_ET, {2}, std::vector<T>{11, 21}),
"gather_nd_scalar_from_3d"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
reference_tests::Tensor(element::i32, {2, 2}, std::vector<int32_t>{0, 1, 1, 0}),
0,
reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{12, 13, 20, 21}),
"gather_nd_1d_from_3d"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
reference_tests::Tensor(element::i32, {1, 1}, std::vector<int32_t>{1}),
0,
reference_tests::Tensor(IN_ET, {1, 2, 2}, std::vector<T>{20, 21, 22, 23}),
"gather_nd_2d_from_3d"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{10, 11, 12, 13}),
reference_tests::Tensor(element::i32, {2, 1, 2}, std::vector<int32_t>{0, 0, 0, 1}),
0,
reference_tests::Tensor(IN_ET, {2, 1}, std::vector<T>{10, 11}),
"gather_nd_batch_scalar_from_2d"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{10, 11, 12, 13}),
reference_tests::Tensor(element::i32, {2, 1, 1}, std::vector<int32_t>{1, 0}),
0,
reference_tests::Tensor(IN_ET, {2, 1, 2}, std::vector<T>{12, 13, 10, 11}),
"gather_nd_batch_1d_from_2d"),
std::vector<GatherNDParams> params{
GatherNDParams(reference_tests::Tensor(IN_ET, {3, 3}, std::vector<T>{10, 11, 12, 13, 14, 15, 16, 17, 18}),
reference_tests::Tensor(element::i32, {2}, std::vector<int32_t>{1, 2}),
0,
reference_tests::Tensor(IN_ET, {}, std::vector<T>{15}),
"gather_nd_single_indices"),
GatherNDParams(reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{10, 11, 12, 13}),
reference_tests::Tensor(element::i32, {2, 2}, std::vector<int32_t>{0, 0, 1, 1}),
0,
reference_tests::Tensor(IN_ET, {2}, std::vector<T>{10, 13}),
"gather_nd_scalar_from_2d"),
GatherNDParams(reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{10, 11, 12, 13}),
reference_tests::Tensor(element::i32, {2, 1}, std::vector<int32_t>{1, 0}),
0,
reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{12, 13, 10, 11}),
"gather_nd_1d_from_2d"),
GatherNDParams(reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
reference_tests::Tensor(element::i32, {2, 3}, std::vector<int32_t>{0, 0, 1, 1, 0, 1}),
0,
reference_tests::Tensor(IN_ET, {2}, std::vector<T>{11, 21}),
"gather_nd_scalar_from_3d"),
GatherNDParams(reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
reference_tests::Tensor(element::i32, {2, 2}, std::vector<int32_t>{0, 1, 1, 0}),
0,
reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{12, 13, 20, 21}),
"gather_nd_1d_from_3d"),
GatherNDParams(reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
reference_tests::Tensor(element::i32, {1, 1}, std::vector<int32_t>{1}),
0,
reference_tests::Tensor(IN_ET, {1, 2, 2}, std::vector<T>{20, 21, 22, 23}),
"gather_nd_2d_from_3d"),
GatherNDParams(reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{10, 11, 12, 13}),
reference_tests::Tensor(element::i32, {2, 1, 2}, std::vector<int32_t>{0, 0, 0, 1}),
0,
reference_tests::Tensor(IN_ET, {2, 1}, std::vector<T>{10, 11}),
"gather_nd_batch_scalar_from_2d"),
GatherNDParams(reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{10, 11, 12, 13}),
reference_tests::Tensor(element::i32, {2, 1, 1}, std::vector<int32_t>{1, 0}),
0,
reference_tests::Tensor(IN_ET, {2, 1, 2}, std::vector<T>{12, 13, 10, 11}),
"gather_nd_batch_1d_from_2d"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
reference_tests::Tensor(element::i32, {2, 2, 3}, std::vector<int32_t>{0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0}),
0,
reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{11, 21, 13, 22}),
"gather_nd_batch_scalar_from_3d"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
reference_tests::Tensor(element::i32, {2, 2, 2}, std::vector<int32_t>{0, 1, 1, 0, 0, 0, 1, 1}),
0,
reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{12, 13, 20, 21, 10, 11, 22, 23}),
"gather_nd_batch_1d_from_3d"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
reference_tests::Tensor(element::i32, {2, 2, 2}, std::vector<int32_t>{0, -1, -1, 0, 0, 0, 1, 1}),
0,
reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{12, 13, 20, 21, 10, 11, 22, 23}),
"gather_nd_batch_1d_from_3d_negative"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
reference_tests::Tensor(element::i32, {2, 1, 1}, std::vector<int32_t>{1, 0}),
0,
reference_tests::Tensor(IN_ET, {2, 1, 2, 2}, std::vector<T>{20, 21, 22, 23, 10, 11, 12, 13}),
"gather_nd_batch_2d_from_3d"),
GatherNDParams(reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
reference_tests::Tensor(element::i32, {2, 2, 2}, std::vector<int32_t>{0, 1, 1, 0, 0, 0, 1, 1}),
0,
reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{12, 13, 20, 21, 10, 11, 22, 23}),
"gather_nd_batch_1d_from_3d"),
GatherNDParams(reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
reference_tests::Tensor(element::i32, {2, 2, 2}, std::vector<int32_t>{0, -1, -1, 0, 0, 0, 1, 1}),
0,
reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{12, 13, 20, 21, 10, 11, 22, 23}),
"gather_nd_batch_1d_from_3d_negative"),
GatherNDParams(reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
reference_tests::Tensor(element::i32, {2, 1, 1}, std::vector<int32_t>{1, 0}),
0,
reference_tests::Tensor(IN_ET, {2, 1, 2, 2}, std::vector<T>{20, 21, 22, 23, 10, 11, 12, 13}),
"gather_nd_batch_2d_from_3d"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 3, 4}, std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}),
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}),
reference_tests::Tensor(element::i32, {2, 1}, std::vector<int32_t>{1, 0}),
1,
reference_tests::Tensor(IN_ET, {2, 4}, std::vector<T>{5, 6, 7, 8, 13, 14, 15, 16}),
"gather_nd_batch_dims1"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 3, 4, 2}, std::vector<T>{
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48}),
reference_tests::Tensor(element::i32, {2, 3, 3, 2}, std::vector<int32_t>{
1, 0, 3, 1, 2, 1, 0, 1, 1, 1, 2, 0, 3, 0, 3, 1, 2, 1,
2, 0, 1, 1, 3, 1, 1, 1, 2, 0, 2, 0, 0, 0, 3, 1, 3, 1}),
reference_tests::Tensor(IN_ET,
{2, 3, 4, 2},
std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48}),
reference_tests::Tensor(element::i32,
{2, 3, 3, 2},
std::vector<int32_t>{1, 0, 3, 1, 2, 1, 0, 1, 1, 1, 2, 0, 3, 0, 3, 1, 2, 1,
2, 0, 1, 1, 3, 1, 1, 1, 2, 0, 2, 0, 0, 0, 3, 1, 3, 1}),
2,
reference_tests::Tensor(IN_ET, {6, 3}, std::vector<T>{
3, 8, 6, 10, 12, 13, 23, 24, 22, 29, 28, 32, 36, 37, 37, 41, 48, 48}),
reference_tests::Tensor(
IN_ET,
{6, 3},
std::vector<T>{3, 8, 6, 10, 12, 13, 23, 24, 22, 29, 28, 32, 36, 37, 37, 41, 48, 48}),
"gather_nd_batch_dims2"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 3, 4}, std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}),
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}),
reference_tests::Tensor(element::i32, {2, 3, 1, 1}, std::vector<int32_t>{1, 0, 2, 0, 2, 2}),
2,
reference_tests::Tensor(IN_ET, {6, 1}, std::vector<T>{2, 5, 11, 13, 19, 23}),
@ -181,7 +180,7 @@ std::vector<GatherNDParams> generateParams() {
}
std::vector<GatherNDParams> generateCombinedParams() {
const std::vector<std::vector<GatherNDParams>> generatedParams {
const std::vector<std::vector<GatherNDParams>> generatedParams{
generateParams<element::Type_t::i8>(),
generateParams<element::Type_t::i16>(),
generateParams<element::Type_t::i32>(),
@ -203,9 +202,10 @@ std::vector<GatherNDParams> generateCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_GatherND_With_Hardcoded_Refs, ReferenceGatherND5Test,
testing::ValuesIn(generateCombinedParams()), ReferenceGatherND5Test::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_GatherND_With_Hardcoded_Refs,
ReferenceGatherND5Test,
testing::ValuesIn(generateCombinedParams()),
ReferenceGatherND5Test::getTestCaseName);
class ReferenceGatherND8Test : public testing::TestWithParam<GatherNDParams>, public CommonReferenceTest {
public:
@ -237,17 +237,17 @@ public:
private:
static std::shared_ptr<Model> CreateFunction(const GatherNDParams& params) {
std::shared_ptr<Model> function;
const auto data = std::make_shared<op::v0::Parameter>(params.dataTensor.type,
PartialShape{params.dataTensor.shape});
const auto indices = std::make_shared<op::v0::Parameter>(params.indicesTensor.type,
PartialShape{params.indicesTensor.shape});
const auto data =
std::make_shared<op::v0::Parameter>(params.dataTensor.type, PartialShape{params.dataTensor.shape});
const auto indices =
std::make_shared<op::v0::Parameter>(params.indicesTensor.type, PartialShape{params.indicesTensor.shape});
std::shared_ptr<op::v8::GatherND> gatherND;
if (params.batchDims == 0) {
gatherND = std::make_shared<op::v8::GatherND>(data, indices);
} else {
gatherND = std::make_shared<op::v8::GatherND>(data, indices, params.batchDims);
}
function = std::make_shared<ov::Model>(NodeVector {gatherND}, ParameterVector {data, indices});
function = std::make_shared<ov::Model>(NodeVector{gatherND}, ParameterVector{data, indices});
return function;
}
};
@ -259,142 +259,139 @@ TEST_P(ReferenceGatherND8Test, CompareWithRefs) {
template <element::Type_t IN_ET>
std::vector<GatherNDParams> generateParams_v8() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<GatherNDParams> params {
GatherNDParams(
reference_tests::Tensor(IN_ET, {3, 3}, std::vector<T>{10, 11, 12, 13, 14, 15, 16, 17, 18}),
reference_tests::Tensor(element::i32, {2}, std::vector<int32_t>{1, 2}),
0,
reference_tests::Tensor(IN_ET, {}, std::vector<T>{15}),
"gather_nd_8_single_indices"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{10, 11, 12, 13}),
reference_tests::Tensor(element::i32, {2, 2}, std::vector<int32_t>{0, 0, 1, 1}),
0,
reference_tests::Tensor(IN_ET, {2}, std::vector<T>{10, 13}),
"gather_nd_8_scalar_from_2d"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{10, 11, 12, 13}),
reference_tests::Tensor(element::i32, {2, 1}, std::vector<int32_t>{1, 0}),
0,
reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{12, 13, 10, 11}),
"gather_nd_8_1d_from_2d"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
reference_tests::Tensor(element::i32, {2, 3}, std::vector<int32_t>{0, 0, 1, 1, 0, 1}),
0,
reference_tests::Tensor(IN_ET, {2}, std::vector<T>{11, 21}),
"gather_nd_8_scalar_from_3d"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
reference_tests::Tensor(element::i32, {2, 2}, std::vector<int32_t>{0, 1, 1, 0}),
0,
reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{12, 13, 20, 21}),
"gather_nd_8_1d_from_3d"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
reference_tests::Tensor(element::i32, {1, 1}, std::vector<int32_t>{1}),
0,
reference_tests::Tensor(IN_ET, {1, 2, 2}, std::vector<T>{20, 21, 22, 23}),
"gather_nd_8_2d_from_3d"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{10, 11, 12, 13}),
reference_tests::Tensor(element::i32, {2, 1, 2}, std::vector<int32_t>{0, 0, 0, 1}),
0,
reference_tests::Tensor(IN_ET, {2, 1}, std::vector<T>{10, 11}),
"gather_nd_8_batch_scalar_from_2d"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{10, 11, 12, 13}),
reference_tests::Tensor(element::i32, {2, 1, 1}, std::vector<int32_t>{1, 0}),
0,
reference_tests::Tensor(IN_ET, {2, 1, 2}, std::vector<T>{12, 13, 10, 11}),
"gather_nd_8_batch_1d_from_2d"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
reference_tests::Tensor(element::i32, {2, 2, 3}, std::vector<int32_t>{0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0}),
0,
reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{11, 21, 13, 22}),
"gather_nd_8_batch_scalar_from_3d"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
reference_tests::Tensor(element::i32, {2, 2, 2}, std::vector<int32_t>{0, 1, 1, 0, 0, 0, 1, 1}),
0,
reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{12, 13, 20, 21, 10, 11, 22, 23}),
"gather_nd_8_batch_1d_from_3d"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
reference_tests::Tensor(element::i32, {2, 2, 2}, std::vector<int32_t>{0, -1, -1, 0, 0, 0, 1, 1}),
0,
reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{12, 13, 20, 21, 10, 11, 22, 23}),
"gather_nd_8_batch_1d_from_3d_negative"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
reference_tests::Tensor(element::i32, {2, 1, 1}, std::vector<int32_t>{1, 0}),
0,
reference_tests::Tensor(IN_ET, {2, 1, 2, 2}, std::vector<T>{20, 21, 22, 23, 10, 11, 12, 13}),
"gather_nd_8_batch_2d_from_3d"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 3, 4}, std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}),
reference_tests::Tensor(element::i32, {2, 1}, std::vector<int32_t>{1, 0}),
1,
reference_tests::Tensor(IN_ET, {2, 4}, std::vector<T>{5, 6, 7, 8, 13, 14, 15, 16}),
"gather_nd_8_batch_dims1"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 3, 4, 2}, std::vector<T>{
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48}),
reference_tests::Tensor(element::i32, {2, 3, 3, 2}, std::vector<int32_t>{
1, 0, 3, 1, 2, 1, 0, 1, 1, 1, 2, 0, 3, 0, 3, 1, 2, 1,
2, 0, 1, 1, 3, 1, 1, 1, 2, 0, 2, 0, 0, 0, 3, 1, 3, 1}),
2,
reference_tests::Tensor(IN_ET, {2, 3, 3}, std::vector<T>{
3, 8, 6, 10, 12, 13, 23, 24, 22, 29, 28, 32, 36, 37, 37, 41, 48, 48}),
"gather_8_nd_batch_dims2"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 3, 4}, std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}),
reference_tests::Tensor(element::i32, {2, 3, 1, 1}, std::vector<int32_t>{1, 0, 2, 0, 2, 2}),
2,
reference_tests::Tensor(IN_ET, {2, 3, 1}, std::vector<T>{2, 5, 11, 13, 19, 23}),
"gather_8_nd_batch_dims2_lead_dims"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 3, 4, 5}, std::vector<T>{
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
111, 112, 113, 114, 115, 116, 117, 118, 119, 120}),
reference_tests::Tensor(element::i32, {2, 3, 2, 1}, std::vector<int32_t>{
1, 0, 2, 0, 2, 0, 1, 0, 2, 0, 2, 0}),
2,
reference_tests::Tensor(IN_ET, {2, 3, 2, 5}, std::vector<T>{
6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 31, 32, 33, 34, 35, 21, 22, 23,
24, 25, 51, 52, 53, 54, 55, 41, 42, 43, 44, 45, 66, 67, 68, 69,
70, 61, 62, 63, 64, 65, 91, 92, 93, 94, 95, 81, 82, 83, 84, 85,
111, 112, 113, 114, 115, 101, 102, 103, 104, 105}),
"gather_8_nd_batch_dims2_non_scalar_slices"),
std::vector<GatherNDParams> params{
GatherNDParams(reference_tests::Tensor(IN_ET, {3, 3}, std::vector<T>{10, 11, 12, 13, 14, 15, 16, 17, 18}),
reference_tests::Tensor(element::i32, {2}, std::vector<int32_t>{1, 2}),
0,
reference_tests::Tensor(IN_ET, {}, std::vector<T>{15}),
"gather_nd_8_single_indices"),
GatherNDParams(reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{10, 11, 12, 13}),
reference_tests::Tensor(element::i32, {2, 2}, std::vector<int32_t>{0, 0, 1, 1}),
0,
reference_tests::Tensor(IN_ET, {2}, std::vector<T>{10, 13}),
"gather_nd_8_scalar_from_2d"),
GatherNDParams(reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{10, 11, 12, 13}),
reference_tests::Tensor(element::i32, {2, 1}, std::vector<int32_t>{1, 0}),
0,
reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{12, 13, 10, 11}),
"gather_nd_8_1d_from_2d"),
GatherNDParams(reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
reference_tests::Tensor(element::i32, {2, 3}, std::vector<int32_t>{0, 0, 1, 1, 0, 1}),
0,
reference_tests::Tensor(IN_ET, {2}, std::vector<T>{11, 21}),
"gather_nd_8_scalar_from_3d"),
GatherNDParams(reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
reference_tests::Tensor(element::i32, {2, 2}, std::vector<int32_t>{0, 1, 1, 0}),
0,
reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{12, 13, 20, 21}),
"gather_nd_8_1d_from_3d"),
GatherNDParams(reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
reference_tests::Tensor(element::i32, {1, 1}, std::vector<int32_t>{1}),
0,
reference_tests::Tensor(IN_ET, {1, 2, 2}, std::vector<T>{20, 21, 22, 23}),
"gather_nd_8_2d_from_3d"),
GatherNDParams(reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{10, 11, 12, 13}),
reference_tests::Tensor(element::i32, {2, 1, 2}, std::vector<int32_t>{0, 0, 0, 1}),
0,
reference_tests::Tensor(IN_ET, {2, 1}, std::vector<T>{10, 11}),
"gather_nd_8_batch_scalar_from_2d"),
GatherNDParams(reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{10, 11, 12, 13}),
reference_tests::Tensor(element::i32, {2, 1, 1}, std::vector<int32_t>{1, 0}),
0,
reference_tests::Tensor(IN_ET, {2, 1, 2}, std::vector<T>{12, 13, 10, 11}),
"gather_nd_8_batch_1d_from_2d"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
reference_tests::Tensor(element::i32, {2, 2, 3}, std::vector<int32_t>{0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0}),
0,
reference_tests::Tensor(IN_ET, {2, 2}, std::vector<T>{11, 21, 13, 22}),
"gather_nd_8_batch_scalar_from_3d"),
GatherNDParams(reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
reference_tests::Tensor(element::i32, {2, 2, 2}, std::vector<int32_t>{0, 1, 1, 0, 0, 0, 1, 1}),
0,
reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{12, 13, 20, 21, 10, 11, 22, 23}),
"gather_nd_8_batch_1d_from_3d"),
GatherNDParams(reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
reference_tests::Tensor(element::i32, {2, 2, 2}, std::vector<int32_t>{0, -1, -1, 0, 0, 0, 1, 1}),
0,
reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{12, 13, 20, 21, 10, 11, 22, 23}),
"gather_nd_8_batch_1d_from_3d_negative"),
GatherNDParams(reference_tests::Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
reference_tests::Tensor(element::i32, {2, 1, 1}, std::vector<int32_t>{1, 0}),
0,
reference_tests::Tensor(IN_ET, {2, 1, 2, 2}, std::vector<T>{20, 21, 22, 23, 10, 11, 12, 13}),
"gather_nd_8_batch_2d_from_3d"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 3, 4}, std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}),
reference_tests::Tensor(element::i32, {2, 1}, std::vector<int32_t>{1, 0}),
1,
reference_tests::Tensor(IN_ET, {2, 4}, std::vector<T>{5, 6, 7, 8, 13, 14, 15, 16}),
"gather_nd_8_batch_dims1"),
GatherNDParams(
reference_tests::Tensor(IN_ET,
{2, 3, 4, 2},
std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48}),
reference_tests::Tensor(element::i32,
{2, 3, 3, 2},
std::vector<int32_t>{1, 0, 3, 1, 2, 1, 0, 1, 1, 1, 2, 0, 3, 0, 3, 1, 2, 1,
2, 0, 1, 1, 3, 1, 1, 1, 2, 0, 2, 0, 0, 0, 3, 1, 3, 1}),
2,
reference_tests::Tensor(
IN_ET,
{2, 3, 3},
std::vector<T>{3, 8, 6, 10, 12, 13, 23, 24, 22, 29, 28, 32, 36, 37, 37, 41, 48, 48}),
"gather_8_nd_batch_dims2"),
GatherNDParams(
reference_tests::Tensor(IN_ET, {2, 3, 4}, std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}),
reference_tests::Tensor(element::i32, {2, 3, 1, 1}, std::vector<int32_t>{1, 0, 2, 0, 2, 2}),
2,
reference_tests::Tensor(IN_ET, {2, 3, 1}, std::vector<T>{2, 5, 11, 13, 19, 23}),
"gather_8_nd_batch_dims2_lead_dims"),
GatherNDParams(
reference_tests::Tensor(
IN_ET,
{2, 3, 4, 5},
std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120}),
reference_tests::Tensor(element::i32,
{2, 3, 2, 1},
std::vector<int32_t>{1, 0, 2, 0, 2, 0, 1, 0, 2, 0, 2, 0}),
2,
reference_tests::Tensor(
IN_ET,
{2, 3, 2, 5},
std::vector<T>{6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 31, 32, 33, 34, 35,
21, 22, 23, 24, 25, 51, 52, 53, 54, 55, 41, 42, 43, 44, 45,
66, 67, 68, 69, 70, 61, 62, 63, 64, 65, 91, 92, 93, 94, 95,
81, 82, 83, 84, 85, 111, 112, 113, 114, 115, 101, 102, 103, 104, 105}),
"gather_8_nd_batch_dims2_non_scalar_slices"),
};
return params;
}
std::vector<GatherNDParams> generateCombinedParams_v8() {
const std::vector<std::vector<GatherNDParams>> generatedParams {
generateParams_v8<element::Type_t::i8>(),
generateParams_v8<element::Type_t::i16>(),
generateParams_v8<element::Type_t::i32>(),
generateParams_v8<element::Type_t::i64>(),
generateParams_v8<element::Type_t::u8>(),
generateParams_v8<element::Type_t::u16>(),
generateParams_v8<element::Type_t::u32>(),
generateParams_v8<element::Type_t::u64>(),
generateParams_v8<element::Type_t::bf16>(),
generateParams_v8<element::Type_t::f16>(),
generateParams_v8<element::Type_t::f32>(),
generateParams_v8<element::Type_t::f64>(),
const std::vector<std::vector<GatherNDParams>> generatedParams{
generateParams_v8<element::Type_t::i8>(),
generateParams_v8<element::Type_t::i16>(),
generateParams_v8<element::Type_t::i32>(),
generateParams_v8<element::Type_t::i64>(),
generateParams_v8<element::Type_t::u8>(),
generateParams_v8<element::Type_t::u16>(),
generateParams_v8<element::Type_t::u32>(),
generateParams_v8<element::Type_t::u64>(),
generateParams_v8<element::Type_t::bf16>(),
generateParams_v8<element::Type_t::f16>(),
generateParams_v8<element::Type_t::f32>(),
generateParams_v8<element::Type_t::f64>(),
};
std::vector<GatherNDParams> combinedParams;
@ -404,6 +401,8 @@ std::vector<GatherNDParams> generateCombinedParams_v8() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_GatherND_With_Hardcoded_Refs, ReferenceGatherND8Test,
testing::ValuesIn(generateCombinedParams_v8()), ReferenceGatherND8Test::getTestCaseName);
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_GatherND_With_Hardcoded_Refs,
ReferenceGatherND8Test,
testing::ValuesIn(generateCombinedParams_v8()),
ReferenceGatherND8Test::getTestCaseName);
} // namespace

View File

@ -4,8 +4,8 @@
#include <gtest/gtest.h>
#include "openvino/opsets/opset1.hpp"
#include "base_reference_test.hpp"
#include "openvino/opsets/opset1.hpp"
using namespace reference_tests;
using namespace ov;
@ -64,7 +64,8 @@ private:
const auto max_seq_len = std::make_shared<opset1::Parameter>(params.maxSeqLen.type, params.maxSeqLen.shape);
const auto end_token = std::make_shared<opset1::Parameter>(params.endToken.type, params.endToken.shape);
const auto gather_tree = std::make_shared<opset1::GatherTree>(step_ids, parent_idx, max_seq_len, end_token);
const auto f = std::make_shared<Model>(gather_tree, ParameterVector{step_ids, parent_idx, max_seq_len, end_token});
const auto f =
std::make_shared<Model>(gather_tree, ParameterVector{step_ids, parent_idx, max_seq_len, end_token});
return f;
}
};
@ -76,84 +77,72 @@ TEST_P(ReferenceGatherTreeTest, CompareWithRefs) {
template <element::Type_t ET>
std::vector<GatherTreeParams> generateParams() {
using T = typename element_type_traits<ET>::value_type;
std::vector<GatherTreeParams> params {
Builder {}
.stepIds(reference_tests::Tensor(ET, {1, 1, 10}, std::vector<T>{
1, 4, 9, 7, 9, 1, 2, 3, 9, 9}))
.parentIdx(reference_tests::Tensor(ET, {1, 1, 10}, std::vector<T>{
1, 4, 9, 7, 9, 1, 2, 3, 9, 9}))
.maxSeqLen(reference_tests::Tensor(ET, {1}, std::vector<T>{9}))
.endToken(reference_tests::Tensor(ET, {}, std::vector<T>{9}))
.finalIdx(reference_tests::Tensor(ET, {1, 1, 10}, std::vector<T>{
1, 4, 9, 7, 9, 1, 2, 3, 9, 9}))
.testcaseName("gather_tree_1"),
std::vector<GatherTreeParams> params{
Builder{}
.stepIds(reference_tests::Tensor(ET, {1, 1, 10}, std::vector<T>{1, 4, 9, 7, 9, 1, 2, 3, 9, 9}))
.parentIdx(reference_tests::Tensor(ET, {1, 1, 10}, std::vector<T>{1, 4, 9, 7, 9, 1, 2, 3, 9, 9}))
.maxSeqLen(reference_tests::Tensor(ET, {1}, std::vector<T>{9}))
.endToken(reference_tests::Tensor(ET, {}, std::vector<T>{9}))
.finalIdx(reference_tests::Tensor(ET, {1, 1, 10}, std::vector<T>{1, 4, 9, 7, 9, 1, 2, 3, 9, 9}))
.testcaseName("gather_tree_1"),
Builder {}
.stepIds(reference_tests::Tensor(ET, {5, 1, 10}, std::vector<T>{
1, 4, 9, 7, 9, 1, 2, 3, 9, 2,
3, 1, 4, 2, 4, 4, 7, 4, 9, 5,
8, 4, 3, 7, 5, 2, 4, 8, 3, 1,
5, 7, 9, 4, 5, 6, 4, 2, 9, 2,
8, 8, 7, 9, 8, 3, 1, 7, 5, 9}))
.parentIdx(reference_tests::Tensor(ET, {5, 1, 10}, std::vector<T>{
1, 4, 9, 7, 9, 1, 2, 3, 9, 2,
3, 1, 4, 2, 4, 4, 7, 4, 9, 5,
8, 4, 3, 7, 5, 2, 4, 8, 3, 1,
5, 7, 9, 4, 5, 6, 4, 2, 9, 2,
8, 8, 7, 9, 8, 3, 1, 7, 5, 9}))
.maxSeqLen(reference_tests::Tensor(ET, {1}, std::vector<T>{9}))
.endToken(reference_tests::Tensor(ET, {}, std::vector<T>{9}))
.finalIdx(reference_tests::Tensor(ET, {5, 1, 10}, std::vector<T>{
4, 4, 9, 9, 4, 9, 2, 9, 9, 9,
1, 1, 9, 9, 1, 9, 9, 9, 9, 9,
1, 1, 9, 9, 1, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9}))
.testcaseName("gather_tree_5"),
Builder{}
.stepIds(reference_tests::Tensor(ET, {5, 1, 10}, std::vector<T>{1, 4, 9, 7, 9, 1, 2, 3, 9, 2, 3, 1, 4,
2, 4, 4, 7, 4, 9, 5, 8, 4, 3, 7, 5, 2,
4, 8, 3, 1, 5, 7, 9, 4, 5, 6, 4, 2, 9,
2, 8, 8, 7, 9, 8, 3, 1, 7, 5, 9}))
.parentIdx(reference_tests::Tensor(ET, {5, 1, 10}, std::vector<T>{1, 4, 9, 7, 9, 1, 2, 3, 9, 2, 3, 1, 4,
2, 4, 4, 7, 4, 9, 5, 8, 4, 3, 7, 5, 2,
4, 8, 3, 1, 5, 7, 9, 4, 5, 6, 4, 2, 9,
2, 8, 8, 7, 9, 8, 3, 1, 7, 5, 9}))
.maxSeqLen(reference_tests::Tensor(ET, {1}, std::vector<T>{9}))
.endToken(reference_tests::Tensor(ET, {}, std::vector<T>{9}))
.finalIdx(reference_tests::Tensor(ET, {5, 1, 10}, std::vector<T>{4, 4, 9, 9, 4, 9, 2, 9, 9, 9, 1, 1, 9,
9, 1, 9, 9, 9, 9, 9, 1, 1, 9, 9, 1, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9}))
.testcaseName("gather_tree_5"),
Builder {}
.stepIds(reference_tests::Tensor(ET, {20, 1, 10}, std::vector<T>{
1, 4, 9, 7, 9, 1, 2, 3, 9, 2, 3, 1, 4, 2, 4, 4, 7, 4, 9, 5,
8, 4, 3, 7, 5, 2, 4, 8, 3, 1, 5, 7, 9, 4, 5, 6, 4, 2, 9, 2,
8, 8, 7, 9, 8, 3, 1, 7, 5, 8, 8, 9, 8, 1, 8, 1, 3, 2, 1, 8,
7, 1, 6, 4, 7, 9, 4, 5, 2, 7, 3, 3, 2, 7, 8, 8, 4, 1, 1, 7,
6, 9, 6, 7, 3, 3, 5, 8, 2, 1, 1, 5, 5, 9, 1, 3, 9, 3, 2, 2,
5, 1, 1, 7, 9, 2, 9, 3, 3, 5, 6, 1, 6, 6, 6, 2, 9, 6, 3, 7,
3, 1, 5, 4, 9, 7, 5, 4, 5, 1, 7, 5, 1, 6, 2, 5, 8, 9, 1, 6,
8, 9, 5, 2, 5, 2, 9, 8, 4, 4, 5, 2, 6, 9, 4, 4, 6, 7, 6, 7,
2, 8, 7, 6, 6, 7, 4, 4, 7, 3, 4, 9, 7, 4, 8, 9, 1, 6, 5, 6,
1, 2, 8, 9, 1, 5, 4, 6, 9, 4, 4, 3, 7, 9, 7, 6, 3, 1, 7, 9}))
.parentIdx(reference_tests::Tensor(ET, {20, 1, 10}, std::vector<T>{
1, 4, 9, 7, 9, 1, 2, 3, 9, 2, 3, 1, 4, 2, 4, 4, 7, 4, 9, 5,
8, 4, 3, 7, 5, 2, 4, 8, 3, 1, 5, 7, 9, 4, 5, 6, 4, 2, 9, 2,
8, 8, 7, 9, 8, 3, 1, 7, 5, 8, 8, 9, 8, 1, 8, 1, 3, 2, 1, 8,
7, 1, 6, 4, 7, 9, 4, 5, 2, 7, 3, 3, 2, 7, 8, 8, 4, 1, 1, 7,
6, 9, 6, 7, 3, 3, 5, 8, 2, 1, 1, 5, 5, 9, 1, 3, 9, 3, 2, 2,
5, 1, 1, 7, 9, 2, 9, 3, 3, 5, 6, 1, 6, 6, 6, 2, 9, 6, 3, 7,
3, 1, 5, 4, 9, 7, 5, 4, 5, 1, 7, 5, 1, 6, 2, 5, 8, 9, 1, 6,
8, 9, 5, 2, 5, 2, 9, 8, 4, 4, 5, 2, 6, 9, 4, 4, 6, 7, 6, 7,
2, 8, 7, 6, 6, 7, 4, 4, 7, 3, 4, 9, 7, 4, 8, 9, 1, 6, 5, 6,
1, 2, 8, 9, 1, 5, 4, 6, 9, 4, 4, 3, 7, 9, 7, 6, 3, 1, 7, 9}))
.maxSeqLen(reference_tests::Tensor(ET, {1}, std::vector<T>{9}))
.endToken(reference_tests::Tensor(ET, {}, std::vector<T>{9}))
.finalIdx(reference_tests::Tensor(ET, {20, 1, 10}, std::vector<T>{
9, 4, 9, 4, 4, 4, 9, 4, 9, 9, 9, 1, 9, 1, 1, 1, 9, 1, 9, 9,
9, 1, 9, 1, 1, 1, 9, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9}))
.testcaseName("gather_tree_10"),
Builder{}
.stepIds(reference_tests::Tensor(
ET,
{20, 1, 10},
std::vector<T>{1, 4, 9, 7, 9, 1, 2, 3, 9, 2, 3, 1, 4, 2, 4, 4, 7, 4, 9, 5, 8, 4, 3, 7, 5, 2, 4, 8, 3,
1, 5, 7, 9, 4, 5, 6, 4, 2, 9, 2, 8, 8, 7, 9, 8, 3, 1, 7, 5, 8, 8, 9, 8, 1, 8, 1, 3, 2,
1, 8, 7, 1, 6, 4, 7, 9, 4, 5, 2, 7, 3, 3, 2, 7, 8, 8, 4, 1, 1, 7, 6, 9, 6, 7, 3, 3, 5,
8, 2, 1, 1, 5, 5, 9, 1, 3, 9, 3, 2, 2, 5, 1, 1, 7, 9, 2, 9, 3, 3, 5, 6, 1, 6, 6, 6, 2,
9, 6, 3, 7, 3, 1, 5, 4, 9, 7, 5, 4, 5, 1, 7, 5, 1, 6, 2, 5, 8, 9, 1, 6, 8, 9, 5, 2, 5,
2, 9, 8, 4, 4, 5, 2, 6, 9, 4, 4, 6, 7, 6, 7, 2, 8, 7, 6, 6, 7, 4, 4, 7, 3, 4, 9, 7, 4,
8, 9, 1, 6, 5, 6, 1, 2, 8, 9, 1, 5, 4, 6, 9, 4, 4, 3, 7, 9, 7, 6, 3, 1, 7, 9}))
.parentIdx(reference_tests::Tensor(
ET,
{20, 1, 10},
std::vector<T>{1, 4, 9, 7, 9, 1, 2, 3, 9, 2, 3, 1, 4, 2, 4, 4, 7, 4, 9, 5, 8, 4, 3, 7, 5, 2, 4, 8, 3,
1, 5, 7, 9, 4, 5, 6, 4, 2, 9, 2, 8, 8, 7, 9, 8, 3, 1, 7, 5, 8, 8, 9, 8, 1, 8, 1, 3, 2,
1, 8, 7, 1, 6, 4, 7, 9, 4, 5, 2, 7, 3, 3, 2, 7, 8, 8, 4, 1, 1, 7, 6, 9, 6, 7, 3, 3, 5,
8, 2, 1, 1, 5, 5, 9, 1, 3, 9, 3, 2, 2, 5, 1, 1, 7, 9, 2, 9, 3, 3, 5, 6, 1, 6, 6, 6, 2,
9, 6, 3, 7, 3, 1, 5, 4, 9, 7, 5, 4, 5, 1, 7, 5, 1, 6, 2, 5, 8, 9, 1, 6, 8, 9, 5, 2, 5,
2, 9, 8, 4, 4, 5, 2, 6, 9, 4, 4, 6, 7, 6, 7, 2, 8, 7, 6, 6, 7, 4, 4, 7, 3, 4, 9, 7, 4,
8, 9, 1, 6, 5, 6, 1, 2, 8, 9, 1, 5, 4, 6, 9, 4, 4, 3, 7, 9, 7, 6, 3, 1, 7, 9}))
.maxSeqLen(reference_tests::Tensor(ET, {1}, std::vector<T>{9}))
.endToken(reference_tests::Tensor(ET, {}, std::vector<T>{9}))
.finalIdx(reference_tests::Tensor(
ET,
{20, 1, 10},
std::vector<T>{9, 4, 9, 4, 4, 4, 9, 4, 9, 9, 9, 1, 9, 1, 1, 1, 9, 1, 9, 9, 9, 1, 9, 1, 1, 1, 9, 1, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9}))
.testcaseName("gather_tree_10"),
};
return params;
}
std::vector<GatherTreeParams> generateCombinedParams() {
const std::vector<std::vector<GatherTreeParams>> generatedParams {
const std::vector<std::vector<GatherTreeParams>> generatedParams{
generateParams<element::Type_t::i32>(),
generateParams<element::Type_t::f32>(),
};
@ -165,6 +154,8 @@ std::vector<GatherTreeParams> generateCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_GatherTree_With_Hardcoded_Refs, ReferenceGatherTreeTest,
testing::ValuesIn(generateCombinedParams()), ReferenceGatherTreeTest::getTestCaseName);
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_GatherTree_With_Hardcoded_Refs,
ReferenceGatherTreeTest,
testing::ValuesIn(generateCombinedParams()),
ReferenceGatherTreeTest::getTestCaseName);
} // namespace

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/gelu.hpp"
#include <gtest/gtest.h>
#include "openvino/op/gelu.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
@ -14,8 +15,11 @@ using namespace InferenceEngine;
namespace {
struct GeluParams {
template <class IT>
GeluParams(const ov::PartialShape& shape, const ov::element::Type& iType, const std::vector<IT>& iValues, const std::vector<IT>& oValues,
const ov::op::GeluApproximationMode mode)
GeluParams(const ov::PartialShape& shape,
const ov::element::Type& iType,
const std::vector<IT>& iValues,
const std::vector<IT>& oValues,
const ov::op::GeluApproximationMode mode)
: mode(mode),
pshape(shape),
inType(iType),
@ -49,11 +53,13 @@ public:
}
private:
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape, const element::Type& input_type,
const element::Type& expected_output_type, const op::GeluApproximationMode mode) {
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape,
const element::Type& input_type,
const element::Type& expected_output_type,
const op::GeluApproximationMode mode) {
const auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
const auto Gelu = std::make_shared<op::v0::Gelu>(in);
return std::make_shared<ov::Model>(NodeVector {Gelu}, ParameterVector {in});
return std::make_shared<ov::Model>(NodeVector{Gelu}, ParameterVector{in});
}
};
@ -76,11 +82,13 @@ public:
}
private:
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape, const element::Type& input_type,
const element::Type& expected_output_type, const op::GeluApproximationMode mode) {
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape,
const element::Type& input_type,
const element::Type& expected_output_type,
const op::GeluApproximationMode mode) {
const auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
const auto Gelu = std::make_shared<op::v7::Gelu>(in, mode);
return std::make_shared<ov::Model>(NodeVector {Gelu}, ParameterVector {in});
return std::make_shared<ov::Model>(NodeVector{Gelu}, ParameterVector{in});
}
};
@ -95,18 +103,19 @@ template <element::Type_t IN_ET>
std::vector<GeluParams> generateGeluV0FloatParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<GeluParams> geluParams {
GeluParams(ov::PartialShape {8},
IN_ET,
std::vector<T>{-4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0},
std::vector<T>{-0.00012636185, -0.0040495098, -0.04550028, -0.15865529, 0.0, 0.8413447, 1.9544997, 2.9959507},
op::GeluApproximationMode::ERF),
GeluParams(ov::PartialShape {3},
IN_ET,
std::vector<T>{-0.5, 0.1, 0.4},
std::vector<T>{-0.15426877, 0.05398279, 0.2621686},
op::GeluApproximationMode::ERF)
};
std::vector<GeluParams> geluParams{
GeluParams(
ov::PartialShape{8},
IN_ET,
std::vector<T>{-4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0},
std::vector<
T>{-0.00012636185, -0.0040495098, -0.04550028, -0.15865529, 0.0, 0.8413447, 1.9544997, 2.9959507},
op::GeluApproximationMode::ERF),
GeluParams(ov::PartialShape{3},
IN_ET,
std::vector<T>{-0.5, 0.1, 0.4},
std::vector<T>{-0.15426877, 0.05398279, 0.2621686},
op::GeluApproximationMode::ERF)};
return geluParams;
}
@ -114,36 +123,37 @@ template <element::Type_t IN_ET>
std::vector<GeluParams> generateGeluV7FloatParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<GeluParams> geluParams {
GeluParams(ov::PartialShape {8},
IN_ET,
std::vector<T>{-4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0},
std::vector<T>{-0.00012636185, -0.0040495098, -0.04550028, -0.15865529, 0.0, 0.8413447, 1.9544997, 2.9959507},
op::GeluApproximationMode::ERF),
GeluParams(ov::PartialShape {8},
IN_ET,
std::vector<T>{-4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0},
std::vector<T>{-0.00012636185, -0.0040495098, -0.04550028, -0.15865529, 0.0, 0.8413447, 1.9544997, 2.9959507},
op::GeluApproximationMode::TANH),
GeluParams(ov::PartialShape {3},
IN_ET,
std::vector<T>{-0.5, 0.1, 0.4},
std::vector<T>{-0.15426877, 0.05398279, 0.2621686},
op::GeluApproximationMode::ERF),
GeluParams(ov::PartialShape {3},
IN_ET,
std::vector<T>{-0.5, 0.1, 0.4},
std::vector<T>{-0.15428599, 0.053982753, 0.262161165},
op::GeluApproximationMode::TANH)
};
std::vector<GeluParams> geluParams{
GeluParams(
ov::PartialShape{8},
IN_ET,
std::vector<T>{-4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0},
std::vector<
T>{-0.00012636185, -0.0040495098, -0.04550028, -0.15865529, 0.0, 0.8413447, 1.9544997, 2.9959507},
op::GeluApproximationMode::ERF),
GeluParams(
ov::PartialShape{8},
IN_ET,
std::vector<T>{-4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0},
std::vector<
T>{-0.00012636185, -0.0040495098, -0.04550028, -0.15865529, 0.0, 0.8413447, 1.9544997, 2.9959507},
op::GeluApproximationMode::TANH),
GeluParams(ov::PartialShape{3},
IN_ET,
std::vector<T>{-0.5, 0.1, 0.4},
std::vector<T>{-0.15426877, 0.05398279, 0.2621686},
op::GeluApproximationMode::ERF),
GeluParams(ov::PartialShape{3},
IN_ET,
std::vector<T>{-0.5, 0.1, 0.4},
std::vector<T>{-0.15428599, 0.053982753, 0.262161165},
op::GeluApproximationMode::TANH)};
return geluParams;
}
std::vector<GeluParams> generateGeluV0CombinedParams() {
const std::vector<std::vector<GeluParams>> geluTypeParams {
generateGeluV0FloatParams<element::Type_t::f32>(),
generateGeluV0FloatParams<element::Type_t::f16>()
};
const std::vector<std::vector<GeluParams>> geluTypeParams{generateGeluV0FloatParams<element::Type_t::f32>(),
generateGeluV0FloatParams<element::Type_t::f16>()};
std::vector<GeluParams> combinedParams;
for (const auto& params : geluTypeParams) {
@ -153,10 +163,8 @@ std::vector<GeluParams> generateGeluV0CombinedParams() {
}
std::vector<GeluParams> generateGeluV7CombinedParams() {
const std::vector<std::vector<GeluParams>> geluTypeParams {
generateGeluV7FloatParams<element::Type_t::f32>(),
generateGeluV7FloatParams<element::Type_t::f16>()
};
const std::vector<std::vector<GeluParams>> geluTypeParams{generateGeluV7FloatParams<element::Type_t::f32>(),
generateGeluV7FloatParams<element::Type_t::f16>()};
std::vector<GeluParams> combinedParams;
for (const auto& params : geluTypeParams) {
@ -165,10 +173,14 @@ std::vector<GeluParams> generateGeluV7CombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_Gelu_v2_With_Hardcoded_Refs, ReferenceGeluV0LayerTest,
testing::ValuesIn(generateGeluV0CombinedParams()), ReferenceGeluV0LayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Gelu_v2_With_Hardcoded_Refs,
ReferenceGeluV0LayerTest,
testing::ValuesIn(generateGeluV0CombinedParams()),
ReferenceGeluV0LayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Gelu_v7_With_Hardcoded_Refs, ReferenceGeluV7LayerTest,
testing::ValuesIn(generateGeluV7CombinedParams()), ReferenceGeluV7LayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Gelu_v7_With_Hardcoded_Refs,
ReferenceGeluV7LayerTest,
testing::ValuesIn(generateGeluV7CombinedParams()),
ReferenceGeluV7LayerTest::getTestCaseName);
} // namespace
} // namespace

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/generate_proposals.hpp"
#include <gtest/gtest.h>
#include "openvino/op/generate_proposals.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
@ -16,13 +17,20 @@ namespace {
struct GPParams {
template <class IT, class RT>
GPParams(const Attrs& attrs,
const size_t batch, const size_t number_of_channels, const size_t height, const size_t width,
const element::Type& iType, const element::Type& roiNumType,
const std::vector<IT>& imageSizeInfoValues, const std::vector<IT>& anchorsValues,
const std::vector<IT>& deltasValues, const std::vector<IT>& scoresValues,
const std::vector<IT>& refRoisValues, const std::vector<IT>& refScoresValues,
const std::vector<RT>& refRoiNumValues,
const std::string& testcaseName = "")
const size_t batch,
const size_t number_of_channels,
const size_t height,
const size_t width,
const element::Type& iType,
const element::Type& roiNumType,
const std::vector<IT>& imageSizeInfoValues,
const std::vector<IT>& anchorsValues,
const std::vector<IT>& deltasValues,
const std::vector<IT>& scoresValues,
const std::vector<IT>& refRoisValues,
const std::vector<IT>& refScoresValues,
const std::vector<RT>& refRoiNumValues,
const std::string& testcaseName = "")
: attrs(attrs),
inType(iType),
outType(iType),
@ -35,11 +43,11 @@ struct GPParams {
refScoresData(CreateTensor(iType, refScoresValues)),
refRoiNumData(CreateTensor(roiNumType, refRoiNumValues)),
testcaseName(testcaseName) {
imageSizeInfoShape = Shape{batch, 3};
anchorsShape = Shape{height, width, number_of_channels, 4};
deltasShape = Shape{batch, number_of_channels * 4, height, width};
scoresShape = Shape{batch, number_of_channels, height, width};
}
imageSizeInfoShape = Shape{batch, 3};
anchorsShape = Shape{height, width, number_of_channels, 4};
deltasShape = Shape{batch, number_of_channels * 4, height, width};
scoresShape = Shape{batch, number_of_channels, height, width};
}
Attrs attrs;
PartialShape imageSizeInfoShape;
@ -88,13 +96,11 @@ private:
const auto anchors = std::make_shared<op::v0::Parameter>(params.inType, params.anchorsShape);
const auto deltas = std::make_shared<op::v0::Parameter>(params.inType, params.deltasShape);
const auto scores = std::make_shared<op::v0::Parameter>(params.inType, params.scoresShape);
const auto GenerateProposal = std::make_shared<op::v9::GenerateProposals>(im_info,
anchors,
deltas,
scores,
params.attrs);
const auto GenerateProposal =
std::make_shared<op::v9::GenerateProposals>(im_info, anchors, deltas, scores, params.attrs);
GenerateProposal->set_roi_num_type(params.roiNumType);
return std::make_shared<ov::Model>(GenerateProposal->outputs(), ParameterVector {im_info, anchors, deltas, scores});
return std::make_shared<ov::Model>(GenerateProposal->outputs(),
ParameterVector{im_info, anchors, deltas, scores});
}
};
@ -115,185 +121,194 @@ std::vector<GPParams> generateGPFloatParams() {
attrs.nms_eta = 1.0;
attrs.normalized = true;
std::vector<GPParams> generateProposalParams {
std::vector<GPParams> generateProposalParams{
GPParams(attrs,
1,
3, // A
2, // H
6, // W
IN_ET,
OUT_RT,
std::vector<T>{1.0f, 1.0f, 0.0f},
std::vector<T>(144, 1.0f), // anchors [H, W, A, 4]
std::vector<T>(144, 1.0f), // deltas [N, A * 4, H, W]
std::vector<T>{5.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 4.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 8.0f, 1.0f}, // scores [N, A, H, W]
std::vector<T>(24, 1.0f), // ref rois
std::vector<T>{8.0f, 5.0f, 4.0f, 1.0f, 1.0f, 1.0f}, // ref scores
std::vector<RT>{6}, // ref roiNum
"eval"),
1,
3, // A
2, // H
6, // W
IN_ET,
OUT_RT,
std::vector<T>{1.0f, 1.0f, 0.0f},
std::vector<T>(144, 1.0f), // anchors [H, W, A, 4]
std::vector<T>(144, 1.0f), // deltas [N, A * 4, H, W]
std::vector<T>{5.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 4.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 8.0f, 1.0f}, // scores [N, A, H, W]
std::vector<T>(24, 1.0f), // ref rois
std::vector<T>{8.0f, 5.0f, 4.0f, 1.0f, 1.0f, 1.0f}, // ref scores
std::vector<RT>{6}, // ref roiNum
"eval"),
GPParams(
attrs,
2,
3,
2,
6,
IN_ET,
OUT_RT,
std::vector<T>{150.0, 150.0, 0.0, 150.0, 150.0, 0.0},
std::vector<T>{
12.0, 68.0, 102.0, 123.0, 46.0, 80.0, 79.0, 128.0, 33.0, 71.0, 127.0, 86.0, 33.0, 56.0, 150.0,
73.0, 5.0, 41.0, 93.0, 150.0, 74.0, 66.0, 106.0, 115.0, 17.0, 37.0, 87.0, 150.0, 31.0, 27.0,
150.0, 39.0, 29.0, 23.0, 112.0, 123.0, 41.0, 37.0, 103.0, 150.0, 8.0, 46.0, 98.0, 111.0, 7.0,
69.0, 114.0, 150.0, 70.0, 21.0, 150.0, 125.0, 54.0, 19.0, 132.0, 68.0, 62.0, 8.0, 150.0, 101.0,
57.0, 81.0, 150.0, 97.0, 79.0, 29.0, 109.0, 130.0, 12.0, 63.0, 100.0, 150.0, 17.0, 33.0, 113.0,
150.0, 90.0, 78.0, 150.0, 111.0, 47.0, 68.0, 150.0, 71.0, 66.0, 103.0, 111.0, 150.0, 4.0, 17.0,
112.0, 94.0, 12.0, 8.0, 119.0, 98.0, 54.0, 56.0, 120.0, 150.0, 56.0, 29.0, 150.0, 31.0, 42.0,
3.0, 139.0, 92.0, 41.0, 65.0, 150.0, 130.0, 49.0, 13.0, 143.0, 30.0, 40.0, 60.0, 150.0, 150.0,
23.0, 73.0, 24.0, 115.0, 56.0, 84.0, 107.0, 108.0, 63.0, 8.0, 142.0, 125.0, 78.0, 37.0, 93.0,
144.0, 40.0, 34.0, 150.0, 46.0, 30.0, 21.0, 150.0, 120.0},
std::vector<T>{
9.062256, 10.883133, 9.8441105, 12.694285, 0.41781136, 8.749107, 14.990341, 6.587644,
1.4206103, 13.299262, 12.432549, 2.736371, 0.22732796, 6.3361835, 12.268727, 2.1009045,
4.771589, 2.5131326, 5.610736, 9.3604145, 4.27379, 8.317948, 0.60510135, 6.7446275,
1.0207708, 1.1352817, 1.5785321, 1.718335, 1.8093798, 0.99247587, 1.3233583, 1.7432803,
1.8534478, 1.2593061, 1.7394226, 1.7686696, 1.647999, 1.7611449, 1.3119122, 0.03007332,
1.1106564, 0.55669737, 0.2546148, 1.9181818, 0.7134989, 2.0407224, 1.7211134, 1.8565536,
14.562747, 2.8786168, 0.5927796, 0.2064463, 7.6794515, 8.672126, 10.139171, 8.002429,
7.002932, 12.6314945, 10.550842, 0.15784842, 0.3194304, 10.752157, 3.709805, 11.628928,
0.7136225, 14.619964, 15.177284, 2.2824087, 15.381494, 0.16618137, 7.507227, 11.173228,
0.4923559, 1.8227729, 1.4749299, 1.7833921, 1.2363617, -0.23659119, 1.5737582, 1.779316,
1.9828427, 1.0482665, 1.4900246, 1.3563544, 1.5341306, 0.7634312, 4.6216766e-05, 1.6161222,
1.7512476, 1.9363779, 0.9195784, 1.4906164, -0.03244795, 0.681073, 0.6192401, 1.8033613,
14.146055, 3.4043705, 15.292292, 3.5295358, 11.138999, 9.952057, 5.633434, 12.114562,
9.427372, 12.384038, 9.583308, 8.427233, 15.293704, 3.288159, 11.64898, 9.350885,
2.0037227, 13.523184, 4.4176426, 6.1057625, 14.400079, 8.248259, 11.815807, 15.713364,
1.0023532, 1.3203261, 1.7100681, 0.7407832, 1.09448, 1.7188418, 1.4412547, 1.4862992,
0.74790007, 0.31571656, 0.6398838, 2.0236106, 1.1869069, 1.7265586, 1.2624544, 0.09934269,
1.3508598, 0.85212964, -0.38968498, 1.7059708, 1.6533034, 1.7400402, 1.8123854, -0.43063712,
9.062256, 10.883133, 9.8441105, 12.694285, 0.41781136, 8.749107, 14.990341, 6.587644,
1.4206103, 13.299262, 12.432549, 2.736371, 0.22732796, 6.3361835, 12.268727, 2.1009045,
4.771589, 2.5131326, 5.610736, 9.3604145, 4.27379, 8.317948, 0.60510135, 6.7446275,
1.0207708, 1.1352817, 1.5785321, 1.718335, 1.8093798, 0.99247587, 1.3233583, 1.7432803,
1.8534478, 1.2593061, 1.7394226, 1.7686696, 1.647999, 1.7611449, 1.3119122, 0.03007332,
1.1106564, 0.55669737, 0.2546148, 1.9181818, 0.7134989, 2.0407224, 1.7211134, 1.8565536,
14.562747, 2.8786168, 0.5927796, 0.2064463, 7.6794515, 8.672126, 10.139171, 8.002429,
7.002932, 12.6314945, 10.550842, 0.15784842, 0.3194304, 10.752157, 3.709805, 11.628928,
0.7136225, 14.619964, 15.177284, 2.2824087, 15.381494, 0.16618137, 7.507227, 11.173228,
0.4923559, 1.8227729, 1.4749299, 1.7833921, 1.2363617, -0.23659119, 1.5737582, 1.779316,
1.9828427, 1.0482665, 1.4900246, 1.3563544, 1.5341306, 0.7634312, 4.6216766e-05, 1.6161222,
1.7512476, 1.9363779, 0.9195784, 1.4906164, -0.03244795, 0.681073, 0.6192401, 1.8033613,
14.146055, 3.4043705, 15.292292, 3.5295358, 11.138999, 9.952057, 5.633434, 12.114562,
9.427372, 12.384038, 9.583308, 8.427233, 15.293704, 3.288159, 11.64898, 9.350885,
2.0037227, 13.523184, 4.4176426, 6.1057625, 14.400079, 8.248259, 11.815807, 15.713364,
1.0023532, 1.3203261, 1.7100681, 0.7407832, 1.09448, 1.7188418, 1.4412547, 1.4862992,
0.74790007, 0.31571656, 0.6398838, 2.0236106, 1.1869069, 1.7265586, 1.2624544, 0.09934269,
1.3508598, 0.85212964, -0.38968498, 1.7059708, 1.6533034, 1.7400402, 1.8123854, -0.43063712},
std::vector<T>{
0.7719922, 0.35906568, 0.29054508, 0.18124384, 0.5604661, 0.84750974, 0.98948747, 0.009793862,
0.7184191, 0.5560748, 0.6952493, 0.6732593, 0.3306898, 0.6790913, 0.41128764, 0.34593266,
0.94296855, 0.7348507, 0.24478768, 0.94024557, 0.05405676, 0.06466125, 0.36244348, 0.07942984,
0.10619422, 0.09412837, 0.9053611, 0.22870538, 0.9237487, 0.20986171, 0.5067282, 0.29709867,
0.53138554, 0.189101, 0.4786443, 0.88421875, 0.7719922, 0.35906568, 0.29054508, 0.18124384,
0.5604661, 0.84750974, 0.98948747, 0.009793862, 0.7184191, 0.5560748, 0.6952493, 0.6732593,
0.3306898, 0.6790913, 0.41128764, 0.34593266, 0.94296855, 0.7348507, 0.24478768, 0.94024557,
0.05405676, 0.06466125, 0.36244348, 0.07942984, 0.10619422, 0.09412837, 0.9053611, 0.22870538,
0.9237487, 0.20986171, 0.5067282, 0.29709867, 0.53138554, 0.189101, 0.4786443, 0.88421875},
std::vector<T>{149, 149,
149, 149,
149, 0,
149, 149,
149, 60.87443542480469,
149, 149,
149, 61.89498901367188,
149, 149,
149, 149,
149, 149,
149, 149,
149, 149,
149, 149,
149, 149,
149, 0,
149, 149,
149, 60.87443542480469,
149, 149,
149, 61.89498901367188,
149, 149,
149, 149,
149, 149,
149, 149,
149, 149},
std::vector<T>{0.9894874691963196,
0.9429685473442078,
0.9402455687522888,
0.9237486720085144,
0.9053611159324646,
0.8842187523841858,
0.9894874691963196,
0.9429685473442078,
0.9402455687522888,
0.9237486720085144,
0.9053611159324646,
0.8842187523841858},
std::vector<RT>{6, 6},
"batch_2"),
GPParams(attrs,
2,
3,
2,
6,
IN_ET,
OUT_RT,
std::vector<T>{150.0, 150.0, 0.0, 150.0, 150.0, 0.0},
std::vector<T>{12.0, 68.0, 102.0, 123.0, 46.0, 80.0, 79.0, 128.0, 33.0, 71.0, 127.0, 86.0, 33.0, 56.0, 150.0, 73.0,
5.0, 41.0, 93.0, 150.0, 74.0, 66.0, 106.0, 115.0, 17.0, 37.0, 87.0, 150.0, 31.0, 27.0, 150.0, 39.0,
29.0, 23.0, 112.0, 123.0, 41.0, 37.0, 103.0, 150.0, 8.0, 46.0, 98.0, 111.0, 7.0, 69.0, 114.0, 150.0,
70.0, 21.0, 150.0, 125.0, 54.0, 19.0, 132.0, 68.0, 62.0, 8.0, 150.0, 101.0, 57.0, 81.0, 150.0, 97.0,
79.0, 29.0, 109.0, 130.0, 12.0, 63.0, 100.0, 150.0, 17.0, 33.0, 113.0, 150.0, 90.0, 78.0, 150.0, 111.0,
47.0, 68.0, 150.0, 71.0, 66.0, 103.0, 111.0, 150.0, 4.0, 17.0, 112.0, 94.0, 12.0, 8.0, 119.0, 98.0,
54.0, 56.0, 120.0, 150.0, 56.0, 29.0, 150.0, 31.0, 42.0, 3.0, 139.0, 92.0, 41.0, 65.0, 150.0, 130.0,
49.0, 13.0, 143.0, 30.0, 40.0, 60.0, 150.0, 150.0, 23.0, 73.0, 24.0, 115.0, 56.0, 84.0, 107.0, 108.0,
63.0, 8.0, 142.0, 125.0, 78.0, 37.0, 93.0, 144.0, 40.0, 34.0, 150.0, 46.0, 30.0, 21.0, 150.0, 120.0},
std::vector<T>{9.062256, 10.883133, 9.8441105, 12.694285, 0.41781136, 8.749107, 14.990341, 6.587644, 1.4206103,
13.299262, 12.432549, 2.736371, 0.22732796, 6.3361835, 12.268727, 2.1009045, 4.771589, 2.5131326,
5.610736, 9.3604145, 4.27379, 8.317948, 0.60510135, 6.7446275, 1.0207708, 1.1352817, 1.5785321,
1.718335, 1.8093798, 0.99247587, 1.3233583, 1.7432803, 1.8534478, 1.2593061, 1.7394226, 1.7686696,
1.647999, 1.7611449, 1.3119122, 0.03007332, 1.1106564, 0.55669737, 0.2546148, 1.9181818, 0.7134989,
2.0407224, 1.7211134, 1.8565536, 14.562747, 2.8786168, 0.5927796, 0.2064463, 7.6794515, 8.672126,
10.139171, 8.002429, 7.002932, 12.6314945, 10.550842, 0.15784842, 0.3194304, 10.752157, 3.709805,
11.628928, 0.7136225, 14.619964, 15.177284, 2.2824087, 15.381494, 0.16618137, 7.507227, 11.173228,
0.4923559, 1.8227729, 1.4749299, 1.7833921, 1.2363617, -0.23659119, 1.5737582, 1.779316, 1.9828427,
1.0482665, 1.4900246, 1.3563544, 1.5341306, 0.7634312, 4.6216766e-05, 1.6161222, 1.7512476, 1.9363779,
0.9195784, 1.4906164, -0.03244795, 0.681073, 0.6192401, 1.8033613, 14.146055, 3.4043705, 15.292292,
3.5295358, 11.138999, 9.952057, 5.633434, 12.114562, 9.427372, 12.384038, 9.583308, 8.427233,
15.293704, 3.288159, 11.64898, 9.350885, 2.0037227, 13.523184, 4.4176426, 6.1057625, 14.400079,
8.248259, 11.815807, 15.713364, 1.0023532, 1.3203261, 1.7100681, 0.7407832, 1.09448, 1.7188418,
1.4412547, 1.4862992, 0.74790007, 0.31571656, 0.6398838, 2.0236106, 1.1869069, 1.7265586, 1.2624544,
0.09934269, 1.3508598, 0.85212964, -0.38968498, 1.7059708, 1.6533034, 1.7400402, 1.8123854, -0.43063712,
9.062256, 10.883133, 9.8441105, 12.694285, 0.41781136, 8.749107, 14.990341, 6.587644, 1.4206103,
13.299262, 12.432549, 2.736371, 0.22732796, 6.3361835, 12.268727, 2.1009045, 4.771589, 2.5131326,
5.610736, 9.3604145, 4.27379, 8.317948, 0.60510135, 6.7446275, 1.0207708, 1.1352817, 1.5785321,
1.718335, 1.8093798, 0.99247587, 1.3233583, 1.7432803, 1.8534478, 1.2593061, 1.7394226, 1.7686696,
1.647999, 1.7611449, 1.3119122, 0.03007332, 1.1106564, 0.55669737, 0.2546148, 1.9181818, 0.7134989,
2.0407224, 1.7211134, 1.8565536, 14.562747, 2.8786168, 0.5927796, 0.2064463, 7.6794515, 8.672126,
10.139171, 8.002429, 7.002932, 12.6314945, 10.550842, 0.15784842, 0.3194304, 10.752157, 3.709805,
11.628928, 0.7136225, 14.619964, 15.177284, 2.2824087, 15.381494, 0.16618137, 7.507227, 11.173228,
0.4923559, 1.8227729, 1.4749299, 1.7833921, 1.2363617, -0.23659119, 1.5737582, 1.779316, 1.9828427,
1.0482665, 1.4900246, 1.3563544, 1.5341306, 0.7634312, 4.6216766e-05, 1.6161222, 1.7512476, 1.9363779,
0.9195784, 1.4906164, -0.03244795, 0.681073, 0.6192401, 1.8033613, 14.146055, 3.4043705, 15.292292,
3.5295358, 11.138999, 9.952057, 5.633434, 12.114562, 9.427372, 12.384038, 9.583308, 8.427233,
15.293704, 3.288159, 11.64898, 9.350885, 2.0037227, 13.523184, 4.4176426, 6.1057625, 14.400079,
8.248259, 11.815807, 15.713364, 1.0023532, 1.3203261, 1.7100681, 0.7407832, 1.09448, 1.7188418,
1.4412547, 1.4862992, 0.74790007, 0.31571656, 0.6398838, 2.0236106, 1.1869069, 1.7265586, 1.2624544,
0.09934269, 1.3508598, 0.85212964, -0.38968498, 1.7059708, 1.6533034, 1.7400402, 1.8123854, -0.43063712},
std::vector<T>{0.7719922, 0.35906568, 0.29054508, 0.18124384, 0.5604661, 0.84750974, 0.98948747, 0.009793862, 0.7184191,
0.5560748, 0.6952493, 0.6732593, 0.3306898, 0.6790913, 0.41128764, 0.34593266, 0.94296855, 0.7348507,
0.24478768, 0.94024557, 0.05405676, 0.06466125, 0.36244348, 0.07942984, 0.10619422, 0.09412837, 0.9053611,
0.22870538, 0.9237487, 0.20986171, 0.5067282, 0.29709867, 0.53138554, 0.189101, 0.4786443, 0.88421875,
0.7719922, 0.35906568, 0.29054508, 0.18124384, 0.5604661, 0.84750974, 0.98948747, 0.009793862, 0.7184191,
0.5560748, 0.6952493, 0.6732593, 0.3306898, 0.6790913, 0.41128764, 0.34593266, 0.94296855, 0.7348507,
0.24478768, 0.94024557, 0.05405676, 0.06466125, 0.36244348, 0.07942984, 0.10619422, 0.09412837, 0.9053611,
0.22870538, 0.9237487, 0.20986171, 0.5067282, 0.29709867, 0.53138554, 0.189101, 0.4786443, 0.88421875},
std::vector<T>{149, 149, 149, 149, 149, 0, 149, 149, 149, 60.87443542480469, 149, 149, 149, 61.89498901367188, 149,
149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 0, 149, 149, 149, 60.87443542480469,
149, 149, 149, 61.89498901367188, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149},
std::vector<T>{0.9894874691963196, 0.9429685473442078,
0.9402455687522888, 0.9237486720085144,
0.9053611159324646, 0.8842187523841858,
0.9894874691963196, 0.9429685473442078,
0.9402455687522888, 0.9237486720085144,
0.9053611159324646, 0.8842187523841858},
std::vector<RT>{6, 6},
"batch_2"),
GPParams(attrs,
1,
3, // A
2, // H
6, // W
IN_ET,
OUT_RT,
std::vector<T>{200.0f, 200.0f, 4.0f},
std::vector<T>{0.0f, 1.0f, 2.0f, 3.0f,
4.0f, 5.0f, 6.0f, 7.0f,
8.0f, 9.0f, 10.0f, 11.0f,
12.0f, 13.0f, 14.0f, 15.0f,
16.0f, 17.0f, 18.0f, 19.0f,
20.0f, 21.0f, 22.0f, 23.0f,
24.0f, 25.0f, 26.0f, 27.0f,
28.0f, 29.0f, 30.0f, 31.0f,
32.0f, 33.0f, 34.0f, 35.0f,
36.0f, 37.0f, 38.0f, 39.0f,
40.0f, 41.0f, 42.0f, 43.0f,
44.0f, 45.0f, 46.0f, 47.0f,
48.0f, 49.0f, 50.0f, 51.0f,
52.0f, 53.0f, 54.0f, 55.0f,
56.0f, 57.0f, 58.0f, 59.0f,
60.0f, 61.0f, 62.0f, 63.0f,
64.0f, 65.0f, 66.0f, 67.0f,
68.0f, 69.0f, 70.0f, 71.0f,
72.0f, 73.0f, 74.0f, 75.0f,
76.0f, 77.0f, 78.0f, 79.0f,
80.0f, 81.0f, 82.0f, 83.0f,
84.0f, 85.0f, 86.0f, 87.0f,
88.0f, 89.0f, 90.0f, 91.0f,
92.0f, 93.0f, 94.0f, 95.0f,
96.0f, 97.0f, 98.0f, 99.0f,
100.0f, 101.0f, 102.0f, 103.0f,
104.0f, 105.0f, 106.0f, 107.0f,
108.0f, 109.0f, 110.0f, 111.0f,
112.0f, 113.0f, 114.0f, 115.0f,
116.0f, 117.0f, 118.0f, 119.0f,
120.0f, 121.0f, 122.0f, 123.0f,
124.0f, 125.0f, 126.0f, 127.0f,
128.0f, 129.0f, 130.0f, 131.0f,
132.0f, 133.0f, 134.0f, 135.0f,
136.0f, 137.0f, 138.0f, 139.0f,
140.0f, 141.0f, 142.0f, 143.0f}, // anchors H, W, A, 4
std::vector<T>{0.5337073 ,0.86607957,0.55151343,0.21626699,0.4462629, 0.03985678,
0.5157072 ,0.9932138 ,0.7565954 ,0.43803605,0.802818 ,0.14834064,
0.53932905,0.14314 ,0.3817048 ,0.95075196,0.05516243,0.2567484,
0.25508744,0.77438325,0.43561 ,0.2094628 ,0.8299043 ,0.44982538,
0.95615596,0.5651084 ,0.11801951,0.05352486,0.9774733 ,0.14439464,
0.62644225,0.14370479,0.54161614,0.557915 ,0.53102225,0.0840179,
0.7249888 ,0.9843559 ,0.5490522 ,0.53788143,0.822474 ,0.3278008,
0.39688024,0.3286012 ,0.5117038 ,0.04743988,0.9408995 ,0.29885054,
0.81039643,0.85277915,0.06807619,0.86430097,0.36225632,0.16606331,
0.5401001 ,0.7541649 ,0.11998601,0.5131829 ,0.40606487,0.327888 ,
0.27721855,0.6378373 ,0.22795396,0.4961256 ,0.3215895 ,0.15607187,
0.14782153,0.8908137 ,0.8835288 ,0.834191 ,0.29907143,0.7983525 ,
0.755875 ,0.30837986,0.0839176 ,0.26624718,0.04371626,0.09472824,
0.20689541,0.37622106,0.1083321 ,0.1342548 ,0.05815459,0.7676379 ,
0.8105144 ,0.92348766,0.26761323,0.7183306 ,0.8947588 ,0.19020908,
0.42731014,0.7473663 ,0.85775334,0.9340091 ,0.3278848 ,0.755993 ,
0.05307213,0.39705503,0.21003333,0.5625373 ,0.66188884,0.80521655,
0.6125863 ,0.44678232,0.97802377,0.0204936 ,0.02686367,0.7390654 ,
0.74631 ,0.58399844,0.5988792 ,0.37413648,0.5946692 ,0.6955776 ,
0.36377597,0.7891322 ,0.40900692,0.99139464,0.50169915,0.41435778,
0.17142445,0.26761186,0.31591868,0.14249913,0.12919712,0.5418711 ,
0.6523203 ,0.50259084,0.7379765 ,0.01171071,0.94423133,0.00841132,
0.97486794,0.2921785 ,0.7633071 ,0.88477814,0.03563205,0.50833166,
0.01354555,0.535081 ,0.41366324,0.0694767 ,0.9944055 ,0.9981207}, // deltas N, A * 4, H, W
std::vector<T>{0.56637216,0.90457034,0.69827306,0.4353543, 0.47985056,0.42658508,
0.14516132,0.08081771,0.1799732 ,0.9229515 ,0.42420176,0.50857586,
0.82664067,0.4972319 ,0.3752427 ,0.56731623,0.18241242,0.33252355,
0.30608943,0.6572437 ,0.69185436,0.88646156,0.36985755,0.5590753 ,
0.5256446 ,0.03342898,0.1344396 ,0.68642473,0.37953874,0.32575172,
0.21108444,0.5661886 ,0.45378175,0.62126315,0.26799858,0.37272978}, // scores N, A, H, W
std::vector<T>{4.49132, 4.30537, 8.75027, 8.8035,
0, 1.01395, 4.66909, 5.14337,
135.501, 137.467, 139.81, 141.726,
47.2348, 47.8342, 52.5503, 52.3864,
126.483, 128.3, 131.625, 133.707}, // ref rois
std::vector<T>{0.826641, 0.566372, 0.559075, 0.479851, 0.267999}, // ref scores
std::vector<RT>{5}, // ref roiNum
"eval_2")
};
1,
3, // A
2, // H
6, // W
IN_ET,
OUT_RT,
std::vector<T>{200.0f, 200.0f, 4.0f},
std::vector<T>{0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f,
11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, 20.0f, 21.0f,
22.0f, 23.0f, 24.0f, 25.0f, 26.0f, 27.0f, 28.0f, 29.0f, 30.0f, 31.0f, 32.0f,
33.0f, 34.0f, 35.0f, 36.0f, 37.0f, 38.0f, 39.0f, 40.0f, 41.0f, 42.0f, 43.0f,
44.0f, 45.0f, 46.0f, 47.0f, 48.0f, 49.0f, 50.0f, 51.0f, 52.0f, 53.0f, 54.0f,
55.0f, 56.0f, 57.0f, 58.0f, 59.0f, 60.0f, 61.0f, 62.0f, 63.0f, 64.0f, 65.0f,
66.0f, 67.0f, 68.0f, 69.0f, 70.0f, 71.0f, 72.0f, 73.0f, 74.0f, 75.0f, 76.0f,
77.0f, 78.0f, 79.0f, 80.0f, 81.0f, 82.0f, 83.0f, 84.0f, 85.0f, 86.0f, 87.0f,
88.0f, 89.0f, 90.0f, 91.0f, 92.0f, 93.0f, 94.0f, 95.0f, 96.0f, 97.0f, 98.0f,
99.0f, 100.0f, 101.0f, 102.0f, 103.0f, 104.0f, 105.0f, 106.0f, 107.0f, 108.0f, 109.0f,
110.0f, 111.0f, 112.0f, 113.0f, 114.0f, 115.0f, 116.0f, 117.0f, 118.0f, 119.0f, 120.0f,
121.0f, 122.0f, 123.0f, 124.0f, 125.0f, 126.0f, 127.0f, 128.0f, 129.0f, 130.0f, 131.0f,
132.0f, 133.0f, 134.0f, 135.0f, 136.0f, 137.0f, 138.0f, 139.0f, 140.0f, 141.0f, 142.0f,
143.0f}, // anchors H, W, A, 4
std::vector<T>{0.5337073, 0.86607957, 0.55151343, 0.21626699, 0.4462629, 0.03985678, 0.5157072,
0.9932138, 0.7565954, 0.43803605, 0.802818, 0.14834064, 0.53932905, 0.14314,
0.3817048, 0.95075196, 0.05516243, 0.2567484, 0.25508744, 0.77438325, 0.43561,
0.2094628, 0.8299043, 0.44982538, 0.95615596, 0.5651084, 0.11801951, 0.05352486,
0.9774733, 0.14439464, 0.62644225, 0.14370479, 0.54161614, 0.557915, 0.53102225,
0.0840179, 0.7249888, 0.9843559, 0.5490522, 0.53788143, 0.822474, 0.3278008,
0.39688024, 0.3286012, 0.5117038, 0.04743988, 0.9408995, 0.29885054, 0.81039643,
0.85277915, 0.06807619, 0.86430097, 0.36225632, 0.16606331, 0.5401001, 0.7541649,
0.11998601, 0.5131829, 0.40606487, 0.327888, 0.27721855, 0.6378373, 0.22795396,
0.4961256, 0.3215895, 0.15607187, 0.14782153, 0.8908137, 0.8835288, 0.834191,
0.29907143, 0.7983525, 0.755875, 0.30837986, 0.0839176, 0.26624718, 0.04371626,
0.09472824, 0.20689541, 0.37622106, 0.1083321, 0.1342548, 0.05815459, 0.7676379,
0.8105144, 0.92348766, 0.26761323, 0.7183306, 0.8947588, 0.19020908, 0.42731014,
0.7473663, 0.85775334, 0.9340091, 0.3278848, 0.755993, 0.05307213, 0.39705503,
0.21003333, 0.5625373, 0.66188884, 0.80521655, 0.6125863, 0.44678232, 0.97802377,
0.0204936, 0.02686367, 0.7390654, 0.74631, 0.58399844, 0.5988792, 0.37413648,
0.5946692, 0.6955776, 0.36377597, 0.7891322, 0.40900692, 0.99139464, 0.50169915,
0.41435778, 0.17142445, 0.26761186, 0.31591868, 0.14249913, 0.12919712, 0.5418711,
0.6523203, 0.50259084, 0.7379765, 0.01171071, 0.94423133, 0.00841132, 0.97486794,
0.2921785, 0.7633071, 0.88477814, 0.03563205, 0.50833166, 0.01354555, 0.535081,
0.41366324, 0.0694767, 0.9944055, 0.9981207}, // deltas N, A * 4, H, W
std::vector<T>{0.56637216, 0.90457034, 0.69827306, 0.4353543, 0.47985056, 0.42658508, 0.14516132,
0.08081771, 0.1799732, 0.9229515, 0.42420176, 0.50857586, 0.82664067, 0.4972319,
0.3752427, 0.56731623, 0.18241242, 0.33252355, 0.30608943, 0.6572437, 0.69185436,
0.88646156, 0.36985755, 0.5590753, 0.5256446, 0.03342898, 0.1344396, 0.68642473,
0.37953874, 0.32575172, 0.21108444, 0.5661886, 0.45378175, 0.62126315, 0.26799858,
0.37272978}, // scores N, A, H, W
std::vector<T>{4.49132, 4.30537, 8.75027, 8.8035, 0, 1.01395, 4.66909,
5.14337, 135.501, 137.467, 139.81, 141.726, 47.2348, 47.8342,
52.5503, 52.3864, 126.483, 128.3, 131.625, 133.707}, // ref rois
std::vector<T>{0.826641, 0.566372, 0.559075, 0.479851, 0.267999}, // ref scores
std::vector<RT>{5}, // ref roiNum
"eval_2")};
return generateProposalParams;
}
std::vector<GPParams> generateGPCombinedParams() {
const std::vector<std::vector<GPParams>> GPTypeParams {
const std::vector<std::vector<GPParams>> GPTypeParams{
generateGPFloatParams<element::Type_t::f32, element::Type_t::i32>(),
generateGPFloatParams<element::Type_t::f32, element::Type_t::i64>(),
generateGPFloatParams<element::Type_t::f16, element::Type_t::i32>(),
generateGPFloatParams<element::Type_t::bf16, element::Type_t::i64>(),
};
};
std::vector<GPParams> combinedParams;
for (const auto& params : GPTypeParams) {
@ -302,6 +317,8 @@ std::vector<GPParams> generateGPCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_GenerateProposals_With_Hardcoded_Refs, ReferenceGPLayerTest,
testing::ValuesIn(generateGPCombinedParams()), ReferenceGPLayerTest::getTestCaseName);
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_GenerateProposals_With_Hardcoded_Refs,
ReferenceGPLayerTest,
testing::ValuesIn(generateGPCombinedParams()),
ReferenceGPLayerTest::getTestCaseName);
} // namespace

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/greater.hpp"
#include <gtest/gtest.h>
#include "openvino/op/greater.hpp"
#include "comparison.hpp"
using namespace ov;
@ -19,43 +20,43 @@ TEST_P(ReferenceComparisonLayerTest, GreaterCompareWithHardcodedRefs) {
template <element::Type_t IN_ET>
std::vector<RefComparisonParams> generateComparisonParams(const element::Type& type) {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<RefComparisonParams> compParams {
std::vector<RefComparisonParams> compParams{
// 1D // 2D // 3D // 4D
Builder {}
Builder{}
.compType(ComparisonTypes::GREATER)
.input1({{2, 2}, type, std::vector<T> {0, 12, 23, 0}})
.input2({{2, 2}, type, std::vector<T> {0, 12, 23, 0}})
.expected({{2, 2}, element::boolean, std::vector<char> {0, 0, 0, 0}}),
Builder {}
.input1({{2, 2}, type, std::vector<T>{0, 12, 23, 0}})
.input2({{2, 2}, type, std::vector<T>{0, 12, 23, 0}})
.expected({{2, 2}, element::boolean, std::vector<char>{0, 0, 0, 0}}),
Builder{}
.compType(ComparisonTypes::GREATER)
.input1({{2, 3}, type, std::vector<T> {0, 6, 45, 1, 21, 21}})
.input2({{2, 3}, type, std::vector<T> {1, 18, 23, 1, 19, 21}})
.expected({{2, 3}, element::boolean, std::vector<char> {0, 0, 1, 0, 1, 0}}),
Builder {}
.input1({{2, 3}, type, std::vector<T>{0, 6, 45, 1, 21, 21}})
.input2({{2, 3}, type, std::vector<T>{1, 18, 23, 1, 19, 21}})
.expected({{2, 3}, element::boolean, std::vector<char>{0, 0, 1, 0, 1, 0}}),
Builder{}
.compType(ComparisonTypes::GREATER)
.input1({{1}, type, std::vector<T> {53}})
.input2({{1}, type, std::vector<T> {53}})
.expected({{1}, element::boolean, std::vector<char> {0}}),
Builder {}
.input1({{1}, type, std::vector<T>{53}})
.input2({{1}, type, std::vector<T>{53}})
.expected({{1}, element::boolean, std::vector<char>{0}}),
Builder{}
.compType(ComparisonTypes::GREATER)
.input1({{2, 4}, type, std::vector<T> {0, 12, 23, 0, 1, 5, 12, 8}})
.input2({{2, 4}, type, std::vector<T> {0, 12, 23, 0, 10, 5, 11, 8}})
.expected({{2, 4}, element::boolean, std::vector<char> {0, 0, 0, 0, 0, 0, 1, 0}}),
Builder {}
.input1({{2, 4}, type, std::vector<T>{0, 12, 23, 0, 1, 5, 12, 8}})
.input2({{2, 4}, type, std::vector<T>{0, 12, 23, 0, 10, 5, 11, 8}})
.expected({{2, 4}, element::boolean, std::vector<char>{0, 0, 0, 0, 0, 0, 1, 0}}),
Builder{}
.compType(ComparisonTypes::GREATER)
.input1({{3, 1, 2}, type, std::vector<T> {2, 1, 4, 1, 3, 1}})
.input2({{1, 2, 1}, type, std::vector<T> {1, 1}})
.expected({{3, 2, 2}, element::boolean, std::vector<char> {1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0}}),
Builder {}
.input1({{3, 1, 2}, type, std::vector<T>{2, 1, 4, 1, 3, 1}})
.input2({{1, 2, 1}, type, std::vector<T>{1, 1}})
.expected({{3, 2, 2}, element::boolean, std::vector<char>{1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0}}),
Builder{}
.compType(ComparisonTypes::GREATER)
.input1({{2, 1, 2, 1}, type, std::vector<T> {2, 1, 4, 1}})
.input2({{1, 2, 1}, type, std::vector<T> {1, 1}})
.expected({{2, 1, 2, 1}, element::boolean, std::vector<char> {1, 0, 1, 0}})};
.input1({{2, 1, 2, 1}, type, std::vector<T>{2, 1, 4, 1}})
.input2({{1, 2, 1}, type, std::vector<T>{1, 1}})
.expected({{2, 1, 2, 1}, element::boolean, std::vector<char>{1, 0, 1, 0}})};
return compParams;
}
std::vector<RefComparisonParams> generateComparisonCombinedParams() {
const std::vector<std::vector<RefComparisonParams>> compTypeParams {
const std::vector<std::vector<RefComparisonParams>> compTypeParams{
generateComparisonParams<element::Type_t::f32>(element::f32),
generateComparisonParams<element::Type_t::f16>(element::f16),
generateComparisonParams<element::Type_t::i32>(element::i32),
@ -71,8 +72,10 @@ std::vector<RefComparisonParams> generateComparisonCombinedParams() {
return combinedParams;
}
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_Comparison_With_Hardcoded_Refs, ReferenceComparisonLayerTest, ::testing::ValuesIn(generateComparisonCombinedParams()),
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_Comparison_With_Hardcoded_Refs,
ReferenceComparisonLayerTest,
::testing::ValuesIn(generateComparisonCombinedParams()),
ReferenceComparisonLayerTest::getTestCaseName);
} // namespace ComparisonOpsRefTestDefinitions
} // namespace reference_tests
} // namespace ComparisonOpsRefTestDefinitions
} // namespace reference_tests

View File

@ -4,8 +4,8 @@
#include <gtest/gtest.h>
#include "openvino/op/greater_eq.hpp"
#include "comparison.hpp"
#include "openvino/op/greater_eq.hpp"
using namespace ov;
@ -16,43 +16,43 @@ namespace {
template <element::Type_t IN_ET>
std::vector<RefComparisonParams> generateComparisonParams(const element::Type& type) {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<RefComparisonParams> compParams {
std::vector<RefComparisonParams> compParams{
// 1D // 2D // 3D // 4D
Builder {}
Builder{}
.compType(ComparisonTypes::GREATER_EQUAL)
.input1({{2, 2}, type, std::vector<T> {0, 12, 23, 0}})
.input2({{2, 2}, type, std::vector<T> {0, 12, 23, 0}})
.expected({{2, 2}, element::boolean, std::vector<char> {1, 1, 1, 1}}),
Builder {}
.input1({{2, 2}, type, std::vector<T>{0, 12, 23, 0}})
.input2({{2, 2}, type, std::vector<T>{0, 12, 23, 0}})
.expected({{2, 2}, element::boolean, std::vector<char>{1, 1, 1, 1}}),
Builder{}
.compType(ComparisonTypes::GREATER_EQUAL)
.input1({{2, 3}, type, std::vector<T> {0, 6, 45, 1, 21, 21}})
.input2({{2, 3}, type, std::vector<T> {1, 18, 23, 1, 19, 21}})
.expected({{2, 3}, element::boolean, std::vector<char> {0, 0, 1, 1, 1, 1}}),
Builder {}
.input1({{2, 3}, type, std::vector<T>{0, 6, 45, 1, 21, 21}})
.input2({{2, 3}, type, std::vector<T>{1, 18, 23, 1, 19, 21}})
.expected({{2, 3}, element::boolean, std::vector<char>{0, 0, 1, 1, 1, 1}}),
Builder{}
.compType(ComparisonTypes::GREATER_EQUAL)
.input1({{1}, type, std::vector<T> {53}})
.input2({{1}, type, std::vector<T> {53}})
.expected({{1}, element::boolean, std::vector<char> {1}}),
Builder {}
.input1({{1}, type, std::vector<T>{53}})
.input2({{1}, type, std::vector<T>{53}})
.expected({{1}, element::boolean, std::vector<char>{1}}),
Builder{}
.compType(ComparisonTypes::GREATER_EQUAL)
.input1({{2, 4}, type, std::vector<T> {0, 12, 23, 0, 1, 5, 12, 8}})
.input2({{2, 4}, type, std::vector<T> {0, 12, 23, 0, 10, 5, 11, 8}})
.expected({{2, 4}, element::boolean, std::vector<char> {1, 1, 1, 1, 0, 1, 1, 1}}),
Builder {}
.input1({{2, 4}, type, std::vector<T>{0, 12, 23, 0, 1, 5, 12, 8}})
.input2({{2, 4}, type, std::vector<T>{0, 12, 23, 0, 10, 5, 11, 8}})
.expected({{2, 4}, element::boolean, std::vector<char>{1, 1, 1, 1, 0, 1, 1, 1}}),
Builder{}
.compType(ComparisonTypes::GREATER_EQUAL)
.input1({{3, 1, 2}, type, std::vector<T> {2, 1, 4, 1, 3, 1}})
.input2({{1, 2, 1}, type, std::vector<T> {1, 1}})
.expected({{3, 2, 2}, element::boolean, std::vector<char> {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}}),
Builder {}
.input1({{3, 1, 2}, type, std::vector<T>{2, 1, 4, 1, 3, 1}})
.input2({{1, 2, 1}, type, std::vector<T>{1, 1}})
.expected({{3, 2, 2}, element::boolean, std::vector<char>{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}}),
Builder{}
.compType(ComparisonTypes::GREATER_EQUAL)
.input1({{2, 1, 2, 1}, type, std::vector<T> {2, 1, 4, 1}})
.input2({{1, 2, 1}, type, std::vector<T> {1, 1}})
.expected({{2, 1, 2, 1}, element::boolean, std::vector<char> {1, 1, 1, 1}})};
.input1({{2, 1, 2, 1}, type, std::vector<T>{2, 1, 4, 1}})
.input2({{1, 2, 1}, type, std::vector<T>{1, 1}})
.expected({{2, 1, 2, 1}, element::boolean, std::vector<char>{1, 1, 1, 1}})};
return compParams;
}
std::vector<RefComparisonParams> generateComparisonCombinedParams() {
const std::vector<std::vector<RefComparisonParams>> compTypeParams {
const std::vector<std::vector<RefComparisonParams>> compTypeParams{
generateComparisonParams<element::Type_t::f32>(element::f32),
generateComparisonParams<element::Type_t::f16>(element::f16),
generateComparisonParams<element::Type_t::i64>(element::i64),
@ -68,8 +68,10 @@ std::vector<RefComparisonParams> generateComparisonCombinedParams() {
return combinedParams;
}
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_Comparison_With_Hardcoded_Refs, ReferenceComparisonLayerTest, ::testing::ValuesIn(generateComparisonCombinedParams()),
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_Comparison_With_Hardcoded_Refs,
ReferenceComparisonLayerTest,
::testing::ValuesIn(generateComparisonCombinedParams()),
ReferenceComparisonLayerTest::getTestCaseName);
} // namespace ComparisonOpsRefTestDefinitions
} // namespace reference_tests
} // namespace ComparisonOpsRefTestDefinitions
} // namespace reference_tests

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/grn.hpp"
#include <gtest/gtest.h>
#include "openvino/op/grn.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
@ -13,9 +14,17 @@ using namespace ov;
namespace {
struct GrnParams {
template <class IT>
GrnParams(const float bias, const PartialShape& shape, const element::Type& iType, const std::vector<IT>& iValues,
GrnParams(const float bias,
const PartialShape& shape,
const element::Type& iType,
const std::vector<IT>& iValues,
const std::vector<IT>& oValues)
: bias(bias), pshape(shape), inType(iType), outType(iType), inputData(CreateTensor(iType, iValues)), refData(CreateTensor(iType, oValues)) {}
: bias(bias),
pshape(shape),
inType(iType),
outType(iType),
inputData(CreateTensor(iType, iValues)),
refData(CreateTensor(iType, oValues)) {}
float bias;
PartialShape pshape;
element::Type inType;
@ -43,10 +52,12 @@ public:
}
private:
static std::shared_ptr<Model> CreateFunction(float bias, const PartialShape& input_shape, const element::Type& input_type) {
static std::shared_ptr<Model> CreateFunction(float bias,
const PartialShape& input_shape,
const element::Type& input_type) {
const auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
const auto grn = std::make_shared<op::v0::GRN>(in, bias);
return std::make_shared<ov::Model>(NodeVector {grn}, ParameterVector {in});
return std::make_shared<ov::Model>(NodeVector{grn}, ParameterVector{in});
}
};
@ -57,50 +68,100 @@ TEST_P(ReferenceGrnLayerTest, CompareWithHardcodedRefs) {
template <element::Type_t IN_ET>
std::vector<GrnParams> generateGrnParams(const element::Type& type) {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<GrnParams> grnParams {
std::vector<GrnParams> grnParams{
// bias 1e-6 // 2D // 3D // 4D
GrnParams(1e-6f, PartialShape {3, 4}, type, std::vector<T> {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12},
std::vector<T> {0.182574, 0.365148, 0.547723, 0.730297, 0.379049, 0.454859, 0.530669, 0.606478, 0.426162, 0.473514, 0.520865, 0.568217}),
GrnParams(1e-6f, PartialShape {2, 3, 4}, type,
std::vector<T> {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24},
std::vector<T> {0.0966737, 0.169031, 0.224231, 0.267261, 0.483368, 0.507093, 0.523205, 0.534522, 0.870063, 0.845154, 0.822179, 0.801784,
0.433574, 0.441836, 0.449215, 0.455842, 0.566982, 0.568075, 0.569005, 0.569803, 0.700389, 0.694314, 0.688796, 0.683763}),
GrnParams(1e-6f, PartialShape {1, 2, 3, 4}, type,
std::vector<T> {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24},
std::vector<T> {0.0766965, 0.141421, 0.196116, 0.242536, 0.282166, 0.316228, 0.345705, 0.371391, 0.393919, 0.413803, 0.431455, 0.447214,
0.997055, 0.989949, 0.980581, 0.970143, 0.959365, 0.948683, 0.938343, 0.928477, 0.919145, 0.910366, 0.902134, 0.894427}),
GrnParams(1e-6f, PartialShape {2, 2, 3, 4}, type,
std::vector<T> {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48},
std::vector<T> {0.0766965, 0.141421, 0.196116, 0.242536, 0.282166, 0.316228, 0.345705, 0.371391, 0.393919, 0.413803, 0.431455, 0.447214,
0.997055, 0.989949, 0.980581, 0.970143, 0.959365, 0.948683, 0.938343, 0.928477, 0.919145, 0.910366, 0.902134, 0.894427,
0.559857, 0.564684, 0.56921, 0.573462, 0.577465, 0.581238, 0.584802, 0.588172, 0.591364, 0.594391, 0.597266, 0.6,
0.828589, 0.825307, 0.822192, 0.819232, 0.816416, 0.813733, 0.811176, 0.808736, 0.806405, 0.804176, 0.802043, 0.8}),
GrnParams(1e-6f,
PartialShape{3, 4},
type,
std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12},
std::vector<T>{0.182574,
0.365148,
0.547723,
0.730297,
0.379049,
0.454859,
0.530669,
0.606478,
0.426162,
0.473514,
0.520865,
0.568217}),
GrnParams(1e-6f,
PartialShape{2, 3, 4},
type,
std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24},
std::vector<T>{0.0966737, 0.169031, 0.224231, 0.267261, 0.483368, 0.507093, 0.523205, 0.534522,
0.870063, 0.845154, 0.822179, 0.801784, 0.433574, 0.441836, 0.449215, 0.455842,
0.566982, 0.568075, 0.569005, 0.569803, 0.700389, 0.694314, 0.688796, 0.683763}),
GrnParams(1e-6f,
PartialShape{1, 2, 3, 4},
type,
std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24},
std::vector<T>{0.0766965, 0.141421, 0.196116, 0.242536, 0.282166, 0.316228, 0.345705, 0.371391,
0.393919, 0.413803, 0.431455, 0.447214, 0.997055, 0.989949, 0.980581, 0.970143,
0.959365, 0.948683, 0.938343, 0.928477, 0.919145, 0.910366, 0.902134, 0.894427}),
GrnParams(1e-6f,
PartialShape{2, 2, 3, 4},
type,
std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48},
std::vector<T>{0.0766965, 0.141421, 0.196116, 0.242536, 0.282166, 0.316228, 0.345705, 0.371391,
0.393919, 0.413803, 0.431455, 0.447214, 0.997055, 0.989949, 0.980581, 0.970143,
0.959365, 0.948683, 0.938343, 0.928477, 0.919145, 0.910366, 0.902134, 0.894427,
0.559857, 0.564684, 0.56921, 0.573462, 0.577465, 0.581238, 0.584802, 0.588172,
0.591364, 0.594391, 0.597266, 0.6, 0.828589, 0.825307, 0.822192, 0.819232,
0.816416, 0.813733, 0.811176, 0.808736, 0.806405, 0.804176, 0.802043, 0.8}),
// bias 100.25 // 2D // 3D // 4D
GrnParams(100.25f, PartialShape {3, 4}, type, std::vector<T> {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12},
std::vector<T> {0.0876216, 0.175243, 0.262865, 0.350486, 0.301923, 0.362308, 0.422693, 0.483077, 0.385076, 0.427863, 0.470649, 0.513435}),
GrnParams(100.25f, PartialShape {2, 3, 4}, type,
std::vector<T> {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24},
std::vector<T> {0.0694629, 0.129032, 0.179525, 0.222137, 0.347314, 0.387097, 0.418891, 0.444273, 0.625166, 0.645161, 0.658258, 0.66641,
0.41125, 0.421303, 0.430287, 0.438356, 0.537789, 0.541675, 0.54503, 0.547945, 0.664327, 0.662047, 0.659774, 0.657534}),
GrnParams(100.25f, PartialShape {1, 2, 3, 4}, type,
std::vector<T> {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24},
std::vector<T> {0.0608299, 0.115422, 0.164091, 0.207321, 0.245662, 0.279675, 0.309889, 0.336786, 0.360795, 0.38229, 0.401596, 0.418994,
0.790789, 0.807954, 0.820457, 0.829283, 0.835252, 0.839026, 0.841128, 0.841965, 0.841854, 0.841037, 0.839701, 0.837989f}),
GrnParams(100.25f, PartialShape {2, 2, 3, 4}, type,
std::vector<T> {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48},
std::vector<T> {0.0608299, 0.115422, 0.164091, 0.207321, 0.245662, 0.279675, 0.309889, 0.336786, 0.360795, 0.38229, 0.401596, 0.418994,
0.790789, 0.807954, 0.820457, 0.829283, 0.835252, 0.839026, 0.841128, 0.841965, 0.841854, 0.841037, 0.839701, 0.837989,
0.546293, 0.551788, 0.556938, 0.561772, 0.566319, 0.570601, 0.574641, 0.578458, 0.582069, 0.585489, 0.588734, 0.591816,
0.808514, 0.80646, 0.804466, 0.802532, 0.800658, 0.798842, 0.797083, 0.795379, 0.79373, 0.792133, 0.790586, 0.789088})};
GrnParams(100.25f,
PartialShape{3, 4},
type,
std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12},
std::vector<T>{0.0876216,
0.175243,
0.262865,
0.350486,
0.301923,
0.362308,
0.422693,
0.483077,
0.385076,
0.427863,
0.470649,
0.513435}),
GrnParams(100.25f,
PartialShape{2, 3, 4},
type,
std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24},
std::vector<T>{0.0694629, 0.129032, 0.179525, 0.222137, 0.347314, 0.387097, 0.418891, 0.444273,
0.625166, 0.645161, 0.658258, 0.66641, 0.41125, 0.421303, 0.430287, 0.438356,
0.537789, 0.541675, 0.54503, 0.547945, 0.664327, 0.662047, 0.659774, 0.657534}),
GrnParams(100.25f,
PartialShape{1, 2, 3, 4},
type,
std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24},
std::vector<T>{0.0608299, 0.115422, 0.164091, 0.207321, 0.245662, 0.279675, 0.309889, 0.336786,
0.360795, 0.38229, 0.401596, 0.418994, 0.790789, 0.807954, 0.820457, 0.829283,
0.835252, 0.839026, 0.841128, 0.841965, 0.841854, 0.841037, 0.839701, 0.837989f}),
GrnParams(100.25f,
PartialShape{2, 2, 3, 4},
type,
std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48},
std::vector<T>{0.0608299, 0.115422, 0.164091, 0.207321, 0.245662, 0.279675, 0.309889, 0.336786,
0.360795, 0.38229, 0.401596, 0.418994, 0.790789, 0.807954, 0.820457, 0.829283,
0.835252, 0.839026, 0.841128, 0.841965, 0.841854, 0.841037, 0.839701, 0.837989,
0.546293, 0.551788, 0.556938, 0.561772, 0.566319, 0.570601, 0.574641, 0.578458,
0.582069, 0.585489, 0.588734, 0.591816, 0.808514, 0.80646, 0.804466, 0.802532,
0.800658, 0.798842, 0.797083, 0.795379, 0.79373, 0.792133, 0.790586, 0.789088})};
return grnParams;
}
std::vector<GrnParams> generateGrnCombinedParams() {
const std::vector<std::vector<GrnParams>> grnTypeParams {generateGrnParams<element::Type_t::bf16>(element::bf16),
generateGrnParams<element::Type_t::f16>(element::f16),
generateGrnParams<element::Type_t::f32>(element::f32)};
const std::vector<std::vector<GrnParams>> grnTypeParams{generateGrnParams<element::Type_t::bf16>(element::bf16),
generateGrnParams<element::Type_t::f16>(element::f16),
generateGrnParams<element::Type_t::f32>(element::f32)};
std::vector<GrnParams> combinedParams;
std::for_each(grnTypeParams.begin(), grnTypeParams.end(), [&](std::vector<GrnParams> params) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
@ -108,6 +169,8 @@ std::vector<GrnParams> generateGrnCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_GRN_With_Hardcoded_Refs, ReferenceGrnLayerTest, ::testing::ValuesIn(generateGrnCombinedParams()),
INSTANTIATE_TEST_SUITE_P(smoke_GRN_With_Hardcoded_Refs,
ReferenceGrnLayerTest,
::testing::ValuesIn(generateGrnCombinedParams()),
ReferenceGrnLayerTest::getTestCaseName);
} // namespace

View File

@ -4,8 +4,8 @@
#include <gtest/gtest.h>
#include "openvino/op/group_conv.hpp"
#include "base_reference_test.hpp"
#include "openvino/op/group_conv.hpp"
using namespace reference_tests;
using namespace ov;
@ -13,10 +13,17 @@ using namespace ov;
namespace {
struct GroupConvolutionParams {
template <class IT>
GroupConvolutionParams(const PartialShape& inputShape, const PartialShape& filterShape, const PartialShape& outputShape,
const element::Type& iType,
const std::vector<IT>& iValues, const std::vector<IT>& filterValues, const std::vector<IT>& oValues,
const Strides& strides, const CoordinateDiff& padBegin, const CoordinateDiff& padEnd, const Strides& dialations)
GroupConvolutionParams(const PartialShape& inputShape,
const PartialShape& filterShape,
const PartialShape& outputShape,
const element::Type& iType,
const std::vector<IT>& iValues,
const std::vector<IT>& filterValues,
const std::vector<IT>& oValues,
const Strides& strides,
const CoordinateDiff& padBegin,
const CoordinateDiff& padEnd,
const Strides& dialations)
: inputShape(inputShape),
filterShape(filterShape),
outputShape(outputShape),
@ -46,7 +53,8 @@ struct GroupConvolutionParams {
ov::Strides dialations;
};
class ReferenceGroupConvolutionLayerTest : public testing::TestWithParam<GroupConvolutionParams>, public CommonReferenceTest {
class ReferenceGroupConvolutionLayerTest : public testing::TestWithParam<GroupConvolutionParams>,
public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
@ -76,13 +84,13 @@ private:
const auto in = std::make_shared<op::v0::Parameter>(params.inType, params.inputShape);
const auto filter = std::make_shared<op::v0::Parameter>(params.inType, params.filterShape);
const auto GroupConvolution = std::make_shared<op::v1::GroupConvolution>(in,
filter,
params.strides,
params.padBegin,
params.padEnd,
params.dialations,
auto_pad);
return std::make_shared<ov::Model>(NodeVector {GroupConvolution}, ParameterVector {in, filter});
filter,
params.strides,
params.padBegin,
params.padEnd,
params.dialations,
auto_pad);
return std::make_shared<ov::Model>(NodeVector{GroupConvolution}, ParameterVector{in, filter});
}
};
@ -94,74 +102,77 @@ template <element::Type_t IN_ET>
std::vector<GroupConvolutionParams> generateGroupConvolutionParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<GroupConvolutionParams> groupConvolutionParams {
// --------------------- 1D GroupConvolution ------------------------------------------
GroupConvolutionParams(PartialShape {1, 1, 6},
PartialShape {1, 1, 1, 3},
PartialShape {1, 1, 4},
IN_ET,
std::vector<T>{1, 3, 3, 0, 1, 2},
std::vector<T>{2, 0, 1},
std::vector<T>{5, 6, 7, 2},
{1},
{0},
{0},
{1}),
GroupConvolutionParams(PartialShape {1, 2, 6},
PartialShape {2, 1, 1, 3},
PartialShape {1, 2, 4},
IN_ET,
std::vector<T>{1, 3, 3, 0, 1, 2,
1, 3, 3, 0, 1, 2},
std::vector<T>{1, 0, 3,
3, 0, 1},
std::vector<T>{10, 3, 6, 6,
6, 9, 10, 2},
{1},
{0},
{0},
{1}),
GroupConvolutionParams(PartialShape {1, 2, 6},
PartialShape {2, 2, 1, 3},
PartialShape {1, 4, 4},
IN_ET,
std::vector<T>{1, 3, 3, 0, 1, 2,
-1, -3, -3, 0, 1, 2},
std::vector<T>{1, 0, 3,
3, 0, 1,
-3, 0, 1,
3, 2, -1},
std::vector<T>{
10, 3, 6, 6,
6, 9, 10, 2,
0, 9, 10, 2,
-6, -15, -10, 0},
{1},
{0},
{0},
{1}),
GroupConvolutionParams(PartialShape {2, 2, 6},
PartialShape {2, 1, 1, 3},
PartialShape {2, 2, 4},
IN_ET,
std::vector<T>{
// -- batch 1 --
1, 3, 3, 0, 1, 2,
1, 3, 3, 0, 1, 2,
// -- batch 2 --
1, 3, 3, 0, 1, 2,
1, 3, 3, 0, 1, 2},
std::vector<T>{1, 0, 3,
3, 0, 1},
std::vector<T>{
10, 3, 6, 6,
6, 9, 10, 2,
10, 3, 6, 6,
6, 9, 10, 2},
{1},
{0},
{0},
{1}),
std::vector<GroupConvolutionParams> groupConvolutionParams{
// --------------------- 1D GroupConvolution ------------------------------------------
GroupConvolutionParams(PartialShape{1, 1, 6},
PartialShape{1, 1, 1, 3},
PartialShape{1, 1, 4},
IN_ET,
std::vector<T>{1, 3, 3, 0, 1, 2},
std::vector<T>{2, 0, 1},
std::vector<T>{5, 6, 7, 2},
{1},
{0},
{0},
{1}),
GroupConvolutionParams(PartialShape{1, 2, 6},
PartialShape{2, 1, 1, 3},
PartialShape{1, 2, 4},
IN_ET,
std::vector<T>{1, 3, 3, 0, 1, 2, 1, 3, 3, 0, 1, 2},
std::vector<T>{1, 0, 3, 3, 0, 1},
std::vector<T>{10, 3, 6, 6, 6, 9, 10, 2},
{1},
{0},
{0},
{1}),
GroupConvolutionParams(PartialShape{1, 2, 6},
PartialShape{2, 2, 1, 3},
PartialShape{1, 4, 4},
IN_ET,
std::vector<T>{1, 3, 3, 0, 1, 2, -1, -3, -3, 0, 1, 2},
std::vector<T>{1, 0, 3, 3, 0, 1, -3, 0, 1, 3, 2, -1},
std::vector<T>{10, 3, 6, 6, 6, 9, 10, 2, 0, 9, 10, 2, -6, -15, -10, 0},
{1},
{0},
{0},
{1}),
GroupConvolutionParams(PartialShape{2, 2, 6},
PartialShape{2, 1, 1, 3},
PartialShape{2, 2, 4},
IN_ET,
std::vector<T>{// -- batch 1 --
1,
3,
3,
0,
1,
2,
1,
3,
3,
0,
1,
2,
// -- batch 2 --
1,
3,
3,
0,
1,
2,
1,
3,
3,
0,
1,
2},
std::vector<T>{1, 0, 3, 3, 0, 1},
std::vector<T>{10, 3, 6, 6, 6, 9, 10, 2, 10, 3, 6, 6, 6, 9, 10, 2},
{1},
{0},
{0},
{1}),
};
return groupConvolutionParams;
}
@ -170,61 +181,72 @@ template <element::Type_t IN_ET>
std::vector<GroupConvolutionParams> generateGroupConvolutionUintParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<GroupConvolutionParams> groupConvolutionParams {
// --------------------- 1D GroupConvolution ------------------------------------------
GroupConvolutionParams(PartialShape {1, 1, 6},
PartialShape {1, 1, 1, 3},
PartialShape {1, 1, 4},
IN_ET,
std::vector<T>{1, 3, 3, 0, 1, 2},
std::vector<T>{2, 0, 1},
std::vector<T>{5, 6, 7, 2},
{1},
{0},
{0},
{1}),
GroupConvolutionParams(PartialShape {1, 2, 6},
PartialShape {2, 1, 1, 3},
PartialShape {1, 2, 4},
IN_ET,
std::vector<T>{1, 3, 3, 0, 1, 2,
1, 3, 3, 0, 1, 2},
std::vector<T>{1, 0, 3,
3, 0, 1},
std::vector<T>{10, 3, 6, 6,
6, 9, 10, 2},
{1},
{0},
{0},
{1}),
GroupConvolutionParams(PartialShape {2, 2, 6},
PartialShape {2, 1, 1, 3},
PartialShape {2, 2, 4},
IN_ET,
std::vector<T>{
// -- batch 1 --
1, 3, 3, 0, 1, 2,
1, 3, 3, 0, 1, 2,
// -- batch 2 --
1, 3, 3, 0, 1, 2,
1, 3, 3, 0, 1, 2},
std::vector<T>{1, 0, 3,
3, 0, 1},
std::vector<T>{
10, 3, 6, 6,
6, 9, 10, 2,
10, 3, 6, 6,
6, 9, 10, 2},
{1},
{0},
{0},
{1}),
std::vector<GroupConvolutionParams> groupConvolutionParams{
// --------------------- 1D GroupConvolution ------------------------------------------
GroupConvolutionParams(PartialShape{1, 1, 6},
PartialShape{1, 1, 1, 3},
PartialShape{1, 1, 4},
IN_ET,
std::vector<T>{1, 3, 3, 0, 1, 2},
std::vector<T>{2, 0, 1},
std::vector<T>{5, 6, 7, 2},
{1},
{0},
{0},
{1}),
GroupConvolutionParams(PartialShape{1, 2, 6},
PartialShape{2, 1, 1, 3},
PartialShape{1, 2, 4},
IN_ET,
std::vector<T>{1, 3, 3, 0, 1, 2, 1, 3, 3, 0, 1, 2},
std::vector<T>{1, 0, 3, 3, 0, 1},
std::vector<T>{10, 3, 6, 6, 6, 9, 10, 2},
{1},
{0},
{0},
{1}),
GroupConvolutionParams(PartialShape{2, 2, 6},
PartialShape{2, 1, 1, 3},
PartialShape{2, 2, 4},
IN_ET,
std::vector<T>{// -- batch 1 --
1,
3,
3,
0,
1,
2,
1,
3,
3,
0,
1,
2,
// -- batch 2 --
1,
3,
3,
0,
1,
2,
1,
3,
3,
0,
1,
2},
std::vector<T>{1, 0, 3, 3, 0, 1},
std::vector<T>{10, 3, 6, 6, 6, 9, 10, 2, 10, 3, 6, 6, 6, 9, 10, 2},
{1},
{0},
{0},
{1}),
};
return groupConvolutionParams;
}
std::vector<GroupConvolutionParams> generateGroupConvolutionCombinedParams() {
const std::vector<std::vector<GroupConvolutionParams>> groupConvolutionTypeParams {
const std::vector<std::vector<GroupConvolutionParams>> groupConvolutionTypeParams{
generateGroupConvolutionParams<element::Type_t::f64>(),
generateGroupConvolutionParams<element::Type_t::f32>(),
generateGroupConvolutionParams<element::Type_t::f16>(),
@ -236,8 +258,7 @@ std::vector<GroupConvolutionParams> generateGroupConvolutionCombinedParams() {
generateGroupConvolutionUintParams<element::Type_t::u64>(),
generateGroupConvolutionUintParams<element::Type_t::u32>(),
generateGroupConvolutionUintParams<element::Type_t::u16>(),
generateGroupConvolutionUintParams<element::Type_t::u8>()
};
generateGroupConvolutionUintParams<element::Type_t::u8>()};
std::vector<GroupConvolutionParams> combinedParams;
for (const auto& params : groupConvolutionTypeParams) {
@ -246,7 +267,9 @@ std::vector<GroupConvolutionParams> generateGroupConvolutionCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_GroupConvolution_With_Hardcoded_Refs, ReferenceGroupConvolutionLayerTest,
testing::ValuesIn(generateGroupConvolutionCombinedParams()), ReferenceGroupConvolutionLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_GroupConvolution_With_Hardcoded_Refs,
ReferenceGroupConvolutionLayerTest,
testing::ValuesIn(generateGroupConvolutionCombinedParams()),
ReferenceGroupConvolutionLayerTest::getTestCaseName);
} // namespace
} // namespace

View File

@ -4,8 +4,8 @@
#include <gtest/gtest.h>
#include "openvino/op/group_conv.hpp"
#include "base_reference_test.hpp"
#include "openvino/op/group_conv.hpp"
#include "openvino/opsets/opset8.hpp"
using namespace reference_tests;
@ -14,11 +14,18 @@ using namespace ov;
namespace {
struct GroupConvolutionBackpropDataParams {
template <class IT>
GroupConvolutionBackpropDataParams(const PartialShape& inputShape, const PartialShape& filterShape, const PartialShape& outputShape,
const element::Type& iType,
const std::vector<IT>& iValues, const std::vector<IT>& filterValues, const std::vector<IT>& oValues,
const Strides& strides, const CoordinateDiff& padBegin, const CoordinateDiff& padEnd, const Strides& dialations,
const CoordinateDiff& outPadding = {})
GroupConvolutionBackpropDataParams(const PartialShape& inputShape,
const PartialShape& filterShape,
const PartialShape& outputShape,
const element::Type& iType,
const std::vector<IT>& iValues,
const std::vector<IT>& filterValues,
const std::vector<IT>& oValues,
const Strides& strides,
const CoordinateDiff& padBegin,
const CoordinateDiff& padEnd,
const Strides& dialations,
const CoordinateDiff& outPadding = {})
: inputShape(inputShape),
filterShape(filterShape),
outputShape(outputShape),
@ -52,11 +59,17 @@ struct GroupConvolutionBackpropDataParams {
struct GroupConvolutionBackpropDataOutShapeParams {
template <class IT>
GroupConvolutionBackpropDataOutShapeParams(const PartialShape& inputShape, const PartialShape& filterShape, const PartialShape& outputShape,
const element::Type& iType,
const std::vector<IT>& iValues, const std::vector<IT>& filterValues, const std::vector<IT>& oValues,
const Strides& strides, const Strides& dialations,
const Shape& constantOutputShape, const std::vector<int64_t>& constantOutputShapeData)
GroupConvolutionBackpropDataOutShapeParams(const PartialShape& inputShape,
const PartialShape& filterShape,
const PartialShape& outputShape,
const element::Type& iType,
const std::vector<IT>& iValues,
const std::vector<IT>& filterValues,
const std::vector<IT>& oValues,
const Strides& strides,
const Strides& dialations,
const Shape& constantOutputShape,
const std::vector<int64_t>& constantOutputShapeData)
: inputShape(inputShape),
filterShape(filterShape),
outputShape(outputShape),
@ -86,7 +99,9 @@ struct GroupConvolutionBackpropDataOutShapeParams {
std::vector<int64_t> constantOutputShapeData;
};
class ReferenceGroupConvolutionBackpropDataLayerTest : public testing::TestWithParam<GroupConvolutionBackpropDataParams>, public CommonReferenceTest {
class ReferenceGroupConvolutionBackpropDataLayerTest
: public testing::TestWithParam<GroupConvolutionBackpropDataParams>,
public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
@ -118,30 +133,33 @@ private:
const auto in = std::make_shared<op::v0::Parameter>(params.inType, params.inputShape);
const auto filter = std::make_shared<op::v0::Parameter>(params.inType, params.filterShape);
if (params.outPadding.size() != 0) {
const auto GroupConvolutionBackpropData = std::make_shared<op::v1::GroupConvolutionBackpropData>(in,
filter,
params.strides,
params.padBegin,
params.padEnd,
params.dialations,
auto_pad,
params.outPadding);
return std::make_shared<ov::Model>(NodeVector {GroupConvolutionBackpropData}, ParameterVector {in, filter});
const auto GroupConvolutionBackpropData =
std::make_shared<op::v1::GroupConvolutionBackpropData>(in,
filter,
params.strides,
params.padBegin,
params.padEnd,
params.dialations,
auto_pad,
params.outPadding);
return std::make_shared<ov::Model>(NodeVector{GroupConvolutionBackpropData}, ParameterVector{in, filter});
} else {
const auto GroupConvolutionBackpropData = std::make_shared<op::v1::GroupConvolutionBackpropData>(in,
filter,
params.strides,
params.padBegin,
params.padEnd,
params.dialations,
auto_pad);
return std::make_shared<ov::Model>(NodeVector {GroupConvolutionBackpropData}, ParameterVector {in, filter});
const auto GroupConvolutionBackpropData =
std::make_shared<op::v1::GroupConvolutionBackpropData>(in,
filter,
params.strides,
params.padBegin,
params.padEnd,
params.dialations,
auto_pad);
return std::make_shared<ov::Model>(NodeVector{GroupConvolutionBackpropData}, ParameterVector{in, filter});
}
}
};
class ReferenceGroupConvolutionBackpropDataLayerOutShapeTest
: public testing::TestWithParam<GroupConvolutionBackpropDataOutShapeParams>, public CommonReferenceTest {
: public testing::TestWithParam<GroupConvolutionBackpropDataOutShapeParams>,
public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
@ -169,14 +187,17 @@ private:
const auto in = std::make_shared<op::v0::Parameter>(params.inType, params.inputShape);
const auto filter = std::make_shared<op::v0::Parameter>(params.inType, params.filterShape);
auto output_shape = std::make_shared<opset8::Constant>(element::i64, params.constantOutputShape, params.constantOutputShapeData);
const auto GroupConvolutionBackpropData = std::make_shared<op::v1::GroupConvolutionBackpropData>(in,
filter,
output_shape,
params.strides,
params.dialations,
auto_pad);
return std::make_shared<ov::Model>(NodeVector {GroupConvolutionBackpropData}, ParameterVector {in, filter});
auto output_shape = std::make_shared<opset8::Constant>(element::i64,
params.constantOutputShape,
params.constantOutputShapeData);
const auto GroupConvolutionBackpropData =
std::make_shared<op::v1::GroupConvolutionBackpropData>(in,
filter,
output_shape,
params.strides,
params.dialations,
auto_pad);
return std::make_shared<ov::Model>(NodeVector{GroupConvolutionBackpropData}, ParameterVector{in, filter});
}
};
@ -192,104 +213,104 @@ template <element::Type_t IN_ET>
std::vector<GroupConvolutionBackpropDataParams> generateGroupConvolutionBackpropDataFloatParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<GroupConvolutionBackpropDataParams> groupConvolutionBackpropDataParams {
// --------------------- 1D GroupConvolutionBackpropData ------------------------------------------
GroupConvolutionBackpropDataParams(PartialShape {1, 1, 4},
PartialShape {1, 1, 1, 3},
PartialShape {1, 1, 6},
IN_ET,
std::vector<T>{1, 3, 3, 0},
std::vector<T>{2, 0, 1},
std::vector<T>{2, 6, 7, 3, 3, 0},
{1},
{0},
{0},
{1}),
GroupConvolutionBackpropDataParams(PartialShape {1, 2, 4},
PartialShape {2, 1, 1, 3},
PartialShape {1, 2, 6},
IN_ET,
std::vector<T>{1, 3, 3, 0,
1, 2, 1, 3},
std::vector<T>{1, 0, 3,
3, 0, 1},
std::vector<T>{1, 3, 6, 9, 9, 0,
3, 6, 4, 11, 1, 3},
{1},
{0},
{0},
{1}),
GroupConvolutionBackpropDataParams(PartialShape {1, 4, 4},
PartialShape {2, 2, 1, 3},
PartialShape {1, 2, 6},
IN_ET,
std::vector<T>{1, 3, 3, 0,
1, 2, -1, -3,
-3, 0, 1, 2,
0, -2, 3, -1},
std::vector<T>{1, 0, 3,
3, 0, 1,
-3, 0, 1,
3, 2, -1},
std::vector<T>{4, 9, 4, 2, 8, -3,
9, -6, -1, -1, -4, 3},
{1},
{0},
{0},
{1}),
GroupConvolutionBackpropDataParams(PartialShape {2, 2, 4},
PartialShape {2, 1, 1, 3},
PartialShape {2, 2, 6},
IN_ET,
std::vector<T>{// -- batch 1 --
1, 3, 0, 1,
1, 3, 0, 2,
// -- batch 2 --
1, 3, 0, 1,
1, 3, 0, 2},
std::vector<T>{1, 0, 3,
3, 0, 1},
std::vector<T>{1, 3, 3, 10, 0, 3,
3, 9, 1, 9, 0, 2,
1, 3, 3, 10, 0, 3,
3, 9, 1, 9, 0, 2},
{1},
{0},
{0},
{1}),
GroupConvolutionBackpropDataParams(PartialShape {1, 1, 3, 3},
PartialShape {1, 1, 1, 3, 3},
PartialShape {1, 1, 6, 6},
IN_ET,
std::vector<T>{0.16857791f,
-0.15161794f,
0.08540368f,
0.1820628f,
-0.21746576f,
0.08245695f,
0.1431433f,
-0.43156421f,
0.30591947f},
std::vector<T>{-0.06230065f,
0.37932432f,
-0.25388849f,
0.33878803f,
0.43709868f,
-0.22477469f,
0.04118127f,
-0.44696793f,
0.06373066f},
std::vector<T>{0.07368518f, -0.08925839f, -0.06627201f, 0.06301362f, 0.03732984f, -0.01919658f,
-0.00628807f, -0.02817563f, -0.01472169f, 0.04392925f, -0.00689478f, -0.01549204f,
0.07957941f, -0.11459791f, -0.09505399f, 0.07681622f, 0.03604182f, -0.01853423f,
-0.0270785f, -0.00680824f, -0.06650258f, 0.08004665f, 0.07918708f, -0.0724144f,
0.06256775f, -0.17838378f, -0.18863615f, 0.20064656f, 0.133717f, -0.06876295f,
-0.06398046f, -0.00864975f, 0.19289537f, -0.01490572f, -0.13673618f, 0.01949645f},
{2, 2},
{1, 1},
{1, 1},
{1, 1},
{1, 1}),
std::vector<GroupConvolutionBackpropDataParams> groupConvolutionBackpropDataParams{
// --------------------- 1D GroupConvolutionBackpropData ------------------------------------------
GroupConvolutionBackpropDataParams(PartialShape{1, 1, 4},
PartialShape{1, 1, 1, 3},
PartialShape{1, 1, 6},
IN_ET,
std::vector<T>{1, 3, 3, 0},
std::vector<T>{2, 0, 1},
std::vector<T>{2, 6, 7, 3, 3, 0},
{1},
{0},
{0},
{1}),
GroupConvolutionBackpropDataParams(PartialShape{1, 2, 4},
PartialShape{2, 1, 1, 3},
PartialShape{1, 2, 6},
IN_ET,
std::vector<T>{1, 3, 3, 0, 1, 2, 1, 3},
std::vector<T>{1, 0, 3, 3, 0, 1},
std::vector<T>{1, 3, 6, 9, 9, 0, 3, 6, 4, 11, 1, 3},
{1},
{0},
{0},
{1}),
GroupConvolutionBackpropDataParams(PartialShape{1, 4, 4},
PartialShape{2, 2, 1, 3},
PartialShape{1, 2, 6},
IN_ET,
std::vector<T>{1, 3, 3, 0, 1, 2, -1, -3, -3, 0, 1, 2, 0, -2, 3, -1},
std::vector<T>{1, 0, 3, 3, 0, 1, -3, 0, 1, 3, 2, -1},
std::vector<T>{4, 9, 4, 2, 8, -3, 9, -6, -1, -1, -4, 3},
{1},
{0},
{0},
{1}),
GroupConvolutionBackpropDataParams(
PartialShape{2, 2, 4},
PartialShape{2, 1, 1, 3},
PartialShape{2, 2, 6},
IN_ET,
std::vector<T>{// -- batch 1 --
1,
3,
0,
1,
1,
3,
0,
2,
// -- batch 2 --
1,
3,
0,
1,
1,
3,
0,
2},
std::vector<T>{1, 0, 3, 3, 0, 1},
std::vector<T>{1, 3, 3, 10, 0, 3, 3, 9, 1, 9, 0, 2, 1, 3, 3, 10, 0, 3, 3, 9, 1, 9, 0, 2},
{1},
{0},
{0},
{1}),
GroupConvolutionBackpropDataParams(
PartialShape{1, 1, 3, 3},
PartialShape{1, 1, 1, 3, 3},
PartialShape{1, 1, 6, 6},
IN_ET,
std::vector<T>{0.16857791f,
-0.15161794f,
0.08540368f,
0.1820628f,
-0.21746576f,
0.08245695f,
0.1431433f,
-0.43156421f,
0.30591947f},
std::vector<T>{-0.06230065f,
0.37932432f,
-0.25388849f,
0.33878803f,
0.43709868f,
-0.22477469f,
0.04118127f,
-0.44696793f,
0.06373066f},
std::vector<T>{0.07368518f, -0.08925839f, -0.06627201f, 0.06301362f, 0.03732984f, -0.01919658f,
-0.00628807f, -0.02817563f, -0.01472169f, 0.04392925f, -0.00689478f, -0.01549204f,
0.07957941f, -0.11459791f, -0.09505399f, 0.07681622f, 0.03604182f, -0.01853423f,
-0.0270785f, -0.00680824f, -0.06650258f, 0.08004665f, 0.07918708f, -0.0724144f,
0.06256775f, -0.17838378f, -0.18863615f, 0.20064656f, 0.133717f, -0.06876295f,
-0.06398046f, -0.00864975f, 0.19289537f, -0.01490572f, -0.13673618f, 0.01949645f},
{2, 2},
{1, 1},
{1, 1},
{1, 1},
{1, 1}),
};
return groupConvolutionBackpropDataParams;
}
@ -298,71 +319,70 @@ template <element::Type_t IN_ET>
std::vector<GroupConvolutionBackpropDataParams> generateGroupConvolutionBackpropDataIntParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<GroupConvolutionBackpropDataParams> groupConvolutionBackpropDataParams {
// --------------------- 1D GroupConvolutionBackpropData ------------------------------------------
GroupConvolutionBackpropDataParams(PartialShape {1, 1, 4},
PartialShape {1, 1, 1, 3},
PartialShape {1, 1, 6},
IN_ET,
std::vector<T>{1, 3, 3, 0},
std::vector<T>{2, 0, 1},
std::vector<T>{2, 6, 7, 3, 3, 0},
{1},
{0},
{0},
{1}),
GroupConvolutionBackpropDataParams(PartialShape {1, 2, 4},
PartialShape {2, 1, 1, 3},
PartialShape {1, 2, 6},
IN_ET,
std::vector<T>{1, 3, 3, 0,
1, 2, 1, 3},
std::vector<T>{1, 0, 3,
3, 0, 1},
std::vector<T>{1, 3, 6, 9, 9, 0,
3, 6, 4, 11, 1, 3},
{1},
{0},
{0},
{1}),
GroupConvolutionBackpropDataParams(PartialShape {1, 4, 4},
PartialShape {2, 2, 1, 3},
PartialShape {1, 2, 6},
IN_ET,
std::vector<T>{1, 3, 3, 0,
1, 2, -1, -3,
-3, 0, 1, 2,
0, -2, 3, -1},
std::vector<T>{1, 0, 3,
3, 0, 1,
-3, 0, 1,
3, 2, -1},
std::vector<T>{4, 9, 4, 2, 8, -3,
9, -6, -1, -1, -4, 3},
{1},
{0},
{0},
{1}),
GroupConvolutionBackpropDataParams(PartialShape {2, 2, 4},
PartialShape {2, 1, 1, 3},
PartialShape {2, 2, 6},
IN_ET,
std::vector<T>{// -- batch 1 --
1, 3, 0, 1,
1, 3, 0, 2,
// -- batch 2 --
1, 3, 0, 1,
1, 3, 0, 2},
std::vector<T>{1, 0, 3,
3, 0, 1},
std::vector<T>{1, 3, 3, 10, 0, 3,
3, 9, 1, 9, 0, 2,
1, 3, 3, 10, 0, 3,
3, 9, 1, 9, 0, 2},
{1},
{0},
{0},
{1}),
std::vector<GroupConvolutionBackpropDataParams> groupConvolutionBackpropDataParams{
// --------------------- 1D GroupConvolutionBackpropData ------------------------------------------
GroupConvolutionBackpropDataParams(PartialShape{1, 1, 4},
PartialShape{1, 1, 1, 3},
PartialShape{1, 1, 6},
IN_ET,
std::vector<T>{1, 3, 3, 0},
std::vector<T>{2, 0, 1},
std::vector<T>{2, 6, 7, 3, 3, 0},
{1},
{0},
{0},
{1}),
GroupConvolutionBackpropDataParams(PartialShape{1, 2, 4},
PartialShape{2, 1, 1, 3},
PartialShape{1, 2, 6},
IN_ET,
std::vector<T>{1, 3, 3, 0, 1, 2, 1, 3},
std::vector<T>{1, 0, 3, 3, 0, 1},
std::vector<T>{1, 3, 6, 9, 9, 0, 3, 6, 4, 11, 1, 3},
{1},
{0},
{0},
{1}),
GroupConvolutionBackpropDataParams(PartialShape{1, 4, 4},
PartialShape{2, 2, 1, 3},
PartialShape{1, 2, 6},
IN_ET,
std::vector<T>{1, 3, 3, 0, 1, 2, -1, -3, -3, 0, 1, 2, 0, -2, 3, -1},
std::vector<T>{1, 0, 3, 3, 0, 1, -3, 0, 1, 3, 2, -1},
std::vector<T>{4, 9, 4, 2, 8, -3, 9, -6, -1, -1, -4, 3},
{1},
{0},
{0},
{1}),
GroupConvolutionBackpropDataParams(
PartialShape{2, 2, 4},
PartialShape{2, 1, 1, 3},
PartialShape{2, 2, 6},
IN_ET,
std::vector<T>{// -- batch 1 --
1,
3,
0,
1,
1,
3,
0,
2,
// -- batch 2 --
1,
3,
0,
1,
1,
3,
0,
2},
std::vector<T>{1, 0, 3, 3, 0, 1},
std::vector<T>{1, 3, 3, 10, 0, 3, 3, 9, 1, 9, 0, 2, 1, 3, 3, 10, 0, 3, 3, 9, 1, 9, 0, 2},
{1},
{0},
{0},
{1}),
};
return groupConvolutionBackpropDataParams;
}
@ -371,59 +391,65 @@ template <element::Type_t IN_ET>
std::vector<GroupConvolutionBackpropDataParams> generateGroupConvolutionBackpropDataUintParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<GroupConvolutionBackpropDataParams> groupConvolutionBackpropDataParams {
// --------------------- 1D GroupConvolutionBackpropData ------------------------------------------
GroupConvolutionBackpropDataParams(PartialShape {1, 1, 4},
PartialShape {1, 1, 1, 3},
PartialShape {1, 1, 6},
IN_ET,
std::vector<T>{1, 3, 3, 0},
std::vector<T>{2, 0, 1},
std::vector<T>{2, 6, 7, 3, 3, 0},
{1},
{0},
{0},
{1}),
GroupConvolutionBackpropDataParams(PartialShape {1, 2, 4},
PartialShape {2, 1, 1, 3},
PartialShape {1, 2, 6},
IN_ET,
std::vector<T>{1, 3, 3, 0,
1, 2, 1, 3},
std::vector<T>{1, 0, 3,
3, 0, 1},
std::vector<T>{1, 3, 6, 9, 9, 0,
3, 6, 4, 11, 1, 3},
{1},
{0},
{0},
{1}),
GroupConvolutionBackpropDataParams(PartialShape {2, 2, 4},
PartialShape {2, 1, 1, 3},
PartialShape {2, 2, 6},
IN_ET,
std::vector<T>{// -- batch 1 --
1, 3, 0, 1,
1, 3, 0, 2,
// -- batch 2 --
1, 3, 0, 1,
1, 3, 0, 2},
std::vector<T>{1, 0, 3,
3, 0, 1},
std::vector<T>{1, 3, 3, 10, 0, 3,
3, 9, 1, 9, 0, 2,
1, 3, 3, 10, 0, 3,
3, 9, 1, 9, 0, 2},
{1},
{0},
{0},
{1}),
std::vector<GroupConvolutionBackpropDataParams> groupConvolutionBackpropDataParams{
// --------------------- 1D GroupConvolutionBackpropData ------------------------------------------
GroupConvolutionBackpropDataParams(PartialShape{1, 1, 4},
PartialShape{1, 1, 1, 3},
PartialShape{1, 1, 6},
IN_ET,
std::vector<T>{1, 3, 3, 0},
std::vector<T>{2, 0, 1},
std::vector<T>{2, 6, 7, 3, 3, 0},
{1},
{0},
{0},
{1}),
GroupConvolutionBackpropDataParams(PartialShape{1, 2, 4},
PartialShape{2, 1, 1, 3},
PartialShape{1, 2, 6},
IN_ET,
std::vector<T>{1, 3, 3, 0, 1, 2, 1, 3},
std::vector<T>{1, 0, 3, 3, 0, 1},
std::vector<T>{1, 3, 6, 9, 9, 0, 3, 6, 4, 11, 1, 3},
{1},
{0},
{0},
{1}),
GroupConvolutionBackpropDataParams(
PartialShape{2, 2, 4},
PartialShape{2, 1, 1, 3},
PartialShape{2, 2, 6},
IN_ET,
std::vector<T>{// -- batch 1 --
1,
3,
0,
1,
1,
3,
0,
2,
// -- batch 2 --
1,
3,
0,
1,
1,
3,
0,
2},
std::vector<T>{1, 0, 3, 3, 0, 1},
std::vector<T>{1, 3, 3, 10, 0, 3, 3, 9, 1, 9, 0, 2, 1, 3, 3, 10, 0, 3, 3, 9, 1, 9, 0, 2},
{1},
{0},
{0},
{1}),
};
return groupConvolutionBackpropDataParams;
}
std::vector<GroupConvolutionBackpropDataParams> generateGroupConvolutionBackpropDataCombinedParams() {
const std::vector<std::vector<GroupConvolutionBackpropDataParams>> groupConvolutionBackpropDataTypeParams {
const std::vector<std::vector<GroupConvolutionBackpropDataParams>> groupConvolutionBackpropDataTypeParams{
generateGroupConvolutionBackpropDataFloatParams<element::Type_t::f64>(),
generateGroupConvolutionBackpropDataFloatParams<element::Type_t::f32>(),
generateGroupConvolutionBackpropDataFloatParams<element::Type_t::f16>(),
@ -435,8 +461,7 @@ std::vector<GroupConvolutionBackpropDataParams> generateGroupConvolutionBackprop
generateGroupConvolutionBackpropDataUintParams<element::Type_t::u64>(),
generateGroupConvolutionBackpropDataUintParams<element::Type_t::u32>(),
generateGroupConvolutionBackpropDataUintParams<element::Type_t::u16>(),
generateGroupConvolutionBackpropDataUintParams<element::Type_t::u8>()
};
generateGroupConvolutionBackpropDataUintParams<element::Type_t::u8>()};
std::vector<GroupConvolutionBackpropDataParams> combinedParams;
for (const auto& params : groupConvolutionBackpropDataTypeParams) {
@ -449,38 +474,38 @@ template <element::Type_t IN_ET>
std::vector<GroupConvolutionBackpropDataOutShapeParams> generateGroupConvolutionBackpropDataOutShapeParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<GroupConvolutionBackpropDataOutShapeParams> groupConvolutionBackpropDataOutShapeParams {
// --------------------- 1D GroupConvolutionBackpropData ------------------------------------------
GroupConvolutionBackpropDataOutShapeParams(PartialShape {1, 1, 1, 10},
PartialShape {1, 1, 1, 1, 5},
PartialShape {1, 1, 1, 14},
IN_ET,
std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
std::vector<T>{1, 2, 3, 2, 1},
std::vector<T>{0, 1, 4, 10, 18, 27, 36, 45, 54, 63, 62, 50, 26, 9},
{1, 1},
{1, 1},
{2},
{1, 14}),
std::vector<GroupConvolutionBackpropDataOutShapeParams> groupConvolutionBackpropDataOutShapeParams{
// --------------------- 1D GroupConvolutionBackpropData ------------------------------------------
GroupConvolutionBackpropDataOutShapeParams(PartialShape{1, 1, 1, 10},
PartialShape{1, 1, 1, 1, 5},
PartialShape{1, 1, 1, 14},
IN_ET,
std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
std::vector<T>{1, 2, 3, 2, 1},
std::vector<T>{0, 1, 4, 10, 18, 27, 36, 45, 54, 63, 62, 50, 26, 9},
{1, 1},
{1, 1},
{2},
{1, 14}),
};
return groupConvolutionBackpropDataOutShapeParams;
}
std::vector<GroupConvolutionBackpropDataOutShapeParams> generateGroupConvolutionBackpropDataOutShapeCombinedParams() {
const std::vector<std::vector<GroupConvolutionBackpropDataOutShapeParams>> groupConvolutionBackpropDataOutShapeTypeParams {
generateGroupConvolutionBackpropDataOutShapeParams<element::Type_t::f64>(),
generateGroupConvolutionBackpropDataOutShapeParams<element::Type_t::f32>(),
generateGroupConvolutionBackpropDataOutShapeParams<element::Type_t::f16>(),
generateGroupConvolutionBackpropDataOutShapeParams<element::Type_t::bf16>(),
generateGroupConvolutionBackpropDataOutShapeParams<element::Type_t::i64>(),
generateGroupConvolutionBackpropDataOutShapeParams<element::Type_t::i32>(),
generateGroupConvolutionBackpropDataOutShapeParams<element::Type_t::i16>(),
generateGroupConvolutionBackpropDataOutShapeParams<element::Type_t::i8>(),
generateGroupConvolutionBackpropDataOutShapeParams<element::Type_t::u64>(),
generateGroupConvolutionBackpropDataOutShapeParams<element::Type_t::u32>(),
generateGroupConvolutionBackpropDataOutShapeParams<element::Type_t::u16>(),
generateGroupConvolutionBackpropDataOutShapeParams<element::Type_t::u8>()
};
const std::vector<std::vector<GroupConvolutionBackpropDataOutShapeParams>>
groupConvolutionBackpropDataOutShapeTypeParams{
generateGroupConvolutionBackpropDataOutShapeParams<element::Type_t::f64>(),
generateGroupConvolutionBackpropDataOutShapeParams<element::Type_t::f32>(),
generateGroupConvolutionBackpropDataOutShapeParams<element::Type_t::f16>(),
generateGroupConvolutionBackpropDataOutShapeParams<element::Type_t::bf16>(),
generateGroupConvolutionBackpropDataOutShapeParams<element::Type_t::i64>(),
generateGroupConvolutionBackpropDataOutShapeParams<element::Type_t::i32>(),
generateGroupConvolutionBackpropDataOutShapeParams<element::Type_t::i16>(),
generateGroupConvolutionBackpropDataOutShapeParams<element::Type_t::i8>(),
generateGroupConvolutionBackpropDataOutShapeParams<element::Type_t::u64>(),
generateGroupConvolutionBackpropDataOutShapeParams<element::Type_t::u32>(),
generateGroupConvolutionBackpropDataOutShapeParams<element::Type_t::u16>(),
generateGroupConvolutionBackpropDataOutShapeParams<element::Type_t::u8>()};
std::vector<GroupConvolutionBackpropDataOutShapeParams> combinedParams;
for (const auto& params : groupConvolutionBackpropDataOutShapeTypeParams) {
@ -489,10 +514,14 @@ std::vector<GroupConvolutionBackpropDataOutShapeParams> generateGroupConvolution
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_GroupConvolutionBackpropData_With_Hardcoded_Refs, ReferenceGroupConvolutionBackpropDataLayerTest,
testing::ValuesIn(generateGroupConvolutionBackpropDataCombinedParams()), ReferenceGroupConvolutionBackpropDataLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_GroupConvolutionBackpropData_With_Hardcoded_Refs,
ReferenceGroupConvolutionBackpropDataLayerTest,
testing::ValuesIn(generateGroupConvolutionBackpropDataCombinedParams()),
ReferenceGroupConvolutionBackpropDataLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_GroupConvolutionBackpropDataOutShape_With_Hardcoded_Refs, ReferenceGroupConvolutionBackpropDataLayerOutShapeTest,
testing::ValuesIn(generateGroupConvolutionBackpropDataOutShapeCombinedParams()), ReferenceGroupConvolutionBackpropDataLayerOutShapeTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_GroupConvolutionBackpropDataOutShape_With_Hardcoded_Refs,
ReferenceGroupConvolutionBackpropDataLayerOutShapeTest,
testing::ValuesIn(generateGroupConvolutionBackpropDataOutShapeCombinedParams()),
ReferenceGroupConvolutionBackpropDataLayerOutShapeTest::getTestCaseName);
} // namespace
} // namespace

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/gru_cell.hpp"
#include <gtest/gtest.h>
#include "openvino/op/gru_cell.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
@ -12,12 +13,30 @@ using namespace ov;
namespace {
struct GRUCellParams {
GRUCellParams(
const int32_t batchSize, const int32_t inputSize, const int32_t hiddenSize, const int32_t gatesCount, const bool linearBeforeReset,
const reference_tests::Tensor& X, const reference_tests::Tensor& H_t, const reference_tests::Tensor& W, const reference_tests::Tensor& R, const reference_tests::Tensor& B,
const reference_tests::Tensor& Ho, const std::string& testcaseName = "") :
batchSize(batchSize), inputSize(inputSize), hiddenSize(hiddenSize), gatesCount(gatesCount), linearBeforeReset(linearBeforeReset),
X(X), H_t(H_t), W(W), R(R), B(B), Ho(Ho), testcaseName(testcaseName) {}
GRUCellParams(const int32_t batchSize,
const int32_t inputSize,
const int32_t hiddenSize,
const int32_t gatesCount,
const bool linearBeforeReset,
const reference_tests::Tensor& X,
const reference_tests::Tensor& H_t,
const reference_tests::Tensor& W,
const reference_tests::Tensor& R,
const reference_tests::Tensor& B,
const reference_tests::Tensor& Ho,
const std::string& testcaseName = "")
: batchSize(batchSize),
inputSize(inputSize),
hiddenSize(hiddenSize),
gatesCount(gatesCount),
linearBeforeReset(linearBeforeReset),
X(X),
H_t(H_t),
W(W),
R(R),
B(B),
Ho(Ho),
testcaseName(testcaseName) {}
int32_t batchSize;
int32_t inputSize;
@ -144,78 +163,104 @@ TEST_P(ReferenceGRUCellTestHardsigmoidActivationFunction, CompareWithRefs) {
template <element::Type_t ET>
std::vector<GRUCellParams> generateParams() {
using T = typename element_type_traits<ET>::value_type;
std::vector<GRUCellParams> params {
std::vector<GRUCellParams> params{
GRUCellParams(
2, 3, 3, 3, false,
reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.52421564f, 0.78845507f, 0.9372873f, 0.59783894f, 0.18278378f, 0.2084126f}),
reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.45738035f, 0.996877f, 0.82882977f, 0.47492632f, 0.88471466f, 0.57833236f}),
reference_tests::Tensor(ET, {3 * 3, 3}, std::vector<T>{
0.5815369f, 0.16559383f, 0.08464007f, 0.843122f, 0.73968244f, 0.11359601f,
0.8295078f, 0.9240567f, 0.10007995f, 0.20573162f, 0.09002485f, 0.2839569f,
0.3096991f, 0.5638341f, 0.5787327f, 0.84552664f, 0.16263747f, 0.7243242f,
0.8049057f, 0.43966424f, 0.46294412f, 0.9833361f, 0.31369713f, 0.1719934f,
0.4937093f, 0.6353004f, 0.77982515f}),
reference_tests::Tensor(ET, {3 * 3, 3}, std::vector<T>{
0.16510165f, 0.52435565f, 0.2788478f, 0.99427545f, 0.1623331f, 0.01389796f,
0.99669236f, 0.53901845f, 0.8737506f, 0.9254788f, 0.21172932f, 0.11634306f,
0.40111724f, 0.37497616f, 0.2903471f, 0.6796794f, 0.65131867f, 0.78163475f,
0.12058706f, 0.45591718f, 0.791677f, 0.76497287f, 0.9895242f, 0.7845312f,
0.51267904f, 0.49030215f, 0.08498167f}),
reference_tests::Tensor(ET, {3 * 3}, std::vector<T>{
0.8286678f + 0.9175602f,
0.9153158f + 0.14958014f,
0.9581612f + 0.49230585f,
0.6639213f + 0.63162816f,
0.84239805f + 0.4161903f,
0.5282445f + 0.22148274f,
0.14153397f + 0.50496656f,
0.22404431f + 0.34798595f,
0.6549655f + 0.6699164f}),
reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.48588726f, 0.99670005f, 0.83759373f, 0.5023099f, 0.89410484f, 0.60011315f}),
2,
3,
3,
3,
false,
reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.52421564f, 0.78845507f, 0.9372873f, 0.59783894f, 0.18278378f, 0.2084126f}),
reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.45738035f, 0.996877f, 0.82882977f, 0.47492632f, 0.88471466f, 0.57833236f}),
reference_tests::Tensor(
ET,
{3 * 3, 3},
std::vector<T>{0.5815369f, 0.16559383f, 0.08464007f, 0.843122f, 0.73968244f, 0.11359601f, 0.8295078f,
0.9240567f, 0.10007995f, 0.20573162f, 0.09002485f, 0.2839569f, 0.3096991f, 0.5638341f,
0.5787327f, 0.84552664f, 0.16263747f, 0.7243242f, 0.8049057f, 0.43966424f, 0.46294412f,
0.9833361f, 0.31369713f, 0.1719934f, 0.4937093f, 0.6353004f, 0.77982515f}),
reference_tests::Tensor(ET, {3 * 3, 3}, std::vector<T>{0.16510165f, 0.52435565f, 0.2788478f, 0.99427545f,
0.1623331f, 0.01389796f, 0.99669236f, 0.53901845f,
0.8737506f, 0.9254788f, 0.21172932f, 0.11634306f,
0.40111724f, 0.37497616f, 0.2903471f, 0.6796794f,
0.65131867f, 0.78163475f, 0.12058706f, 0.45591718f,
0.791677f, 0.76497287f, 0.9895242f, 0.7845312f,
0.51267904f, 0.49030215f, 0.08498167f}),
reference_tests::Tensor(ET,
{3 * 3},
std::vector<T>{0.8286678f + 0.9175602f,
0.9153158f + 0.14958014f,
0.9581612f + 0.49230585f,
0.6639213f + 0.63162816f,
0.84239805f + 0.4161903f,
0.5282445f + 0.22148274f,
0.14153397f + 0.50496656f,
0.22404431f + 0.34798595f,
0.6549655f + 0.6699164f}),
reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.48588726f, 0.99670005f, 0.83759373f, 0.5023099f, 0.89410484f, 0.60011315f}),
"gru_cell_bias_clip"),
GRUCellParams(
2, 3, 3, 3, true,
reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.12249453f, 0.6127907f, 0.5001741f, 0.5124603f, 0.04329684f, 0.023834f}),
reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.8598948f, 0.41189128f, 0.72824323f, 0.53940123f, 0.31485787f, 0.04053852f}),
reference_tests::Tensor(ET, {3 * 3, 3}, std::vector<T>{
0.72259396f, 0.11561195f, 0.9457856f, 0.19037509f, 0.6964006f, 0.33459795f,
0.5468904f, 0.85646594f, 0.5101311f, 0.9712257f, 0.3687071f, 0.60280246f,
0.56943774f, 0.7475505f, 0.2490578f, 0.86977345f, 0.85542053f, 0.29660386f,
0.49717373f, 0.7473479f, 0.53454477f, 0.15974349f, 0.5804805f, 0.14303213f,
0.07514781f, 0.5865731f, 0.76409274f}),
reference_tests::Tensor(ET, {3 * 3, 3}, std::vector<T>{
0.91382647f, 0.41527033f, 0.28040004f, 0.23601337f, 0.04471736f, 0.03888785f,
0.06308217f, 0.44844428f, 0.29384327f, 0.49037653f, 0.50421673f, 0.7366393f,
0.63143945f, 0.00277612f, 0.37198433f, 0.06966069f, 0.4613444f, 0.10999731f,
0.78273284f, 0.21453214f, 0.10751773f, 0.18332677f, 0.1326976f, 0.9998985f,
0.19263928f, 0.10979804f, 0.52575564f}),
reference_tests::Tensor(ET, {(3 + 1) * 3}, std::vector<T>{
0.61395123f, // 0.09875853f + 0.5151927f,
1.08667738f, // 0.37801138f + 0.708666f,
1.32600244f, // 0.7729636f + 0.55303884f,
0.81917698f, // 0.78493553f + 0.03424145f,
1.37736335f, // 0.5662702f + 0.81109315f,
0.42931147f, // 0.12406381f + 0.30524766f,
0.66729516f,
0.7752771f,
0.78819966f,
0.6606634f,
0.99040645f,
0.21112025f}),
reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.8709214f, 0.48411977f, 0.74495184f, 0.6074972f, 0.44572943f, 0.1467715f}),
2,
3,
3,
3,
true,
reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.12249453f, 0.6127907f, 0.5001741f, 0.5124603f, 0.04329684f, 0.023834f}),
reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.8598948f, 0.41189128f, 0.72824323f, 0.53940123f, 0.31485787f, 0.04053852f}),
reference_tests::Tensor(ET, {3 * 3, 3}, std::vector<T>{0.72259396f, 0.11561195f, 0.9457856f, 0.19037509f,
0.6964006f, 0.33459795f, 0.5468904f, 0.85646594f,
0.5101311f, 0.9712257f, 0.3687071f, 0.60280246f,
0.56943774f, 0.7475505f, 0.2490578f, 0.86977345f,
0.85542053f, 0.29660386f, 0.49717373f, 0.7473479f,
0.53454477f, 0.15974349f, 0.5804805f, 0.14303213f,
0.07514781f, 0.5865731f, 0.76409274f}),
reference_tests::Tensor(ET, {3 * 3, 3}, std::vector<T>{0.91382647f, 0.41527033f, 0.28040004f, 0.23601337f,
0.04471736f, 0.03888785f, 0.06308217f, 0.44844428f,
0.29384327f, 0.49037653f, 0.50421673f, 0.7366393f,
0.63143945f, 0.00277612f, 0.37198433f, 0.06966069f,
0.4613444f, 0.10999731f, 0.78273284f, 0.21453214f,
0.10751773f, 0.18332677f, 0.1326976f, 0.9998985f,
0.19263928f, 0.10979804f, 0.52575564f}),
reference_tests::Tensor(ET,
{(3 + 1) * 3},
std::vector<T>{0.61395123f, // 0.09875853f + 0.5151927f,
1.08667738f, // 0.37801138f + 0.708666f,
1.32600244f, // 0.7729636f + 0.55303884f,
0.81917698f, // 0.78493553f + 0.03424145f,
1.37736335f, // 0.5662702f + 0.81109315f,
0.42931147f, // 0.12406381f + 0.30524766f,
0.66729516f,
0.7752771f,
0.78819966f,
0.6606634f,
0.99040645f,
0.21112025f}),
reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.8709214f, 0.48411977f, 0.74495184f, 0.6074972f, 0.44572943f, 0.1467715f}),
"gru_cell_linear_before_reset"),
};
return params;
}
std::vector<GRUCellParams> generateCombinedParams() {
const std::vector<std::vector<GRUCellParams>> generatedParams {
const std::vector<std::vector<GRUCellParams>> generatedParams{
generateParams<element::Type_t::bf16>(),
generateParams<element::Type_t::f16>(),
generateParams<element::Type_t::f32>(),
@ -232,47 +277,60 @@ std::vector<GRUCellParams> generateCombinedParams() {
template <element::Type_t ET>
std::vector<GRUCellParams> generateParamsHardsigmoidActivationFunction() {
using T = typename element_type_traits<ET>::value_type;
std::vector<GRUCellParams> params {
std::vector<GRUCellParams> params{
GRUCellParams(
2, 3, 3, 3, true,
reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.12249453f, 0.6127907f, 0.5001741f, 0.5124603f, 0.04329684f, 0.023834f}),
reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.8598948f, 0.41189128f, 0.72824323f, 0.53940123f, 0.31485787f, 0.04053852f}),
reference_tests::Tensor(ET, {3 * 3, 3}, std::vector<T>{
0.72259396f, 0.11561195f, 0.9457856f, 0.19037509f, 0.6964006f, 0.33459795f,
0.5468904f, 0.85646594f, 0.5101311f, 0.9712257f, 0.3687071f, 0.60280246f,
0.56943774f, 0.7475505f, 0.2490578f, 0.86977345f, 0.85542053f, 0.29660386f,
0.49717373f, 0.7473479f, 0.53454477f, 0.15974349f, 0.5804805f, 0.14303213f,
0.07514781f, 0.5865731f, 0.76409274f}),
reference_tests::Tensor(ET, {3 * 3, 3}, std::vector<T>{
0.91382647f, 0.41527033f, 0.28040004f, 0.23601337f, 0.04471736f, 0.03888785f,
0.06308217f, 0.44844428f, 0.29384327f, 0.49037653f, 0.50421673f, 0.7366393f,
0.63143945f, 0.00277612f, 0.37198433f, 0.06966069f, 0.4613444f, 0.10999731f,
0.78273284f, 0.21453214f, 0.10751773f, 0.18332677f, 0.1326976f, 0.9998985f,
0.19263928f, 0.10979804f, 0.52575564f}),
reference_tests::Tensor(ET, {(3 + 1) * 3}, std::vector<T>{
0.09875853f + 0.5151927f,
0.37801138f + 0.708666f,
0.7729636f + 0.55303884f,
0.78493553f + 0.03424145f,
0.5662702f + 0.81109315f,
0.12406381f + 0.30524766f,
0.66729516f,
0.7752771f,
0.78819966f,
0.6606634f,
0.99040645f,
0.21112025f}),
reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.8598948f, 0.41189128f, 0.72824323f, 0.53940123f, 0.31485787f, 0.04053852f}),
2,
3,
3,
3,
true,
reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.12249453f, 0.6127907f, 0.5001741f, 0.5124603f, 0.04329684f, 0.023834f}),
reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.8598948f, 0.41189128f, 0.72824323f, 0.53940123f, 0.31485787f, 0.04053852f}),
reference_tests::Tensor(ET, {3 * 3, 3}, std::vector<T>{0.72259396f, 0.11561195f, 0.9457856f, 0.19037509f,
0.6964006f, 0.33459795f, 0.5468904f, 0.85646594f,
0.5101311f, 0.9712257f, 0.3687071f, 0.60280246f,
0.56943774f, 0.7475505f, 0.2490578f, 0.86977345f,
0.85542053f, 0.29660386f, 0.49717373f, 0.7473479f,
0.53454477f, 0.15974349f, 0.5804805f, 0.14303213f,
0.07514781f, 0.5865731f, 0.76409274f}),
reference_tests::Tensor(ET, {3 * 3, 3}, std::vector<T>{0.91382647f, 0.41527033f, 0.28040004f, 0.23601337f,
0.04471736f, 0.03888785f, 0.06308217f, 0.44844428f,
0.29384327f, 0.49037653f, 0.50421673f, 0.7366393f,
0.63143945f, 0.00277612f, 0.37198433f, 0.06966069f,
0.4613444f, 0.10999731f, 0.78273284f, 0.21453214f,
0.10751773f, 0.18332677f, 0.1326976f, 0.9998985f,
0.19263928f, 0.10979804f, 0.52575564f}),
reference_tests::Tensor(ET,
{(3 + 1) * 3},
std::vector<T>{0.09875853f + 0.5151927f,
0.37801138f + 0.708666f,
0.7729636f + 0.55303884f,
0.78493553f + 0.03424145f,
0.5662702f + 0.81109315f,
0.12406381f + 0.30524766f,
0.66729516f,
0.7752771f,
0.78819966f,
0.6606634f,
0.99040645f,
0.21112025f}),
reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.8598948f, 0.41189128f, 0.72824323f, 0.53940123f, 0.31485787f, 0.04053852f}),
"gru_cell_hardsigmoid_activation_function"),
};
return params;
}
std::vector<GRUCellParams> generateCombinedParamsHardsigmoidActivationFunction() {
const std::vector<std::vector<GRUCellParams>> generatedParams {
const std::vector<std::vector<GRUCellParams>> generatedParams{
generateParamsHardsigmoidActivationFunction<element::Type_t::bf16>(),
generateParamsHardsigmoidActivationFunction<element::Type_t::f16>(),
generateParamsHardsigmoidActivationFunction<element::Type_t::f32>(),
@ -286,9 +344,13 @@ std::vector<GRUCellParams> generateCombinedParamsHardsigmoidActivationFunction()
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_GRUCell_With_Hardcoded_Refs, ReferenceGRUCellTest,
testing::ValuesIn(generateCombinedParams()), ReferenceGRUCellTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_GRUCell_With_Hardcoded_Refs,
ReferenceGRUCellTest,
testing::ValuesIn(generateCombinedParams()),
ReferenceGRUCellTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_GRUCell_With_Hardcoded_Refs, ReferenceGRUCellTestHardsigmoidActivationFunction,
testing::ValuesIn(generateCombinedParamsHardsigmoidActivationFunction()), ReferenceGRUCellTest::getTestCaseName);
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_GRUCell_With_Hardcoded_Refs,
ReferenceGRUCellTestHardsigmoidActivationFunction,
testing::ValuesIn(generateCombinedParamsHardsigmoidActivationFunction()),
ReferenceGRUCellTest::getTestCaseName);
} // namespace

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/hard_sigmoid.hpp"
#include <gtest/gtest.h>
#include "openvino/op/hard_sigmoid.hpp"
#include "base_reference_test.hpp"
#include "openvino/op/constant.hpp"
@ -14,8 +15,12 @@ using namespace ov;
namespace {
struct HardSigmoidParams {
template <class IT>
HardSigmoidParams(const ov::PartialShape& shape, const ov::element::Type& iType, const std::vector<IT>& iValues, const std::vector<IT>& oValues,
const float alpha, const float beta)
HardSigmoidParams(const ov::PartialShape& shape,
const ov::element::Type& iType,
const std::vector<IT>& iValues,
const std::vector<IT>& oValues,
const float alpha,
const float beta)
: pshape(shape),
inType(iType),
outType(iType),
@ -53,8 +58,11 @@ public:
}
private:
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape, const element::Type& input_type,
const element::Type& expected_output_type, const float alphaData, const float betaData) {
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape,
const element::Type& input_type,
const element::Type& expected_output_type,
const float alphaData,
const float betaData) {
std::vector<float> alphaArray;
std::vector<float> betaArray;
alphaArray.push_back(alphaData);
@ -63,7 +71,7 @@ private:
const auto alpha = ov::op::v0::Constant::create(input_type, Shape{}, {alphaData});
const auto beta = ov::op::v0::Constant::create(input_type, Shape{}, {betaData});
const auto HardSigmoid = std::make_shared<op::v0::HardSigmoid>(in, alpha, beta);
return std::make_shared<ov::Model>(NodeVector {HardSigmoid}, ParameterVector {in});
return std::make_shared<ov::Model>(NodeVector{HardSigmoid}, ParameterVector{in});
}
};
@ -75,28 +83,26 @@ template <element::Type_t IN_ET>
std::vector<HardSigmoidParams> generateHardSigmoidFloatParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<HardSigmoidParams> hardSigmoidParams {
HardSigmoidParams(ov::PartialShape {3},
IN_ET,
std::vector<T>{-1.0f, 0.0f, 1.0f},
std::vector<T>{0.1f, 0.6f, 1.f},
0.5,
0.6),
HardSigmoidParams(ov::PartialShape {2, 5},
IN_ET,
std::vector<T>{-3.0f, -1.0f, 0.0f, 1.0f, 3.0f, 0.5f, -0.2f, 6.0f, 8.0f, 0.1f},
std::vector<T>{0.0f, 0.3f, 0.5f, 0.7f, 1.0f, 0.6f, 0.46f, 1.0f, 1.0f, 0.52f},
0.2,
0.5)
};
std::vector<HardSigmoidParams> hardSigmoidParams{
HardSigmoidParams(ov::PartialShape{3},
IN_ET,
std::vector<T>{-1.0f, 0.0f, 1.0f},
std::vector<T>{0.1f, 0.6f, 1.f},
0.5,
0.6),
HardSigmoidParams(ov::PartialShape{2, 5},
IN_ET,
std::vector<T>{-3.0f, -1.0f, 0.0f, 1.0f, 3.0f, 0.5f, -0.2f, 6.0f, 8.0f, 0.1f},
std::vector<T>{0.0f, 0.3f, 0.5f, 0.7f, 1.0f, 0.6f, 0.46f, 1.0f, 1.0f, 0.52f},
0.2,
0.5)};
return hardSigmoidParams;
}
std::vector<HardSigmoidParams> generateHardSigmoidCombinedParams() {
const std::vector<std::vector<HardSigmoidParams>> hardSigmoidTypeParams {
const std::vector<std::vector<HardSigmoidParams>> hardSigmoidTypeParams{
generateHardSigmoidFloatParams<element::Type_t::f32>(),
generateHardSigmoidFloatParams<element::Type_t::f16>()
};
generateHardSigmoidFloatParams<element::Type_t::f16>()};
std::vector<HardSigmoidParams> combinedParams;
for (const auto& params : hardSigmoidTypeParams) {
@ -105,7 +111,9 @@ std::vector<HardSigmoidParams> generateHardSigmoidCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_HardSigmoid_With_Hardcoded_Refs, ReferenceHardSigmoidLayerTest,
testing::ValuesIn(generateHardSigmoidCombinedParams()), ReferenceHardSigmoidLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_HardSigmoid_With_Hardcoded_Refs,
ReferenceHardSigmoidLayerTest,
testing::ValuesIn(generateHardSigmoidCombinedParams()),
ReferenceHardSigmoidLayerTest::getTestCaseName);
} // namespace
} // namespace

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/hsigmoid.hpp"
#include <gtest/gtest.h>
#include "openvino/op/hsigmoid.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
@ -13,7 +14,10 @@ using namespace ov;
namespace {
struct HSigmoidParams {
template <class IT>
HSigmoidParams(const ov::PartialShape& shape, const ov::element::Type& iType, const std::vector<IT>& iValues, const std::vector<IT>& oValues)
HSigmoidParams(const ov::PartialShape& shape,
const ov::element::Type& iType,
const std::vector<IT>& iValues,
const std::vector<IT>& oValues)
: pshape(shape),
inType(iType),
outType(iType),
@ -45,11 +49,12 @@ public:
}
private:
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape, const element::Type& input_type,
const element::Type& HSigmoidected_output_type) {
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape,
const element::Type& input_type,
const element::Type& HSigmoidected_output_type) {
const auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
const auto HSigmoid = std::make_shared<op::v5::HSigmoid>(in);
return std::make_shared<ov::Model>(NodeVector {HSigmoid}, ParameterVector {in});
return std::make_shared<ov::Model>(NodeVector{HSigmoid}, ParameterVector{in});
}
};
@ -57,25 +62,23 @@ TEST_P(ReferenceHSigmoidLayerTest, CompareWithRefs) {
Exec();
}
template <element::Type_t IN_ET>
std::vector<HSigmoidParams> generateHSigmoidFloatParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<HSigmoidParams> hSigmoidParams {
HSigmoidParams(ov::PartialShape {13},
IN_ET,
std::vector<T>{-10.f, -5.f, -4.f, -3.f, -2.f, -1.f, 0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 10.f},
std::vector<T>{0.f, 0.f, 0.f, 0.f, 0.16666667f, 0.33333333f, 0.5f, 0.66666667f, 0.83333333f, 1.f, 1.f, 1.f, 1.f})
};
std::vector<HSigmoidParams> hSigmoidParams{HSigmoidParams(
ov::PartialShape{13},
IN_ET,
std::vector<T>{-10.f, -5.f, -4.f, -3.f, -2.f, -1.f, 0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 10.f},
std::vector<
T>{0.f, 0.f, 0.f, 0.f, 0.16666667f, 0.33333333f, 0.5f, 0.66666667f, 0.83333333f, 1.f, 1.f, 1.f, 1.f})};
return hSigmoidParams;
}
std::vector<HSigmoidParams> generateHSigmoidCombinedParams() {
const std::vector<std::vector<HSigmoidParams>> hSigmoidTypeParams {
const std::vector<std::vector<HSigmoidParams>> hSigmoidTypeParams{
generateHSigmoidFloatParams<element::Type_t::f32>(),
generateHSigmoidFloatParams<element::Type_t::f16>()
};
generateHSigmoidFloatParams<element::Type_t::f16>()};
std::vector<HSigmoidParams> combinedParams;
for (const auto& params : hSigmoidTypeParams) {
@ -84,7 +87,9 @@ std::vector<HSigmoidParams> generateHSigmoidCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_HSigmoid_With_Hardcoded_Refs, ReferenceHSigmoidLayerTest,
testing::ValuesIn(generateHSigmoidCombinedParams()), ReferenceHSigmoidLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_HSigmoid_With_Hardcoded_Refs,
ReferenceHSigmoidLayerTest,
testing::ValuesIn(generateHSigmoidCombinedParams()),
ReferenceHSigmoidLayerTest::getTestCaseName);
} // namespace
} // namespace

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/hswish.hpp"
#include <gtest/gtest.h>
#include "openvino/op/hswish.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
@ -14,7 +15,10 @@ using namespace InferenceEngine;
namespace {
struct HSwishParams {
template <class IT>
HSwishParams(const ov::PartialShape& shape, const ov::element::Type& iType, const std::vector<IT>& iValues, const std::vector<IT>& oValues)
HSwishParams(const ov::PartialShape& shape,
const ov::element::Type& iType,
const std::vector<IT>& iValues,
const std::vector<IT>& oValues)
: pshape(shape),
inType(iType),
outType(iType),
@ -46,11 +50,12 @@ public:
}
private:
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape, const element::Type& input_type,
const element::Type& HSwishected_output_type) {
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape,
const element::Type& input_type,
const element::Type& HSwishected_output_type) {
const auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
const auto HSwish = std::make_shared<op::v4::HSwish>(in);
return std::make_shared<ov::Model>(NodeVector {HSwish}, ParameterVector {in});
return std::make_shared<ov::Model>(NodeVector{HSwish}, ParameterVector{in});
}
};
@ -58,29 +63,25 @@ TEST_P(ReferenceHSwishLayerTest, CompareWithRefs) {
Exec();
}
template <element::Type_t IN_ET>
std::vector<HSwishParams> generateHSwishFloatParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<HSwishParams> hSwishParams {
HSwishParams(ov::PartialShape {2, 3},
IN_ET,
std::vector<T>{1.f, 8.f, -8.f, 17.f, -0.5f, -1.f},
std::vector<T>{0.66666667f, 8.f, 0.f, 17.f, -0.20833333f, -0.33333333f}),
HSwishParams(ov::PartialShape {2, 2, 1, 2},
IN_ET,
std::vector<T>{0.1f, 0.6f, 20.f, -7.f, -5.3f, 3.5f, -9.f, 11.f},
std::vector<T>{0.05166667f, 0.36f, 20.f, 0.f, 0.f, 3.5f, 0.f, 11.f})
};
std::vector<HSwishParams> hSwishParams{
HSwishParams(ov::PartialShape{2, 3},
IN_ET,
std::vector<T>{1.f, 8.f, -8.f, 17.f, -0.5f, -1.f},
std::vector<T>{0.66666667f, 8.f, 0.f, 17.f, -0.20833333f, -0.33333333f}),
HSwishParams(ov::PartialShape{2, 2, 1, 2},
IN_ET,
std::vector<T>{0.1f, 0.6f, 20.f, -7.f, -5.3f, 3.5f, -9.f, 11.f},
std::vector<T>{0.05166667f, 0.36f, 20.f, 0.f, 0.f, 3.5f, 0.f, 11.f})};
return hSwishParams;
}
std::vector<HSwishParams> generateHSwishCombinedParams() {
const std::vector<std::vector<HSwishParams>> hSwishTypeParams {
generateHSwishFloatParams<element::Type_t::f32>(),
generateHSwishFloatParams<element::Type_t::f16>()
};
const std::vector<std::vector<HSwishParams>> hSwishTypeParams{generateHSwishFloatParams<element::Type_t::f32>(),
generateHSwishFloatParams<element::Type_t::f16>()};
std::vector<HSwishParams> combinedParams;
for (const auto& params : hSwishTypeParams) {
@ -89,7 +90,9 @@ std::vector<HSwishParams> generateHSwishCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_HSwish_With_Hardcoded_Refs, ReferenceHSwishLayerTest,
testing::ValuesIn(generateHSwishCombinedParams()), ReferenceHSwishLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_HSwish_With_Hardcoded_Refs,
ReferenceHSwishLayerTest,
testing::ValuesIn(generateHSwishCombinedParams()),
ReferenceHSwishLayerTest::getTestCaseName);
} // namespace
} // namespace

View File

@ -2,11 +2,12 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/idft.hpp"
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
#include "openvino/op/constant.hpp"
#include "openvino/op/idft.hpp"
using namespace reference_tests;
using namespace ov;
@ -16,13 +17,13 @@ namespace {
struct IDFTParams {
template <class T>
IDFTParams(const Shape& input_shape,
const Shape& expected_shape,
const element::Type_t& input_type,
const element::Type_t& expected_type,
const std::vector<T>& input_value,
const std::vector<T>& expected_value,
const std::shared_ptr<op::v0::Constant>& axes,
const std::shared_ptr<op::v0::Constant>& signal) {
const Shape& expected_shape,
const element::Type_t& input_type,
const element::Type_t& expected_type,
const std::vector<T>& input_value,
const std::vector<T>& expected_value,
const std::shared_ptr<op::v0::Constant>& axes,
const std::shared_ptr<op::v0::Constant>& signal) {
m_input_shape = input_shape;
m_expected_shape = expected_shape;
m_input_type = input_type;
@ -1157,12 +1158,12 @@ std::vector<IDFTParams> generateParamsForIDFT() {
// idft1d_eval_1
IDFTParams(Shape{4, 6, 8, 2},
Shape{4, 6, 8, 2},
ET,
ET,
idft1d_input_data_1,
data_1,
op::v0::Constant::create<int64_t>(element::Type_t::i64, Shape{1}, {2}),
NULL),
ET,
ET,
idft1d_input_data_1,
data_1,
op::v0::Constant::create<int64_t>(element::Type_t::i64, Shape{1}, {2}),
NULL),
// idft1d_eval
IDFTParams(Shape{2, 10, 10, 2},
Shape{2, 10, 10, 2},
@ -1393,10 +1394,9 @@ std::vector<IDFTParams> generateCombinedParamsForIDFT() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(
smoke_IDFT_With_Hardcoded_Refs,
ReferenceIDFTLayerTest,
::testing::ValuesIn(generateCombinedParamsForIDFT()),
ReferenceIDFTLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_IDFT_With_Hardcoded_Refs,
ReferenceIDFTLayerTest,
::testing::ValuesIn(generateCombinedParamsForIDFT()),
ReferenceIDFTLayerTest::getTestCaseName);
} // namespace

View File

@ -17,13 +17,13 @@ using namespace InferenceEngine;
struct IfFunctionalBase {
virtual std::shared_ptr<Model> create_function(const std::vector<reference_tests::Tensor>& if_inputs,
const std::vector<reference_tests::Tensor>& results) = 0;
const std::vector<reference_tests::Tensor>& results) = 0;
IfFunctionalBase() {}
};
struct IfCondConst : public IfFunctionalBase {
std::shared_ptr<Model> create_function(const std::vector<reference_tests::Tensor>& if_inputs,
const std::vector<reference_tests::Tensor>& results) override {
const std::vector<reference_tests::Tensor>& results) override {
OPENVINO_ASSERT(if_inputs.size() == 2, "Incorrect test case! Number of inputs is not 2.");
OPENVINO_ASSERT(results.size() == 1, "Incorrect test case! Number of outputs is not 1.");
@ -55,7 +55,7 @@ struct IfCondConst : public IfFunctionalBase {
struct IfCondIsNonConst : public IfFunctionalBase {
std::shared_ptr<Model> create_function(const std::vector<reference_tests::Tensor>& if_inputs,
const std::vector<reference_tests::Tensor>& results) override {
const std::vector<reference_tests::Tensor>& results) override {
OPENVINO_ASSERT(if_inputs.size() == 3, "Incorrect test case! Number of inputs is not 3.");
OPENVINO_ASSERT(results.size() == 1, "Incorrect test case! Number of outputs is not 1.");
@ -89,7 +89,7 @@ struct IfCondIsNonConst : public IfFunctionalBase {
struct IfWithoutAdditionalInputs : IfFunctionalBase {
std::shared_ptr<Model> create_function(const std::vector<reference_tests::Tensor>& if_inputs,
const std::vector<reference_tests::Tensor>& results) override {
const std::vector<reference_tests::Tensor>& results) override {
OPENVINO_ASSERT(if_inputs.size() == 1, "Incorrect test case! Number of inputs is not 1.");
OPENVINO_ASSERT(results.size() == 1, "Incorrect test case! Number of outputs is not 1.");
@ -111,7 +111,7 @@ struct IfWithoutAdditionalInputs : IfFunctionalBase {
struct IfDynamismCaseWithStaticInputs : public IfFunctionalBase {
std::shared_ptr<Model> create_function(const std::vector<reference_tests::Tensor>& if_inputs,
const std::vector<reference_tests::Tensor>& results) override {
const std::vector<reference_tests::Tensor>& results) override {
OPENVINO_ASSERT(if_inputs.size() == 4, "Incorrect test case! Number of inputs is not 4.");
OPENVINO_ASSERT(results.size() == 2, "Incorrect test case! Number of outputs is not 2.");
@ -153,7 +153,7 @@ struct IfDynamismCaseWithStaticInputs : public IfFunctionalBase {
struct IfConditionIsScalar : public IfFunctionalBase {
std::shared_ptr<Model> create_function(const std::vector<reference_tests::Tensor>& if_inputs,
const std::vector<reference_tests::Tensor>& results) override {
const std::vector<reference_tests::Tensor>& results) override {
OPENVINO_ASSERT(if_inputs.size() == 3, "Incorrect test case! Number of inputs is not 3.");
OPENVINO_ASSERT(results.size() == 1, "Incorrect test case! Number of outputs is not 1.");
@ -189,7 +189,7 @@ struct IfConditionIsScalar : public IfFunctionalBase {
struct IfConditionIsDynamic : public IfFunctionalBase {
std::shared_ptr<Model> create_function(const std::vector<reference_tests::Tensor>& if_inputs,
const std::vector<reference_tests::Tensor>& results) override {
const std::vector<reference_tests::Tensor>& results) override {
OPENVINO_ASSERT(if_inputs.size() == 3, "Incorrect test case! Number of inputs is not 3.");
OPENVINO_ASSERT(results.size() == 1, "Incorrect test case! Number of outputs is not 1.");
@ -318,97 +318,117 @@ INSTANTIATE_TEST_SUITE_P(
smoke_If_With_Hardcoded_Refs,
ReferenceIfLayerTest,
::testing::Values(
IfParams(
std::make_shared<IfCondConst>(true),
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{1.0, 1.0, 1.0, 1.0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{2.0, 2.0, 2.0, 2.0})},
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{2.0, 2.0, 2.0, 2.0})},
"if_condition_const_is_true"),
IfParams(
std::make_shared<IfCondConst>(false),
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{1.0, 1.0, 1.0, 1.0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{2.0, 2.0, 2.0, 2.0})},
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{1.0, 1.0, 1.0, 1.0})},
"if_condition_const_is_false"),
IfParams(
std::make_shared<IfCondIsNonConst>(),
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{1}, ov::element::boolean, std::vector<unsigned char>{1}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{1.0, 2.0, 3.0, 4.0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{2.0, 1.0, 2.0, 3.0})},
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{2.0, 2.0, 6.0, 12.0})},
"if_condition_si_non_const_true"),
IfParams(
std::make_shared<IfCondIsNonConst>(),
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{1}, ov::element::boolean, std::vector<unsigned char>{0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{1.0, 2.0, 3.0, 4.0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{2.0, 1.0, 2.0, 3.0})},
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{3.0, 3.0, 5.0, 7.0})},
"if_condition_is_non_const_false"),
IfParams(std::make_shared<IfCondConst>(true),
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{1.0, 1.0, 1.0, 1.0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{2.0, 2.0, 2.0, 2.0})},
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{2.0, 2.0, 2.0, 2.0})},
"if_condition_const_is_true"),
IfParams(std::make_shared<IfCondConst>(false),
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{1.0, 1.0, 1.0, 1.0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{2.0, 2.0, 2.0, 2.0})},
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{1.0, 1.0, 1.0, 1.0})},
"if_condition_const_is_false"),
IfParams(std::make_shared<IfCondIsNonConst>(),
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(Shape{1}, ov::element::boolean, std::vector<unsigned char>{1}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{1.0, 2.0, 3.0, 4.0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{2.0, 1.0, 2.0, 3.0})},
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{1, 2, 2},
ov::element::f32,
std::vector<float>{2.0, 2.0, 6.0, 12.0})},
"if_condition_si_non_const_true"),
IfParams(std::make_shared<IfCondIsNonConst>(),
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(Shape{1}, ov::element::boolean, std::vector<unsigned char>{0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{1.0, 2.0, 3.0, 4.0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{2.0, 1.0, 2.0, 3.0})},
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{3.0, 3.0, 5.0, 7.0})},
"if_condition_is_non_const_false"),
IfParams(std::make_shared<IfWithoutAdditionalInputs>(),
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{1}, ov::element::boolean, std::vector<unsigned char>{1})},
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{1}, ov::element::f32, std::vector<float>{8.0})},
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(Shape{1}, ov::element::boolean, std::vector<unsigned char>{1})},
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(Shape{1}, ov::element::f32, std::vector<float>{8.0})},
"if_without_addition_inputs_condition_is_true"),
IfParams(std::make_shared<IfWithoutAdditionalInputs>(),
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{1}, ov::element::boolean, std::vector<unsigned char>{0})},
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{1}, ov::element::f32, std::vector<float>{2.0})},
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(Shape{1}, ov::element::boolean, std::vector<unsigned char>{0})},
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(Shape{1}, ov::element::f32, std::vector<float>{2.0})},
"if_without_addition_inputs_condition_is_false"),
IfParams(
std::make_shared<IfConditionIsScalar>(),
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{}, ov::element::boolean, std::vector<unsigned char>{1}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{1.0, 2.0, 3.0, 4.0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{2.0, 1.0, 2.0, 3.0})},
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{2.0, 2.0, 6.0, 12.0})},
"if_condition_is_scalar_cond_true"),
IfParams(
std::make_shared<IfConditionIsScalar>(),
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{}, ov::element::boolean, std::vector<unsigned char>{0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{1.0, 2.0, 3.0, 4.0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{2.0, 1.0, 2.0, 3.0})},
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{3.0, 3.0, 5.0, 7.0})},
"if_condition_is_scalar_cond_false"),
IfParams(
std::make_shared<IfDynamismCaseWithStaticInputs>(),
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{}, ov::element::boolean, std::vector<unsigned char>{1}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{1.0, 2.0, 3.0, 4.0}),
reference_tests::Tensor(Shape{4, 2, 2}, ov::element::f32, Y_gen()),
reference_tests::Tensor(Shape{8, 8, 8}, ov::element::f32, Z_gen())},
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{1.0, 4.0, 9.0, 16.0}),
reference_tests::Tensor(Shape{4, 2, 2}, ov::element::f32, Y_gen())},
"If_dynamism_case_with_static_inputs_condition_true"),
IfParams(
std::make_shared<IfDynamismCaseWithStaticInputs>(),
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{}, ov::element::boolean, std::vector<unsigned char>{0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{1.0, 2.0, 3.0, 4.0}),
reference_tests::Tensor(Shape{4, 2, 2}, ov::element::f32, Y_gen()),
reference_tests::Tensor(Shape{8, 8, 8}, ov::element::f32, Z_gen())},
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{2.0, 4.0, 6.0, 8.0}),
reference_tests::Tensor(Shape{8, 8, 8}, ov::element::f32, Z_gen())},
"If_dynamism_case_with_static_inputs_condition_false"),
IfParams(
std::make_shared<IfConditionIsDynamic>(),
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{}, ov::element::boolean, std::vector<unsigned char>{1}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{1.0, 2.0, 3.0, 4.0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{2.0, 1.0, 2.0, 3.0})},
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{2.0, 2.0, 6.0, 12.0})},
"if_condition_is_dynamic_cond_true"),
IfParams(
std::make_shared<IfConditionIsDynamic>(),
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{}, ov::element::boolean, std::vector<unsigned char>{0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{1.0, 2.0, 3.0, 4.0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{2.0, 1.0, 2.0, 3.0})},
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{3.0, 3.0, 5.0, 7.0})},
"if_condition_is_dynamic_cond_false"),
IfParams(
std::make_shared<IfDynamicInputs>(),
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{}, ov::element::boolean, std::vector<unsigned char>{1}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{1.0, 2.0, 3.0, 4.0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{2.0, 1.0, 2.0, 3.0})},
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{2.0, 2.0, 6.0, 12.0})},
"if_dynamic_inputs_cond_true"),
IfParams(
std::make_shared<IfDynamicInputs>(),
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{}, ov::element::boolean, std::vector<unsigned char>{0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{1.0, 2.0, 3.0, 4.0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{2.0, 1.0, 2.0, 3.0})},
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{3.0, 3.0, 5.0, 7.0})},
"if_dynamic_inputs_cond_false")));
IfParams(std::make_shared<IfConditionIsScalar>(),
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(Shape{}, ov::element::boolean, std::vector<unsigned char>{1}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{1.0, 2.0, 3.0, 4.0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{2.0, 1.0, 2.0, 3.0})},
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{1, 2, 2},
ov::element::f32,
std::vector<float>{2.0, 2.0, 6.0, 12.0})},
"if_condition_is_scalar_cond_true"),
IfParams(std::make_shared<IfConditionIsScalar>(),
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(Shape{}, ov::element::boolean, std::vector<unsigned char>{0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{1.0, 2.0, 3.0, 4.0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{2.0, 1.0, 2.0, 3.0})},
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{3.0, 3.0, 5.0, 7.0})},
"if_condition_is_scalar_cond_false"),
IfParams(std::make_shared<IfDynamismCaseWithStaticInputs>(),
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(Shape{}, ov::element::boolean, std::vector<unsigned char>{1}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{1.0, 2.0, 3.0, 4.0}),
reference_tests::Tensor(Shape{4, 2, 2}, ov::element::f32, Y_gen()),
reference_tests::Tensor(Shape{8, 8, 8}, ov::element::f32, Z_gen())},
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{1.0, 4.0, 9.0, 16.0}),
reference_tests::Tensor(Shape{4, 2, 2}, ov::element::f32, Y_gen())},
"If_dynamism_case_with_static_inputs_condition_true"),
IfParams(std::make_shared<IfDynamismCaseWithStaticInputs>(),
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(Shape{}, ov::element::boolean, std::vector<unsigned char>{0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{1.0, 2.0, 3.0, 4.0}),
reference_tests::Tensor(Shape{4, 2, 2}, ov::element::f32, Y_gen()),
reference_tests::Tensor(Shape{8, 8, 8}, ov::element::f32, Z_gen())},
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{2.0, 4.0, 6.0, 8.0}),
reference_tests::Tensor(Shape{8, 8, 8}, ov::element::f32, Z_gen())},
"If_dynamism_case_with_static_inputs_condition_false"),
IfParams(std::make_shared<IfConditionIsDynamic>(),
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(Shape{}, ov::element::boolean, std::vector<unsigned char>{1}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{1.0, 2.0, 3.0, 4.0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{2.0, 1.0, 2.0, 3.0})},
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{1, 2, 2},
ov::element::f32,
std::vector<float>{2.0, 2.0, 6.0, 12.0})},
"if_condition_is_dynamic_cond_true"),
IfParams(std::make_shared<IfConditionIsDynamic>(),
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(Shape{}, ov::element::boolean, std::vector<unsigned char>{0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{1.0, 2.0, 3.0, 4.0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{2.0, 1.0, 2.0, 3.0})},
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{3.0, 3.0, 5.0, 7.0})},
"if_condition_is_dynamic_cond_false"),
IfParams(std::make_shared<IfDynamicInputs>(),
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(Shape{}, ov::element::boolean, std::vector<unsigned char>{1}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{1.0, 2.0, 3.0, 4.0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{2.0, 1.0, 2.0, 3.0})},
std::vector<reference_tests::Tensor>{reference_tests::Tensor(Shape{1, 2, 2},
ov::element::f32,
std::vector<float>{2.0, 2.0, 6.0, 12.0})},
"if_dynamic_inputs_cond_true"),
IfParams(std::make_shared<IfDynamicInputs>(),
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(Shape{}, ov::element::boolean, std::vector<unsigned char>{0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{1.0, 2.0, 3.0, 4.0}),
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{2.0, 1.0, 2.0, 3.0})},
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(Shape{1, 2, 2}, ov::element::f32, std::vector<float>{3.0, 3.0, 5.0, 7.0})},
"if_dynamic_inputs_cond_false")));

File diff suppressed because it is too large Load Diff

View File

@ -2,10 +2,12 @@
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
#include "openvino/op/is_finite.hpp"
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
using namespace ov;
using namespace reference_tests;
@ -14,10 +16,10 @@ namespace {
struct IsFiniteParams {
template <class IT, class OT>
IsFiniteParams(const PartialShape& shape,
const element::Type& iType,
const element::Type& oType,
const std::vector<IT>& iValues,
const std::vector<OT>& oValues)
const element::Type& iType,
const element::Type& oType,
const std::vector<IT>& iValues,
const std::vector<OT>& oValues)
: pshape(shape),
inType(iType),
outType(oType),
@ -51,8 +53,8 @@ public:
private:
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape,
const element::Type& input_type,
const element::Type& expected_output_type) {
const element::Type& input_type,
const element::Type& expected_output_type) {
const auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
const auto is_finite = std::make_shared<op::v10::IsFinite>(in);
return std::make_shared<Model>(NodeVector{is_finite}, ParameterVector{in});
@ -70,16 +72,17 @@ std::vector<IsFiniteParams> generateParamsForIsFiniteFloat() {
std::vector<IsFiniteParams> params{
IsFiniteParams(ov::PartialShape{8},
IN_ET, element::Type_t::boolean,
std::vector<T>{std::numeric_limits<T>::infinity(), 0.0000f,
std::numeric_limits<T>::max(), -0.5000f,
-std::numeric_limits<T>::infinity(), 1.0000f,
std::numeric_limits<T>::min(), std::nanf("")},
std::vector<U>{false, true,
true, true,
false, true,
true, false})
};
IN_ET,
element::Type_t::boolean,
std::vector<T>{std::numeric_limits<T>::infinity(),
0.0000f,
std::numeric_limits<T>::max(),
-0.5000f,
-std::numeric_limits<T>::infinity(),
1.0000f,
std::numeric_limits<T>::min(),
std::nanf("")},
std::vector<U>{false, true, true, true, false, true, true, false})};
return params;
}
@ -100,9 +103,8 @@ std::vector<IsFiniteParams> generateCombinedParamsForIsFinite() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(
smoke_IsFinite_With_Hardcoded_Refs,
ReferenceIsFiniteLayerTest,
::testing::ValuesIn(generateCombinedParamsForIsFinite()),
ReferenceIsFiniteLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_IsFinite_With_Hardcoded_Refs,
ReferenceIsFiniteLayerTest,
::testing::ValuesIn(generateCombinedParamsForIsFinite()),
ReferenceIsFiniteLayerTest::getTestCaseName);
} // namespace

View File

@ -2,10 +2,12 @@
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
#include "openvino/op/is_inf.hpp"
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
using namespace ov;
using namespace reference_tests;
@ -60,9 +62,9 @@ public:
private:
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape,
const element::Type& input_type,
const element::Type& expected_output_type,
op::v10::IsInf::Attributes attrs) {
const element::Type& input_type,
const element::Type& expected_output_type,
op::v10::IsInf::Attributes attrs) {
const auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
const auto is_inf = std::make_shared<op::v10::IsInf>(in, attrs);
return std::make_shared<Model>(NodeVector{is_inf}, ParameterVector{in});
@ -78,20 +80,20 @@ std::vector<IsInfParams> generateParamsForIsInfDefault() {
using T = typename element_type_traits<IN_ET>::value_type;
using U = typename element_type_traits<element::Type_t::boolean>::value_type;
op::v10::IsInf::Attributes attrs{};
std::vector<IsInfParams> params{
IsInfParams("IsInfDefault", ov::PartialShape{8},
IN_ET, element::Type_t::boolean,
std::vector<T>{std::numeric_limits<T>::infinity(), 0.0000f,
std::numeric_limits<T>::max(), -0.5000f,
-std::numeric_limits<T>::infinity(), 1.0000f,
std::numeric_limits<T>::min(), std::nanf("")},
std::vector<U>{true, false,
false, false,
true, false,
false, false},
attrs
)
};
std::vector<IsInfParams> params{IsInfParams("IsInfDefault",
ov::PartialShape{8},
IN_ET,
element::Type_t::boolean,
std::vector<T>{std::numeric_limits<T>::infinity(),
0.0000f,
std::numeric_limits<T>::max(),
-0.5000f,
-std::numeric_limits<T>::infinity(),
1.0000f,
std::numeric_limits<T>::min(),
std::nanf("")},
std::vector<U>{true, false, false, false, true, false, false, false},
attrs)};
return params;
}
@ -101,20 +103,20 @@ std::vector<IsInfParams> generateParamsForIsInfPositive() {
using U = typename element_type_traits<element::Type_t::boolean>::value_type;
op::v10::IsInf::Attributes attrs{};
attrs.detect_negative = false;
std::vector<IsInfParams> params{
IsInfParams("IsInfPositiveOnly", ov::PartialShape{8},
IN_ET, element::Type_t::boolean,
std::vector<T>{std::numeric_limits<T>::infinity(), 0.0000f,
std::numeric_limits<T>::max(), -0.5000f,
-std::numeric_limits<T>::infinity(), 1.0000f,
std::numeric_limits<T>::min(), std::nanf("")},
std::vector<U>{true, false,
false, false,
false, false,
false, false},
attrs
)
};
std::vector<IsInfParams> params{IsInfParams("IsInfPositiveOnly",
ov::PartialShape{8},
IN_ET,
element::Type_t::boolean,
std::vector<T>{std::numeric_limits<T>::infinity(),
0.0000f,
std::numeric_limits<T>::max(),
-0.5000f,
-std::numeric_limits<T>::infinity(),
1.0000f,
std::numeric_limits<T>::min(),
std::nanf("")},
std::vector<U>{true, false, false, false, false, false, false, false},
attrs)};
return params;
}
@ -124,20 +126,20 @@ std::vector<IsInfParams> generateParamsForIsInfNegative() {
using U = typename element_type_traits<element::Type_t::boolean>::value_type;
op::v10::IsInf::Attributes attrs{};
attrs.detect_positive = false;
std::vector<IsInfParams> params{
IsInfParams("IsInfNegativeOnly", ov::PartialShape{8},
IN_ET, element::Type_t::boolean,
std::vector<T>{std::numeric_limits<T>::infinity(), 0.0000f,
std::numeric_limits<T>::max(), -0.5000f,
-std::numeric_limits<T>::infinity(), 1.0000f,
std::numeric_limits<T>::min(), std::nanf("")},
std::vector<U>{false, false,
false, false,
true, false,
false, false},
attrs
)
};
std::vector<IsInfParams> params{IsInfParams("IsInfNegativeOnly",
ov::PartialShape{8},
IN_ET,
element::Type_t::boolean,
std::vector<T>{std::numeric_limits<T>::infinity(),
0.0000f,
std::numeric_limits<T>::max(),
-0.5000f,
-std::numeric_limits<T>::infinity(),
1.0000f,
std::numeric_limits<T>::min(),
std::nanf("")},
std::vector<U>{false, false, false, false, true, false, false, false},
attrs)};
return params;
}
@ -148,20 +150,20 @@ std::vector<IsInfParams> generateParamsForIsInfNone() {
op::v10::IsInf::Attributes attrs{};
attrs.detect_negative = false;
attrs.detect_positive = false;
std::vector<IsInfParams> params{
IsInfParams("IsInfDetectNone", ov::PartialShape{8},
IN_ET, element::Type_t::boolean,
std::vector<T>{std::numeric_limits<T>::infinity(), 0.0000f,
std::numeric_limits<T>::max(), -0.5000f,
-std::numeric_limits<T>::infinity(), 1.0000f,
std::numeric_limits<T>::min(), std::nanf("")},
std::vector<U>{false, false,
false, false,
false, false,
false, false},
attrs
)
};
std::vector<IsInfParams> params{IsInfParams("IsInfDetectNone",
ov::PartialShape{8},
IN_ET,
element::Type_t::boolean,
std::vector<T>{std::numeric_limits<T>::infinity(),
0.0000f,
std::numeric_limits<T>::max(),
-0.5000f,
-std::numeric_limits<T>::infinity(),
1.0000f,
std::numeric_limits<T>::min(),
std::nanf("")},
std::vector<U>{false, false, false, false, false, false, false, false},
attrs)};
return params;
}
@ -194,9 +196,8 @@ std::vector<IsInfParams> generateCombinedParamsForIsInf() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(
smoke_IsInf_With_Hardcoded_Refs,
ReferenceIsInfLayerTest,
::testing::ValuesIn(generateCombinedParamsForIsInf()),
ReferenceIsInfLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_IsInf_With_Hardcoded_Refs,
ReferenceIsInfLayerTest,
::testing::ValuesIn(generateCombinedParamsForIsInf()),
ReferenceIsInfLayerTest::getTestCaseName);
} // namespace

View File

@ -2,10 +2,12 @@
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
#include "openvino/op/is_nan.hpp"
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
using namespace ov;
using namespace reference_tests;
@ -14,10 +16,10 @@ namespace {
struct IsNaNParams {
template <class IT, class OT>
IsNaNParams(const PartialShape& shape,
const element::Type& iType,
const element::Type& oType,
const std::vector<IT>& iValues,
const std::vector<OT>& oValues)
const element::Type& iType,
const element::Type& oType,
const std::vector<IT>& iValues,
const std::vector<OT>& oValues)
: pshape(shape),
inType(iType),
outType(oType),
@ -51,8 +53,8 @@ public:
private:
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape,
const element::Type& input_type,
const element::Type& expected_output_type) {
const element::Type& input_type,
const element::Type& expected_output_type) {
const auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
const auto is_nan = std::make_shared<op::v10::IsNaN>(in);
return std::make_shared<Model>(NodeVector{is_nan}, ParameterVector{in});
@ -68,18 +70,18 @@ std::vector<IsNaNParams> generateParamsForIsNaNFloat() {
using T = typename element_type_traits<IN_ET>::value_type;
using U = typename element_type_traits<element::Type_t::boolean>::value_type;
std::vector<IsNaNParams> params{
IsNaNParams(ov::PartialShape{8},
IN_ET, element::Type_t::boolean,
std::vector<T>{std::numeric_limits<T>::infinity(), 0.0000f,
std::numeric_limits<T>::max(), -0.5000f,
-std::numeric_limits<T>::infinity(), 1.0000f,
std::numeric_limits<T>::min(), std::nanf("")},
std::vector<U>{false, false,
false, false,
false, false,
false, true})
};
std::vector<IsNaNParams> params{IsNaNParams(ov::PartialShape{8},
IN_ET,
element::Type_t::boolean,
std::vector<T>{std::numeric_limits<T>::infinity(),
0.0000f,
std::numeric_limits<T>::max(),
-0.5000f,
-std::numeric_limits<T>::infinity(),
1.0000f,
std::numeric_limits<T>::min(),
std::nanf("")},
std::vector<U>{false, false, false, false, false, false, false, true})};
return params;
}
@ -100,9 +102,8 @@ std::vector<IsNaNParams> generateCombinedParamsForIsNaN() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(
smoke_IsNaN_With_Hardcoded_Refs,
ReferenceIsNaNLayerTest,
::testing::ValuesIn(generateCombinedParamsForIsNaN()),
ReferenceIsNaNLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_IsNaN_With_Hardcoded_Refs,
ReferenceIsNaNLayerTest,
::testing::ValuesIn(generateCombinedParamsForIsNaN()),
ReferenceIsNaNLayerTest::getTestCaseName);
} // namespace

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/less.hpp"
#include <gtest/gtest.h>
#include "openvino/op/less.hpp"
#include "comparison.hpp"
using namespace ov;
@ -16,43 +17,43 @@ namespace {
template <element::Type_t IN_ET>
std::vector<RefComparisonParams> generateComparisonParams(const element::Type& type) {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<RefComparisonParams> compParams {
std::vector<RefComparisonParams> compParams{
// 1D // 2D // 3D // 4D
Builder {}
Builder{}
.compType(ComparisonTypes::LESS)
.input1({{2, 2}, type, std::vector<T> {0, 12, 23, 0}})
.input2({{2, 2}, type, std::vector<T> {0, 12, 23, 0}})
.expected({{2, 2}, element::boolean, std::vector<char> {0, 0, 0, 0}}),
Builder {}
.input1({{2, 2}, type, std::vector<T>{0, 12, 23, 0}})
.input2({{2, 2}, type, std::vector<T>{0, 12, 23, 0}})
.expected({{2, 2}, element::boolean, std::vector<char>{0, 0, 0, 0}}),
Builder{}
.compType(ComparisonTypes::LESS)
.input1({{2, 3}, type, std::vector<T> {0, 6, 45, 1, 21, 21}})
.input2({{2, 3}, type, std::vector<T> {1, 18, 23, 1, 19, 21}})
.expected({{2, 3}, element::boolean, std::vector<char> {1, 1, 0, 0, 0, 0}}),
Builder {}
.input1({{2, 3}, type, std::vector<T>{0, 6, 45, 1, 21, 21}})
.input2({{2, 3}, type, std::vector<T>{1, 18, 23, 1, 19, 21}})
.expected({{2, 3}, element::boolean, std::vector<char>{1, 1, 0, 0, 0, 0}}),
Builder{}
.compType(ComparisonTypes::LESS)
.input1({{1}, type, std::vector<T> {53}})
.input2({{1}, type, std::vector<T> {53}})
.expected({{1}, element::boolean, std::vector<char> {0}}),
Builder {}
.input1({{1}, type, std::vector<T>{53}})
.input2({{1}, type, std::vector<T>{53}})
.expected({{1}, element::boolean, std::vector<char>{0}}),
Builder{}
.compType(ComparisonTypes::LESS)
.input1({{2, 4}, type, std::vector<T> {0, 12, 23, 0, 1, 5, 11, 8}})
.input2({{2, 4}, type, std::vector<T> {0, 12, 23, 0, 10, 5, 11, 8}})
.expected({{2, 4}, element::boolean, std::vector<char> {0, 0, 0, 0, 1, 0, 0, 0}}),
Builder {}
.input1({{2, 4}, type, std::vector<T>{0, 12, 23, 0, 1, 5, 11, 8}})
.input2({{2, 4}, type, std::vector<T>{0, 12, 23, 0, 10, 5, 11, 8}})
.expected({{2, 4}, element::boolean, std::vector<char>{0, 0, 0, 0, 1, 0, 0, 0}}),
Builder{}
.compType(ComparisonTypes::LESS)
.input1({{3, 1, 2}, type, std::vector<T> {2, 1, 4, 1, 3, 1}})
.input2({{1, 2, 1}, type, std::vector<T> {1, 1}})
.expected({{3, 2, 2}, element::boolean, std::vector<char> {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}),
Builder {}
.input1({{3, 1, 2}, type, std::vector<T>{2, 1, 4, 1, 3, 1}})
.input2({{1, 2, 1}, type, std::vector<T>{1, 1}})
.expected({{3, 2, 2}, element::boolean, std::vector<char>{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}),
Builder{}
.compType(ComparisonTypes::LESS)
.input1({{2, 1, 2, 1}, type, std::vector<T> {2, 1, 4, 1}})
.input2({{1, 2, 1}, type, std::vector<T> {1, 1}})
.expected({{2, 1, 2, 1}, element::boolean, std::vector<char> {0, 0, 0, 0}})};
.input1({{2, 1, 2, 1}, type, std::vector<T>{2, 1, 4, 1}})
.input2({{1, 2, 1}, type, std::vector<T>{1, 1}})
.expected({{2, 1, 2, 1}, element::boolean, std::vector<char>{0, 0, 0, 0}})};
return compParams;
}
std::vector<RefComparisonParams> generateComparisonCombinedParams() {
const std::vector<std::vector<RefComparisonParams>> compTypeParams {
const std::vector<std::vector<RefComparisonParams>> compTypeParams{
generateComparisonParams<element::Type_t::f32>(element::f32),
generateComparisonParams<element::Type_t::f16>(element::f16),
generateComparisonParams<element::Type_t::i32>(element::i32),
@ -66,8 +67,10 @@ std::vector<RefComparisonParams> generateComparisonCombinedParams() {
return combinedParams;
}
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_Comparison_With_Hardcoded_Refs, ReferenceComparisonLayerTest, ::testing::ValuesIn(generateComparisonCombinedParams()),
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_Comparison_With_Hardcoded_Refs,
ReferenceComparisonLayerTest,
::testing::ValuesIn(generateComparisonCombinedParams()),
ReferenceComparisonLayerTest::getTestCaseName);
} // namespace ComparisonOpsRefTestDefinitions
} // namespace reference_tests
} // namespace ComparisonOpsRefTestDefinitions
} // namespace reference_tests

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/less_eq.hpp"
#include <gtest/gtest.h>
#include "openvino/op/less_eq.hpp"
#include "comparison.hpp"
using namespace ov;
@ -16,43 +17,43 @@ namespace {
template <element::Type_t IN_ET>
std::vector<RefComparisonParams> generateComparisonParams(const element::Type& type) {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<RefComparisonParams> compParams {
std::vector<RefComparisonParams> compParams{
// 1D // 2D // 3D // 4D
Builder {}
Builder{}
.compType(ComparisonTypes::LESS_EQUAL)
.input1({{2, 2}, type, std::vector<T> {0, 12, 23, 0}})
.input2({{2, 2}, type, std::vector<T> {0, 12, 23, 0}})
.expected({{2, 2}, element::boolean, std::vector<char> {1, 1, 1, 1}}),
Builder {}
.input1({{2, 2}, type, std::vector<T>{0, 12, 23, 0}})
.input2({{2, 2}, type, std::vector<T>{0, 12, 23, 0}})
.expected({{2, 2}, element::boolean, std::vector<char>{1, 1, 1, 1}}),
Builder{}
.compType(ComparisonTypes::LESS_EQUAL)
.input1({{2, 3}, type, std::vector<T> {0, 6, 45, 1, 21, 21}})
.input2({{2, 3}, type, std::vector<T> {1, 18, 23, 1, 19, 21}})
.expected({{2, 3}, element::boolean, std::vector<char> {1, 1, 0, 1, 0, 1}}),
Builder {}
.input1({{2, 3}, type, std::vector<T>{0, 6, 45, 1, 21, 21}})
.input2({{2, 3}, type, std::vector<T>{1, 18, 23, 1, 19, 21}})
.expected({{2, 3}, element::boolean, std::vector<char>{1, 1, 0, 1, 0, 1}}),
Builder{}
.compType(ComparisonTypes::LESS_EQUAL)
.input1({{1}, type, std::vector<T> {53}})
.input2({{1}, type, std::vector<T> {53}})
.expected({{1}, element::boolean, std::vector<char> {1}}),
Builder {}
.input1({{1}, type, std::vector<T>{53}})
.input2({{1}, type, std::vector<T>{53}})
.expected({{1}, element::boolean, std::vector<char>{1}}),
Builder{}
.compType(ComparisonTypes::LESS_EQUAL)
.input1({{2, 4}, type, std::vector<T> {0, 12, 23, 0, 1, 5, 11, 8}})
.input2({{2, 4}, type, std::vector<T> {0, 12, 23, 0, 10, 5, 11, 8}})
.expected({{2, 4}, element::boolean, std::vector<char> {1, 1, 1, 1, 1, 1, 1, 1}}),
Builder {}
.input1({{2, 4}, type, std::vector<T>{0, 12, 23, 0, 1, 5, 11, 8}})
.input2({{2, 4}, type, std::vector<T>{0, 12, 23, 0, 10, 5, 11, 8}})
.expected({{2, 4}, element::boolean, std::vector<char>{1, 1, 1, 1, 1, 1, 1, 1}}),
Builder{}
.compType(ComparisonTypes::LESS_EQUAL)
.input1({{3, 1, 2}, type, std::vector<T> {2, 1, 4, 1, 3, 1}})
.input2({{1, 2, 1}, type, std::vector<T> {1, 1}})
.expected({{3, 2, 2}, element::boolean, std::vector<char> {0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}}),
Builder {}
.input1({{3, 1, 2}, type, std::vector<T>{2, 1, 4, 1, 3, 1}})
.input2({{1, 2, 1}, type, std::vector<T>{1, 1}})
.expected({{3, 2, 2}, element::boolean, std::vector<char>{0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}}),
Builder{}
.compType(ComparisonTypes::LESS_EQUAL)
.input1({{2, 1, 2, 1}, type, std::vector<T> {2, 1, 4, 1}})
.input2({{1, 2, 1}, type, std::vector<T> {1, 1}})
.expected({{2, 1, 2, 1}, element::boolean, std::vector<char> {0, 1, 0, 1}})};
.input1({{2, 1, 2, 1}, type, std::vector<T>{2, 1, 4, 1}})
.input2({{1, 2, 1}, type, std::vector<T>{1, 1}})
.expected({{2, 1, 2, 1}, element::boolean, std::vector<char>{0, 1, 0, 1}})};
return compParams;
}
std::vector<RefComparisonParams> generateComparisonCombinedParams() {
const std::vector<std::vector<RefComparisonParams>> compTypeParams {
const std::vector<std::vector<RefComparisonParams>> compTypeParams{
generateComparisonParams<element::Type_t::f32>(element::f32),
generateComparisonParams<element::Type_t::f16>(element::f16),
generateComparisonParams<element::Type_t::i32>(element::i32),
@ -66,8 +67,10 @@ std::vector<RefComparisonParams> generateComparisonCombinedParams() {
return combinedParams;
}
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_Comparison_With_Hardcoded_Refs, ReferenceComparisonLayerTest, ::testing::ValuesIn(generateComparisonCombinedParams()),
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_Comparison_With_Hardcoded_Refs,
ReferenceComparisonLayerTest,
::testing::ValuesIn(generateComparisonCombinedParams()),
ReferenceComparisonLayerTest::getTestCaseName);
} // namespace ComparisonOpsRefTestDefinitions
} // namespace reference_tests
} // namespace ComparisonOpsRefTestDefinitions
} // namespace reference_tests

View File

@ -2,10 +2,12 @@
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
#include "openvino/op/log.hpp"
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
using namespace ov;
using namespace reference_tests;
@ -14,9 +16,9 @@ namespace {
struct LogParams {
template <class IT>
LogParams(const PartialShape& shape,
const element::Type& iType,
const std::vector<IT>& iValues,
const std::vector<IT>& oValues)
const element::Type& iType,
const std::vector<IT>& iValues,
const std::vector<IT>& oValues)
: pshape(shape),
inType(iType),
outType(iType),
@ -50,8 +52,8 @@ public:
private:
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape,
const element::Type& input_type,
const element::Type& expected_output_type) {
const element::Type& input_type,
const element::Type& expected_output_type) {
const auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
const auto log = std::make_shared<op::v0::Log>(in);
return std::make_shared<Model>(NodeVector{log}, ParameterVector{in});
@ -66,38 +68,36 @@ template <element::Type_t IN_ET>
std::vector<LogParams> generateParamsForLog() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<LogParams> logParams{
LogParams(ov::PartialShape{8},
IN_ET,
std::vector<T>{0.125f, 0.25f, 0.5f, 1.f, 2.f, 4.f, 8.f, 16.f},
std::vector<T>{-2.07944154f, -1.38629436f, -0.69314718f, 0.00000000f, 0.69314718f, 1.38629436f, 2.07944154f, 2.77258872f})
};
std::vector<LogParams> logParams{LogParams(ov::PartialShape{8},
IN_ET,
std::vector<T>{0.125f, 0.25f, 0.5f, 1.f, 2.f, 4.f, 8.f, 16.f},
std::vector<T>{-2.07944154f,
-1.38629436f,
-0.69314718f,
0.00000000f,
0.69314718f,
1.38629436f,
2.07944154f,
2.77258872f})};
return logParams;
}
template <element::Type_t IN_ET>
std::vector<LogParams> generateParamsForLogInt() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<LogParams> logParams{
LogParams(ov::PartialShape{4},
IN_ET,
std::vector<T>{10, 100, 1000, 10000},
std::vector<T>{2, 4, 6, 9})
};
LogParams(ov::PartialShape{4}, IN_ET, std::vector<T>{10, 100, 1000, 10000}, std::vector<T>{2, 4, 6, 9})};
return logParams;
}
std::vector<LogParams> generateCombinedParamsForLog() {
const std::vector<std::vector<LogParams>> allTypeParams{
generateParamsForLog<element::Type_t::f32>(),
generateParamsForLog<element::Type_t::f16>(),
generateParamsForLogInt<element::Type_t::i64>(),
generateParamsForLogInt<element::Type_t::i32>(),
generateParamsForLogInt<element::Type_t::u64>(),
generateParamsForLogInt<element::Type_t::u32>()
};
const std::vector<std::vector<LogParams>> allTypeParams{generateParamsForLog<element::Type_t::f32>(),
generateParamsForLog<element::Type_t::f16>(),
generateParamsForLogInt<element::Type_t::i64>(),
generateParamsForLogInt<element::Type_t::i32>(),
generateParamsForLogInt<element::Type_t::u64>(),
generateParamsForLogInt<element::Type_t::u32>()};
std::vector<LogParams> combinedParams;
@ -108,10 +108,9 @@ std::vector<LogParams> generateCombinedParamsForLog() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(
smoke_Log_With_Hardcoded_Refs,
ReferenceLogLayerTest,
::testing::ValuesIn(generateCombinedParamsForLog()),
ReferenceLogLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Log_With_Hardcoded_Refs,
ReferenceLogLayerTest,
::testing::ValuesIn(generateCombinedParamsForLog()),
ReferenceLogLayerTest::getTestCaseName);
} // namespace

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/log_softmax.hpp"
#include <gtest/gtest.h>
#include "openvino/op/log_softmax.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
@ -14,8 +15,11 @@ using namespace InferenceEngine;
namespace {
struct LogSoftmaxParams {
template <class IT>
LogSoftmaxParams(const ov::PartialShape& shape, const ov::element::Type& iType, const std::vector<IT>& iValues, const std::vector<IT>& oValues,
const int64_t axis)
LogSoftmaxParams(const ov::PartialShape& shape,
const ov::element::Type& iType,
const std::vector<IT>& iValues,
const std::vector<IT>& oValues,
const int64_t axis)
: axis(axis),
pshape(shape),
inType(iType),
@ -51,11 +55,13 @@ public:
}
private:
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape, const element::Type& input_type,
const element::Type& expected_output_type, const int64_t axis) {
static std::shared_ptr<Model> CreateFunction(const PartialShape& input_shape,
const element::Type& input_type,
const element::Type& expected_output_type,
const int64_t axis) {
const auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
const auto LogSoftmax = std::make_shared<op::v5::LogSoftmax>(in, axis);
return std::make_shared<ov::Model>(NodeVector {LogSoftmax}, ParameterVector {in});
return std::make_shared<ov::Model>(NodeVector{LogSoftmax}, ParameterVector{in});
}
};
@ -67,173 +73,171 @@ template <element::Type_t IN_ET>
std::vector<LogSoftmaxParams> generateLogSoftmaxFloatParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<LogSoftmaxParams> logSoftmaxParams {
LogSoftmaxParams(ov::PartialShape {1},
IN_ET,
std::vector<T>{1},
std::vector<T>{0},
0),
LogSoftmaxParams(ov::PartialShape {2, 4},
IN_ET,
std::vector<T>{0, 1, 2, 3, 10000, 10001, 10002, 10003},
std::vector<T>{-10000., -10000., -10000., -10000., 0., 0., 0., 0.},
0),
LogSoftmaxParams(ov::PartialShape {2, 4},
IN_ET,
std::vector<T>{0, 1, 2, 3, 10000, 10001, 10002, 10003},
std::vector<T>{-3.4401896, -2.4401896, -1.4401897, -0.4401897, -3.4401896, -2.4401896, -1.4401897, -0.4401897},
1),
LogSoftmaxParams(ov::PartialShape {2, 4},
IN_ET,
std::vector<T>{0, 1, 2, 3, 10000, 10001, 10002, 10003},
std::vector<T>{-3.4401896, -2.4401896, -1.4401897, -0.4401897, -3.4401896, -2.4401896, -1.4401897, -0.4401897},
-1),
LogSoftmaxParams(ov::PartialShape {2, 4},
IN_ET,
std::vector<T>{0, 1, 2, 3, 10000, 10001, 10002, 10003},
std::vector<T>{-10000., -10000., -10000., -10000., 0., 0., 0., 0.},
-2),
LogSoftmaxParams(ov::PartialShape {3, 2, 3},
IN_ET,
std::vector<T>{-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8},
std::vector<T>{-12.0024818,
-12.0024818,
-12.0024818,
-12.0024818,
-12.0024818,
-12.0024818,
-6.00248181,
-6.00248181,
-6.00248181,
-6.00248181,
-6.00248181,
-6.00248181,
-2.48181414e-03,
-2.48181414e-03,
-2.48181414e-03,
-2.48181414e-03,
-2.48181414e-03,
-2.48181414e-03},
0),
LogSoftmaxParams(ov::PartialShape {3, 2, 3},
IN_ET,
std::vector<T>{-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8},
std::vector<T>{-3.04858735,
-3.04858735,
-3.04858735,
-0.04858735,
-0.04858735,
-0.04858735,
-3.04858735,
-3.04858735,
-3.04858735,
-0.04858735,
-0.04858735,
-0.04858735,
-3.04858735,
-3.04858735,
-3.04858735,
-0.04858735,
-0.04858735,
-0.04858735},
1),
LogSoftmaxParams(ov::PartialShape {3, 2, 3},
IN_ET,
std::vector<T>{-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8},
std::vector<T>{-2.40760596,
-1.40760596,
-0.40760596,
-2.40760596,
-1.40760596,
-0.40760596,
-2.40760596,
-1.40760596,
-0.40760596,
-2.40760596,
-1.40760596,
-0.40760596,
-2.40760596,
-1.40760596,
-0.40760596,
-2.40760596,
-1.40760596,
-0.40760596},
2),
LogSoftmaxParams(ov::PartialShape {3, 2, 3},
IN_ET,
std::vector<T>{-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8},
std::vector<T>{-2.40760596,
-1.40760596,
-0.40760596,
-2.40760596,
-1.40760596,
-0.40760596,
-2.40760596,
-1.40760596,
-0.40760596,
-2.40760596,
-1.40760596,
-0.40760596,
-2.40760596,
-1.40760596,
-0.40760596,
-2.40760596,
-1.40760596,
-0.40760596},
-1),
LogSoftmaxParams(ov::PartialShape {3, 2, 3},
IN_ET,
std::vector<T>{-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8},
std::vector<T>{-3.04858735,
-3.04858735,
-3.04858735,
-0.04858735,
-0.04858735,
-0.04858735,
-3.04858735,
-3.04858735,
-3.04858735,
-0.04858735,
-0.04858735,
-0.04858735,
-3.04858735,
-3.04858735,
-3.04858735,
-0.04858735,
-0.04858735,
-0.04858735},
-2),
LogSoftmaxParams(ov::PartialShape {3, 2, 3},
IN_ET,
std::vector<T>{-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8},
std::vector<T>{-12.0024818,
-12.0024818,
-12.0024818,
-12.0024818,
-12.0024818,
-12.0024818,
-6.00248181,
-6.00248181,
-6.00248181,
-6.00248181,
-6.00248181,
-6.00248181,
-2.48181414e-03,
-2.48181414e-03,
-2.48181414e-03,
-2.48181414e-03,
-2.48181414e-03,
-2.48181414e-03},
-3)
};
std::vector<LogSoftmaxParams> logSoftmaxParams{
LogSoftmaxParams(ov::PartialShape{1}, IN_ET, std::vector<T>{1}, std::vector<T>{0}, 0),
LogSoftmaxParams(ov::PartialShape{2, 4},
IN_ET,
std::vector<T>{0, 1, 2, 3, 10000, 10001, 10002, 10003},
std::vector<T>{-10000., -10000., -10000., -10000., 0., 0., 0., 0.},
0),
LogSoftmaxParams(
ov::PartialShape{2, 4},
IN_ET,
std::vector<T>{0, 1, 2, 3, 10000, 10001, 10002, 10003},
std::vector<
T>{-3.4401896, -2.4401896, -1.4401897, -0.4401897, -3.4401896, -2.4401896, -1.4401897, -0.4401897},
1),
LogSoftmaxParams(
ov::PartialShape{2, 4},
IN_ET,
std::vector<T>{0, 1, 2, 3, 10000, 10001, 10002, 10003},
std::vector<
T>{-3.4401896, -2.4401896, -1.4401897, -0.4401897, -3.4401896, -2.4401896, -1.4401897, -0.4401897},
-1),
LogSoftmaxParams(ov::PartialShape{2, 4},
IN_ET,
std::vector<T>{0, 1, 2, 3, 10000, 10001, 10002, 10003},
std::vector<T>{-10000., -10000., -10000., -10000., 0., 0., 0., 0.},
-2),
LogSoftmaxParams(ov::PartialShape{3, 2, 3},
IN_ET,
std::vector<T>{-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8},
std::vector<T>{-12.0024818,
-12.0024818,
-12.0024818,
-12.0024818,
-12.0024818,
-12.0024818,
-6.00248181,
-6.00248181,
-6.00248181,
-6.00248181,
-6.00248181,
-6.00248181,
-2.48181414e-03,
-2.48181414e-03,
-2.48181414e-03,
-2.48181414e-03,
-2.48181414e-03,
-2.48181414e-03},
0),
LogSoftmaxParams(ov::PartialShape{3, 2, 3},
IN_ET,
std::vector<T>{-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8},
std::vector<T>{-3.04858735,
-3.04858735,
-3.04858735,
-0.04858735,
-0.04858735,
-0.04858735,
-3.04858735,
-3.04858735,
-3.04858735,
-0.04858735,
-0.04858735,
-0.04858735,
-3.04858735,
-3.04858735,
-3.04858735,
-0.04858735,
-0.04858735,
-0.04858735},
1),
LogSoftmaxParams(ov::PartialShape{3, 2, 3},
IN_ET,
std::vector<T>{-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8},
std::vector<T>{-2.40760596,
-1.40760596,
-0.40760596,
-2.40760596,
-1.40760596,
-0.40760596,
-2.40760596,
-1.40760596,
-0.40760596,
-2.40760596,
-1.40760596,
-0.40760596,
-2.40760596,
-1.40760596,
-0.40760596,
-2.40760596,
-1.40760596,
-0.40760596},
2),
LogSoftmaxParams(ov::PartialShape{3, 2, 3},
IN_ET,
std::vector<T>{-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8},
std::vector<T>{-2.40760596,
-1.40760596,
-0.40760596,
-2.40760596,
-1.40760596,
-0.40760596,
-2.40760596,
-1.40760596,
-0.40760596,
-2.40760596,
-1.40760596,
-0.40760596,
-2.40760596,
-1.40760596,
-0.40760596,
-2.40760596,
-1.40760596,
-0.40760596},
-1),
LogSoftmaxParams(ov::PartialShape{3, 2, 3},
IN_ET,
std::vector<T>{-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8},
std::vector<T>{-3.04858735,
-3.04858735,
-3.04858735,
-0.04858735,
-0.04858735,
-0.04858735,
-3.04858735,
-3.04858735,
-3.04858735,
-0.04858735,
-0.04858735,
-0.04858735,
-3.04858735,
-3.04858735,
-3.04858735,
-0.04858735,
-0.04858735,
-0.04858735},
-2),
LogSoftmaxParams(ov::PartialShape{3, 2, 3},
IN_ET,
std::vector<T>{-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8},
std::vector<T>{-12.0024818,
-12.0024818,
-12.0024818,
-12.0024818,
-12.0024818,
-12.0024818,
-6.00248181,
-6.00248181,
-6.00248181,
-6.00248181,
-6.00248181,
-6.00248181,
-2.48181414e-03,
-2.48181414e-03,
-2.48181414e-03,
-2.48181414e-03,
-2.48181414e-03,
-2.48181414e-03},
-3)};
return logSoftmaxParams;
}
std::vector<LogSoftmaxParams> generateLogSoftmaxCombinedParams() {
const std::vector<std::vector<LogSoftmaxParams>> logSoftmaxTypeParams {
const std::vector<std::vector<LogSoftmaxParams>> logSoftmaxTypeParams{
generateLogSoftmaxFloatParams<element::Type_t::f32>(),
generateLogSoftmaxFloatParams<element::Type_t::f16>()
};
generateLogSoftmaxFloatParams<element::Type_t::f16>()};
std::vector<LogSoftmaxParams> combinedParams;
for (const auto& params : logSoftmaxTypeParams) {
@ -242,7 +246,9 @@ std::vector<LogSoftmaxParams> generateLogSoftmaxCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_LogSoftmax_With_Hardcoded_Refs, ReferenceLogSoftmaxLayerTest,
testing::ValuesIn(generateLogSoftmaxCombinedParams()), ReferenceLogSoftmaxLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_LogSoftmax_With_Hardcoded_Refs,
ReferenceLogSoftmaxLayerTest,
testing::ValuesIn(generateLogSoftmaxCombinedParams()),
ReferenceLogSoftmaxLayerTest::getTestCaseName);
} // namespace
} // namespace

View File

@ -5,7 +5,6 @@
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
#include "openvino/op/logical_and.hpp"
#include "openvino/op/logical_not.hpp"
#include "openvino/op/logical_or.hpp"
@ -16,12 +15,7 @@ using namespace ov;
namespace reference_tests {
namespace LogicalOpsRefTestDefinitions {
enum LogicalTypes {
LOGICAL_AND,
LOGICAL_OR,
LOGICAL_XOR,
LOGICAL_NOT
};
enum LogicalTypes { LOGICAL_AND, LOGICAL_OR, LOGICAL_XOR, LOGICAL_NOT };
struct RefLogicalParams {
LogicalTypes opType;
@ -49,7 +43,7 @@ public:
const auto& param = obj.param;
std::ostringstream result;
result << "LogicalType=" << param.opType << "_";
for (size_t i =0; i< param.inputs.size(); i++) {
for (size_t i = 0; i < param.inputs.size(); i++) {
const auto input = param.inputs[i];
result << "inpt_shape" << i << "=" << input.shape << "_";
result << "inpt_type" << i << "=" << input.type << "_";
@ -59,7 +53,8 @@ public:
}
private:
static std::shared_ptr<ov::Model> CreateFunction(LogicalTypes op_type, const std::vector<reference_tests::Tensor>& inputs) {
static std::shared_ptr<ov::Model> CreateFunction(LogicalTypes op_type,
const std::vector<reference_tests::Tensor>& inputs) {
ov::ParameterVector params_vec;
for (auto& input : inputs) {
params_vec.push_back(std::make_shared<op::v0::Parameter>(input.type, input.shape));
@ -86,8 +81,8 @@ private:
default: {
throw std::runtime_error("Incorrect type of Logical operation");
}
}
return std::make_shared<ov::Model>(ov::NodeVector {logical_op}, ov::ParameterVector {params_vec});
}
return std::make_shared<ov::Model>(ov::NodeVector{logical_op}, ov::ParameterVector{params_vec});
}
};
} // namespace LogicalOpsRefTestDefinitions

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/logical_and.hpp"
#include <gtest/gtest.h>
#include "openvino/op/logical_and.hpp"
#include "logical.hpp"
using namespace ov;
@ -14,26 +15,34 @@ namespace LogicalOpsRefTestDefinitions {
namespace {
std::vector<RefLogicalParams> generateLogicalParams() {
std::vector<RefLogicalParams> logicalParams {
Builder {}
std::vector<RefLogicalParams> logicalParams{
Builder{}
.opType(LogicalTypes::LOGICAL_AND)
.inputs({{{2, 2}, element::boolean, std::vector<char> {true, false, true, false}},
{{2, 2}, element::boolean, std::vector<char> {false, true, true, false}}})
.expected({{2, 2}, element::boolean, std::vector<char> {false, false, true, false}}),
Builder {}
.inputs({{{2, 2}, element::boolean, std::vector<char>{true, false, true, false}},
{{2, 2}, element::boolean, std::vector<char>{false, true, true, false}}})
.expected({{2, 2}, element::boolean, std::vector<char>{false, false, true, false}}),
Builder{}
.opType(LogicalTypes::LOGICAL_AND)
.inputs({{{2, 1, 2, 1}, element::boolean, std::vector<char> {true, false, true, false}},
{{1, 1, 2, 1}, element::boolean, std::vector<char> {true, false}}})
.expected({{2, 1, 2, 1}, element::boolean, std::vector<char> {true, false, true, false}}),
Builder {}
.inputs({{{2, 1, 2, 1}, element::boolean, std::vector<char>{true, false, true, false}},
{{1, 1, 2, 1}, element::boolean, std::vector<char>{true, false}}})
.expected({{2, 1, 2, 1}, element::boolean, std::vector<char>{true, false, true, false}}),
Builder{}
.opType(LogicalTypes::LOGICAL_AND)
.inputs({{{3, 4}, element::boolean, std::vector<char> {true, true, true, true, true, false, true, false, false, true, true, true}},
{{3, 4}, element::boolean, std::vector<char> {true, true, true, true, true, false, true, false, false, true, true, false}}})
.expected({{3, 4}, element::boolean, std::vector<char> {true, true, true, true, true, false, true, false, false, true, true, false}})};
.inputs({{{3, 4},
element::boolean,
std::vector<char>{true, true, true, true, true, false, true, false, false, true, true, true}},
{{3, 4},
element::boolean,
std::vector<char>{true, true, true, true, true, false, true, false, false, true, true, false}}})
.expected({{3, 4},
element::boolean,
std::vector<char>{true, true, true, true, true, false, true, false, false, true, true, false}})};
return logicalParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_LogicalAnd_With_Hardcoded_Refs, ReferenceLogicalLayerTest, ::testing::ValuesIn(generateLogicalParams()),
INSTANTIATE_TEST_SUITE_P(smoke_LogicalAnd_With_Hardcoded_Refs,
ReferenceLogicalLayerTest,
::testing::ValuesIn(generateLogicalParams()),
ReferenceLogicalLayerTest::getTestCaseName);
} // namespace

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/logical_not.hpp"
#include <gtest/gtest.h>
#include "openvino/op/logical_not.hpp"
#include "logical.hpp"
using namespace ov;
@ -14,15 +15,17 @@ namespace LogicalOpsRefTestDefinitions {
namespace {
std::vector<RefLogicalParams> generateLogicalParams() {
std::vector<RefLogicalParams> logicalParams {
Builder {}
std::vector<RefLogicalParams> logicalParams{
Builder{}
.opType(LogicalTypes::LOGICAL_NOT)
.inputs({{{2, 2}, element::boolean, std::vector<char> {true, false, true, false}}})
.expected({{2, 2}, element::boolean, std::vector<char> {false, true, false, true}})};
.inputs({{{2, 2}, element::boolean, std::vector<char>{true, false, true, false}}})
.expected({{2, 2}, element::boolean, std::vector<char>{false, true, false, true}})};
return logicalParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_LogicalNot_With_Hardcoded_Refs, ReferenceLogicalLayerTest, ::testing::ValuesIn(generateLogicalParams()),
INSTANTIATE_TEST_SUITE_P(smoke_LogicalNot_With_Hardcoded_Refs,
ReferenceLogicalLayerTest,
::testing::ValuesIn(generateLogicalParams()),
ReferenceLogicalLayerTest::getTestCaseName);
} // namespace

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/logical_or.hpp"
#include <gtest/gtest.h>
#include "openvino/op/logical_or.hpp"
#include "logical.hpp"
using namespace ov;
@ -14,26 +15,34 @@ namespace LogicalOpsRefTestDefinitions {
namespace {
std::vector<RefLogicalParams> generateLogicalParams() {
std::vector<RefLogicalParams> logicalParams {
Builder {}
std::vector<RefLogicalParams> logicalParams{
Builder{}
.opType(LogicalTypes::LOGICAL_OR)
.inputs({{{2, 2}, element::boolean, std::vector<char> {true, false, true, false}},
{{2, 2}, element::boolean, std::vector<char> {false, true, true, false}}})
.expected({{2, 2}, element::boolean, std::vector<char> {true, true, true, false}}),
Builder {}
.inputs({{{2, 2}, element::boolean, std::vector<char>{true, false, true, false}},
{{2, 2}, element::boolean, std::vector<char>{false, true, true, false}}})
.expected({{2, 2}, element::boolean, std::vector<char>{true, true, true, false}}),
Builder{}
.opType(LogicalTypes::LOGICAL_OR)
.inputs({{{2, 1, 2, 1}, element::boolean, std::vector<char> {true, false, true, false}},
{{1, 1, 2, 1}, element::boolean, std::vector<char> {true, false}}})
.expected({{2, 1, 2, 1}, element::boolean, std::vector<char> {true, false, true, false}}),
Builder {}
.inputs({{{2, 1, 2, 1}, element::boolean, std::vector<char>{true, false, true, false}},
{{1, 1, 2, 1}, element::boolean, std::vector<char>{true, false}}})
.expected({{2, 1, 2, 1}, element::boolean, std::vector<char>{true, false, true, false}}),
Builder{}
.opType(LogicalTypes::LOGICAL_OR)
.inputs({{{3, 4}, element::boolean, std::vector<char> {true, true, true, true, true, false, true, false, false, true, true, true}},
{{3, 4}, element::boolean, std::vector<char> {true, true, true, true, true, true, true, false, false, true, true, false}}})
.expected({{3, 4}, element::boolean, std::vector<char> {true, true, true, true, true, true, true, false, false, true, true, true}})};
.inputs({{{3, 4},
element::boolean,
std::vector<char>{true, true, true, true, true, false, true, false, false, true, true, true}},
{{3, 4},
element::boolean,
std::vector<char>{true, true, true, true, true, true, true, false, false, true, true, false}}})
.expected({{3, 4},
element::boolean,
std::vector<char>{true, true, true, true, true, true, true, false, false, true, true, true}})};
return logicalParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_LogicalOr_With_Hardcoded_Refs, ReferenceLogicalLayerTest, ::testing::ValuesIn(generateLogicalParams()),
INSTANTIATE_TEST_SUITE_P(smoke_LogicalOr_With_Hardcoded_Refs,
ReferenceLogicalLayerTest,
::testing::ValuesIn(generateLogicalParams()),
ReferenceLogicalLayerTest::getTestCaseName);
} // namespace

View File

@ -2,9 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/logical_xor.hpp"
#include <gtest/gtest.h>
#include "openvino/op/logical_xor.hpp"
#include "logical.hpp"
using namespace ov;
@ -14,26 +15,35 @@ namespace LogicalOpsRefTestDefinitions {
namespace {
std::vector<RefLogicalParams> generateLogicalParams() {
std::vector<RefLogicalParams> logicalParams {
Builder {}
std::vector<RefLogicalParams> logicalParams{
Builder{}
.opType(LogicalTypes::LOGICAL_XOR)
.inputs({{{2, 2}, element::boolean, std::vector<char> {true, false, true, false}},
{{2, 2}, element::boolean, std::vector<char> {false, true, true, false}}})
.expected({{2, 2}, element::boolean, std::vector<char> {true, true, false, false}}),
Builder {}
.inputs({{{2, 2}, element::boolean, std::vector<char>{true, false, true, false}},
{{2, 2}, element::boolean, std::vector<char>{false, true, true, false}}})
.expected({{2, 2}, element::boolean, std::vector<char>{true, true, false, false}}),
Builder{}
.opType(LogicalTypes::LOGICAL_XOR)
.inputs({{{2, 1, 2, 1}, element::boolean, std::vector<char> {true, false, true, false}},
{{1, 1, 2, 1}, element::boolean, std::vector<char> {true, false}}})
.expected({{2, 1, 2, 1}, element::boolean, std::vector<char> {false, false, false, false}}),
Builder {}
.inputs({{{2, 1, 2, 1}, element::boolean, std::vector<char>{true, false, true, false}},
{{1, 1, 2, 1}, element::boolean, std::vector<char>{true, false}}})
.expected({{2, 1, 2, 1}, element::boolean, std::vector<char>{false, false, false, false}}),
Builder{}
.opType(LogicalTypes::LOGICAL_XOR)
.inputs({{{3, 4}, element::boolean, std::vector<char> {true, true, true, true, true, false, true, false, false, true, true, true}},
{{3, 4}, element::boolean, std::vector<char> {true, true, true, true, true, true, true, false, false, true, true, false}}})
.expected({{3, 4}, element::boolean, std::vector<char> {false, false, false, false, false, true, false, false, false, false, false, true}})};
.inputs({{{3, 4},
element::boolean,
std::vector<char>{true, true, true, true, true, false, true, false, false, true, true, true}},
{{3, 4},
element::boolean,
std::vector<char>{true, true, true, true, true, true, true, false, false, true, true, false}}})
.expected(
{{3, 4},
element::boolean,
std::vector<char>{false, false, false, false, false, true, false, false, false, false, false, true}})};
return logicalParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_LogicalOr_With_Hardcoded_Refs, ReferenceLogicalLayerTest, ::testing::ValuesIn(generateLogicalParams()),
INSTANTIATE_TEST_SUITE_P(smoke_LogicalOr_With_Hardcoded_Refs,
ReferenceLogicalLayerTest,
::testing::ValuesIn(generateLogicalParams()),
ReferenceLogicalLayerTest::getTestCaseName);
} // namespace

View File

@ -8,14 +8,11 @@
#include <openvino/opsets/opset8.hpp>
#include "base_reference_test.hpp"
#include "functional_test_utils/skip_tests_config.hpp"
#include "common_test_utils/common_utils.hpp"
#include "functional_test_utils/skip_tests_config.hpp"
namespace {
enum LOOP_IN_TYPE {
INVARIANT,
MERGED
};
enum LOOP_IN_TYPE { INVARIANT, MERGED };
struct LoopFunctionalBase {
virtual std::shared_ptr<ov::Model> create_function(const std::vector<reference_tests::Tensor>& loop_inputs,
@ -49,8 +46,8 @@ struct LoopDynamicInputs : public LoopFunctionalBase {
// Body
auto sum = std::make_shared<ov::opset8::Add>(Xi, Yi);
auto Zo = std::make_shared<ov::opset8::Multiply>(sum, M_body);
auto body = std::make_shared<ov::Model>(ov::OutputVector{body_condition, Zo},
ov::ParameterVector{Xi, Yi, M_body});
auto body =
std::make_shared<ov::Model>(ov::OutputVector{body_condition, Zo}, ov::ParameterVector{Xi, Yi, M_body});
auto loop = std::make_shared<ov::opset8::Loop>(trip_count, exec_condition);
loop->set_function(body);
@ -72,10 +69,10 @@ struct LoopParams {
const std::vector<reference_tests::Tensor>& loop_inputs,
const std::vector<reference_tests::Tensor>& expected_results,
const std::string& test_case_name)
: function(functional),
inputs(loop_inputs),
expected_results(expected_results),
test_case_name(test_case_name) {}
: function(functional),
inputs(loop_inputs),
expected_results(expected_results),
test_case_name(test_case_name) {}
std::shared_ptr<LoopFunctionalBase> function;
std::vector<reference_tests::Tensor> inputs;
@ -109,23 +106,22 @@ TEST_P(ReferenceLoopLayerTest, TensorIteratorWithHardcodedRefs) {
}
INSTANTIATE_TEST_SUITE_P(
smoke_TensorIterator_With_Hardcoded_Refs,
ReferenceLoopLayerTest,
::testing::Values(
LoopParams(
std::make_shared<LoopDynamicInputs>(),
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(ov::element::f32, ov::Shape{2, 2}, std::vector<float>{0, 1, 2, 3}),
reference_tests::Tensor(ov::element::f32, ov::Shape{2, 2}, std::vector<float>{1, 2, 3, 4}),
reference_tests::Tensor(ov::element::f32, ov::Shape{2, 2}, std::vector<float>{5, 4, 3, 2})},
// 5*(0+1)*(0+1)*(0+1) = 5
// 4*(1+2)*(1+2)*(1+2) = 108
// 3*(2+3)*(2+3)*(2+3) = 375
// 2*(3+4)*(3+4)*(3+4) = 686
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(ov::element::f32, ov::Shape{2, 2}, std::vector<float>{5, 108, 375, 686})},
"loop_dynamic_inputs")),
ReferenceLoopLayerTest::getTestCaseName);
smoke_TensorIterator_With_Hardcoded_Refs,
ReferenceLoopLayerTest,
::testing::Values(LoopParams(
std::make_shared<LoopDynamicInputs>(),
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(ov::element::f32, ov::Shape{2, 2}, std::vector<float>{0, 1, 2, 3}),
reference_tests::Tensor(ov::element::f32, ov::Shape{2, 2}, std::vector<float>{1, 2, 3, 4}),
reference_tests::Tensor(ov::element::f32, ov::Shape{2, 2}, std::vector<float>{5, 4, 3, 2})},
// 5*(0+1)*(0+1)*(0+1) = 5
// 4*(1+2)*(1+2)*(1+2) = 108
// 3*(2+3)*(2+3)*(2+3) = 375
// 2*(3+4)*(3+4)*(3+4) = 686
std::vector<reference_tests::Tensor>{
reference_tests::Tensor(ov::element::f32, ov::Shape{2, 2}, std::vector<float>{5, 108, 375, 686})},
"loop_dynamic_inputs")),
ReferenceLoopLayerTest::getTestCaseName);
struct LoopStaticInputs : public LoopFunctionalBase {
std::shared_ptr<ov::Model> create_function(const std::vector<reference_tests::Tensor>& loop_inputs,
@ -146,7 +142,8 @@ struct LoopStaticInputs : public LoopFunctionalBase {
body_params.emplace_back(std::make_shared<ov::opset8::Parameter>(net_type, pshape));
}
const auto body_condition_const = std::make_shared<ov::opset8::Constant>(ov::element::boolean, ov::Shape{1}, true);
const auto body_condition_const =
std::make_shared<ov::opset8::Constant>(ov::element::boolean, ov::Shape{1}, true);
const auto exec_condition = std::make_shared<ov::opset8::Constant>(ov::element::boolean, ov::Shape{1}, true);
std::shared_ptr<ov::Node> trip_count_input;
trip_count_input = std::make_shared<ov::opset8::Constant>(ov::element::i64, ov::Shape{1}, trip_count);
@ -157,8 +154,7 @@ struct LoopStaticInputs : public LoopFunctionalBase {
Zo = std::make_shared<ov::opset8::Add>(body_params[i], Zo);
}
const auto body = std::make_shared<ov::Model>(ov::OutputVector{body_condition_const, Zo},
body_params);
const auto body = std::make_shared<ov::Model>(ov::OutputVector{body_condition_const, Zo}, body_params);
const auto loop = std::make_shared<ov::opset8::Loop>(trip_count_input, exec_condition);
loop->set_function(body);
@ -184,27 +180,27 @@ struct LoopStaticInputs : public LoopFunctionalBase {
const auto result0 = std::make_shared<ov::opset8::Result>(out0);
const auto result1 = std::make_shared<ov::opset8::Result>(out1);
const auto result2 = std::make_shared<ov::opset8::Result>(out2);
const auto function = std::make_shared<ov::Model>(ov::ResultVector{result0, result1, result2}, loop_params, "loop");
const auto function =
std::make_shared<ov::Model>(ov::ResultVector{result0, result1, result2}, loop_params, "loop");
return function;
}
};
struct LoopStaticParams {
LoopStaticParams(
const std::shared_ptr<LoopFunctionalBase>& functional,
const std::vector<reference_tests::Tensor>& loop_inputs,
const std::vector<reference_tests::Tensor>& expected_results,
const int64_t& trip_count,
const std::vector<LOOP_IN_TYPE>& loop_in_type,
const ov::element::Type& net_type,
const std::string& test_case_name)
: function(functional),
inputs(loop_inputs),
expected_results(expected_results),
trip_count(trip_count),
loop_in_type(loop_in_type),
net_type(net_type),
test_case_name(test_case_name) {}
LoopStaticParams(const std::shared_ptr<LoopFunctionalBase>& functional,
const std::vector<reference_tests::Tensor>& loop_inputs,
const std::vector<reference_tests::Tensor>& expected_results,
const int64_t& trip_count,
const std::vector<LOOP_IN_TYPE>& loop_in_type,
const ov::element::Type& net_type,
const std::string& test_case_name)
: function(functional),
inputs(loop_inputs),
expected_results(expected_results),
trip_count(trip_count),
loop_in_type(loop_in_type),
net_type(net_type),
test_case_name(test_case_name) {}
std::shared_ptr<LoopFunctionalBase> function;
std::vector<reference_tests::Tensor> inputs;
@ -215,7 +211,8 @@ struct LoopStaticParams {
std::string test_case_name;
};
class ReferenceLoopLayerStaticTest : public testing::TestWithParam<LoopStaticParams>, public reference_tests::CommonReferenceTest {
class ReferenceLoopLayerStaticTest : public testing::TestWithParam<LoopStaticParams>,
public reference_tests::CommonReferenceTest {
public:
void SetUp() override {
SKIP_IF_CURRENT_TEST_IS_DISABLED()
@ -262,138 +259,110 @@ TEST_P(ReferenceLoopLayerStaticTest, CompareWithRefs) {
template <ov::element::Type_t ET>
std::vector<LoopStaticParams> generateParams() {
using T = typename ov::element_type_traits<ET>::value_type;
std::vector<LoopStaticParams> params {
std::vector<LoopStaticParams> params{
LoopStaticParams(
std::make_shared<LoopStaticInputs>(),
{reference_tests::Tensor(
ET,
{10, 1, 10},
std::vector<T>{
7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2,
3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6,
7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2,
3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6,
7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2}),
reference_tests::Tensor(
ET,
{1, 1, 1},
std::vector<T>{7}),
reference_tests::Tensor(
ET,
{10, 1, 10},
std::vector<T>{
7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2,
3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6,
7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2,
3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6,
7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2})},
{reference_tests::Tensor(
ov::element::Type_t::boolean,
{1},
std::vector<char>{1}),
reference_tests::Tensor(
ET,
{10, 1, 10},
std::vector<T>{
21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11,
13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19,
21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11,
13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19,
21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11}),
reference_tests::Tensor(
ET,
{10, 1, 10},
std::vector<T>{
21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11,
13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19,
21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11,
13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19,
21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11})},
1,
{LOOP_IN_TYPE::INVARIANT, LOOP_IN_TYPE::INVARIANT, LOOP_IN_TYPE::MERGED},
ET,
"loop_for_common"),
std::make_shared<LoopStaticInputs>(),
{reference_tests::Tensor(ET, {10, 1, 10}, std::vector<T>{7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7,
4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4,
5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5,
2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2,
3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3,
0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2}),
reference_tests::Tensor(ET, {1, 1, 1}, std::vector<T>{7}),
reference_tests::Tensor(ET, {10, 1, 10}, std::vector<T>{7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7,
4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4,
5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5,
2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2,
3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3,
0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2})},
{reference_tests::Tensor(ov::element::Type_t::boolean, {1}, std::vector<char>{1}),
reference_tests::Tensor(
ET,
{10, 1, 10},
std::vector<T>{21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11,
13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19,
21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11,
13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19,
21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11}),
reference_tests::Tensor(
ET,
{10, 1, 10},
std::vector<T>{21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11,
13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19,
21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11,
13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19,
21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11})},
1,
{LOOP_IN_TYPE::INVARIANT, LOOP_IN_TYPE::INVARIANT, LOOP_IN_TYPE::MERGED},
ET,
"loop_for_common"),
LoopStaticParams(
std::make_shared<LoopStaticInputs>(),
{reference_tests::Tensor(
ET,
{10, 1, 10},
std::vector<T>{
7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2,
3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6,
7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2,
3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6,
7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2}),
reference_tests::Tensor(
ET,
{1, 1, 1},
std::vector<T>{7}),
reference_tests::Tensor(
ET,
{10, 1, 10},
std::vector<T>{
7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2,
3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6,
7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2,
3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6,
7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2})},
{reference_tests::Tensor(
ov::element::Type_t::boolean,
{1},
std::vector<char>{1}),
reference_tests::Tensor(
ET,
{10, 1, 10},
std::vector<T>{
77, 59, 65, 47, 53, 35, 41, 71, 77, 59, 65, 47, 53, 35, 41, 71, 77, 59, 65, 47,
53, 35, 41, 71, 77, 59, 65, 47, 53, 35, 41, 71, 77, 59, 65, 47, 53, 35, 41, 71,
77, 59, 65, 47, 53, 35, 41, 71, 77, 59, 65, 47, 53, 35, 41, 71, 77, 59, 65, 47,
53, 35, 41, 71, 77, 59, 65, 47, 53, 35, 41, 71, 77, 59, 65, 47, 53, 35, 41, 71,
77, 59, 65, 47, 53, 35, 41, 71, 77, 59, 65, 47, 53, 35, 41, 71, 77, 59, 65, 47}),
reference_tests::Tensor(
ET,
{10, 5, 10},
std::vector<T>{
21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 35, 26, 29, 20, 23, 14, 17, 32, 35, 26,
49, 37, 41, 29, 33, 21, 25, 45, 49, 37, 63, 48, 53, 38, 43, 28, 33, 58, 63, 48,
77, 59, 65, 47, 53, 35, 41, 71, 77, 59, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11,
29, 20, 23, 14, 17, 32, 35, 26, 29, 20, 41, 29, 33, 21, 25, 45, 49, 37, 41, 29,
53, 38, 43, 28, 33, 58, 63, 48, 53, 38, 65, 47, 53, 35, 41, 71, 77, 59, 65, 47,
std::make_shared<LoopStaticInputs>(),
{reference_tests::Tensor(ET, {10, 1, 10}, std::vector<T>{7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7,
4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4,
5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5,
2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2,
3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3,
0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2}),
reference_tests::Tensor(ET, {1, 1, 1}, std::vector<T>{7}),
reference_tests::Tensor(ET, {10, 1, 10}, std::vector<T>{7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7,
4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4,
5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5,
2, 3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2,
3, 0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2, 3,
0, 1, 6, 7, 4, 5, 2, 3, 0, 1, 6, 7, 4, 5, 2})},
{reference_tests::Tensor(ov::element::Type_t::boolean, {1}, std::vector<char>{1}),
reference_tests::Tensor(
ET,
{10, 1, 10},
std::vector<T>{77, 59, 65, 47, 53, 35, 41, 71, 77, 59, 65, 47, 53, 35, 41, 71, 77, 59, 65, 47,
53, 35, 41, 71, 77, 59, 65, 47, 53, 35, 41, 71, 77, 59, 65, 47, 53, 35, 41, 71,
77, 59, 65, 47, 53, 35, 41, 71, 77, 59, 65, 47, 53, 35, 41, 71, 77, 59, 65, 47,
53, 35, 41, 71, 77, 59, 65, 47, 53, 35, 41, 71, 77, 59, 65, 47, 53, 35, 41, 71,
77, 59, 65, 47, 53, 35, 41, 71, 77, 59, 65, 47, 53, 35, 41, 71, 77, 59, 65, 47}),
reference_tests::Tensor(
ET,
{10, 5, 10},
std::vector<T>{21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 35, 26, 29, 20, 23, 14, 17, 32, 35, 26,
49, 37, 41, 29, 33, 21, 25, 45, 49, 37, 63, 48, 53, 38, 43, 28, 33, 58, 63, 48,
77, 59, 65, 47, 53, 35, 41, 71, 77, 59, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11,
29, 20, 23, 14, 17, 32, 35, 26, 29, 20, 41, 29, 33, 21, 25, 45, 49, 37, 41, 29,
53, 38, 43, 28, 33, 58, 63, 48, 53, 38, 65, 47, 53, 35, 41, 71, 77, 59, 65, 47,
13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 23, 14, 17, 32, 35, 26, 29, 20, 23, 14,
33, 21, 25, 45, 49, 37, 41, 29, 33, 21, 43, 28, 33, 58, 63, 48, 53, 38, 43, 28,
53, 35, 41, 71, 77, 59, 65, 47, 53, 35, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19,
17, 32, 35, 26, 29, 20, 23, 14, 17, 32, 25, 45, 49, 37, 41, 29, 33, 21, 25, 45,
33, 58, 63, 48, 53, 38, 43, 28, 33, 58, 41, 71, 77, 59, 65, 47, 53, 35, 41, 71,
13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 23, 14, 17, 32, 35, 26, 29, 20, 23, 14,
33, 21, 25, 45, 49, 37, 41, 29, 33, 21, 43, 28, 33, 58, 63, 48, 53, 38, 43, 28,
53, 35, 41, 71, 77, 59, 65, 47, 53, 35, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19,
17, 32, 35, 26, 29, 20, 23, 14, 17, 32, 25, 45, 49, 37, 41, 29, 33, 21, 25, 45,
33, 58, 63, 48, 53, 38, 43, 28, 33, 58, 41, 71, 77, 59, 65, 47, 53, 35, 41, 71,
21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 35, 26, 29, 20, 23, 14, 17, 32, 35, 26,
49, 37, 41, 29, 33, 21, 25, 45, 49, 37, 63, 48, 53, 38, 43, 28, 33, 58, 63, 48,
77, 59, 65, 47, 53, 35, 41, 71, 77, 59, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11,
29, 20, 23, 14, 17, 32, 35, 26, 29, 20, 41, 29, 33, 21, 25, 45, 49, 37, 41, 29,
53, 38, 43, 28, 33, 58, 63, 48, 53, 38, 65, 47, 53, 35, 41, 71, 77, 59, 65, 47,
21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 35, 26, 29, 20, 23, 14, 17, 32, 35, 26,
49, 37, 41, 29, 33, 21, 25, 45, 49, 37, 63, 48, 53, 38, 43, 28, 33, 58, 63, 48,
77, 59, 65, 47, 53, 35, 41, 71, 77, 59, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11,
29, 20, 23, 14, 17, 32, 35, 26, 29, 20, 41, 29, 33, 21, 25, 45, 49, 37, 41, 29,
53, 38, 43, 28, 33, 58, 63, 48, 53, 38, 65, 47, 53, 35, 41, 71, 77, 59, 65, 47,
13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 23, 14, 17, 32, 35, 26, 29, 20, 23, 14,
33, 21, 25, 45, 49, 37, 41, 29, 33, 21, 43, 28, 33, 58, 63, 48, 53, 38, 43, 28,
53, 35, 41, 71, 77, 59, 65, 47, 53, 35, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19,
17, 32, 35, 26, 29, 20, 23, 14, 17, 32, 25, 45, 49, 37, 41, 29, 33, 21, 25, 45,
33, 58, 63, 48, 53, 38, 43, 28, 33, 58, 41, 71, 77, 59, 65, 47, 53, 35, 41, 71,
13, 7, 9, 19, 21, 15, 17, 11, 13, 7, 23, 14, 17, 32, 35, 26, 29, 20, 23, 14,
33, 21, 25, 45, 49, 37, 41, 29, 33, 21, 43, 28, 33, 58, 63, 48, 53, 38, 43, 28,
53, 35, 41, 71, 77, 59, 65, 47, 53, 35, 9, 19, 21, 15, 17, 11, 13, 7, 9, 19,
17, 32, 35, 26, 29, 20, 23, 14, 17, 32, 25, 45, 49, 37, 41, 29, 33, 21, 25, 45,
33, 58, 63, 48, 53, 38, 43, 28, 33, 58, 41, 71, 77, 59, 65, 47, 53, 35, 41, 71,
21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 35, 26, 29, 20, 23, 14, 17, 32, 35, 26,
49, 37, 41, 29, 33, 21, 25, 45, 49, 37, 63, 48, 53, 38, 43, 28, 33, 58, 63, 48,
77, 59, 65, 47, 53, 35, 41, 71, 77, 59, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11,
29, 20, 23, 14, 17, 32, 35, 26, 29, 20, 41, 29, 33, 21, 25, 45, 49, 37, 41, 29,
53, 38, 43, 28, 33, 58, 63, 48, 53, 38, 65, 47, 53, 35, 41, 71, 77, 59, 65, 47})},
5,
{LOOP_IN_TYPE::INVARIANT, LOOP_IN_TYPE::INVARIANT, LOOP_IN_TYPE::MERGED},
ET,
"loop_for_common"),
21, 15, 17, 11, 13, 7, 9, 19, 21, 15, 35, 26, 29, 20, 23, 14, 17, 32, 35, 26,
49, 37, 41, 29, 33, 21, 25, 45, 49, 37, 63, 48, 53, 38, 43, 28, 33, 58, 63, 48,
77, 59, 65, 47, 53, 35, 41, 71, 77, 59, 17, 11, 13, 7, 9, 19, 21, 15, 17, 11,
29, 20, 23, 14, 17, 32, 35, 26, 29, 20, 41, 29, 33, 21, 25, 45, 49, 37, 41, 29,
53, 38, 43, 28, 33, 58, 63, 48, 53, 38, 65, 47, 53, 35, 41, 71, 77, 59, 65, 47})},
5,
{LOOP_IN_TYPE::INVARIANT, LOOP_IN_TYPE::INVARIANT, LOOP_IN_TYPE::MERGED},
ET,
"loop_for_common"),
};
return params;
}
std::vector<LoopStaticParams> generateCombinedParams() {
const std::vector<std::vector<LoopStaticParams>> generatedParams {
const std::vector<std::vector<LoopStaticParams>> generatedParams{
generateParams<ov::element::Type_t::i8>(),
generateParams<ov::element::Type_t::i16>(),
generateParams<ov::element::Type_t::i32>(),
@ -414,6 +383,8 @@ std::vector<LoopStaticParams> generateCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_Loop_With_Hardcoded_Refs, ReferenceLoopLayerStaticTest,
testing::ValuesIn(generateCombinedParams()), ReferenceLoopLayerStaticTest::getTestCaseName);
}
INSTANTIATE_TEST_SUITE_P(smoke_Loop_With_Hardcoded_Refs,
ReferenceLoopLayerStaticTest,
testing::ValuesIn(generateCombinedParams()),
ReferenceLoopLayerStaticTest::getTestCaseName);
} // namespace

View File

@ -2,11 +2,12 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/op/lrn.hpp"
#include <gtest/gtest.h>
#include "base_reference_test.hpp"
#include "openvino/op/constant.hpp"
#include "openvino/op/lrn.hpp"
using namespace reference_tests;
using namespace ov;
@ -115,12 +116,12 @@ public:
private:
static std::shared_ptr<Model> CreateFunction(const Shape& input_shape,
const element::Type_t& input_type,
const float& alpah,
const float& beta,
const float& bias,
const size_t& size,
const std::shared_ptr<op::v0::Constant>& axes) {
const element::Type_t& input_type,
const float& alpah,
const float& beta,
const float& bias,
const size_t& size,
const std::shared_ptr<op::v0::Constant>& axes) {
auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
std::shared_ptr<op::v0::LRN> lrn;
@ -161,7 +162,10 @@ std::vector<LRNParams> generateParamsForLRN() {
0.5669467f,
0.7784989f,
0.7720487f},
3, 0.5, 1, 3,
3,
0.5,
1,
3,
NULL),
// lrn_across_h
LRNParams(Shape{2, 3, 2, 1},
@ -181,7 +185,10 @@ std::vector<LRNParams> generateParamsForLRN() {
0.7448453f,
0.6711560f,
0.7382717f},
3, 0.5, 1, 3,
3,
0.5,
1,
3,
std::make_shared<op::v0::Constant>(element::Type_t::i64, Shape{1}, std::vector<int64_t>{2})),
// lrn_across_hw
LRNParams(Shape{2, 3, 2, 1},
@ -201,7 +208,10 @@ std::vector<LRNParams> generateParamsForLRN() {
1.2813632f,
1.1572751f,
1.2730026f},
3, 0.5, 1, 3,
3,
0.5,
1,
3,
std::make_shared<op::v0::Constant>(element::Type_t::i64, Shape{2}, std::vector<int64_t>{2, 3})),
// lrn_across_all_dims
LRNParams(Shape{2, 3, 2, 1},
@ -221,7 +231,10 @@ std::vector<LRNParams> generateParamsForLRN() {
2.0256331f,
2.4576957f,
2.7034652f},
3, 0.5, 1, 3,
3,
0.5,
1,
3,
std::make_shared<op::v0::Constant>(element::Type_t::i64, Shape{4}, std::vector<int64_t>{0, 1, 2, 3})),
// lrn_across_nw
LRNParams(Shape{2, 3, 2, 1},
@ -241,7 +254,10 @@ std::vector<LRNParams> generateParamsForLRN() {
1.6164477f,
1.5877683f,
1.5608464f},
3, 0.5, 1, 3,
3,
0.5,
1,
3,
std::make_shared<op::v0::Constant>(element::Type_t::i64, Shape{2}, std::vector<int64_t>{0, 3})),
// lrn_across_empty
LRNParams(Shape{2, 3, 2, 1},
@ -261,7 +277,10 @@ std::vector<LRNParams> generateParamsForLRN() {
0.5761660f,
0.5763904f,
0.5765567f},
3, 0.5, 1, 3,
3,
0.5,
1,
3,
std::make_shared<op::v0::Constant>(element::Type_t::i64, Shape{0}, std::vector<int64_t>{})),
// lrn_6D_across_2_axes
LRNParams(Shape{2, 3, 2, 2, 1, 1},
@ -273,7 +292,10 @@ std::vector<LRNParams> generateParamsForLRN() {
0.9149914f, 1.0674900f, 0.7213357f, 0.8115027f, 0.9016696f, 0.9918366f,
0.7656109f, 0.8294119f, 0.8932127f, 0.9570137f, 0.7892218f, 0.8385482f,
0.8878745f, 0.9372009f, 0.8038679f, 0.8440613f, 0.8842546f, 0.9244481f},
3, 0.5, 1, 3,
3,
0.5,
1,
3,
std::make_shared<op::v0::Constant>(element::Type_t::i64, Shape{2}, std::vector<int64_t>{2, 3})),
// lrn_2d_across_empty
LRNParams(Shape{12},
@ -293,9 +315,12 @@ std::vector<LRNParams> generateParamsForLRN() {
0.5761660f,
0.5763904f,
0.5765566f},
3, 0.5, 1, 3,
3,
0.5,
1,
3,
std::make_shared<op::v0::Constant>(element::Type_t::i64, Shape{0}, std::vector<int64_t>{})),
// lrn_2d_across_empty
// lrn_2d_across_empty
LRNParams(Shape{6, 2},
Shape{6, 2},
ET,
@ -324,7 +349,10 @@ std::vector<LRNParams> generateParamsForLRN() {
-0.3425926f,
0.3559732f,
-0.7039225f},
0.0002, 0.5, 2.0, 3,
0.0002,
0.5,
2.0,
3,
std::make_shared<op::v0::Constant>(element::Type_t::i64, Shape{1}, std::vector<int64_t>{0})),
};
@ -332,10 +360,8 @@ std::vector<LRNParams> generateParamsForLRN() {
}
std::vector<LRNParams> generateCombinedParamsForLRN() {
const std::vector<std::vector<LRNParams>> allTypeParams{
generateParamsForLRN<element::Type_t::f64>(),
generateParamsForLRN<element::Type_t::f32>()
};
const std::vector<std::vector<LRNParams>> allTypeParams{generateParamsForLRN<element::Type_t::f64>(),
generateParamsForLRN<element::Type_t::f32>()};
std::vector<LRNParams> combinedParams;
@ -346,10 +372,9 @@ std::vector<LRNParams> generateCombinedParamsForLRN() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(
smoke_LRN_With_Hardcoded_Refs,
ReferenceLRNLayerTest,
::testing::ValuesIn(generateCombinedParamsForLRN()),
ReferenceLRNLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_LRN_With_Hardcoded_Refs,
ReferenceLRNLayerTest,
::testing::ValuesIn(generateCombinedParamsForLRN()),
ReferenceLRNLayerTest::getTestCaseName);
} // namespace

View File

@ -4,9 +4,9 @@
#include <gtest/gtest.h>
#include "openvino/opsets/opset4.hpp"
#include "openvino/opsets/opset1.hpp"
#include "base_reference_test.hpp"
#include "openvino/opsets/opset1.hpp"
#include "openvino/opsets/opset4.hpp"
using namespace reference_tests;
using namespace ov;
@ -159,18 +159,17 @@ private:
const auto C_t = std::make_shared<opset1::Parameter>(params.C_t.type, params.C_t.shape);
const auto B = std::make_shared<opset1::Parameter>(params.B.type, params.B.shape);
const auto lstm_cell =
std::make_shared<opset4::LSTMCell>(X,
H_t,
C_t,
W,
R,
B,
params.hiddenSize,
std::vector<std::string>{"sigmoid", "tanh", "tanh"},
std::vector<float>{},
std::vector<float>{},
clip_threshold);
const auto lstm_cell = std::make_shared<opset4::LSTMCell>(X,
H_t,
C_t,
W,
R,
B,
params.hiddenSize,
std::vector<std::string>{"sigmoid", "tanh", "tanh"},
std::vector<float>{},
std::vector<float>{},
clip_threshold);
auto function = std::make_shared<Model>(lstm_cell->outputs(), ParameterVector{X, H_t, C_t, W, R, B});
return function;
@ -243,7 +242,13 @@ public:
threshold = 1e-1f;
auto params = GetParam();
function = CreateFunction(params);
inputData = {params.X.data, params.H_t.data, params.C_t.data, params.W.data, params.R.data, params.B.data, params.P.data};
inputData = {params.X.data,
params.H_t.data,
params.C_t.data,
params.W.data,
params.R.data,
params.B.data,
params.P.data};
refOutData = {params.Ho.data, params.Co.data};
}
@ -259,21 +264,20 @@ private:
const auto B = std::make_shared<opset1::Parameter>(params.B.type, params.B.shape);
const auto P = std::make_shared<opset1::Parameter>(params.P.type, params.P.shape);
const auto lstm_cell =
std::make_shared<opset1::LSTMCell>(X,
H_t,
C_t,
W,
R,
B,
P,
params.hiddenSize,
op::LSTMWeightsFormat::FICO,
std::vector<std::string>{"sigmoid", "tanh", "tanh"},
std::vector<float>{},
std::vector<float>{},
clip_threshold,
false);
const auto lstm_cell = std::make_shared<opset1::LSTMCell>(X,
H_t,
C_t,
W,
R,
B,
P,
params.hiddenSize,
op::LSTMWeightsFormat::FICO,
std::vector<std::string>{"sigmoid", "tanh", "tanh"},
std::vector<float>{},
std::vector<float>{},
clip_threshold,
false);
auto function = std::make_shared<Model>(lstm_cell->outputs(), ParameterVector{X, H_t, C_t, W, R, B, P});
return function;
@ -295,43 +299,59 @@ TEST_P(ReferenceLSTMCellV1TestBiasClip, CompareWithRefs) {
template <element::Type_t ET>
std::vector<LSTMCellParams> generateParams() {
using T = typename element_type_traits<ET>::value_type;
std::vector<LSTMCellParams> params {
Builder {}
.batchSize(2)
.inputSize(3)
.hiddenSize(3)
.gatesCount(4)
.X(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.81342685f, 0.84108883f, 0.8152282f, 0.46893653f, 0.0901856f, 0.37088776f}))
.W(reference_tests::Tensor(ET, {4 * 3, 3}, std::vector<T>{
3.3330739e-01f, 3.6229487e-04f, 4.6773660e-01f, 4.3046016e-01f, 7.3950343e-02f, 3.8063636e-01f,
9.6921772e-01f, 9.6897459e-01f, 6.2964785e-01f, 3.1134409e-01f, 8.4709978e-01f, 9.4928098e-01f,
6.1676943e-01f, 6.6020679e-01f, 1.9072217e-01f, 8.8032126e-02f, 4.0472135e-01f, 6.8342745e-01f,
8.3432144e-01f, 4.4928190e-01f, 7.9524308e-01f, 5.3966165e-01f, 8.5936421e-01f, 8.3136767e-01f,
5.5125546e-02f, 4.7791195e-01f, 3.5788772e-01f, 6.7507404e-01f, 2.1716513e-01f, 2.7473119e-01f,
3.3999152e-02f, 9.6835363e-01f, 3.7581277e-01f, 2.4026000e-01f, 6.7418844e-01f, 3.4199652e-01f}))
.R(reference_tests::Tensor(ET, {4 * 3, 3}, std::vector<T>{
0.0987983f, 0.52032113f, 0.5848073f, 0.5356095f, 0.74497133f, 0.73260087f,
0.1700787f, 0.45684233f, 0.1495722f, 0.42734373f, 0.4433832f, 0.25906256f,
0.03854987f, 0.47480518f, 0.37215272f, 0.99890584f, 0.74019486f, 0.3518967f,
0.6881257f, 0.8170279f, 0.54088944f, 0.81225616f, 0.14619833f, 0.42941234f,
0.86843914f, 0.45967972f, 0.6237719f, 0.11074839f, 0.6029616f, 0.3149305f,
0.46504205f, 0.5843412f, 0.8733427f, 0.7687243f, 0.07074859f, 0.39188156f}))
.H_t(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.77956f, 0.5331557f, 0.04297554f, 0.7962175f, 0.7635707f, 0.11989366f}))
.C_t(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.8488452f, 0.18851636f, 0.5020695f, 0.29716516f, 0.06740791f, 0.45384037f}))
.B(reference_tests::Tensor(ET, {4 * 3}, std::vector<T>(4 * 3, 0.f)))
.P(reference_tests::Tensor(ET, {3 * 3}, std::vector<T>(3 * 3, 0.f)))
.Ho(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{0.81457126f, 0.61109227f, 0.769522f, 0.52239674f, 0.4324641f, 0.63183f}))
.Co(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{1.4444952f, 0.9635685f, 1.2875274f, 0.8053419f, 0.7184521f, 0.95803297f}))
.testcaseName("lstm_cell_zero_bias_default_attrs")
};
std::vector<LSTMCellParams> params{
Builder{}
.batchSize(2)
.inputSize(3)
.hiddenSize(3)
.gatesCount(4)
.X(reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.81342685f, 0.84108883f, 0.8152282f, 0.46893653f, 0.0901856f, 0.37088776f}))
.W(reference_tests::Tensor(
ET,
{4 * 3, 3},
std::vector<T>{
3.3330739e-01f, 3.6229487e-04f, 4.6773660e-01f, 4.3046016e-01f, 7.3950343e-02f, 3.8063636e-01f,
9.6921772e-01f, 9.6897459e-01f, 6.2964785e-01f, 3.1134409e-01f, 8.4709978e-01f, 9.4928098e-01f,
6.1676943e-01f, 6.6020679e-01f, 1.9072217e-01f, 8.8032126e-02f, 4.0472135e-01f, 6.8342745e-01f,
8.3432144e-01f, 4.4928190e-01f, 7.9524308e-01f, 5.3966165e-01f, 8.5936421e-01f, 8.3136767e-01f,
5.5125546e-02f, 4.7791195e-01f, 3.5788772e-01f, 6.7507404e-01f, 2.1716513e-01f, 2.7473119e-01f,
3.3999152e-02f, 9.6835363e-01f, 3.7581277e-01f, 2.4026000e-01f, 6.7418844e-01f, 3.4199652e-01f}))
.R(reference_tests::Tensor(
ET,
{4 * 3, 3},
std::vector<T>{0.0987983f, 0.52032113f, 0.5848073f, 0.5356095f, 0.74497133f, 0.73260087f,
0.1700787f, 0.45684233f, 0.1495722f, 0.42734373f, 0.4433832f, 0.25906256f,
0.03854987f, 0.47480518f, 0.37215272f, 0.99890584f, 0.74019486f, 0.3518967f,
0.6881257f, 0.8170279f, 0.54088944f, 0.81225616f, 0.14619833f, 0.42941234f,
0.86843914f, 0.45967972f, 0.6237719f, 0.11074839f, 0.6029616f, 0.3149305f,
0.46504205f, 0.5843412f, 0.8733427f, 0.7687243f, 0.07074859f, 0.39188156f}))
.H_t(reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.77956f, 0.5331557f, 0.04297554f, 0.7962175f, 0.7635707f, 0.11989366f}))
.C_t(reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.8488452f, 0.18851636f, 0.5020695f, 0.29716516f, 0.06740791f, 0.45384037f}))
.B(reference_tests::Tensor(ET, {4 * 3}, std::vector<T>(4 * 3, 0.f)))
.P(reference_tests::Tensor(ET, {3 * 3}, std::vector<T>(3 * 3, 0.f)))
.Ho(reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.81457126f, 0.61109227f, 0.769522f, 0.52239674f, 0.4324641f, 0.63183f}))
.Co(reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{1.4444952f, 0.9635685f, 1.2875274f, 0.8053419f, 0.7184521f, 0.95803297f}))
.testcaseName("lstm_cell_zero_bias_default_attrs")};
return params;
}
std::vector<LSTMCellParams> generateCombinedParams() {
const std::vector<std::vector<LSTMCellParams>> generatedParams {
const std::vector<std::vector<LSTMCellParams>> generatedParams{
generateParams<element::Type_t::bf16>(),
generateParams<element::Type_t::f16>(),
generateParams<element::Type_t::f32>(),
@ -348,64 +368,81 @@ std::vector<LSTMCellParams> generateCombinedParams() {
template <element::Type_t ET>
std::vector<LSTMCellParams> generateParamsBiasDefaultAttrs() {
using T = typename element_type_traits<ET>::value_type;
std::vector<LSTMCellParams> params {
Builder {}
.batchSize(2)
.inputSize(3)
.hiddenSize(3)
.gatesCount(4)
.X(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.81342685f, 0.84108883f, 0.8152282f, 0.46893653f, 0.0901856f, 0.37088776f}))
.W(reference_tests::Tensor(ET, {4 * 3, 3}, std::vector<T>{
3.3330739e-01f, 3.6229487e-04f, 4.6773660e-01f, 4.3046016e-01f, 7.3950343e-02f, 3.8063636e-01f,
9.6921772e-01f, 9.6897459e-01f, 6.2964785e-01f, 3.1134409e-01f, 8.4709978e-01f, 9.4928098e-01f,
6.1676943e-01f, 6.6020679e-01f, 1.9072217e-01f, 8.8032126e-02f, 4.0472135e-01f, 6.8342745e-01f,
8.3432144e-01f, 4.4928190e-01f, 7.9524308e-01f, 5.3966165e-01f, 8.5936421e-01f, 8.3136767e-01f,
5.5125546e-02f, 4.7791195e-01f, 3.5788772e-01f, 6.7507404e-01f, 2.1716513e-01f, 2.7473119e-01f,
3.3999152e-02f, 9.6835363e-01f, 3.7581277e-01f, 2.4026000e-01f, 6.7418844e-01f, 3.4199652e-01f}))
.R(reference_tests::Tensor(ET, {4 * 3, 3}, std::vector<T>{
0.0987983f, 0.52032113f, 0.5848073f, 0.5356095f, 0.74497133f, 0.73260087f,
0.1700787f, 0.45684233f, 0.1495722f, 0.42734373f, 0.4433832f, 0.25906256f,
0.03854987f, 0.47480518f, 0.37215272f, 0.99890584f, 0.74019486f, 0.3518967f,
0.6881257f, 0.8170279f, 0.54088944f, 0.81225616f, 0.14619833f, 0.42941234f,
0.86843914f, 0.45967972f, 0.6237719f, 0.11074839f, 0.6029616f, 0.3149305f,
0.46504205f, 0.5843412f, 0.8733427f, 0.7687243f, 0.07074859f, 0.39188156f}))
.H_t(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.77956f, 0.5331557f, 0.04297554f, 0.7962175f, 0.7635707f, 0.11989366f}))
.C_t(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.8488452f, 0.18851636f, 0.5020695f, 0.29716516f, 0.06740791f, 0.45384037f}))
.B(reference_tests::Tensor(ET, {4 * 3}, std::vector<T>{1.07393714f,
1.15248052f,
1.16671345f,
0.21450312f,
1.2380678f,
1.51688835f,
0.46718366f,
0.91810346f,
1.1274234f,
0.51022074f,
1.11389844f,
0.74174305f}))
.P(reference_tests::Tensor(ET, {3 * 3}, std::vector<T>(3 * 3, 0.f)))
.Ho(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{0.81014400720596313,
0.76665538549423218,
0.82509011030197144,
0.6479143500328064,
0.66586339473724365,
0.74838578701019287}))
.Co(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{1.6800162792205811,
1.1150213479995728,
1.4578367471694946,
1.0649888515472412,
0.93761754035949707,
1.3659683465957642}))
.testcaseName("lstm_cell_bias_default_attrs"),
std::vector<LSTMCellParams> params{
Builder{}
.batchSize(2)
.inputSize(3)
.hiddenSize(3)
.gatesCount(4)
.X(reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.81342685f, 0.84108883f, 0.8152282f, 0.46893653f, 0.0901856f, 0.37088776f}))
.W(reference_tests::Tensor(
ET,
{4 * 3, 3},
std::vector<T>{
3.3330739e-01f, 3.6229487e-04f, 4.6773660e-01f, 4.3046016e-01f, 7.3950343e-02f, 3.8063636e-01f,
9.6921772e-01f, 9.6897459e-01f, 6.2964785e-01f, 3.1134409e-01f, 8.4709978e-01f, 9.4928098e-01f,
6.1676943e-01f, 6.6020679e-01f, 1.9072217e-01f, 8.8032126e-02f, 4.0472135e-01f, 6.8342745e-01f,
8.3432144e-01f, 4.4928190e-01f, 7.9524308e-01f, 5.3966165e-01f, 8.5936421e-01f, 8.3136767e-01f,
5.5125546e-02f, 4.7791195e-01f, 3.5788772e-01f, 6.7507404e-01f, 2.1716513e-01f, 2.7473119e-01f,
3.3999152e-02f, 9.6835363e-01f, 3.7581277e-01f, 2.4026000e-01f, 6.7418844e-01f, 3.4199652e-01f}))
.R(reference_tests::Tensor(
ET,
{4 * 3, 3},
std::vector<T>{0.0987983f, 0.52032113f, 0.5848073f, 0.5356095f, 0.74497133f, 0.73260087f,
0.1700787f, 0.45684233f, 0.1495722f, 0.42734373f, 0.4433832f, 0.25906256f,
0.03854987f, 0.47480518f, 0.37215272f, 0.99890584f, 0.74019486f, 0.3518967f,
0.6881257f, 0.8170279f, 0.54088944f, 0.81225616f, 0.14619833f, 0.42941234f,
0.86843914f, 0.45967972f, 0.6237719f, 0.11074839f, 0.6029616f, 0.3149305f,
0.46504205f, 0.5843412f, 0.8733427f, 0.7687243f, 0.07074859f, 0.39188156f}))
.H_t(reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.77956f, 0.5331557f, 0.04297554f, 0.7962175f, 0.7635707f, 0.11989366f}))
.C_t(reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.8488452f, 0.18851636f, 0.5020695f, 0.29716516f, 0.06740791f, 0.45384037f}))
.B(reference_tests::Tensor(ET,
{4 * 3},
std::vector<T>{1.07393714f,
1.15248052f,
1.16671345f,
0.21450312f,
1.2380678f,
1.51688835f,
0.46718366f,
0.91810346f,
1.1274234f,
0.51022074f,
1.11389844f,
0.74174305f}))
.P(reference_tests::Tensor(ET, {3 * 3}, std::vector<T>(3 * 3, 0.f)))
.Ho(reference_tests::Tensor(ET,
{2, 3},
std::vector<T>{0.81014400720596313,
0.76665538549423218,
0.82509011030197144,
0.6479143500328064,
0.66586339473724365,
0.74838578701019287}))
.Co(reference_tests::Tensor(ET,
{2, 3},
std::vector<T>{1.6800162792205811,
1.1150213479995728,
1.4578367471694946,
1.0649888515472412,
0.93761754035949707,
1.3659683465957642}))
.testcaseName("lstm_cell_bias_default_attrs"),
};
return params;
}
std::vector<LSTMCellParams> generateCombinedParamsBiasDefaultAttrs() {
const std::vector<std::vector<LSTMCellParams>> generatedParams {
const std::vector<std::vector<LSTMCellParams>> generatedParams{
generateParamsBiasDefaultAttrs<element::Type_t::bf16>(),
generateParamsBiasDefaultAttrs<element::Type_t::f16>(),
generateParamsBiasDefaultAttrs<element::Type_t::f32>(),
@ -422,64 +459,81 @@ std::vector<LSTMCellParams> generateCombinedParamsBiasDefaultAttrs() {
template <element::Type_t ET>
std::vector<LSTMCellParams> generateParamsBiasClip() {
using T = typename element_type_traits<ET>::value_type;
std::vector<LSTMCellParams> params {
Builder {}
.batchSize(2)
.inputSize(3)
.hiddenSize(3)
.gatesCount(4)
.X(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.81342685f, 0.84108883f, 0.8152282f, 0.46893653f, 0.0901856f, 0.37088776f}))
.W(reference_tests::Tensor(ET, {4 * 3, 3}, std::vector<T>{
3.3330739e-01f, 3.6229487e-04f, 4.6773660e-01f, 4.3046016e-01f, 7.3950343e-02f, 3.8063636e-01f,
9.6921772e-01f, 9.6897459e-01f, 6.2964785e-01f, 3.1134409e-01f, 8.4709978e-01f, 9.4928098e-01f,
6.1676943e-01f, 6.6020679e-01f, 1.9072217e-01f, 8.8032126e-02f, 4.0472135e-01f, 6.8342745e-01f,
8.3432144e-01f, 4.4928190e-01f, 7.9524308e-01f, 5.3966165e-01f, 8.5936421e-01f, 8.3136767e-01f,
5.5125546e-02f, 4.7791195e-01f, 3.5788772e-01f, 6.7507404e-01f, 2.1716513e-01f, 2.7473119e-01f,
3.3999152e-02f, 9.6835363e-01f, 3.7581277e-01f, 2.4026000e-01f, 6.7418844e-01f, 3.4199652e-01f}))
.R(reference_tests::Tensor(ET, {4 * 3, 3}, std::vector<T>{
0.0987983f, 0.52032113f, 0.5848073f, 0.5356095f, 0.74497133f, 0.73260087f,
0.1700787f, 0.45684233f, 0.1495722f, 0.42734373f, 0.4433832f, 0.25906256f,
0.03854987f, 0.47480518f, 0.37215272f, 0.99890584f, 0.74019486f, 0.3518967f,
0.6881257f, 0.8170279f, 0.54088944f, 0.81225616f, 0.14619833f, 0.42941234f,
0.86843914f, 0.45967972f, 0.6237719f, 0.11074839f, 0.6029616f, 0.3149305f,
0.46504205f, 0.5843412f, 0.8733427f, 0.7687243f, 0.07074859f, 0.39188156f}))
.H_t(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.77956f, 0.5331557f, 0.04297554f, 0.7962175f, 0.7635707f, 0.11989366f}))
.C_t(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.8488452f, 0.18851636f, 0.5020695f, 0.29716516f, 0.06740791f, 0.45384037f}))
.B(reference_tests::Tensor(ET, {4 * 3}, std::vector<T>{1.07393714f,
1.15248052f,
1.16671345f,
0.21450312f,
1.2380678f,
1.51688835f,
0.46718366f,
0.91810346f,
1.1274234f,
0.51022074f,
1.11389844f,
0.74174305f}))
.P(reference_tests::Tensor(ET, {3 * 3}, std::vector<T>(3 * 3, 0.f)))
.Ho(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{0.81014400720596313,
0.76665538549423218,
0.82387429475784302,
0.6479143500328064,
0.66586339473724365,
0.74838578701019287}))
.Co(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{1.6800162792205811,
1.1150213479995728,
1.4510968923568726,
1.0649888515472412,
0.93761754035949707,
1.3659683465957642}))
.testcaseName("lstm_cell_bias_clip"),
std::vector<LSTMCellParams> params{
Builder{}
.batchSize(2)
.inputSize(3)
.hiddenSize(3)
.gatesCount(4)
.X(reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.81342685f, 0.84108883f, 0.8152282f, 0.46893653f, 0.0901856f, 0.37088776f}))
.W(reference_tests::Tensor(
ET,
{4 * 3, 3},
std::vector<T>{
3.3330739e-01f, 3.6229487e-04f, 4.6773660e-01f, 4.3046016e-01f, 7.3950343e-02f, 3.8063636e-01f,
9.6921772e-01f, 9.6897459e-01f, 6.2964785e-01f, 3.1134409e-01f, 8.4709978e-01f, 9.4928098e-01f,
6.1676943e-01f, 6.6020679e-01f, 1.9072217e-01f, 8.8032126e-02f, 4.0472135e-01f, 6.8342745e-01f,
8.3432144e-01f, 4.4928190e-01f, 7.9524308e-01f, 5.3966165e-01f, 8.5936421e-01f, 8.3136767e-01f,
5.5125546e-02f, 4.7791195e-01f, 3.5788772e-01f, 6.7507404e-01f, 2.1716513e-01f, 2.7473119e-01f,
3.3999152e-02f, 9.6835363e-01f, 3.7581277e-01f, 2.4026000e-01f, 6.7418844e-01f, 3.4199652e-01f}))
.R(reference_tests::Tensor(
ET,
{4 * 3, 3},
std::vector<T>{0.0987983f, 0.52032113f, 0.5848073f, 0.5356095f, 0.74497133f, 0.73260087f,
0.1700787f, 0.45684233f, 0.1495722f, 0.42734373f, 0.4433832f, 0.25906256f,
0.03854987f, 0.47480518f, 0.37215272f, 0.99890584f, 0.74019486f, 0.3518967f,
0.6881257f, 0.8170279f, 0.54088944f, 0.81225616f, 0.14619833f, 0.42941234f,
0.86843914f, 0.45967972f, 0.6237719f, 0.11074839f, 0.6029616f, 0.3149305f,
0.46504205f, 0.5843412f, 0.8733427f, 0.7687243f, 0.07074859f, 0.39188156f}))
.H_t(reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.77956f, 0.5331557f, 0.04297554f, 0.7962175f, 0.7635707f, 0.11989366f}))
.C_t(reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.8488452f, 0.18851636f, 0.5020695f, 0.29716516f, 0.06740791f, 0.45384037f}))
.B(reference_tests::Tensor(ET,
{4 * 3},
std::vector<T>{1.07393714f,
1.15248052f,
1.16671345f,
0.21450312f,
1.2380678f,
1.51688835f,
0.46718366f,
0.91810346f,
1.1274234f,
0.51022074f,
1.11389844f,
0.74174305f}))
.P(reference_tests::Tensor(ET, {3 * 3}, std::vector<T>(3 * 3, 0.f)))
.Ho(reference_tests::Tensor(ET,
{2, 3},
std::vector<T>{0.81014400720596313,
0.76665538549423218,
0.82387429475784302,
0.6479143500328064,
0.66586339473724365,
0.74838578701019287}))
.Co(reference_tests::Tensor(ET,
{2, 3},
std::vector<T>{1.6800162792205811,
1.1150213479995728,
1.4510968923568726,
1.0649888515472412,
0.93761754035949707,
1.3659683465957642}))
.testcaseName("lstm_cell_bias_clip"),
};
return params;
}
std::vector<LSTMCellParams> generateCombinedParamsBiasClip() {
const std::vector<std::vector<LSTMCellParams>> generatedParams {
const std::vector<std::vector<LSTMCellParams>> generatedParams{
generateParamsBiasClip<element::Type_t::bf16>(),
generateParamsBiasClip<element::Type_t::f16>(),
generateParamsBiasClip<element::Type_t::f32>(),
@ -493,55 +547,77 @@ std::vector<LSTMCellParams> generateCombinedParamsBiasClip() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_LSTMCell_With_Hardcoded_Refs, ReferenceLSTMCellTest,
testing::ValuesIn(generateCombinedParams()), ReferenceLSTMCellTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_LSTMCell_With_Hardcoded_Refs,
ReferenceLSTMCellTest,
testing::ValuesIn(generateCombinedParams()),
ReferenceLSTMCellTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_LSTMCell_With_Hardcoded_Refs, ReferenceLSTMCellTestBiasDefaultAttrs,
testing::ValuesIn(generateCombinedParamsBiasDefaultAttrs()), ReferenceLSTMCellTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_LSTMCell_With_Hardcoded_Refs,
ReferenceLSTMCellTestBiasDefaultAttrs,
testing::ValuesIn(generateCombinedParamsBiasDefaultAttrs()),
ReferenceLSTMCellTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_LSTMCell_With_Hardcoded_Refs, ReferenceLSTMCellTestBiasClip,
testing::ValuesIn(generateCombinedParamsBiasClip()), ReferenceLSTMCellTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_LSTMCell_With_Hardcoded_Refs,
ReferenceLSTMCellTestBiasClip,
testing::ValuesIn(generateCombinedParamsBiasClip()),
ReferenceLSTMCellTest::getTestCaseName);
template <element::Type_t ET>
std::vector<LSTMCellParams> generateParamsV1() {
using T = typename element_type_traits<ET>::value_type;
std::vector<LSTMCellParams> params {
Builder {}
.batchSize(2)
.inputSize(3)
.hiddenSize(3)
.gatesCount(4)
.X(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.81342685f, 0.84108883f, 0.8152282f, 0.46893653f, 0.0901856f, 0.37088776f}))
.W(reference_tests::Tensor(ET, {4 * 3, 3}, std::vector<T>{
3.3330739e-01f, 3.6229487e-04f, 4.6773660e-01f, 4.3046016e-01f, 7.3950343e-02f, 3.8063636e-01f,
9.6921772e-01f, 9.6897459e-01f, 6.2964785e-01f, 3.1134409e-01f, 8.4709978e-01f, 9.4928098e-01f,
6.1676943e-01f, 6.6020679e-01f, 1.9072217e-01f, 8.8032126e-02f, 4.0472135e-01f, 6.8342745e-01f,
8.3432144e-01f, 4.4928190e-01f, 7.9524308e-01f, 5.3966165e-01f, 8.5936421e-01f, 8.3136767e-01f,
5.5125546e-02f, 4.7791195e-01f, 3.5788772e-01f, 6.7507404e-01f, 2.1716513e-01f, 2.7473119e-01f,
3.3999152e-02f, 9.6835363e-01f, 3.7581277e-01f, 2.4026000e-01f, 6.7418844e-01f, 3.4199652e-01f}))
.R(reference_tests::Tensor(ET, {4 * 3, 3}, std::vector<T>{
0.0987983f, 0.52032113f, 0.5848073f, 0.5356095f, 0.74497133f, 0.73260087f,
0.1700787f, 0.45684233f, 0.1495722f, 0.42734373f, 0.4433832f, 0.25906256f,
0.03854987f, 0.47480518f, 0.37215272f, 0.99890584f, 0.74019486f, 0.3518967f,
0.6881257f, 0.8170279f, 0.54088944f, 0.81225616f, 0.14619833f, 0.42941234f,
0.86843914f, 0.45967972f, 0.6237719f, 0.11074839f, 0.6029616f, 0.3149305f,
0.46504205f, 0.5843412f, 0.8733427f, 0.7687243f, 0.07074859f, 0.39188156f}))
.H_t(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.77956f, 0.5331557f, 0.04297554f, 0.7962175f, 0.7635707f, 0.11989366f}))
.C_t(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.8488452f, 0.18851636f, 0.5020695f, 0.29716516f, 0.06740791f, 0.45384037f}))
.B(reference_tests::Tensor(ET, {4 * 3}, std::vector<T>(4 * 3, 0.f)))
.P(reference_tests::Tensor(ET, {3 * 3}, std::vector<T>(3 * 3, 0.f)))
.Ho(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{0.81457126f, 0.61109227f, 0.769522f, 0.52239674f, 0.4324641f, 0.63183f}))
.Co(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{1.4444952f, 0.9635685f, 1.2875274f, 0.8053419f, 0.7184521f, 0.95803297f}))
.testcaseName("lstm_cell_v1_zero_bias_default_attrs")
};
std::vector<LSTMCellParams> params{
Builder{}
.batchSize(2)
.inputSize(3)
.hiddenSize(3)
.gatesCount(4)
.X(reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.81342685f, 0.84108883f, 0.8152282f, 0.46893653f, 0.0901856f, 0.37088776f}))
.W(reference_tests::Tensor(
ET,
{4 * 3, 3},
std::vector<T>{
3.3330739e-01f, 3.6229487e-04f, 4.6773660e-01f, 4.3046016e-01f, 7.3950343e-02f, 3.8063636e-01f,
9.6921772e-01f, 9.6897459e-01f, 6.2964785e-01f, 3.1134409e-01f, 8.4709978e-01f, 9.4928098e-01f,
6.1676943e-01f, 6.6020679e-01f, 1.9072217e-01f, 8.8032126e-02f, 4.0472135e-01f, 6.8342745e-01f,
8.3432144e-01f, 4.4928190e-01f, 7.9524308e-01f, 5.3966165e-01f, 8.5936421e-01f, 8.3136767e-01f,
5.5125546e-02f, 4.7791195e-01f, 3.5788772e-01f, 6.7507404e-01f, 2.1716513e-01f, 2.7473119e-01f,
3.3999152e-02f, 9.6835363e-01f, 3.7581277e-01f, 2.4026000e-01f, 6.7418844e-01f, 3.4199652e-01f}))
.R(reference_tests::Tensor(
ET,
{4 * 3, 3},
std::vector<T>{0.0987983f, 0.52032113f, 0.5848073f, 0.5356095f, 0.74497133f, 0.73260087f,
0.1700787f, 0.45684233f, 0.1495722f, 0.42734373f, 0.4433832f, 0.25906256f,
0.03854987f, 0.47480518f, 0.37215272f, 0.99890584f, 0.74019486f, 0.3518967f,
0.6881257f, 0.8170279f, 0.54088944f, 0.81225616f, 0.14619833f, 0.42941234f,
0.86843914f, 0.45967972f, 0.6237719f, 0.11074839f, 0.6029616f, 0.3149305f,
0.46504205f, 0.5843412f, 0.8733427f, 0.7687243f, 0.07074859f, 0.39188156f}))
.H_t(reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.77956f, 0.5331557f, 0.04297554f, 0.7962175f, 0.7635707f, 0.11989366f}))
.C_t(reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.8488452f, 0.18851636f, 0.5020695f, 0.29716516f, 0.06740791f, 0.45384037f}))
.B(reference_tests::Tensor(ET, {4 * 3}, std::vector<T>(4 * 3, 0.f)))
.P(reference_tests::Tensor(ET, {3 * 3}, std::vector<T>(3 * 3, 0.f)))
.Ho(reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.81457126f, 0.61109227f, 0.769522f, 0.52239674f, 0.4324641f, 0.63183f}))
.Co(reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{1.4444952f, 0.9635685f, 1.2875274f, 0.8053419f, 0.7184521f, 0.95803297f}))
.testcaseName("lstm_cell_v1_zero_bias_default_attrs")};
return params;
}
std::vector<LSTMCellParams> generateCombinedParamsV1() {
const std::vector<std::vector<LSTMCellParams>> generatedParams {
const std::vector<std::vector<LSTMCellParams>> generatedParams{
generateParamsV1<element::Type_t::bf16>(),
generateParamsV1<element::Type_t::f16>(),
generateParamsV1<element::Type_t::f32>(),
@ -558,64 +634,81 @@ std::vector<LSTMCellParams> generateCombinedParamsV1() {
template <element::Type_t ET>
std::vector<LSTMCellParams> generateParamsBiasDefaultAttrsV1() {
using T = typename element_type_traits<ET>::value_type;
std::vector<LSTMCellParams> params {
Builder {}
.batchSize(2)
.inputSize(3)
.hiddenSize(3)
.gatesCount(4)
.X(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.81342685f, 0.84108883f, 0.8152282f, 0.46893653f, 0.0901856f, 0.37088776f}))
.W(reference_tests::Tensor(ET, {4 * 3, 3}, std::vector<T>{
3.3330739e-01f, 3.6229487e-04f, 4.6773660e-01f, 4.3046016e-01f, 7.3950343e-02f, 3.8063636e-01f,
9.6921772e-01f, 9.6897459e-01f, 6.2964785e-01f, 3.1134409e-01f, 8.4709978e-01f, 9.4928098e-01f,
6.1676943e-01f, 6.6020679e-01f, 1.9072217e-01f, 8.8032126e-02f, 4.0472135e-01f, 6.8342745e-01f,
8.3432144e-01f, 4.4928190e-01f, 7.9524308e-01f, 5.3966165e-01f, 8.5936421e-01f, 8.3136767e-01f,
5.5125546e-02f, 4.7791195e-01f, 3.5788772e-01f, 6.7507404e-01f, 2.1716513e-01f, 2.7473119e-01f,
3.3999152e-02f, 9.6835363e-01f, 3.7581277e-01f, 2.4026000e-01f, 6.7418844e-01f, 3.4199652e-01f}))
.R(reference_tests::Tensor(ET, {4 * 3, 3}, std::vector<T>{
0.0987983f, 0.52032113f, 0.5848073f, 0.5356095f, 0.74497133f, 0.73260087f,
0.1700787f, 0.45684233f, 0.1495722f, 0.42734373f, 0.4433832f, 0.25906256f,
0.03854987f, 0.47480518f, 0.37215272f, 0.99890584f, 0.74019486f, 0.3518967f,
0.6881257f, 0.8170279f, 0.54088944f, 0.81225616f, 0.14619833f, 0.42941234f,
0.86843914f, 0.45967972f, 0.6237719f, 0.11074839f, 0.6029616f, 0.3149305f,
0.46504205f, 0.5843412f, 0.8733427f, 0.7687243f, 0.07074859f, 0.39188156f}))
.H_t(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.77956f, 0.5331557f, 0.04297554f, 0.7962175f, 0.7635707f, 0.11989366f}))
.C_t(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.8488452f, 0.18851636f, 0.5020695f, 0.29716516f, 0.06740791f, 0.45384037f}))
.B(reference_tests::Tensor(ET, {4 * 3}, std::vector<T>{1.07393714f,
1.15248052f,
1.16671345f,
0.21450312f,
1.2380678f,
1.51688835f,
0.46718366f,
0.91810346f,
1.1274234f,
0.51022074f,
1.11389844f,
0.74174305f}))
.P(reference_tests::Tensor(ET, {3 * 3}, std::vector<T>(3 * 3, 0.f)))
.Ho(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{0.81014400720596313,
0.76665538549423218,
0.82509011030197144,
0.6479143500328064,
0.66586339473724365,
0.74838578701019287}))
.Co(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{1.6800162792205811,
1.1150213479995728,
1.4578367471694946,
1.0649888515472412,
0.93761754035949707,
1.3659683465957642}))
.testcaseName("lstm_cell_v1_bias_default_attrs"),
std::vector<LSTMCellParams> params{
Builder{}
.batchSize(2)
.inputSize(3)
.hiddenSize(3)
.gatesCount(4)
.X(reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.81342685f, 0.84108883f, 0.8152282f, 0.46893653f, 0.0901856f, 0.37088776f}))
.W(reference_tests::Tensor(
ET,
{4 * 3, 3},
std::vector<T>{
3.3330739e-01f, 3.6229487e-04f, 4.6773660e-01f, 4.3046016e-01f, 7.3950343e-02f, 3.8063636e-01f,
9.6921772e-01f, 9.6897459e-01f, 6.2964785e-01f, 3.1134409e-01f, 8.4709978e-01f, 9.4928098e-01f,
6.1676943e-01f, 6.6020679e-01f, 1.9072217e-01f, 8.8032126e-02f, 4.0472135e-01f, 6.8342745e-01f,
8.3432144e-01f, 4.4928190e-01f, 7.9524308e-01f, 5.3966165e-01f, 8.5936421e-01f, 8.3136767e-01f,
5.5125546e-02f, 4.7791195e-01f, 3.5788772e-01f, 6.7507404e-01f, 2.1716513e-01f, 2.7473119e-01f,
3.3999152e-02f, 9.6835363e-01f, 3.7581277e-01f, 2.4026000e-01f, 6.7418844e-01f, 3.4199652e-01f}))
.R(reference_tests::Tensor(
ET,
{4 * 3, 3},
std::vector<T>{0.0987983f, 0.52032113f, 0.5848073f, 0.5356095f, 0.74497133f, 0.73260087f,
0.1700787f, 0.45684233f, 0.1495722f, 0.42734373f, 0.4433832f, 0.25906256f,
0.03854987f, 0.47480518f, 0.37215272f, 0.99890584f, 0.74019486f, 0.3518967f,
0.6881257f, 0.8170279f, 0.54088944f, 0.81225616f, 0.14619833f, 0.42941234f,
0.86843914f, 0.45967972f, 0.6237719f, 0.11074839f, 0.6029616f, 0.3149305f,
0.46504205f, 0.5843412f, 0.8733427f, 0.7687243f, 0.07074859f, 0.39188156f}))
.H_t(reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.77956f, 0.5331557f, 0.04297554f, 0.7962175f, 0.7635707f, 0.11989366f}))
.C_t(reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.8488452f, 0.18851636f, 0.5020695f, 0.29716516f, 0.06740791f, 0.45384037f}))
.B(reference_tests::Tensor(ET,
{4 * 3},
std::vector<T>{1.07393714f,
1.15248052f,
1.16671345f,
0.21450312f,
1.2380678f,
1.51688835f,
0.46718366f,
0.91810346f,
1.1274234f,
0.51022074f,
1.11389844f,
0.74174305f}))
.P(reference_tests::Tensor(ET, {3 * 3}, std::vector<T>(3 * 3, 0.f)))
.Ho(reference_tests::Tensor(ET,
{2, 3},
std::vector<T>{0.81014400720596313,
0.76665538549423218,
0.82509011030197144,
0.6479143500328064,
0.66586339473724365,
0.74838578701019287}))
.Co(reference_tests::Tensor(ET,
{2, 3},
std::vector<T>{1.6800162792205811,
1.1150213479995728,
1.4578367471694946,
1.0649888515472412,
0.93761754035949707,
1.3659683465957642}))
.testcaseName("lstm_cell_v1_bias_default_attrs"),
};
return params;
}
std::vector<LSTMCellParams> generateCombinedParamsBiasDefaultAttrsV1() {
const std::vector<std::vector<LSTMCellParams>> generatedParams {
const std::vector<std::vector<LSTMCellParams>> generatedParams{
generateParamsBiasDefaultAttrsV1<element::Type_t::bf16>(),
generateParamsBiasDefaultAttrsV1<element::Type_t::f16>(),
generateParamsBiasDefaultAttrsV1<element::Type_t::f32>(),
@ -632,64 +725,81 @@ std::vector<LSTMCellParams> generateCombinedParamsBiasDefaultAttrsV1() {
template <element::Type_t ET>
std::vector<LSTMCellParams> generateParamsBiasClipV1() {
using T = typename element_type_traits<ET>::value_type;
std::vector<LSTMCellParams> params {
Builder {}
.batchSize(2)
.inputSize(3)
.hiddenSize(3)
.gatesCount(4)
.X(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.81342685f, 0.84108883f, 0.8152282f, 0.46893653f, 0.0901856f, 0.37088776f}))
.W(reference_tests::Tensor(ET, {4 * 3, 3}, std::vector<T>{
3.3330739e-01f, 3.6229487e-04f, 4.6773660e-01f, 4.3046016e-01f, 7.3950343e-02f, 3.8063636e-01f,
9.6921772e-01f, 9.6897459e-01f, 6.2964785e-01f, 3.1134409e-01f, 8.4709978e-01f, 9.4928098e-01f,
6.1676943e-01f, 6.6020679e-01f, 1.9072217e-01f, 8.8032126e-02f, 4.0472135e-01f, 6.8342745e-01f,
8.3432144e-01f, 4.4928190e-01f, 7.9524308e-01f, 5.3966165e-01f, 8.5936421e-01f, 8.3136767e-01f,
5.5125546e-02f, 4.7791195e-01f, 3.5788772e-01f, 6.7507404e-01f, 2.1716513e-01f, 2.7473119e-01f,
3.3999152e-02f, 9.6835363e-01f, 3.7581277e-01f, 2.4026000e-01f, 6.7418844e-01f, 3.4199652e-01f}))
.R(reference_tests::Tensor(ET, {4 * 3, 3}, std::vector<T>{
0.0987983f, 0.52032113f, 0.5848073f, 0.5356095f, 0.74497133f, 0.73260087f,
0.1700787f, 0.45684233f, 0.1495722f, 0.42734373f, 0.4433832f, 0.25906256f,
0.03854987f, 0.47480518f, 0.37215272f, 0.99890584f, 0.74019486f, 0.3518967f,
0.6881257f, 0.8170279f, 0.54088944f, 0.81225616f, 0.14619833f, 0.42941234f,
0.86843914f, 0.45967972f, 0.6237719f, 0.11074839f, 0.6029616f, 0.3149305f,
0.46504205f, 0.5843412f, 0.8733427f, 0.7687243f, 0.07074859f, 0.39188156f}))
.H_t(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.77956f, 0.5331557f, 0.04297554f, 0.7962175f, 0.7635707f, 0.11989366f}))
.C_t(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{
0.8488452f, 0.18851636f, 0.5020695f, 0.29716516f, 0.06740791f, 0.45384037f}))
.B(reference_tests::Tensor(ET, {4 * 3}, std::vector<T>{1.07393714f,
1.15248052f,
1.16671345f,
0.21450312f,
1.2380678f,
1.51688835f,
0.46718366f,
0.91810346f,
1.1274234f,
0.51022074f,
1.11389844f,
0.74174305f}))
.P(reference_tests::Tensor(ET, {3 * 3}, std::vector<T>(3 * 3, 0.f)))
.Ho(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{0.81014400720596313,
0.76665538549423218,
0.82387429475784302,
0.6479143500328064,
0.66586339473724365,
0.74838578701019287}))
.Co(reference_tests::Tensor(ET, {2, 3}, std::vector<T>{1.6800162792205811,
1.1150213479995728,
1.4510968923568726,
1.0649888515472412,
0.93761754035949707,
1.3659683465957642}))
.testcaseName("lstm_cell_v1_bias_clip"),
std::vector<LSTMCellParams> params{
Builder{}
.batchSize(2)
.inputSize(3)
.hiddenSize(3)
.gatesCount(4)
.X(reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.81342685f, 0.84108883f, 0.8152282f, 0.46893653f, 0.0901856f, 0.37088776f}))
.W(reference_tests::Tensor(
ET,
{4 * 3, 3},
std::vector<T>{
3.3330739e-01f, 3.6229487e-04f, 4.6773660e-01f, 4.3046016e-01f, 7.3950343e-02f, 3.8063636e-01f,
9.6921772e-01f, 9.6897459e-01f, 6.2964785e-01f, 3.1134409e-01f, 8.4709978e-01f, 9.4928098e-01f,
6.1676943e-01f, 6.6020679e-01f, 1.9072217e-01f, 8.8032126e-02f, 4.0472135e-01f, 6.8342745e-01f,
8.3432144e-01f, 4.4928190e-01f, 7.9524308e-01f, 5.3966165e-01f, 8.5936421e-01f, 8.3136767e-01f,
5.5125546e-02f, 4.7791195e-01f, 3.5788772e-01f, 6.7507404e-01f, 2.1716513e-01f, 2.7473119e-01f,
3.3999152e-02f, 9.6835363e-01f, 3.7581277e-01f, 2.4026000e-01f, 6.7418844e-01f, 3.4199652e-01f}))
.R(reference_tests::Tensor(
ET,
{4 * 3, 3},
std::vector<T>{0.0987983f, 0.52032113f, 0.5848073f, 0.5356095f, 0.74497133f, 0.73260087f,
0.1700787f, 0.45684233f, 0.1495722f, 0.42734373f, 0.4433832f, 0.25906256f,
0.03854987f, 0.47480518f, 0.37215272f, 0.99890584f, 0.74019486f, 0.3518967f,
0.6881257f, 0.8170279f, 0.54088944f, 0.81225616f, 0.14619833f, 0.42941234f,
0.86843914f, 0.45967972f, 0.6237719f, 0.11074839f, 0.6029616f, 0.3149305f,
0.46504205f, 0.5843412f, 0.8733427f, 0.7687243f, 0.07074859f, 0.39188156f}))
.H_t(reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.77956f, 0.5331557f, 0.04297554f, 0.7962175f, 0.7635707f, 0.11989366f}))
.C_t(reference_tests::Tensor(
ET,
{2, 3},
std::vector<T>{0.8488452f, 0.18851636f, 0.5020695f, 0.29716516f, 0.06740791f, 0.45384037f}))
.B(reference_tests::Tensor(ET,
{4 * 3},
std::vector<T>{1.07393714f,
1.15248052f,
1.16671345f,
0.21450312f,
1.2380678f,
1.51688835f,
0.46718366f,
0.91810346f,
1.1274234f,
0.51022074f,
1.11389844f,
0.74174305f}))
.P(reference_tests::Tensor(ET, {3 * 3}, std::vector<T>(3 * 3, 0.f)))
.Ho(reference_tests::Tensor(ET,
{2, 3},
std::vector<T>{0.81014400720596313,
0.76665538549423218,
0.82387429475784302,
0.6479143500328064,
0.66586339473724365,
0.74838578701019287}))
.Co(reference_tests::Tensor(ET,
{2, 3},
std::vector<T>{1.6800162792205811,
1.1150213479995728,
1.4510968923568726,
1.0649888515472412,
0.93761754035949707,
1.3659683465957642}))
.testcaseName("lstm_cell_v1_bias_clip"),
};
return params;
}
std::vector<LSTMCellParams> generateCombinedParamsBiasClipV1() {
const std::vector<std::vector<LSTMCellParams>> generatedParams {
const std::vector<std::vector<LSTMCellParams>> generatedParams{
generateParamsBiasClipV1<element::Type_t::bf16>(),
generateParamsBiasClipV1<element::Type_t::f16>(),
generateParamsBiasClipV1<element::Type_t::f32>(),
@ -703,12 +813,18 @@ std::vector<LSTMCellParams> generateCombinedParamsBiasClipV1() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_LSTMCellV1_With_Hardcoded_Refs, ReferenceLSTMCellV1Test,
testing::ValuesIn(generateCombinedParamsV1()), ReferenceLSTMCellV1Test::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_LSTMCellV1_With_Hardcoded_Refs,
ReferenceLSTMCellV1Test,
testing::ValuesIn(generateCombinedParamsV1()),
ReferenceLSTMCellV1Test::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_LSTMCellV1_With_Hardcoded_Refs, ReferenceLSTMCellV1TestBiasDefaultAttrs,
testing::ValuesIn(generateCombinedParamsBiasDefaultAttrsV1()), ReferenceLSTMCellV1Test::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_LSTMCellV1_With_Hardcoded_Refs,
ReferenceLSTMCellV1TestBiasDefaultAttrs,
testing::ValuesIn(generateCombinedParamsBiasDefaultAttrsV1()),
ReferenceLSTMCellV1Test::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_LSTMCellV1_With_Hardcoded_Refs, ReferenceLSTMCellV1TestBiasClip,
testing::ValuesIn(generateCombinedParamsBiasClipV1()), ReferenceLSTMCellV1Test::getTestCaseName);
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_LSTMCellV1_With_Hardcoded_Refs,
ReferenceLSTMCellV1TestBiasClip,
testing::ValuesIn(generateCombinedParamsBiasClipV1()),
ReferenceLSTMCellV1Test::getTestCaseName);
} // namespace

Some files were not shown because too many files have changed in this diff Show More