[IE][VPU]: Added wrapper for LogicalNot layer (#2562)
This commit is contained in:
parent
694d1dcd25
commit
af661ae0fe
@ -155,6 +155,8 @@ public:
|
||||
void parseGelu(const Model& model, const ie::CNNLayerPtr& layer, const DataVector& inputs, const DataVector& outputs) const;
|
||||
void parseSoftPlus(const Model& model, const ie::CNNLayerPtr& layer, const DataVector& inputs, const DataVector& outputs) const;
|
||||
void parseSwish(const Model& model, const ie::CNNLayerPtr& layer, const DataVector& inputs, const DataVector& outputs) const;
|
||||
void parseActivation(const Model& model, const ie::CNNLayerPtr& layer, const DataVector& inputs, const DataVector& outputs) const;
|
||||
void parseLogicalNot(const Model& model, const ie::CNNLayerPtr& layer, const DataVector& inputs, const DataVector& outputs) const;
|
||||
|
||||
//
|
||||
// Special layers
|
||||
@ -211,6 +213,10 @@ private:
|
||||
std::unordered_set<ie::DataPtr> _unbatchedOutputs;
|
||||
ie::details::caseless_map<std::string, std::vector<CustomLayer::Ptr>> _customLayers;
|
||||
|
||||
#define LAYER_PARSER(functor_name) \
|
||||
[this](const Model& model, const ie::CNNLayerPtr& layer, const DataVector& inputs, const DataVector& outputs) \
|
||||
{ functor_name(model, layer, inputs, outputs); }
|
||||
|
||||
using LayerParser = std::function<void(const Model&, const ie::CNNLayerPtr&, const DataVector&, const DataVector&)>;
|
||||
const ie::details::caseless_map<std::string, LayerParser> parsers;
|
||||
|
||||
|
@ -39,10 +39,6 @@
|
||||
|
||||
namespace vpu {
|
||||
|
||||
#define LAYER_PARSER(functor_name) \
|
||||
[this](const Model& model, const ie::CNNLayerPtr& layer, const DataVector& inputs, const DataVector& outputs) \
|
||||
{ functor_name(model, layer, inputs, outputs); }
|
||||
|
||||
FrontEnd::FrontEnd(StageBuilder::Ptr stageBuilder, const ie::ICore* core)
|
||||
: _stageBuilder(std::move(stageBuilder)),
|
||||
_core(core),
|
||||
@ -133,6 +129,7 @@ FrontEnd::FrontEnd(StageBuilder::Ptr stageBuilder, const ie::ICore* core)
|
||||
{"Gelu", LAYER_PARSER(parseGelu)},
|
||||
{"SoftPlus", LAYER_PARSER(parseSoftPlus)},
|
||||
{"Swish", LAYER_PARSER(parseSwish)},
|
||||
{"Activation", LAYER_PARSER(parseActivation)},
|
||||
}} {
|
||||
VPU_THROW_UNLESS(_core != nullptr, "Argument core is null");
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <vpu/frontend/frontend.hpp>
|
||||
|
||||
using namespace InferenceEngine;
|
||||
|
||||
namespace vpu {
|
||||
|
||||
void FrontEnd::parseLogicalNot(const Model &model, const ie::CNNLayerPtr &layer, const DataVector &inputs, const DataVector &outputs) const {
|
||||
LayerParams params = {layer->name, "Eltwise", layer->precision};
|
||||
auto res = std::make_shared<InferenceEngine::EltwiseLayer>(params);
|
||||
res->_operation = InferenceEngine::EltwiseLayer::Logical_NOT;
|
||||
|
||||
parseEltwise(model, res, inputs, outputs);
|
||||
}
|
||||
|
||||
void FrontEnd::parseActivation(const Model& model, const ie::CNNLayerPtr& layer, const DataVector& inputs, const DataVector& outputs) const {
|
||||
const ie::details::caseless_map<std::string, LayerParser> activationParsers {
|
||||
{"not", LAYER_PARSER(parseLogicalNot)},
|
||||
};
|
||||
|
||||
const auto type = layer->GetParamAsString("type");
|
||||
|
||||
const auto activationParserIt = activationParsers.find(type);
|
||||
VPU_THROW_UNSUPPORTED_UNLESS(activationParserIt != activationParsers.end(),
|
||||
"Failed to compile layer \"%v\"(type = %v) ", layer->name, type);
|
||||
|
||||
activationParserIt->second(model, layer, inputs, outputs);
|
||||
}
|
||||
|
||||
} // namespace vpu
|
@ -57,7 +57,6 @@ std::map<std::vector<size_t>, std::vector<std::vector<size_t >>> inputShapes = {
|
||||
};
|
||||
|
||||
std::map<std::vector<size_t>, std::vector<std::vector<size_t >>> inputShapesNot = {
|
||||
{{1}, {}},
|
||||
{{5}, {}},
|
||||
{{2, 200}, {}},
|
||||
{{1, 3, 20}, {}},
|
||||
@ -69,6 +68,10 @@ std::vector<ngraph::helpers::LogicalTypes> eltwiseLogicalTypesInt = {
|
||||
ngraph::helpers::LogicalTypes::LOGICAL_AND,
|
||||
};
|
||||
|
||||
std::map<std::string, std::string> additional_config = {
|
||||
{InferenceEngine::MYRIAD_DETECT_NETWORK_BATCH, CONFIG_VALUE(NO)}
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(smoke_EltwiseLogicalInt,
|
||||
LogicalLayerTestVPU,
|
||||
::testing::Combine(
|
||||
@ -78,19 +81,19 @@ INSTANTIATE_TEST_CASE_P(smoke_EltwiseLogicalInt,
|
||||
::testing::Values(ngraph::helpers::InputLayerType::PARAMETER),
|
||||
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
|
||||
::testing::Values(CommonTestUtils::DEVICE_MYRIAD),
|
||||
::testing::Values(Config{{InferenceEngine::MYRIAD_DETECT_NETWORK_BATCH, CONFIG_VALUE(NO)}})),
|
||||
::testing::Values(additional_config)),
|
||||
LogicalLayerTest::getTestCaseName);
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(smoke_EltwiseLogicalNotInt,
|
||||
LogicalLayerTestVPU,
|
||||
LogicalLayerTest,
|
||||
::testing::Combine(
|
||||
::testing::ValuesIn(LogicalLayerTest::combineShapes(inputShapesNot)),
|
||||
::testing::Values(InferenceEngine::Precision::BOOL),
|
||||
::testing::Values(InferenceEngine::Precision::I32),
|
||||
::testing::Values(ngraph::helpers::LogicalTypes::LOGICAL_NOT),
|
||||
::testing::Values(ngraph::helpers::InputLayerType::PARAMETER),
|
||||
::testing::Values(ngraph::helpers::InputLayerType::CONSTANT),
|
||||
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
|
||||
::testing::Values(CommonTestUtils::DEVICE_MYRIAD),
|
||||
::testing::Values(Config{{InferenceEngine::MYRIAD_DETECT_NETWORK_BATCH, CONFIG_VALUE(NO)}})),
|
||||
::testing::Values(additional_config)),
|
||||
LogicalLayerTest::getTestCaseName);
|
||||
|
||||
} // namespace
|
||||
|
@ -23,7 +23,5 @@ std::vector<std::string> disabledTestPatterns() {
|
||||
R"(.*(IEClassLoadNetwork).*(QueryNetworkMULTIWithHETERONoThrow_V10|QueryNetworkHETEROWithMULTINoThrow_V10).*)",
|
||||
// TODO: Issue: 34348
|
||||
R"(.*IEClassGetAvailableDevices.*)",
|
||||
// TODO: Issue: 38643
|
||||
R"(.*EltwiseLogicalNotInt.*)",
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user