func tests for CPU, also DetectionOutput hetero tests (CPU and GPU)

This commit is contained in:
myshevts 2021-11-22 17:06:30 +03:00
parent e334783026
commit b481db79b5
5 changed files with 74 additions and 4 deletions

View File

@ -0,0 +1,18 @@
// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <auto_batching/auto_batching_tests.hpp>
const std::vector<bool> get_vs_set{ true, false };
const std::vector<size_t> num_streams{ 1, 2 };
const std::vector<size_t> num_requests{ 1, 3, 8, 9, 16, 64 };
const std::vector<size_t> num_batch{ 1, 4, 8, 16, 32, 64, 128, 256 };
INSTANTIATE_TEST_SUITE_P(smoke_AutoBatching_CPU, AutoBatching_Test,
::testing::Combine(
::testing::Values(CommonTestUtils::DEVICE_CPU),
::testing::ValuesIn(get_vs_set),
::testing::ValuesIn(num_streams),
::testing::ValuesIn(num_requests),
::testing::ValuesIn(num_batch)),
AutoBatching_Test::getTestCaseName);

View File

@ -57,6 +57,8 @@ const auto params3Inputs = ::testing::Combine(
);
INSTANTIATE_TEST_SUITE_P(smoke_DetectionOutput3In, DetectionOutputLayerTest, params3Inputs, DetectionOutputLayerTest::getTestCaseName);
//INSTANTIATE_TEST_SUITE_P(smoke_DetectionOutput3In_Hetero, DetectionOutputLayerTestWithAutoBatching,
// params3Inputs, DetectionOutputLayerTestWithAutoBatching::getTestCaseName);
/* =============== 5 inputs cases =============== */
@ -81,5 +83,7 @@ const auto params5Inputs = ::testing::Combine(
);
INSTANTIATE_TEST_SUITE_P(smoke_DetectionOutput5In, DetectionOutputLayerTest, params5Inputs, DetectionOutputLayerTest::getTestCaseName);
//INSTANTIATE_TEST_SUITE_P(smoke_DetectionOutput5In_Hetero, DetectionOutputLayerTestWithAutoBatching,
// params5Inputs, DetectionOutputLayerTestWithAutoBatching::getTestCaseName);
} // namespace

View File

@ -57,6 +57,8 @@ const auto params3Inputs = ::testing::Combine(
);
INSTANTIATE_TEST_SUITE_P(smoke_DetectionOutput3In, DetectionOutputLayerTest, params3Inputs, DetectionOutputLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_DetectionOutput3In_HETERO, DetectionOutputLayerTestWithAutoBatching,
params3Inputs, DetectionOutputLayerTestWithAutoBatching::getTestCaseName);
/* =============== 5 inputs cases =============== */
@ -81,5 +83,7 @@ const auto params5Inputs = ::testing::Combine(
);
INSTANTIATE_TEST_SUITE_P(smoke_DetectionOutput5In, DetectionOutputLayerTest, params5Inputs, DetectionOutputLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_DetectionOutput5In_Hetero, DetectionOutputLayerTestWithAutoBatching,
params5Inputs, DetectionOutputLayerTestWithAutoBatching::getTestCaseName);
} // namespace

View File

@ -69,4 +69,10 @@ class DetectionOutputLayerTest : public testing::WithParamInterface<DetectionOut
void SetUp() override;
};
class DetectionOutputLayerTestWithAutoBatching : public DetectionOutputLayerTest {
public:
static std::string getTestCaseName(const testing::TestParamInfo<DetectionOutputParams>& obj);
protected:
void SetUp() override;
};
} // namespace LayerTestsDefinitions

View File

@ -27,10 +27,6 @@ std::string DetectionOutputLayerTest::getTestCaseName(const testing::TestParamIn
inShapes.resize(3);
}
for (size_t i = 0; i < inShapes.size(); i++) {
inShapes[i][0] = batch;
}
std::ostringstream result;
result << "IS = { ";
result << "LOC=" << CommonTestUtils::vec2str(inShapes[0]) << "_";
@ -148,8 +144,50 @@ void DetectionOutputLayerTest::SetUp() {
auto params = ngraph::builder::makeParams(ngraph::element::f32, inShapes);
auto paramOuts = ngraph::helpers::convert2OutputVector(ngraph::helpers::castOps2Nodes<ngraph::opset3::Parameter>(params));
auto detOut = ngraph::builder::makeDetectionOutput(paramOuts, attrs);
ngraph::ResultVector results{std::make_shared<ngraph::opset3::Result>(detOut)};
function = std::make_shared<ngraph::Function>(results, params, "DetectionOutput");
}
std::string DetectionOutputLayerTestWithAutoBatching::getTestCaseName(const testing::TestParamInfo<DetectionOutputParams>& obj) {
return DetectionOutputLayerTest::getTestCaseName(obj) + "_WITH_AUTO_BATCH";
}
void DetectionOutputLayerTestWithAutoBatching::SetUp() {
DetectionOutputAttributes commonAttrs;
ParamsWhichSizeDepends specificAttrs;
size_t batch;
std::tie(commonAttrs, specificAttrs, batch, attrs.objectness_score, targetDevice) = this->GetParam();
std::tie(attrs.num_classes, attrs.background_label_id, attrs.top_k, attrs.keep_top_k, attrs.code_type, attrs.nms_threshold, attrs.confidence_threshold,
attrs.clip_after_nms, attrs.clip_before_nms, attrs.decrease_label_id) = commonAttrs;
inShapes.resize(numInputs);
std::tie(attrs.variance_encoded_in_target, attrs.share_location, attrs.normalized, attrs.input_height, attrs.input_width,
inShapes[idxLocation], inShapes[idxConfidence], inShapes[idxPriors], inShapes[idxArmConfidence], inShapes[idxArmLocation]) = specificAttrs;
if (inShapes[idxArmConfidence].empty()) {
inShapes.resize(3);
}
auto params = ngraph::builder::makeParams(ngraph::element::f32, inShapes);
auto paramOuts = ngraph::helpers::convert2OutputVector(ngraph::helpers::castOps2Nodes<ngraph::opset3::Parameter>(params));
// no-op with Eltwise that adds zeros
// (so that we can tests Auto-Batching's HETERO code-path that splits the DetectionOutput and the rest of the network)
ngraph::OutputVector outs;
for (int i = 0; i < inShapes.size(); i++) {
auto shape = inShapes[i];
auto memory_constant = ngraph::builder::makeConstant<float>(ngraph::element::f32, shape,
std::vector<float>(0, ngraph::shape_size(shape)));
auto values = std::make_shared<ngraph::opset5::ReadValue>(memory_constant, "memory");
auto add = ngraph::builder::makeEltwise(paramOuts[i], values, ngraph::helpers::EltwiseTypes::ADD);
outs.push_back(add->output(0));
}
auto detOut = ngraph::builder::makeDetectionOutput(outs, attrs);
ngraph::ResultVector results{std::make_shared<ngraph::opset3::Result>(detOut)};
function = std::make_shared<ngraph::Function>(results, params, "EltWiseWithDetectionOutput");
}
} // namespace LayerTestsDefinitions