From af661ae0fe243f922e8c8d97642084768c4cc852 Mon Sep 17 00:00:00 2001 From: Nikita Kudriavtsev Date: Fri, 9 Oct 2020 12:09:14 +0300 Subject: [PATCH] [IE][VPU]: Added wrapper for LogicalNot layer (#2562) --- .../include/vpu/frontend/frontend.hpp | 6 ++++ .../src/frontend/frontend.cpp | 5 +-- .../src/stages/activation.cpp | 33 +++++++++++++++++++ .../single_layer_tests/logical.cpp | 15 +++++---- .../skip_tests_config.cpp | 2 -- 5 files changed, 49 insertions(+), 12 deletions(-) create mode 100644 inference-engine/src/vpu/graph_transformer/src/stages/activation.cpp diff --git a/inference-engine/src/vpu/graph_transformer/include/vpu/frontend/frontend.hpp b/inference-engine/src/vpu/graph_transformer/include/vpu/frontend/frontend.hpp index 124eea7a29f..3667c2c921d 100644 --- a/inference-engine/src/vpu/graph_transformer/include/vpu/frontend/frontend.hpp +++ b/inference-engine/src/vpu/graph_transformer/include/vpu/frontend/frontend.hpp @@ -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 _unbatchedOutputs; ie::details::caseless_map> _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; const ie::details::caseless_map parsers; diff --git a/inference-engine/src/vpu/graph_transformer/src/frontend/frontend.cpp b/inference-engine/src/vpu/graph_transformer/src/frontend/frontend.cpp index 1a82be26787..1834b33ee23 100644 --- a/inference-engine/src/vpu/graph_transformer/src/frontend/frontend.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/frontend/frontend.cpp @@ -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"); } diff --git a/inference-engine/src/vpu/graph_transformer/src/stages/activation.cpp b/inference-engine/src/vpu/graph_transformer/src/stages/activation.cpp new file mode 100644 index 00000000000..537627ed048 --- /dev/null +++ b/inference-engine/src/vpu/graph_transformer/src/stages/activation.cpp @@ -0,0 +1,33 @@ +// Copyright (C) 2020 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +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(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 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 diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/logical.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/logical.cpp index 6093e11f547..85ff32ef2b4 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/logical.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/logical.cpp @@ -57,7 +57,6 @@ std::map, std::vector>> inputShapes = { }; std::map, std::vector>> inputShapesNot = { - {{1}, {}}, {{5}, {}}, {{2, 200}, {}}, {{1, 3, 20}, {}}, @@ -69,6 +68,10 @@ std::vector eltwiseLogicalTypesInt = { ngraph::helpers::LogicalTypes::LOGICAL_AND, }; +std::map 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 diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/skip_tests_config.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/skip_tests_config.cpp index f337481b1b2..102e1b0676d 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/skip_tests_config.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/skip_tests_config.cpp @@ -23,7 +23,5 @@ std::vector disabledTestPatterns() { R"(.*(IEClassLoadNetwork).*(QueryNetworkMULTIWithHETERONoThrow_V10|QueryNetworkHETEROWithMULTINoThrow_V10).*)", // TODO: Issue: 34348 R"(.*IEClassGetAvailableDevices.*)", - // TODO: Issue: 38643 - R"(.*EltwiseLogicalNotInt.*)", }; }