[CPU] ExperimentalDetectronTopKROIs dynamic done (#8922)

This commit is contained in:
Egor Shulman 2021-12-03 09:56:44 +03:00 committed by GitHub
parent 36a3033cfe
commit e16e91e328
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 172 additions and 6 deletions

View File

@ -16,10 +16,6 @@ using namespace InferenceEngine;
bool MKLDNNExperimentalDetectronTopKROIsNode::isSupportedOperation(const std::shared_ptr<const ngraph::Node>& op, std::string& errorMessage) noexcept {
try {
if (isDynamicNgraphNode(op)) {
errorMessage = "Doesn't support op with dynamic shapes";
return false;
}
const auto topKROI = std::dynamic_pointer_cast<const ngraph::opset6::ExperimentalDetectronTopKROIs>(op);
if (!topKROI) {
errorMessage = "Only opset6 ExperimentalDetectronTopKROIs operation is supported";
@ -44,10 +40,10 @@ MKLDNNExperimentalDetectronTopKROIsNode::MKLDNNExperimentalDetectronTopKROIsNode
IE_THROW() << "Operation with name '" << op->get_friendly_name() <<
"' is not an instance of ExperimentalDetectronTopKROIs from opset6.";
if (getOriginalInputsNumber() != 2 || getOriginalOutputsNumber() != 1)
if (inputShapes.size() != 2 || outputShapes.size() != 1)
IE_THROW() << errorPrefix << " has incorrect number of input/output edges!";
if (op->get_input_shape(INPUT_ROIS).size() != 2 || op->get_input_shape(INPUT_PROBS).size() != 1)
if (getInputShapeAtPort(INPUT_ROIS).getDims().size() != 2 || getInputShapeAtPort(INPUT_PROBS).getDims().size() != 1)
IE_THROW() << errorPrefix << " has nsupported input shape";
max_rois_num_ = topKROI->get_max_rois();

View File

@ -19,6 +19,10 @@ public:
void execute(mkldnn::stream strm) override;
bool created() const override;
bool needShapeInfer() const override { return false; };
bool needPrepareParams() const override { return false; };
void executeDynamicImpl(mkldnn::stream strm) override { execute(strm); };
static bool isSupportedOperation(const std::shared_ptr<const ngraph::Node>& op, std::string& errorMessage) noexcept;
private:

View File

@ -0,0 +1,55 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <vector>
#include "single_layer_tests/experimental_detectron_topkrois.hpp"
using namespace ov::test;
using namespace ov::test::subgraph;
namespace {
std::vector<int64_t> maxRois {
1000,
1500,
2000,
2500
};
const std::vector<std::vector<InputShape>> staticInputShape = {
static_shapes_to_test_representation({{3000, 4}, {3000}}),
static_shapes_to_test_representation({{4200, 4}, {4200}}),
static_shapes_to_test_representation({{4500, 4}, {4500}})
};
INSTANTIATE_TEST_SUITE_P(smoke_ExperimentalDetectronTopKROIs_static, ExperimentalDetectronTopKROIsLayerTest,
::testing::Combine(
::testing::ValuesIn(staticInputShape),
::testing::ValuesIn(maxRois),
::testing::Values(ElementType::f32),
::testing::Values(CommonTestUtils::DEVICE_CPU)),
ExperimentalDetectronTopKROIsLayerTest::getTestCaseName);
const std::vector<std::vector<InputShape>> dynamicInputShape = {
{
{
{{-1, 4}, {{5000, 4}, {4000, 4}, {3500, 4}}},
{{-1}, {{5000}, {4000}, {3500}}}
}
},
{
{
{{{1000, 5000}, 4}, {{5000, 4}, {3000, 4}, {2500, 4}}},
{{{1000, 5000}}, {{5000}, {3000}, {2500}}}
}
}
};
INSTANTIATE_TEST_SUITE_P(smoke_ExperimentalROI_dynamic, ExperimentalDetectronTopKROIsLayerTest,
::testing::Combine(
::testing::ValuesIn(dynamicInputShape),
::testing::ValuesIn(maxRois),
::testing::Values(ElementType::f32),
::testing::Values(CommonTestUtils::DEVICE_CPU)),
ExperimentalDetectronTopKROIsLayerTest::getTestCaseName);
} // namespace

View File

@ -0,0 +1,19 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <shared_test_classes/single_layer/experimental_detectron_topkrois.hpp>
namespace ov {
namespace test {
namespace subgraph {
TEST_P(ExperimentalDetectronTopKROIsLayerTest, ExperimentalDetectronTopKROIsTests) {
run();
}
} // namespace subgraph
} // namespace test
} // namespace ov

View File

@ -0,0 +1,32 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include "ngraph_functions/utils/ngraph_helpers.hpp"
#include "common_test_utils/common_utils.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
namespace ov {
namespace test {
namespace subgraph {
typedef std::tuple<
std::vector<InputShape>, // input shape
int64_t , // Max rois
ElementType, // Network precision
std::string // Device name
> ExperimentalDetectronTopKROIsTestParams;
class ExperimentalDetectronTopKROIsLayerTest : public testing::WithParamInterface<ExperimentalDetectronTopKROIsTestParams>,
virtual public SubgraphBaseTest {
protected:
void SetUp() override;
public:
static std::string getTestCaseName(const testing::TestParamInfo<ExperimentalDetectronTopKROIsTestParams>& obj);
};
} // namespace subgraph
} // namespace test
} // namespace ov

View File

@ -0,0 +1,60 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "ngraph_functions/builders.hpp"
#include "functional_test_utils/ov_tensor_utils.hpp"
#include "shared_test_classes/single_layer/experimental_detectron_topkrois.hpp"
namespace ov {
namespace test {
namespace subgraph {
std::string ExperimentalDetectronTopKROIsLayerTest::getTestCaseName(const testing::TestParamInfo<ExperimentalDetectronTopKROIsTestParams>& obj) {
std::vector<InputShape> inputShapes;
int64_t maxRois;
ElementType netPrecision;
std::string targetName;
std::tie(inputShapes, maxRois, netPrecision, targetName) = obj.param;
std::ostringstream result;
if (inputShapes.front().first.size() != 0) {
result << "IS=(";
for (const auto &shape : inputShapes) {
result << CommonTestUtils::partialShape2str({shape.first}) << "_";
}
result.seekp(-1, result.cur);
result << ")_";
}
result << "TS=";
for (const auto& shape : inputShapes) {
for (const auto& item : shape.second) {
result << CommonTestUtils::vec2str(item) << "_";
}
}
result << "maxRois=" << maxRois << "_";
result << "netPRC=" << netPrecision << "_";
result << "trgDev=" << targetName;
return result.str();
}
void ExperimentalDetectronTopKROIsLayerTest::SetUp() {
std::vector<InputShape> inputShapes;
int64_t maxRois;
ElementType netPrecision;
std::string targetName;
std::tie(inputShapes, maxRois, netPrecision, targetName) = this->GetParam();
inType = outType = netPrecision;
targetDevice = targetName;
init_input_shapes(inputShapes);
auto params = ngraph::builder::makeDynamicParams(netPrecision, inputDynamicShapes);
auto paramOuts = ngraph::helpers::convert2OutputVector(ngraph::helpers::castOps2Nodes<ngraph::op::Parameter>(params));
auto experimentalDetectronTopKROIs = std::make_shared<ov::op::v6::ExperimentalDetectronTopKROIs>(paramOuts[0], paramOuts[1], maxRois);
function = std::make_shared<ov::Function>(ov::OutputVector {experimentalDetectronTopKROIs->output(0)}, "ExperimentalDetectronTopKROIs");
}
} // namespace subgraph
} // namespace test
} // namespace ov