Missing attr seriazliation (#3920)
* add override method for int since attribute keep_top_k from detection_output requires it * remove if statement to prevent gtest tests duplicate names for avg_pool * add single layer tests for seriazliation for AvgPool, PriorBoxClustered and DetectionOutput operators * add apropiate styling of the code
This commit is contained in:
1 parent
c083e7fb63
commit
cdb9edddfc
5 files changed
+250
-3
No files matched your search
@@ -276,6 +276,12 @@ public:
|
||||
ngraph::ValueAccessor<double>& adapter) override {
|
||||
m_xml_node.append_attribute(name.c_str()).set_value(adapter.get());
|
||||
}
|
||||
void on_adapter(
|
||||
const std::string& name,
|
||||
ngraph::ValueAccessor<std::vector<int>>& adapter) override {
|
||||
m_xml_node.append_attribute(name.c_str())
|
||||
.set_value(create_atribute_list(adapter).c_str());
|
||||
}
|
||||
void on_adapter(
|
||||
const std::string& name,
|
||||
ngraph::ValueAccessor<std::vector<int64_t>>& adapter) override {
|
||||
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
// Copyright (C) 2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "shared_test_classes/single_layer/detection_output.hpp"
|
||||
#include "common_test_utils/test_constants.hpp"
|
||||
|
||||
using namespace LayerTestsDefinitions;
|
||||
|
||||
namespace {
|
||||
TEST_P(DetectionOutputLayerTest, Serialize) {
|
||||
Serialize();
|
||||
}
|
||||
|
||||
const std::vector<InferenceEngine::Precision> netPrecisions = {
|
||||
InferenceEngine::Precision::FP32,
|
||||
InferenceEngine::Precision::FP16
|
||||
};
|
||||
|
||||
/* =============== Detection Output =============== */
|
||||
|
||||
const int numClasses = 11;
|
||||
const int backgroundLabelId = 0;
|
||||
const std::vector<int> topK = {75};
|
||||
const std::vector<std::vector<int>> keepTopK = { {50}, {100} };
|
||||
const std::vector<std::string> codeType = {"caffe.PriorBoxParameter.CORNER", "caffe.PriorBoxParameter.CENTER_SIZE"};
|
||||
const float nmsThreshold = 0.5f;
|
||||
const float confidenceThreshold = 0.3f;
|
||||
const std::vector<bool> clipAfterNms = {true, false};
|
||||
const std::vector<bool> clipBeforeNms = {true, false};
|
||||
const std::vector<bool> decreaseLabelId = {true, false};
|
||||
const std::vector<size_t> numberBatch = {1, 2};
|
||||
const float objectnessScore = 0.4f;
|
||||
|
||||
const auto commonAttributes = ::testing::Combine(
|
||||
::testing::Values(numClasses),
|
||||
::testing::Values(backgroundLabelId),
|
||||
::testing::ValuesIn(topK),
|
||||
::testing::ValuesIn(keepTopK),
|
||||
::testing::ValuesIn(codeType),
|
||||
::testing::Values(nmsThreshold),
|
||||
::testing::Values(confidenceThreshold),
|
||||
::testing::ValuesIn(clipAfterNms),
|
||||
::testing::ValuesIn(clipBeforeNms),
|
||||
::testing::ValuesIn(decreaseLabelId));
|
||||
|
||||
/* =============== 3 inputs cases =============== */
|
||||
|
||||
const std::vector<ParamsWhichSizeDepends> specificParams3In = {
|
||||
ParamsWhichSizeDepends{true, true, true, 1, 1, {1, 60}, {1, 165}, {1, 1, 60}, {}, {}},
|
||||
ParamsWhichSizeDepends{true, false, true, 1, 1, {1, 660}, {1, 165}, {1, 1, 60}, {}, {}},
|
||||
ParamsWhichSizeDepends{false, true, true, 1, 1, {1, 60}, {1, 165}, {1, 2, 60}, {}, {}},
|
||||
ParamsWhichSizeDepends{false, false, true, 1, 1, {1, 660}, {1, 165}, {1, 2, 60}, {}, {}},
|
||||
|
||||
ParamsWhichSizeDepends{true, true, false, 10, 10, {1, 60}, {1, 165}, {1, 1, 75}, {}, {}},
|
||||
ParamsWhichSizeDepends{true, false, false, 10, 10, {1, 660}, {1, 165}, {1, 1, 75}, {}, {}},
|
||||
ParamsWhichSizeDepends{false, true, false, 10, 10, {1, 60}, {1, 165}, {1, 2, 75}, {}, {}},
|
||||
ParamsWhichSizeDepends{false, false, false, 10, 10, {1, 660}, {1, 165}, {1, 2, 75}, {}, {}}};
|
||||
|
||||
const auto params3Inputs = ::testing::Combine(
|
||||
commonAttributes,
|
||||
::testing::ValuesIn(specificParams3In),
|
||||
::testing::ValuesIn(numberBatch),
|
||||
::testing::Values(objectnessScore),
|
||||
::testing::Values(CommonTestUtils::DEVICE_CPU));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
smoke_DetectionOutput3In,
|
||||
DetectionOutputLayerTest,
|
||||
params3Inputs,
|
||||
DetectionOutputLayerTest::getTestCaseName);
|
||||
} // namespace
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
// Copyright (C) 2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "shared_test_classes/single_layer/pooling.hpp"
|
||||
#include "common_test_utils/test_constants.hpp"
|
||||
|
||||
using namespace LayerTestsDefinitions;
|
||||
|
||||
namespace {
|
||||
TEST_P(PoolingLayerTest, Serialize) {
|
||||
Serialize();
|
||||
}
|
||||
|
||||
const std::vector<InferenceEngine::Precision> netPrecisions = {
|
||||
InferenceEngine::Precision::FP32,
|
||||
InferenceEngine::Precision::FP16
|
||||
};
|
||||
|
||||
/* ============= POOLING ============= */
|
||||
const std::vector<std::vector<size_t >> kernels = {{3, 3},
|
||||
{3, 5}};
|
||||
const std::vector<std::vector<size_t >> strides = {{1, 1},
|
||||
{1, 2}};
|
||||
const std::vector<std::vector<size_t >> padBegins = {{0, 0},
|
||||
{0, 2}};
|
||||
const std::vector<std::vector<size_t >> padEnds = {{0, 0},
|
||||
{0, 2}};
|
||||
|
||||
const std::vector<ngraph::op::RoundingType> roundingTypes = {
|
||||
ngraph::op::RoundingType::FLOOR,
|
||||
ngraph::op::RoundingType::CEIL
|
||||
};
|
||||
|
||||
const std::vector<ngraph::op::PadType> padTypes = {
|
||||
ngraph::op::PadType::EXPLICIT,
|
||||
ngraph::op::PadType::SAME_UPPER,
|
||||
ngraph::op::PadType::VALID
|
||||
};
|
||||
|
||||
const std::vector<size_t> inputShape = {511, 11, 13, 15};
|
||||
const std::vector<bool> excludePad = {true, false};
|
||||
|
||||
/* ============= AVERAGE POOLING ============= */
|
||||
|
||||
const auto avgExcludePadParams = ::testing::Combine(
|
||||
::testing::Values(ngraph::helpers::PoolingTypes::AVG),
|
||||
::testing::ValuesIn(kernels),
|
||||
::testing::ValuesIn(strides),
|
||||
::testing::ValuesIn(padBegins),
|
||||
::testing::ValuesIn(padEnds),
|
||||
::testing::ValuesIn(roundingTypes),
|
||||
::testing::ValuesIn(padTypes),
|
||||
::testing::Values(excludePad[0]));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(smoke_AvgPoolExcluePad, PoolingLayerTest,
|
||||
::testing::Combine(
|
||||
avgExcludePadParams,
|
||||
::testing::ValuesIn(netPrecisions),
|
||||
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
|
||||
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
|
||||
::testing::Values(InferenceEngine::Layout::ANY),
|
||||
::testing::Values(InferenceEngine::Layout::ANY),
|
||||
::testing::Values(inputShape),
|
||||
::testing::Values(CommonTestUtils::DEVICE_CPU)),
|
||||
PoolingLayerTest::getTestCaseName);
|
||||
|
||||
const auto avgPadParams = ::testing::Combine(
|
||||
::testing::Values(ngraph::helpers::PoolingTypes::AVG),
|
||||
::testing::ValuesIn(kernels),
|
||||
::testing::ValuesIn(strides),
|
||||
::testing::ValuesIn(padBegins),
|
||||
::testing::ValuesIn(padEnds),
|
||||
::testing::ValuesIn(roundingTypes),
|
||||
::testing::ValuesIn(padTypes),
|
||||
::testing::Values(excludePad[1]));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(smoke_AvgPool, PoolingLayerTest,
|
||||
::testing::Combine(
|
||||
avgPadParams,
|
||||
::testing::ValuesIn(netPrecisions),
|
||||
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
|
||||
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
|
||||
::testing::Values(InferenceEngine::Layout::ANY),
|
||||
::testing::Values(InferenceEngine::Layout::ANY),
|
||||
::testing::Values(inputShape),
|
||||
::testing::Values(CommonTestUtils::DEVICE_CPU)),
|
||||
PoolingLayerTest::getTestCaseName);
|
||||
} // namespace
|
||||
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
// Copyright (C) 2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "shared_test_classes/single_layer/prior_box_clustered.hpp"
|
||||
#include "common_test_utils/test_constants.hpp"
|
||||
|
||||
using namespace LayerTestsDefinitions;
|
||||
|
||||
namespace {
|
||||
TEST_P(PriorBoxClusteredLayerTest, Serialize) {
|
||||
Serialize();
|
||||
}
|
||||
|
||||
const std::vector<InferenceEngine::Precision> netPrecisions = {
|
||||
InferenceEngine::Precision::FP32,
|
||||
InferenceEngine::Precision::FP16
|
||||
};
|
||||
|
||||
const std::vector<std::vector<float>> widths = {
|
||||
{ 5.12f, 14.6f, 13.5f },
|
||||
{ 7.0f, 8.2f, 33.39f }
|
||||
};
|
||||
|
||||
const std::vector<std::vector<float>> heights = {
|
||||
{ 15.12f, 15.6f, 23.5f },
|
||||
{ 10.0f, 16.2f, 36.2f }
|
||||
};
|
||||
|
||||
const std::vector<float> step_widths = {
|
||||
0.0f, 2.0f
|
||||
};
|
||||
|
||||
const std::vector<float> step_heights = {
|
||||
0.0f, 1.5f
|
||||
};
|
||||
|
||||
const std::vector<float> offsets = {
|
||||
0.5f
|
||||
};
|
||||
|
||||
const std::vector<std::vector<float>> variances = {
|
||||
{ 0.1f, 0.1f, 0.2f, 0.2f }
|
||||
};
|
||||
|
||||
const std::vector<bool> clips = {
|
||||
true, false
|
||||
};
|
||||
|
||||
const std::vector<size_t> inputShape = {4, 4};
|
||||
const std::vector<size_t> imageShape = {50, 50};
|
||||
|
||||
const auto layerSpeficParams = ::testing::Combine(
|
||||
::testing::ValuesIn(widths),
|
||||
::testing::ValuesIn(heights),
|
||||
::testing::ValuesIn(clips),
|
||||
::testing::ValuesIn(step_widths),
|
||||
::testing::ValuesIn(step_heights),
|
||||
::testing::ValuesIn(offsets),
|
||||
::testing::ValuesIn(variances));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(smoke_PriorBoxClustered_Basic, PriorBoxClusteredLayerTest,
|
||||
::testing::Combine(
|
||||
layerSpeficParams,
|
||||
::testing::ValuesIn(netPrecisions),
|
||||
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
|
||||
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
|
||||
::testing::Values(InferenceEngine::Layout::ANY),
|
||||
::testing::Values(InferenceEngine::Layout::ANY),
|
||||
::testing::Values(inputShape),
|
||||
::testing::Values(imageShape),
|
||||
::testing::Values(CommonTestUtils::DEVICE_CPU)),
|
||||
PriorBoxClusteredLayerTest::getTestCaseName);
|
||||
|
||||
} // namespace
|
||||
@@ -38,9 +38,7 @@ std::string PoolingLayerTest::getTestCaseName(testing::TestParamInfo<poolLayerTe
|
||||
result << "S" << CommonTestUtils::vec2str(stride) << "_";
|
||||
result << "PB" << CommonTestUtils::vec2str(padBegin) << "_";
|
||||
result << "PE" << CommonTestUtils::vec2str(padEnd) << "_";
|
||||
if (padType == ngraph::op::PadType::EXPLICIT) {
|
||||
result << "Rounding=" << roundingType << "_";
|
||||
}
|
||||
result << "Rounding=" << roundingType << "_";
|
||||
result << "AutoPad=" << padType << "_";
|
||||
result << "netPRC=" << netPrecision.name() << "_";
|
||||
result << "inPRC=" << inPrc.name() << "_";
|
||||
|
||||
Reference in new issue
Block a user