[IE][VPU][GT][IE Transformations]: Fixes for post processing model (#2041)
* Disable StridedSlice to crop convertion in dynamic cases * NMS: increase shave requirements for some cases * Update firmware * Add test cases
This commit is contained in:
parent
dc8bbd930f
commit
928eed9a51
@ -19,7 +19,7 @@ set(VPU_SUPPORTED_FIRMWARES usb-ma2450 usb-ma2x8x pcie-ma248x)
|
||||
# Default packages
|
||||
#
|
||||
|
||||
set(FIRMWARE_PACKAGE_VERSION 1354)
|
||||
set(FIRMWARE_PACKAGE_VERSION 1360)
|
||||
set(VPU_CLC_MA2X8X_VERSION "movi-cltools-20.02.0")
|
||||
|
||||
#
|
||||
|
@ -22,9 +22,9 @@ ngraph::pass::ConvertStridedSliceToCropMatcher::ConvertStridedSliceToCropMatcher
|
||||
std::vector<int64_t> end_mask = {0, 0, 0, 0};
|
||||
auto m_slice = std::make_shared<ngraph::opset1::StridedSlice>(data, m_begin, m_end, m_stride, begin_mask, end_mask);
|
||||
|
||||
ngraph::matcher_pass_callback callback = [](pattern::Matcher& m) {
|
||||
ngraph::matcher_pass_callback callback = [this](pattern::Matcher& m) {
|
||||
auto slice = std::dynamic_pointer_cast<ngraph::opset1::StridedSlice> (m.get_match_root());
|
||||
if (!slice) {
|
||||
if (!slice || m_transformation_callback(slice)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vpu/model/stage.hpp>
|
||||
|
||||
namespace vpu {
|
||||
|
||||
class NonMaxSuppression : public StageNode {
|
||||
protected:
|
||||
StagePtr cloneImpl() const override;
|
||||
|
||||
void propagateDataOrderImpl(StageDataInfo<DimsOrder>& orderInfo) override;
|
||||
|
||||
void getDataStridesRequirementsImpl(StageDataInfo<StridesRequirement>& stridesInfo) override;
|
||||
|
||||
void finalizeDataLayoutImpl() override;
|
||||
|
||||
void getBatchSupportInfoImpl(StageDataInfo<BatchSupport>& batchInfo) override;
|
||||
|
||||
StageSHAVEsRequirements getSHAVEsRequirementsImpl() const override;
|
||||
|
||||
void initialCheckImpl() const override;
|
||||
|
||||
void finalCheckImpl() const override;
|
||||
|
||||
void serializeParamsImpl(BlobSerializer& serializer) const override;
|
||||
|
||||
void serializeDataImpl(BlobSerializer& serializer) const override;
|
||||
};
|
||||
|
||||
} // namespace vpu
|
@ -384,12 +384,16 @@ ModelPtr FrontEnd::runCommonPasses(ie::ICNNNetwork& network, const UnsupportedLa
|
||||
VPU_LOGGER_SECTION(env.log);
|
||||
|
||||
auto convertNetwork = [&convertedNetwork, &originalOrConvertNetwork]() {
|
||||
// disable GeLU decomposition
|
||||
// disable transformations for some cases
|
||||
const auto transformationsPredicate = [](const std::shared_ptr<const ngraph::Node> &node) -> bool {
|
||||
return std::dynamic_pointer_cast<const ngraph::opset3::Gelu>(node) ||
|
||||
(std::dynamic_pointer_cast<const ngraph::opset3::MatMul>(node) &&
|
||||
std::dynamic_pointer_cast<const ngraph::vpu::op::DynamicShapeResolver>(node->input_value(0).get_node_shared_ptr())) ||
|
||||
std::dynamic_pointer_cast<const ngraph::opset4::SoftPlus>(node);
|
||||
const bool casesWithDynamicOrStaticUsage = std::dynamic_pointer_cast<const ngraph::opset3::Gelu>(node) ||
|
||||
std::dynamic_pointer_cast<const ngraph::opset4::SoftPlus>(node);
|
||||
|
||||
const bool casesWithOnlyDynamicUsage = (std::dynamic_pointer_cast<const ngraph::opset3::MatMul>(node) ||
|
||||
std::dynamic_pointer_cast<const ngraph::opset3::StridedSlice>(node)) &&
|
||||
std::dynamic_pointer_cast<const ngraph::vpu::op::DynamicShapeResolver>(node->input_value(0).get_node_shared_ptr());
|
||||
|
||||
return casesWithDynamicOrStaticUsage || casesWithOnlyDynamicUsage;
|
||||
};
|
||||
|
||||
auto nGraphFunc = originalOrConvertNetwork->getFunction();
|
||||
|
@ -2,76 +2,81 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <vpu/stages/nms.hpp>
|
||||
|
||||
#include <vpu/frontend/frontend.hpp>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
|
||||
namespace vpu {
|
||||
|
||||
namespace {
|
||||
StagePtr NonMaxSuppression::cloneImpl() const {
|
||||
return std::make_shared<NonMaxSuppression>(*this);
|
||||
}
|
||||
|
||||
class NonMaxSuppression final : public StageNode {
|
||||
private:
|
||||
StagePtr cloneImpl() const override {
|
||||
return std::make_shared<NonMaxSuppression>(*this);
|
||||
}
|
||||
void NonMaxSuppression::propagateDataOrderImpl(StageDataInfo<DimsOrder>& orderInfo) {
|
||||
}
|
||||
|
||||
void propagateDataOrderImpl(StageDataInfo<DimsOrder>& orderInfo) override {
|
||||
}
|
||||
void NonMaxSuppression::getDataStridesRequirementsImpl(StageDataInfo<StridesRequirement>& stridesInfo) {
|
||||
}
|
||||
|
||||
void getDataStridesRequirementsImpl(StageDataInfo<StridesRequirement>& stridesInfo) override {
|
||||
}
|
||||
void NonMaxSuppression::finalizeDataLayoutImpl() {
|
||||
}
|
||||
|
||||
void finalizeDataLayoutImpl() override {
|
||||
}
|
||||
void NonMaxSuppression::getBatchSupportInfoImpl(StageDataInfo<BatchSupport>& batchInfo) {
|
||||
}
|
||||
|
||||
void getBatchSupportInfoImpl(StageDataInfo<BatchSupport>& batchInfo) override {
|
||||
}
|
||||
StageSHAVEsRequirements NonMaxSuppression::getSHAVEsRequirementsImpl() const {
|
||||
// Current NMS implementation doesn't allow calculation of `> boxesThreshold` boxes using one SHAVE
|
||||
constexpr int boxesThreshold = 3650;
|
||||
|
||||
StageSHAVEsRequirements getSHAVEsRequirementsImpl() const override {
|
||||
const auto& inDesc = input(0)->desc();
|
||||
const auto& maxBoxesNum = inDesc.dim(Dim::H);
|
||||
|
||||
if (maxBoxesNum > boxesThreshold) {
|
||||
return StageSHAVEsRequirements::NeedMax;
|
||||
} else {
|
||||
return StageSHAVEsRequirements::OnlyOne;
|
||||
}
|
||||
}
|
||||
|
||||
void initialCheckImpl() const override {
|
||||
assertInputsOutputsTypes(this,
|
||||
{{DataType::FP16},
|
||||
{DataType::FP16},
|
||||
{DataType::S32},
|
||||
{DataType::FP16},
|
||||
{DataType::FP16}},
|
||||
{{DataType::S32}});
|
||||
}
|
||||
void NonMaxSuppression::initialCheckImpl() const {
|
||||
assertInputsOutputsTypes(this,
|
||||
{{DataType::FP16},
|
||||
{DataType::FP16},
|
||||
{DataType::S32},
|
||||
{DataType::FP16},
|
||||
{DataType::FP16}},
|
||||
{{DataType::S32}});
|
||||
}
|
||||
|
||||
void finalCheckImpl() const override {
|
||||
}
|
||||
void NonMaxSuppression::finalCheckImpl() const {
|
||||
}
|
||||
|
||||
void serializeParamsImpl(BlobSerializer& serializer) const override {
|
||||
bool center_point_box = attrs().get<bool>("center_point_box");
|
||||
void NonMaxSuppression::serializeParamsImpl(BlobSerializer& serializer) const {
|
||||
bool center_point_box = attrs().get<bool>("center_point_box");
|
||||
|
||||
serializer.append(static_cast<int32_t>(center_point_box));
|
||||
}
|
||||
serializer.append(static_cast<int32_t>(center_point_box));
|
||||
}
|
||||
|
||||
void serializeDataImpl(BlobSerializer& serializer) const override {
|
||||
IE_ASSERT(inputEdges().size() >= 2 && inputEdges().size() <= 5);
|
||||
IE_ASSERT(outputEdges().size() == 1);
|
||||
void NonMaxSuppression::serializeDataImpl(BlobSerializer& serializer) const {
|
||||
IE_ASSERT(inputEdges().size() >= 2 && inputEdges().size() <= 5);
|
||||
IE_ASSERT(outputEdges().size() == 1);
|
||||
|
||||
auto input1 = inputEdges()[0]->input();
|
||||
auto input2 = inputEdges()[1]->input();
|
||||
auto input3 = inputEdges()[2]->input();
|
||||
auto input4 = inputEdges()[3]->input();
|
||||
auto input5 = inputEdges()[4]->input();
|
||||
auto output = outputEdges()[0]->output();
|
||||
auto input1 = inputEdges()[0]->input();
|
||||
auto input2 = inputEdges()[1]->input();
|
||||
auto input3 = inputEdges()[2]->input();
|
||||
auto input4 = inputEdges()[3]->input();
|
||||
auto input5 = inputEdges()[4]->input();
|
||||
auto output = outputEdges()[0]->output();
|
||||
|
||||
input1->serializeBuffer(serializer);
|
||||
input2->serializeBuffer(serializer);
|
||||
output->serializeBuffer(serializer);
|
||||
input3->serializeBuffer(serializer);
|
||||
input4->serializeBuffer(serializer);
|
||||
input5->serializeBuffer(serializer);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
input1->serializeBuffer(serializer);
|
||||
input2->serializeBuffer(serializer);
|
||||
output->serializeBuffer(serializer);
|
||||
input3->serializeBuffer(serializer);
|
||||
input4->serializeBuffer(serializer);
|
||||
input5->serializeBuffer(serializer);
|
||||
}
|
||||
|
||||
void FrontEnd::parseNonMaxSuppression(const Model& model, const ie::CNNLayerPtr& _layer, const DataVector& inputs, const DataVector& outputs) const {
|
||||
auto layer = std::dynamic_pointer_cast<ie::NonMaxSuppressionLayer>(_layer);
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <vpu/stages/nms.hpp>
|
||||
#include <vpu/frontend/frontend.hpp>
|
||||
|
||||
#include <ngraph/op/non_max_suppression.hpp>
|
||||
@ -13,28 +14,12 @@ namespace vpu {
|
||||
|
||||
namespace {
|
||||
|
||||
class StaticShapeNMS final : public StageNode {
|
||||
class StaticShapeNMS final : public NonMaxSuppression {
|
||||
private:
|
||||
StagePtr cloneImpl() const override {
|
||||
return std::make_shared<StaticShapeNMS>(*this);
|
||||
}
|
||||
|
||||
void propagateDataOrderImpl(StageDataInfo<DimsOrder>& orderInfo) override {
|
||||
}
|
||||
|
||||
void getDataStridesRequirementsImpl(StageDataInfo<StridesRequirement>& stridesInfo) override {
|
||||
}
|
||||
|
||||
void finalizeDataLayoutImpl() override {
|
||||
}
|
||||
|
||||
void getBatchSupportInfoImpl(StageDataInfo<BatchSupport>& batchInfo) override {
|
||||
}
|
||||
|
||||
StageSHAVEsRequirements getSHAVEsRequirementsImpl() const override {
|
||||
return StageSHAVEsRequirements::OnlyOne;
|
||||
}
|
||||
|
||||
void initialCheckImpl() const override {
|
||||
assertInputsOutputsTypes(this,
|
||||
{{DataType::FP16},
|
||||
@ -46,16 +31,6 @@ private:
|
||||
{DataType::S32}});
|
||||
}
|
||||
|
||||
void finalCheckImpl() const override {
|
||||
initialCheckImpl();
|
||||
}
|
||||
|
||||
void serializeParamsImpl(BlobSerializer& serializer) const override {
|
||||
bool center_point_box = attrs().get<bool>("center_point_box");
|
||||
|
||||
serializer.append(static_cast<int32_t>(center_point_box));
|
||||
}
|
||||
|
||||
void serializeDataImpl(BlobSerializer& serializer) const override {
|
||||
auto input1 = inputEdges()[0]->input();
|
||||
auto input2 = inputEdges()[1]->input();
|
||||
|
@ -98,7 +98,8 @@ std::vector<StaticShapeNMSParam> NMSParams = {
|
||||
std::make_tuple(1, 10, 5, 10, 0., 0.),
|
||||
std::make_tuple(2, 100, 5, 10, 0., 0.),
|
||||
std::make_tuple(3, 10, 5, 2, 0.5, 0.),
|
||||
std::make_tuple(1, 1000, 1, 2000, 0.5, 0.)
|
||||
std::make_tuple(1, 1000, 1, 2000, 0.5, 0.),
|
||||
std::make_tuple(1, 8200, 1, 8200, 0.5, 0.),
|
||||
};
|
||||
|
||||
std::vector<InferenceEngine::Precision> NMSPrecisions = {
|
||||
|
@ -57,6 +57,7 @@ std::vector<StridedSliceParams> testCases = {
|
||||
{ { { 1, 10, 70 }, { 1, 12, 100 } }, { 0, 4, 0 }, { 0, 9, 0 }, { 1, 2, 1 }, { 1, 0, 1 }, { 1, 0, 1 }, {}, {}, {} },
|
||||
{ { { 1, 10, 60 }, { 1, 12, 100 } }, { 0, -8, 0 }, { 0, -6, 0 }, { 1, 2, 1 }, { 1, 0, 1 }, { 1, 0, 1 }, {}, {}, {} },
|
||||
{ { { 1, 2, 2, 2 }, { 1, 3, 3, 3 } }, { 0, 0, 0, 0 }, { 1, -1, -1, -1 }, { 1, 2, 1, 1 }, {0, 0, 0, 0}, {1, 1, 1, 1}, {}, {}, {} },
|
||||
{ { { 4000, 2 }, { 8232, 2 } }, { 0, 1 }, { -1, 2 }, { 1, 1 }, {0, 0 }, {1, 1 }, {}, {}, {} },
|
||||
};
|
||||
|
||||
std::vector<DataType> precisions = {
|
||||
|
Loading…
Reference in New Issue
Block a user