Migrate pooling to template plugin test (#8136)
* Migrate pooling to template plugin test * Fix clang format * Fix clang style error * Fix clang style error * Remove unused variable * Fix cpplint error * Fix CI build error * Remove max_pool.in.cpp
This commit is contained in:
1 parent
db9fbcbec2
commit
d198d57fe1
9 files changed
+736
-692
No files matched your search
@@ -0,0 +1,181 @@
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "base_reference_test.hpp"
|
||||
#include "openvino/op/adaptive_avg_pool.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
|
||||
using namespace ov;
|
||||
using namespace reference_tests;
|
||||
|
||||
namespace {
|
||||
|
||||
struct AdaptiveAvgPoolParams {
|
||||
template <class IT>
|
||||
AdaptiveAvgPoolParams(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 Shape& adaptive_shape,
|
||||
const std::vector<int64_t>& adaptive_values)
|
||||
: m_input_shape(input_shape),
|
||||
m_output_shape(output_shape),
|
||||
m_input_type(input_type),
|
||||
m_output_type(ouput_type),
|
||||
m_input_data(CreateTensor(input_type, input_values)),
|
||||
m_expected_data(CreateTensor(ouput_type, output_values)),
|
||||
m_adaptive_shape(adaptive_shape),
|
||||
m_adaptive_values(adaptive_values) {}
|
||||
Shape m_input_shape;
|
||||
Shape m_output_shape;
|
||||
element::Type m_input_type;
|
||||
element::Type m_output_type;
|
||||
runtime::Tensor m_input_data;
|
||||
runtime::Tensor m_expected_data;
|
||||
Shape m_adaptive_shape;
|
||||
std::vector<int64_t> m_adaptive_values;
|
||||
};
|
||||
|
||||
class ReferenceAdaptiveAvgPoolLayerTest : public testing::TestWithParam<AdaptiveAvgPoolParams>, public CommonReferenceTest {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto params = GetParam();
|
||||
function = CreateFunction(params.m_input_shape,
|
||||
params.m_input_type,
|
||||
params.m_adaptive_shape,
|
||||
params.m_adaptive_values);
|
||||
inputData = {params.m_input_data};
|
||||
refOutData = {params.m_expected_data};
|
||||
}
|
||||
|
||||
static std::string getTestCaseName(const testing::TestParamInfo<AdaptiveAvgPoolParams>& obj) {
|
||||
auto params = obj.param;
|
||||
std::ostringstream result;
|
||||
result << "shape=" << params.m_input_shape << "_";
|
||||
result << "iType=" << params.m_input_type << "_";
|
||||
result << "shape=" << params.m_output_shape << "_";
|
||||
result << "oType=" << params.m_output_type;
|
||||
return result.str();
|
||||
}
|
||||
|
||||
private:
|
||||
static std::shared_ptr<Function> CreateFunction(const Shape& input_shape,
|
||||
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);
|
||||
return std::make_shared<Function>(NodeVector{adaptive_avg_pool}, ParameterVector{in});
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(ReferenceAdaptiveAvgPoolLayerTest, AdaptiveAvgPoolWithHardcodedRefs) {
|
||||
Exec();
|
||||
}
|
||||
|
||||
template <element::Type_t IN_ET>
|
||||
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,
|
||||
|
||||
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,
|
||||
|
||||
-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},
|
||||
std::vector<T>{-1.08333337, -0.25000000, -0.91666669, -0.08333334, -0.66666669,
|
||||
0.75000000, -0.41666666, -1.33333337, -0.58333331,
|
||||
|
||||
-1.66666663, 0.58333331, -0.16666667, -0.33333334, -0.41666666,
|
||||
-0.16666667, -0.33333334, -0.66666669, -0.75000000,
|
||||
|
||||
-0.91666669, 0.83333331, -0.16666667, 0., -0.25000000,
|
||||
-1.16666663, -1.41666663, -0.41666666, -0.08333334},
|
||||
ov::Shape{2},
|
||||
{3, 3}),
|
||||
AdaptiveAvgPoolParams(
|
||||
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,
|
||||
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}),
|
||||
};
|
||||
return params;
|
||||
}
|
||||
|
||||
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>()
|
||||
};
|
||||
|
||||
std::vector<AdaptiveAvgPoolParams> combinedParams;
|
||||
|
||||
for (const auto& params : allTypeParams) {
|
||||
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
|
||||
}
|
||||
|
||||
return combinedParams;
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
smoke_AdaptiveAvgPool_With_Hardcoded_Refs,
|
||||
ReferenceAdaptiveAvgPoolLayerTest,
|
||||
::testing::ValuesIn(generateCombinedParamsForAdaptiveAvgPool()),
|
||||
ReferenceAdaptiveAvgPoolLayerTest::getTestCaseName);
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,217 @@
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "base_reference_test.hpp"
|
||||
#include "openvino/op/adaptive_max_pool.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
|
||||
using namespace ov;
|
||||
using namespace reference_tests;
|
||||
|
||||
namespace {
|
||||
|
||||
struct AdaptiveMaxPoolParams {
|
||||
template <class IT>
|
||||
AdaptiveMaxPoolParams(const Shape& input_shape,
|
||||
const Shape& output_shape,
|
||||
const element::Type& input_type,
|
||||
const element::Type& output_type,
|
||||
const std::vector<IT>& input_values,
|
||||
const std::vector<IT>& output_values,
|
||||
const std::vector<int64_t>& output_indices,
|
||||
const Shape& adaptive_shape,
|
||||
const std::vector<int64_t>& adaptive_values)
|
||||
: m_input_shape(input_shape),
|
||||
m_output_shape(output_shape),
|
||||
m_input_type(input_type),
|
||||
m_output_type(output_type),
|
||||
m_input_data(CreateTensor(input_type, input_values)),
|
||||
m_expected_data(CreateTensor(output_type, output_values)),
|
||||
m_expected_indices(CreateTensor(element::Type_t::i64, output_indices)),
|
||||
m_adaptive_shape(adaptive_shape),
|
||||
m_adaptive_values(adaptive_values) {}
|
||||
Shape m_input_shape;
|
||||
Shape m_output_shape;
|
||||
element::Type m_input_type;
|
||||
element::Type m_output_type;
|
||||
runtime::Tensor m_input_data;
|
||||
runtime::Tensor m_expected_data;
|
||||
runtime::Tensor m_expected_indices;
|
||||
Shape m_adaptive_shape;
|
||||
std::vector<int64_t> m_adaptive_values;
|
||||
};
|
||||
|
||||
class ReferenceAdaptiveMaxPoolLayerTest : public testing::TestWithParam<AdaptiveMaxPoolParams>, public CommonReferenceTest {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto params = GetParam();
|
||||
function = CreateFunction(params.m_input_shape,
|
||||
params.m_input_type,
|
||||
params.m_adaptive_shape,
|
||||
params.m_adaptive_values);
|
||||
inputData = {params.m_input_data};
|
||||
refOutData = {params.m_expected_data, params.m_expected_indices};
|
||||
}
|
||||
|
||||
static std::string getTestCaseName(const testing::TestParamInfo<AdaptiveMaxPoolParams>& obj) {
|
||||
auto params = obj.param;
|
||||
std::ostringstream result;
|
||||
result << "shape=" << params.m_input_shape << "_";
|
||||
result << "iType=" << params.m_input_type << "_";
|
||||
result << "shape=" << params.m_output_shape << "_";
|
||||
result << "oType=" << params.m_output_type;
|
||||
return result.str();
|
||||
}
|
||||
|
||||
private:
|
||||
static std::shared_ptr<Function> CreateFunction(const Shape& input_shape,
|
||||
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);
|
||||
return std::make_shared<Function>(adaptive_max_pool->outputs(), ParameterVector{in});
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(ReferenceAdaptiveMaxPoolLayerTest, AdaptiveMaxPoolWithHardcodedRefs) {
|
||||
Exec();
|
||||
}
|
||||
|
||||
template <element::Type_t IN_ET>
|
||||
std::vector<AdaptiveMaxPoolParams> generateParamsForAdaptiveMaxPoolWithExpectedResult() {
|
||||
using T = typename element_type_traits<IN_ET>::value_type;
|
||||
|
||||
std::vector<AdaptiveMaxPoolParams> params{
|
||||
AdaptiveMaxPoolParams(
|
||||
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>{4,
|
||||
3,
|
||||
-2,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
3,
|
||||
3,
|
||||
|
||||
3,
|
||||
4,
|
||||
1,
|
||||
2,
|
||||
-2,
|
||||
-2,
|
||||
3,
|
||||
2,
|
||||
2},
|
||||
std::vector<int64_t>{1,
|
||||
3,
|
||||
4,
|
||||
1,
|
||||
3,
|
||||
6,
|
||||
1,
|
||||
4,
|
||||
4,
|
||||
|
||||
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,
|
||||
|
||||
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},
|
||||
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,
|
||||
|
||||
-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>{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;
|
||||
}
|
||||
|
||||
std::vector<AdaptiveMaxPoolParams> generateCombinedParamsForAdaptiveMaxPool() {
|
||||
const std::vector<std::vector<AdaptiveMaxPoolParams>> allTypeParams{
|
||||
generateParamsForAdaptiveMaxPoolWithExpectedResult<element::Type_t::f32>(),
|
||||
generateParamsForAdaptiveMaxPoolWithExpectedResult<element::Type_t::f16>(),
|
||||
generateParamsForAdaptiveMaxPoolWithExpectedResult<element::Type_t::bf16>(),
|
||||
generateParamsForAdaptiveMaxPoolWithExpectedResult<element::Type_t::i64>(),
|
||||
generateParamsForAdaptiveMaxPoolWithExpectedResult<element::Type_t::i32>(),
|
||||
generateParamsForAdaptiveMaxPoolWithExpectedResult<element::Type_t::i16>(),
|
||||
generateParamsForAdaptiveMaxPoolWithExpectedResult<element::Type_t::i8>(),
|
||||
};
|
||||
|
||||
std::vector<AdaptiveMaxPoolParams> combinedParams;
|
||||
|
||||
for (const auto& params : allTypeParams) {
|
||||
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
|
||||
}
|
||||
|
||||
return combinedParams;
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
smoke_AdaptiveMaxPool_With_Hardcoded_Refs,
|
||||
ReferenceAdaptiveMaxPoolLayerTest,
|
||||
::testing::ValuesIn(generateCombinedParamsForAdaptiveMaxPool()),
|
||||
ReferenceAdaptiveMaxPoolLayerTest::getTestCaseName);
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,271 @@
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "base_reference_test.hpp"
|
||||
#include "openvino/op/avg_pool.hpp"
|
||||
|
||||
using namespace ov;
|
||||
using namespace reference_tests;
|
||||
|
||||
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)
|
||||
: m_input_shape(input_shape),
|
||||
m_output_shape(output_shape),
|
||||
m_input_type(input_type),
|
||||
m_output_type(ouput_type),
|
||||
m_input_data(CreateTensor(input_type, input_values)),
|
||||
m_expected_data(CreateTensor(ouput_type, output_values)),
|
||||
m_strides(strides),
|
||||
m_pads_begin(pads_begin),
|
||||
m_pads_end(pads_end),
|
||||
m_kernel(kernel),
|
||||
m_exclude_pad(exclude_pad),
|
||||
m_rounding_type(rounding_type),
|
||||
m_pad_type(pad_type) {}
|
||||
|
||||
Shape m_input_shape;
|
||||
Shape m_output_shape;
|
||||
element::Type m_input_type;
|
||||
element::Type m_output_type;
|
||||
runtime::Tensor m_input_data;
|
||||
runtime::Tensor m_expected_data;
|
||||
Strides m_strides;
|
||||
Shape m_pads_begin;
|
||||
Shape m_pads_end;
|
||||
Shape m_kernel;
|
||||
bool m_exclude_pad;
|
||||
op::RoundingType m_rounding_type;
|
||||
op::PadType m_pad_type;
|
||||
};
|
||||
|
||||
class ReferenceAvgPoolLayerTest : public testing::TestWithParam<AvgPoolParams>, public CommonReferenceTest {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto params = GetParam();
|
||||
function = CreateFunction(params.m_input_shape,
|
||||
params.m_input_type,
|
||||
params.m_strides,
|
||||
params.m_pads_begin,
|
||||
params.m_pads_end,
|
||||
params.m_kernel,
|
||||
params.m_exclude_pad,
|
||||
params.m_rounding_type,
|
||||
params.m_pad_type);
|
||||
inputData = {params.m_input_data};
|
||||
refOutData = {params.m_expected_data};
|
||||
}
|
||||
|
||||
static std::string getTestCaseName(const testing::TestParamInfo<AvgPoolParams>& obj) {
|
||||
auto params = obj.param;
|
||||
std::ostringstream result;
|
||||
result << "iShape=" << params.m_input_shape << "_";
|
||||
result << "iType=" << params.m_input_type << "_";
|
||||
result << "iShape=" << params.m_output_shape << "_";
|
||||
result << "oType=" << params.m_output_type << "_";
|
||||
result << "excludePad=" << params.m_exclude_pad << "_";
|
||||
result << "roundingType=" << params.m_rounding_type << "_";
|
||||
result << "padType=" << params.m_pad_type;
|
||||
return result.str();
|
||||
}
|
||||
|
||||
private:
|
||||
static std::shared_ptr<Function> 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 auto in = std::make_shared<op::v0::Parameter>(input_type, input_shape);
|
||||
const auto avgPool = std::make_shared<op::v1::AvgPool>(in,
|
||||
strides,
|
||||
pads_begin,
|
||||
pads_end,
|
||||
kernel,
|
||||
exclude_pad,
|
||||
rounding_type,
|
||||
pad_type);
|
||||
return std::make_shared<Function>(NodeVector{avgPool}, ParameterVector{in});
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(ReferenceAvgPoolLayerTest, AvgPoolWithHardcodedRefs) {
|
||||
Exec();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
template <element::Type_t IN_ET>
|
||||
std::vector<AvgPoolParams> generateParamsForAvgPool() {
|
||||
using T = typename element_type_traits<IN_ET>::value_type;
|
||||
|
||||
std::vector<AvgPoolParams> params{
|
||||
AvgPoolParams(ov::Shape{1, 1, 3, 3},
|
||||
ov::Shape{1, 1, 2, 2},
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9},
|
||||
std::vector<T>{3, 4, 6, 7},
|
||||
Strides{1, 1},
|
||||
Shape{0, 0},
|
||||
Shape{0, 0},
|
||||
Shape{2, 2},
|
||||
true,
|
||||
op::RoundingType::FLOOR,
|
||||
op::PadType::NOTSET),
|
||||
AvgPoolParams(ov::Shape{1, 1, 4, 4},
|
||||
ov::Shape{1, 1, 2, 2},
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16},
|
||||
std::vector<T>{6, 7, 10, 11},
|
||||
Strides{1, 1},
|
||||
Shape{0, 0},
|
||||
Shape{0, 0},
|
||||
Shape{3, 3},
|
||||
true,
|
||||
op::RoundingType::CEIL,
|
||||
op::PadType::NOTSET),
|
||||
AvgPoolParams(ov::Shape{1, 1, 2, 2},
|
||||
ov::Shape{1, 1, 3, 3},
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
std::vector<T>{1, 2, 3, 4},
|
||||
std::vector<T>{1, 1.5, 2, 2, 2.5, 3, 3, 3.5, 4},
|
||||
Strides{1, 1},
|
||||
Shape{1, 1},
|
||||
Shape{1, 1},
|
||||
Shape{2, 2},
|
||||
true,
|
||||
op::RoundingType::CEIL,
|
||||
op::PadType::NOTSET),
|
||||
AvgPoolParams(ov::Shape{1, 1, 1, 5},
|
||||
ov::Shape{1, 1, 1, 3},
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
std::vector<T>{1, 2, 3, 4, 5},
|
||||
std::vector<T>{1.5, 3, 4.5},
|
||||
Strides{1, 2},
|
||||
Shape{1, 1},
|
||||
Shape{1, 1},
|
||||
Shape{3, 3},
|
||||
true,
|
||||
op::RoundingType::CEIL,
|
||||
op::PadType::EXPLICIT),
|
||||
AvgPoolParams(ov::Shape{1, 1, 1, 5},
|
||||
ov::Shape{1, 1, 1, 3},
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
std::vector<T>{2.5, 2, 12, 4, 5},
|
||||
std::vector<T>{0.5, 2, 1},
|
||||
Strides{1, 2},
|
||||
Shape{1, 1},
|
||||
Shape{1, 1},
|
||||
Shape{3, 3},
|
||||
false,
|
||||
op::RoundingType::CEIL,
|
||||
op::PadType::EXPLICIT),
|
||||
AvgPoolParams(ov::Shape{1, 1, 3, 3},
|
||||
ov::Shape{1, 1, 3, 3},
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9},
|
||||
std::vector<T>{3, 4, 2.25, 6, 7, 3.75, 3.75, 4.25, 2.25},
|
||||
Strides{1, 1},
|
||||
Shape{0, 0},
|
||||
Shape{0, 0},
|
||||
Shape{2, 2},
|
||||
false,
|
||||
op::RoundingType::CEIL,
|
||||
op::PadType::SAME_UPPER),
|
||||
AvgPoolParams(ov::Shape{1, 1, 3, 3},
|
||||
ov::Shape{1, 1, 3, 3},
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9},
|
||||
std::vector<T>{0.25, 0.75, 1.25, 1.25, 3, 4, 2.75, 6, 7},
|
||||
Strides{1, 1},
|
||||
Shape{0, 0},
|
||||
Shape{0, 0},
|
||||
Shape{2, 2},
|
||||
false,
|
||||
op::RoundingType::CEIL,
|
||||
op::PadType::SAME_LOWER),
|
||||
AvgPoolParams(ov::Shape{1, 1, 2, 2, 2},
|
||||
ov::Shape{1, 1, 2, 2, 1},
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8},
|
||||
std::vector<T>{1.5, 3.5, 5.5, 7.5},
|
||||
Strides{1, 1, 1},
|
||||
Shape{0, 0, 0},
|
||||
Shape{0, 0, 0},
|
||||
Shape{1, 1, 2},
|
||||
true,
|
||||
op::RoundingType::CEIL,
|
||||
op::PadType::VALID),
|
||||
AvgPoolParams(ov::Shape{1, 1, 3, 3},
|
||||
ov::Shape{1, 1, 3, 3},
|
||||
IN_ET,
|
||||
IN_ET,
|
||||
getContinuousIncreasingValue<T>(1 * 1 * 3 * 3, 1),
|
||||
std::vector<T>{1.0f, 2.5f, 0, 5.5f, 7.0f, 0, 0, 0, 0},
|
||||
Strides{2, 2},
|
||||
Shape{1, 1},
|
||||
Shape{1, 1},
|
||||
Shape{2, 2},
|
||||
true,
|
||||
op::RoundingType::CEIL,
|
||||
op::PadType::NOTSET),
|
||||
};
|
||||
return params;
|
||||
}
|
||||
|
||||
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>()
|
||||
};
|
||||
|
||||
std::vector<AvgPoolParams> combinedParams;
|
||||
|
||||
for (const auto& params : allTypeParams) {
|
||||
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
|
||||
}
|
||||
|
||||
return combinedParams;
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
smoke_AvgPool_With_Hardcoded_Refs,
|
||||
ReferenceAvgPoolLayerTest,
|
||||
::testing::ValuesIn(generateCombinedParamsForAvgPool()),
|
||||
ReferenceAvgPoolLayerTest::getTestCaseName);
|
||||
|
||||
} // namespace
|
||||
@@ -266,6 +266,7 @@ set(SRC
|
||||
visitors/op/asinh.cpp
|
||||
visitors/op/atan.cpp
|
||||
visitors/op/atanh.cpp
|
||||
visitors/op/avg_pool.cpp
|
||||
visitors/op/batch_norm.cpp
|
||||
visitors/op/batch_to_space.cpp
|
||||
visitors/op/binary_convolution.cpp
|
||||
@@ -453,12 +454,9 @@ endif()
|
||||
|
||||
set(MULTI_TEST_SRC
|
||||
backend/abc.in.cpp
|
||||
backend/adaptive_avg_pool.in.cpp
|
||||
backend/adaptive_max_pool.in.cpp
|
||||
backend/aliased_output.in.cpp
|
||||
backend/api.in.cpp
|
||||
backend/auto_broadcast.in.cpp
|
||||
backend/avg_pool.in.cpp
|
||||
backend/batch_norm.in.cpp
|
||||
backend/batch_to_space.in.cpp
|
||||
backend/broadcast.in.cpp
|
||||
@@ -487,7 +485,6 @@ set(MULTI_TEST_SRC
|
||||
backend/lrn.in.cpp
|
||||
backend/matmul.in.cpp
|
||||
backend/matrix_nms.in.cpp
|
||||
backend/max_pool.in.cpp
|
||||
backend/multiclass_nms.in.cpp
|
||||
backend/multiple_backends.in.cpp
|
||||
backend/multiple_result.in.cpp
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "engines_util/test_case.hpp"
|
||||
#include "engines_util/test_engines.hpp"
|
||||
#include "gtest/gtest.h"
|
||||
#include "ngraph/ngraph.hpp"
|
||||
#include "util/test_control.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace ngraph;
|
||||
|
||||
static string s_manifest = "${MANIFEST}";
|
||||
using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME});
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, adaptive_avg_pool_1d) {
|
||||
auto data = make_shared<op::Parameter>(element::f32, Shape{2, 3, 7});
|
||||
auto output_shape = op::Constant::create<int64_t>(element::i64, Shape{1}, {3});
|
||||
auto adaptive_pool = make_shared<op::v8::AdaptiveAvgPool>(data, output_shape);
|
||||
auto fun = make_shared<Function>(OutputVector{adaptive_pool}, ParameterVector{data});
|
||||
|
||||
std::vector<float> inputs{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<float> expected_result{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};
|
||||
|
||||
auto test_case = test::TestCase<TestEngine>(fun);
|
||||
test_case.add_input<float>(Shape{2, 3, 7}, inputs);
|
||||
test_case.add_expected_output<float>(Shape{2, 3, 3}, expected_result);
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, adaptive_avg_pool_2d) {
|
||||
auto data = make_shared<op::Parameter>(element::f32, Shape{1, 3, 7, 10});
|
||||
auto output_shape = op::Constant::create<int64_t>(element::i64, Shape{2}, {3, 3});
|
||||
auto adaptive_pool = make_shared<op::v8::AdaptiveAvgPool>(data, output_shape);
|
||||
auto fun = make_shared<Function>(OutputVector{adaptive_pool}, ParameterVector{data});
|
||||
|
||||
std::vector<float> inputs{
|
||||
-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, -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<float> expected_result{-1.08333337, -0.25000000, -0.91666669, -0.08333334, -0.66666669,
|
||||
0.75000000, -0.41666666, -1.33333337, -0.58333331,
|
||||
|
||||
-1.66666663, 0.58333331, -0.16666667, -0.33333334, -0.41666666,
|
||||
-0.16666667, -0.33333334, -0.66666669, -0.75000000,
|
||||
|
||||
-0.91666669, 0.83333331, -0.16666667, 0., -0.25000000,
|
||||
-1.16666663, -1.41666663, -0.41666666, -0.08333334};
|
||||
|
||||
auto test_case = test::TestCase<TestEngine>(fun);
|
||||
test_case.add_input<float>(Shape{1, 3, 7, 10}, inputs);
|
||||
test_case.add_expected_output<float>(Shape{1, 3, 3, 3}, expected_result);
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, adaptive_avg_pool_3d) {
|
||||
auto data = make_shared<op::Parameter>(element::f32, Shape{2, 2, 3, 3, 3});
|
||||
auto output_shape = op::Constant::create<int64_t>(element::i64, Shape{3}, {2, 2, 2});
|
||||
auto adaptive_pool = make_shared<op::v8::AdaptiveAvgPool>(data, output_shape);
|
||||
auto fun = make_shared<Function>(OutputVector{adaptive_pool}, ParameterVector{data});
|
||||
|
||||
std::vector<float> inputs{
|
||||
-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<float> expected_result{-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.};
|
||||
|
||||
auto test_case = test::TestCase<TestEngine>(fun);
|
||||
test_case.add_input<float>(Shape{2, 2, 3, 3, 3}, inputs);
|
||||
test_case.add_expected_output<float>(Shape{2, 2, 2, 2, 2}, expected_result);
|
||||
test_case.run();
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
#include "engines_util/test_case.hpp"
|
||||
#include "engines_util/test_engines.hpp"
|
||||
#include "gtest/gtest.h"
|
||||
#include "ngraph/ngraph.hpp"
|
||||
#include "util/test_control.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace ngraph;
|
||||
|
||||
static string s_manifest = "${MANIFEST}";
|
||||
using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME});
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, adaptive_max_pool_1d) {
|
||||
auto data = make_shared<op::Parameter>(element::f32, Shape{2, 3, 7});
|
||||
auto output_shape = op::Constant::create<int64_t>(element::i64, Shape{1}, {3});
|
||||
auto adaptive_pool = make_shared<op::v8::AdaptiveMaxPool>(data, output_shape);
|
||||
auto fun = make_shared<Function>(adaptive_pool->outputs(), ParameterVector{data});
|
||||
|
||||
std::vector<float> inputs{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<float> expected_result{4,
|
||||
3,
|
||||
-2,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
3,
|
||||
3,
|
||||
|
||||
3,
|
||||
4,
|
||||
1,
|
||||
2,
|
||||
-2,
|
||||
-2,
|
||||
3,
|
||||
2,
|
||||
2};
|
||||
std::vector<int64_t> expected_indices{1,
|
||||
3,
|
||||
4,
|
||||
1,
|
||||
3,
|
||||
6,
|
||||
1,
|
||||
4,
|
||||
4,
|
||||
|
||||
2,
|
||||
3,
|
||||
6,
|
||||
0,
|
||||
4,
|
||||
4,
|
||||
1,
|
||||
4,
|
||||
4};
|
||||
auto test_case = test::TestCase<TestEngine>(fun);
|
||||
test_case.add_input<float>(Shape{2, 3, 7}, inputs);
|
||||
test_case.add_expected_output<float>(Shape{2, 3, 3}, expected_result);
|
||||
test_case.add_expected_output<int64_t>(Shape{2, 3, 3}, expected_indices);
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, adaptive_max_pool_2d) {
|
||||
auto data = make_shared<op::Parameter>(element::f32, Shape{1, 3, 7, 10});
|
||||
auto output_shape = op::Constant::create<int64_t>(element::i64, Shape{2}, {3, 3});
|
||||
auto adaptive_pool = make_shared<op::v8::AdaptiveMaxPool>(data, output_shape);
|
||||
auto fun = make_shared<Function>(adaptive_pool->outputs(), ParameterVector{data});
|
||||
|
||||
std::vector<float> inputs{
|
||||
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,
|
||||
|
||||
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<float> expected_result{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> expected_indices{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};
|
||||
|
||||
auto test_case = test::TestCase<TestEngine>(fun);
|
||||
test_case.add_input<float>(Shape{1, 3, 7, 10}, inputs);
|
||||
test_case.add_expected_output<float>(Shape{1, 3, 3, 3}, expected_result);
|
||||
test_case.add_expected_output<int64_t>(Shape{1, 3, 3, 3}, expected_indices);
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, adaptive_max_pool_3d) {
|
||||
auto data = make_shared<op::Parameter>(element::f32, Shape{2, 2, 3, 3, 3});
|
||||
auto output_shape = op::Constant::create<int64_t>(element::i64, Shape{3}, {2, 2, 2});
|
||||
auto adaptive_pool = make_shared<op::v8::AdaptiveMaxPool>(data, output_shape);
|
||||
auto fun = make_shared<Function>(adaptive_pool->outputs(), ParameterVector{data});
|
||||
|
||||
std::vector<float> inputs{
|
||||
-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<float> expected_result{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> expected_indices{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};
|
||||
|
||||
auto test_case = test::TestCase<TestEngine>(fun);
|
||||
test_case.add_input<float>(Shape{2, 2, 3, 3, 3}, inputs);
|
||||
test_case.add_expected_output<float>(Shape{2, 2, 2, 2, 2}, expected_result);
|
||||
test_case.add_expected_output<int64_t>(Shape{2, 2, 2, 2, 2}, expected_indices);
|
||||
test_case.run();
|
||||
}
|
||||
@@ -1,251 +0,0 @@
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
// clang-format off
|
||||
#ifdef ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS
|
||||
#define DEFAULT_FLOAT_TOLERANCE_BITS ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS
|
||||
#endif
|
||||
|
||||
#ifdef ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS
|
||||
#define DEFAULT_DOUBLE_TOLERANCE_BITS ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "ngraph/ngraph.hpp"
|
||||
#include "engines_util/test_engines.hpp"
|
||||
#include "engines_util/test_case.hpp"
|
||||
#include "util/test_control.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace ngraph;
|
||||
|
||||
static string s_manifest = "${MANIFEST}";
|
||||
using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME});
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, avg_pool_2d_floor) {
|
||||
Shape in_shape{1, 1, 3, 3};
|
||||
Shape out_shape{1, 1, 2, 2};
|
||||
const Strides& strides{1, 1};
|
||||
const Shape& pads_begin{0, 0};
|
||||
const Shape& pads_end{0, 0};
|
||||
const Shape& kernel{2, 2};
|
||||
const bool exclude_pad = true;
|
||||
const op::RoundingType rounding_type = op::RoundingType::FLOOR;
|
||||
const op::PadType pad_type = op::PadType::NOTSET;
|
||||
|
||||
auto A = make_shared<op::Parameter>(element::f32, in_shape);
|
||||
auto avgPool =
|
||||
make_shared<op::v1::AvgPool>(A, strides, pads_begin, pads_end, kernel, exclude_pad, rounding_type, pad_type);
|
||||
auto f = make_shared<Function>(avgPool, ParameterVector{A});
|
||||
|
||||
std::vector<float> a{1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
std::vector<float> result{3, 4, 6, 7};
|
||||
|
||||
auto test_case = test::TestCase<TestEngine>(f);
|
||||
test_case.add_input<float>({a});
|
||||
test_case.add_expected_output<float>(out_shape, result);
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, avg_pool_2d_ceil) {
|
||||
Shape in_shape{1, 1, 4, 4};
|
||||
Shape out_shape{1, 1, 2, 2};
|
||||
const Strides& strides{1, 1};
|
||||
const Shape& pads_begin{0, 0};
|
||||
const Shape& pads_end{0, 0};
|
||||
const Shape& kernel{3, 3};
|
||||
const bool exclude_pad = true;
|
||||
const op::RoundingType rounding_type = op::RoundingType::CEIL;
|
||||
const op::PadType pad_type = op::PadType::NOTSET;
|
||||
|
||||
auto A = make_shared<op::Parameter>(element::f32, in_shape);
|
||||
auto avgPool =
|
||||
make_shared<op::v1::AvgPool>(A, strides, pads_begin, pads_end, kernel, exclude_pad, rounding_type, pad_type);
|
||||
auto f = make_shared<Function>(avgPool, ParameterVector{A});
|
||||
|
||||
std::vector<float> a{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
|
||||
std::vector<float> result{6, 7, 10, 11};
|
||||
|
||||
auto test_case = test::TestCase<TestEngine>(f);
|
||||
test_case.add_input<float>({a});
|
||||
test_case.add_expected_output<float>(out_shape, result);
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, avg_pool_2d_pad) {
|
||||
Shape in_shape{1, 1, 2, 2};
|
||||
Shape out_shape{1, 1, 3, 3};
|
||||
const Strides& strides{1, 1};
|
||||
const Shape& pads_begin{1, 1};
|
||||
const Shape& pads_end{1, 1};
|
||||
const Shape& kernel{2, 2};
|
||||
const bool exclude_pad = true;
|
||||
const op::RoundingType rounding_type = op::RoundingType::CEIL;
|
||||
const op::PadType pad_type = op::PadType::NOTSET;
|
||||
|
||||
auto A = make_shared<op::Parameter>(element::f32, in_shape);
|
||||
auto avgPool =
|
||||
make_shared<op::v1::AvgPool>(A, strides, pads_begin, pads_end, kernel, exclude_pad, rounding_type, pad_type);
|
||||
auto f = make_shared<Function>(avgPool, ParameterVector{A});
|
||||
|
||||
std::vector<float> a{1, 2, 3, 4};
|
||||
std::vector<float> result{1, 1.5, 2, 2, 2.5, 3, 3, 3.5, 4};
|
||||
|
||||
auto test_case = test::TestCase<TestEngine>(f);
|
||||
test_case.add_input<float>({a});
|
||||
test_case.add_expected_output<float>(out_shape, result);
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, avg_pool_2d_ceil_stride_pad) {
|
||||
Shape in_shape{1, 1, 1, 5};
|
||||
Shape out_shape{1, 1, 1, 3};
|
||||
const Strides& strides{1, 2};
|
||||
const Shape& pads_begin{1, 1};
|
||||
const Shape& pads_end{1, 1};
|
||||
const Shape& kernel{3, 3};
|
||||
const bool exclude_pad = true;
|
||||
const op::RoundingType rounding_type = op::RoundingType::CEIL;
|
||||
const op::PadType pad_type = op::PadType::EXPLICIT;
|
||||
|
||||
auto A = make_shared<op::Parameter>(element::f32, in_shape);
|
||||
auto avgPool =
|
||||
make_shared<op::v1::AvgPool>(A, strides, pads_begin, pads_end, kernel, exclude_pad, rounding_type, pad_type);
|
||||
auto f = make_shared<Function>(avgPool, ParameterVector{A});
|
||||
|
||||
std::vector<float> a{1, 2, 3, 4, 5};
|
||||
std::vector<float> result{1.5, 3, 4.5};
|
||||
|
||||
auto test_case = test::TestCase<TestEngine>(f);
|
||||
test_case.add_input<float>({a});
|
||||
test_case.add_expected_output<float>(out_shape, result);
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, avg_pool_2d_ceil_stride_pad_include_padding) {
|
||||
Shape in_shape{1, 1, 1, 5};
|
||||
Shape out_shape{1, 1, 1, 3};
|
||||
const Strides& strides{1, 2};
|
||||
const Shape& pads_begin{1, 1};
|
||||
const Shape& pads_end{1, 1};
|
||||
const Shape& kernel{3, 3};
|
||||
const bool exclude_pad = false;
|
||||
const op::RoundingType rounding_type = op::RoundingType::CEIL;
|
||||
const op::PadType pad_type = op::PadType::EXPLICIT;
|
||||
|
||||
auto A = make_shared<op::Parameter>(element::f32, in_shape);
|
||||
auto avgPool =
|
||||
make_shared<op::v1::AvgPool>(A, strides, pads_begin, pads_end, kernel, exclude_pad, rounding_type, pad_type);
|
||||
auto f = make_shared<Function>(avgPool, ParameterVector{A});
|
||||
|
||||
std::vector<float> a{2.5, 2, 12, 4, 5};
|
||||
std::vector<float> result{0.5, 2, 1};
|
||||
|
||||
auto test_case = test::TestCase<TestEngine>(f);
|
||||
test_case.add_input<float>({a});
|
||||
test_case.add_expected_output<float>(out_shape, result);
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, avg_pool_2d_same_upper) {
|
||||
Shape in_shape{1, 1, 3, 3};
|
||||
Shape out_shape{1, 1, 3, 3};
|
||||
const Strides& strides{1, 1};
|
||||
const Shape& pads_begin{0, 0};
|
||||
const Shape& pads_end{0, 0};
|
||||
const Shape& kernel{2, 2};
|
||||
const bool exclude_pad = false;
|
||||
const op::RoundingType rounding_type = op::RoundingType::CEIL;
|
||||
const op::PadType pad_type = op::PadType::SAME_UPPER;
|
||||
|
||||
auto A = make_shared<op::Parameter>(element::f32, in_shape);
|
||||
auto avgPool =
|
||||
make_shared<op::v1::AvgPool>(A, strides, pads_begin, pads_end, kernel, exclude_pad, rounding_type, pad_type);
|
||||
auto f = make_shared<Function>(avgPool, ParameterVector{A});
|
||||
|
||||
std::vector<float> a{1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
std::vector<float> result{3, 4, 2.25, 6, 7, 3.75, 3.75, 4.25, 2.25};
|
||||
|
||||
auto test_case = test::TestCase<TestEngine>(f);
|
||||
test_case.add_input<float>({a});
|
||||
test_case.add_expected_output<float>(out_shape, result);
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, avg_pool_3d) {
|
||||
Shape in_shape{1, 1, 2, 2, 2};
|
||||
Shape out_shape{1, 1, 2, 2, 1};
|
||||
const Strides& strides{1, 1, 1};
|
||||
const Shape& pads_begin{0, 0, 0};
|
||||
const Shape& pads_end{0, 0, 0};
|
||||
const Shape& kernel{1, 1, 2};
|
||||
const bool exclude_pad = true;
|
||||
const op::RoundingType rounding_type = op::RoundingType::CEIL;
|
||||
const op::PadType pad_type = op::PadType::VALID;
|
||||
|
||||
auto A = make_shared<op::Parameter>(element::f32, in_shape);
|
||||
auto avgPool =
|
||||
make_shared<op::v1::AvgPool>(A, strides, pads_begin, pads_end, kernel, exclude_pad, rounding_type, pad_type);
|
||||
auto f = make_shared<Function>(avgPool, ParameterVector{A});
|
||||
|
||||
std::vector<float> a{1, 2, 3, 4, 5, 6, 7, 8};
|
||||
std::vector<float> result{1.5, 3.5, 5.5, 7.5};
|
||||
|
||||
auto test_case = test::TestCase<TestEngine>(f);
|
||||
test_case.add_input<float>({a});
|
||||
test_case.add_expected_output<float>(out_shape, result);
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, avg_pool_2d_same_lower) {
|
||||
Shape in_shape{1, 1, 3, 3};
|
||||
Shape out_shape{1, 1, 3, 3};
|
||||
const Strides& strides{1, 1};
|
||||
const Shape& pads_begin{0, 0};
|
||||
const Shape& pads_end{0, 0};
|
||||
const Shape& kernel{2, 2};
|
||||
const bool exclude_pad = false;
|
||||
const op::RoundingType rounding_type = op::RoundingType::CEIL;
|
||||
const op::PadType pad_type = op::PadType::SAME_LOWER;
|
||||
|
||||
auto A = make_shared<op::Parameter>(element::f32, in_shape);
|
||||
auto avgPool =
|
||||
make_shared<op::v1::AvgPool>(A, strides, pads_begin, pads_end, kernel, exclude_pad, rounding_type, pad_type);
|
||||
auto f = make_shared<Function>(avgPool, ParameterVector{A});
|
||||
|
||||
std::vector<float> a{1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
std::vector<float> result{0.25, 0.75, 1.25, 1.25, 3, 4, 2.75, 6, 7};
|
||||
|
||||
auto test_case = test::TestCase<TestEngine>(f);
|
||||
test_case.add_input<float>({a});
|
||||
test_case.add_expected_output<float>(out_shape, result);
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, avg_pool_2d_padding) {
|
||||
Shape in_shape{1, 1, 3, 3};
|
||||
Shape out_shape{1, 1, 3, 3};
|
||||
const Strides& strides{2, 2};
|
||||
const Shape& pads_begin{1, 1};
|
||||
const Shape& pads_end{1, 1};
|
||||
const Shape& kernel{2, 2};
|
||||
const bool exclude_pad = true;
|
||||
const op::RoundingType rounding_type = op::RoundingType::CEIL;
|
||||
const op::PadType pad_type = op::PadType::NOTSET;
|
||||
|
||||
auto A = make_shared<op::Parameter>(element::f32, in_shape);
|
||||
auto avgPool =
|
||||
make_shared<op::v1::AvgPool>(A, strides, pads_begin, pads_end, kernel, exclude_pad, rounding_type, pad_type);
|
||||
auto f = make_shared<Function>(avgPool, ParameterVector{A});
|
||||
|
||||
std::vector<float> a(1 * 1 * 3 * 3);
|
||||
std::iota(std::begin(a), std::end(a), 1);
|
||||
std::vector<float> result{1.0f, 2.5f, 0, 5.5f, 7.0f, 0, 0, 0, 0};
|
||||
|
||||
auto test_case = test::TestCase<TestEngine>(f);
|
||||
test_case.add_input<float>({a});
|
||||
test_case.add_expected_output<float>(out_shape, result);
|
||||
test_case.run();
|
||||
}
|
||||
@@ -1,186 +0,0 @@
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
// clang-format off
|
||||
#ifdef ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS
|
||||
#define DEFAULT_FLOAT_TOLERANCE_BITS ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS
|
||||
#endif
|
||||
|
||||
#ifdef ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS
|
||||
#define DEFAULT_DOUBLE_TOLERANCE_BITS ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "ngraph/ngraph.hpp"
|
||||
#include "engines_util/test_engines.hpp"
|
||||
#include "engines_util/test_case.hpp"
|
||||
#include "util/test_control.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace ngraph;
|
||||
|
||||
static string s_manifest = "${MANIFEST}";
|
||||
using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME});
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, max_pool_2d_floor) {
|
||||
Shape in_shape{1, 1, 3, 3};
|
||||
Shape out_shape{1, 1, 2, 2};
|
||||
const Strides& strides{1, 1};
|
||||
const Shape& pads_begin{0, 0};
|
||||
const Shape& pads_end{0, 0};
|
||||
const Shape& kernel{2, 2};
|
||||
const op::RoundingType rounding_type = op::RoundingType::FLOOR;
|
||||
const op::PadType pad_type = op::PadType::NOTSET;
|
||||
|
||||
auto A = make_shared<op::Parameter>(element::f32, in_shape);
|
||||
auto maxPool = make_shared<op::v1::MaxPool>(A, strides, pads_begin, pads_end, kernel, rounding_type, pad_type);
|
||||
auto f = make_shared<Function>(maxPool, ParameterVector{A});
|
||||
|
||||
std::vector<float> a{1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
std::vector<float> result{5, 6, 8, 9};
|
||||
|
||||
auto test_case = test::TestCase<TestEngine>(f);
|
||||
test_case.add_input<float>({a});
|
||||
test_case.add_expected_output<float>(out_shape, result);
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, max_pool_2d_ceil) {
|
||||
Shape in_shape{1, 1, 4, 4};
|
||||
Shape out_shape{1, 1, 2, 2};
|
||||
const Strides& strides{1, 1};
|
||||
const Shape& pads_begin{0, 0};
|
||||
const Shape& pads_end{0, 0};
|
||||
const Shape& kernel{3, 3};
|
||||
const op::RoundingType rounding_type = op::RoundingType::CEIL;
|
||||
const op::PadType pad_type = op::PadType::NOTSET;
|
||||
|
||||
auto A = make_shared<op::Parameter>(element::f32, in_shape);
|
||||
auto maxPool = make_shared<op::v1::MaxPool>(A, strides, pads_begin, pads_end, kernel, rounding_type, pad_type);
|
||||
auto f = make_shared<Function>(maxPool, ParameterVector{A});
|
||||
|
||||
std::vector<float> a{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
|
||||
std::vector<float> result{11, 12, 15, 16};
|
||||
|
||||
auto test_case = test::TestCase<TestEngine>(f);
|
||||
test_case.add_input<float>({a});
|
||||
test_case.add_expected_output<float>(out_shape, result);
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, max_pool_2d_pad) {
|
||||
Shape in_shape{1, 1, 2, 2};
|
||||
Shape out_shape{1, 1, 3, 3};
|
||||
const Strides& strides{1, 1};
|
||||
const Shape& pads_begin{1, 1};
|
||||
const Shape& pads_end{1, 1};
|
||||
const Shape& kernel{2, 2};
|
||||
const op::RoundingType rounding_type = op::RoundingType::CEIL;
|
||||
const op::PadType pad_type = op::PadType::NOTSET;
|
||||
|
||||
auto A = make_shared<op::Parameter>(element::f32, in_shape);
|
||||
auto maxPool = make_shared<op::v1::MaxPool>(A, strides, pads_begin, pads_end, kernel, rounding_type, pad_type);
|
||||
auto f = make_shared<Function>(maxPool, ParameterVector{A});
|
||||
|
||||
std::vector<float> a{1, 2, 3, 4};
|
||||
std::vector<float> result{1, 2, 2, 3, 4, 4, 3, 4, 4};
|
||||
|
||||
auto test_case = test::TestCase<TestEngine>(f);
|
||||
test_case.add_input<float>({a});
|
||||
test_case.add_expected_output<float>(out_shape, result);
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, max_pool_2d_ceil_stride_pad) {
|
||||
Shape in_shape{1, 1, 1, 5};
|
||||
Shape out_shape{1, 1, 1, 3};
|
||||
const Strides& strides{1, 2};
|
||||
const Shape& pads_begin{1, 1};
|
||||
const Shape& pads_end{1, 1};
|
||||
const Shape& kernel{3, 3};
|
||||
const op::RoundingType rounding_type = op::RoundingType::CEIL;
|
||||
const op::PadType pad_type = op::PadType::EXPLICIT;
|
||||
|
||||
auto A = make_shared<op::Parameter>(element::f32, in_shape);
|
||||
auto maxPool = make_shared<op::v1::MaxPool>(A, strides, pads_begin, pads_end, kernel, rounding_type, pad_type);
|
||||
auto f = make_shared<Function>(maxPool, ParameterVector{A});
|
||||
|
||||
std::vector<float> a{1, 2, 3, 4, 5};
|
||||
std::vector<float> result{2, 4, 5};
|
||||
|
||||
auto test_case = test::TestCase<TestEngine>(f);
|
||||
test_case.add_input<float>({a});
|
||||
test_case.add_expected_output<float>(out_shape, result);
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, max_pool_2d_same_upper) {
|
||||
Shape in_shape{1, 1, 3, 3};
|
||||
Shape out_shape{1, 1, 3, 3};
|
||||
const Strides& strides{1, 1};
|
||||
const Shape& pads_begin{0, 0};
|
||||
const Shape& pads_end{0, 0};
|
||||
const Shape& kernel{2, 2};
|
||||
const op::RoundingType rounding_type = op::RoundingType::CEIL;
|
||||
const op::PadType pad_type = op::PadType::SAME_UPPER;
|
||||
|
||||
auto A = make_shared<op::Parameter>(element::f32, in_shape);
|
||||
auto maxPool = make_shared<op::v1::MaxPool>(A, strides, pads_begin, pads_end, kernel, rounding_type, pad_type);
|
||||
auto f = make_shared<Function>(maxPool, ParameterVector{A});
|
||||
|
||||
std::vector<float> a{1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
std::vector<float> result{5, 6, 6, 8, 9, 9, 8, 9, 9};
|
||||
|
||||
auto test_case = test::TestCase<TestEngine>(f);
|
||||
test_case.add_input<float>({a});
|
||||
test_case.add_expected_output<float>(out_shape, result);
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, max_pool_3d) {
|
||||
Shape in_shape{1, 1, 2, 2, 2};
|
||||
Shape out_shape{1, 1, 2, 2, 1};
|
||||
const Strides& strides{1, 1, 1};
|
||||
const Shape& pads_begin{0, 0, 0};
|
||||
const Shape& pads_end{0, 0, 0};
|
||||
const Shape& kernel{1, 1, 2};
|
||||
const op::RoundingType rounding_type = op::RoundingType::CEIL;
|
||||
const op::PadType pad_type = op::PadType::VALID;
|
||||
|
||||
auto A = make_shared<op::Parameter>(element::f32, in_shape);
|
||||
auto maxPool = make_shared<op::v1::MaxPool>(A, strides, pads_begin, pads_end, kernel, rounding_type, pad_type);
|
||||
auto f = make_shared<Function>(maxPool, ParameterVector{A});
|
||||
|
||||
std::vector<float> a{1, 2, 3, 4, 5, 6, 7, 8};
|
||||
std::vector<float> result{2, 4, 6, 8};
|
||||
|
||||
auto test_case = test::TestCase<TestEngine>(f);
|
||||
test_case.add_input<float>({a});
|
||||
test_case.add_expected_output<float>(out_shape, result);
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, max_pool_2d_same_lower) {
|
||||
Shape in_shape{1, 1, 3, 3};
|
||||
Shape out_shape{1, 1, 3, 3};
|
||||
const Strides& strides{1, 1};
|
||||
const Shape& pads_begin{0, 0};
|
||||
const Shape& pads_end{0, 0};
|
||||
const Shape& kernel{2, 2};
|
||||
const op::RoundingType rounding_type = op::RoundingType::CEIL;
|
||||
const op::PadType pad_type = op::PadType::SAME_LOWER;
|
||||
|
||||
auto A = make_shared<op::Parameter>(element::f32, in_shape);
|
||||
auto maxPool = make_shared<op::v1::MaxPool>(A, strides, pads_begin, pads_end, kernel, rounding_type, pad_type);
|
||||
auto f = make_shared<Function>(maxPool, ParameterVector{A});
|
||||
|
||||
std::vector<float> a{1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
std::vector<float> result{1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
|
||||
auto test_case = test::TestCase<TestEngine>(f);
|
||||
test_case.add_input<float>({a});
|
||||
test_case.add_expected_output<float>(out_shape, result);
|
||||
test_case.run();
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "ngraph/ngraph.hpp"
|
||||
#include "ngraph/op/util/attr_types.hpp"
|
||||
#include "ngraph/opsets/opset1.hpp"
|
||||
#include "ngraph/opsets/opset8.hpp"
|
||||
#include "util/visitor.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace ngraph;
|
||||
using ngraph::test::NodeBuilder;
|
||||
using ngraph::test::ValueMap;
|
||||
|
||||
TEST(attributes, avg_pool_op) {
|
||||
NodeBuilder::get_ops().register_factory<opset1::AvgPool>();
|
||||
auto data = make_shared<op::Parameter>(element::f32, Shape{64, 3, 5});
|
||||
|
||||
auto strides = Strides{2};
|
||||
auto pads_begin = Shape{1};
|
||||
auto pads_end = Shape{1};
|
||||
auto kernel = Shape{1};
|
||||
bool exclude_pad = false;
|
||||
auto rounding_mode = op::RoundingType::FLOOR;
|
||||
auto auto_pad = op::PadType::EXPLICIT;
|
||||
|
||||
auto avg_pool =
|
||||
make_shared<opset1::AvgPool>(data, strides, pads_begin, pads_end, kernel, exclude_pad, rounding_mode, auto_pad);
|
||||
|
||||
NodeBuilder builder(avg_pool);
|
||||
auto g_avg_pool = ov::as_type_ptr<opset1::AvgPool>(builder.create());
|
||||
|
||||
EXPECT_EQ(g_avg_pool->get_strides(), avg_pool->get_strides());
|
||||
EXPECT_EQ(g_avg_pool->get_pads_begin(), avg_pool->get_pads_begin());
|
||||
EXPECT_EQ(g_avg_pool->get_pads_end(), avg_pool->get_pads_end());
|
||||
EXPECT_EQ(g_avg_pool->get_kernel(), avg_pool->get_kernel());
|
||||
EXPECT_EQ(g_avg_pool->get_rounding_type(), avg_pool->get_rounding_type());
|
||||
EXPECT_EQ(g_avg_pool->get_auto_pad(), avg_pool->get_auto_pad());
|
||||
}
|
||||
|
||||
TEST(attributes, avg_pool_v8_op) {
|
||||
NodeBuilder::get_ops().register_factory<opset8::AvgPool>();
|
||||
const auto data = make_shared<op::Parameter>(element::i32, Shape{1, 3, 37, 37});
|
||||
|
||||
const auto strides = Strides{1, 1};
|
||||
const auto pads_begin = Shape{1, 1};
|
||||
const auto pads_end = Shape{1, 1};
|
||||
const auto kernel = Shape{2, 2};
|
||||
bool exclude_pad = false;
|
||||
const auto rounding_mode = op::RoundingType::CEIL;
|
||||
const auto auto_pad = op::PadType::EXPLICIT;
|
||||
|
||||
const auto avg_pool =
|
||||
make_shared<opset8::AvgPool>(data, strides, pads_begin, pads_end, kernel, exclude_pad, rounding_mode, auto_pad);
|
||||
NodeBuilder builder(avg_pool);
|
||||
auto g_avg_pool = ov::as_type_ptr<opset8::AvgPool>(builder.create());
|
||||
|
||||
EXPECT_EQ(g_avg_pool->get_strides(), avg_pool->get_strides());
|
||||
EXPECT_EQ(g_avg_pool->get_pads_begin(), avg_pool->get_pads_begin());
|
||||
EXPECT_EQ(g_avg_pool->get_pads_end(), avg_pool->get_pads_end());
|
||||
EXPECT_EQ(g_avg_pool->get_kernel(), avg_pool->get_kernel());
|
||||
EXPECT_EQ(g_avg_pool->get_rounding_type(), avg_pool->get_rounding_type());
|
||||
EXPECT_EQ(g_avg_pool->get_auto_pad(), avg_pool->get_auto_pad());
|
||||
}
|
||||
Reference in new issue
Block a user