[GNA]specific execution order for delayer copy layer (#2117)

[GNA]specific execution order for delayer copy layer + Test
This commit is contained in:
Andrey Dmitriev 2020-10-01 15:09:53 +03:00 committed by GitHub
parent 6ae332b072
commit 949e23d0e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 142 additions and 2 deletions

View File

@ -52,7 +52,6 @@ intel_dnn_component_t * DnnComponents::findComponent(InferenceEngine::CNNLayerPt
return nullptr;
}
std::vector<intel_dnn_component_t> DnnComponents::getExecutionOrder() {
std::vector<intel_dnn_component_t> result(components.size());

View File

@ -27,6 +27,7 @@
#include "gna_plugin_log.hpp"
#include "frontend/quantized_layer_params.hpp"
#include <layers/gna_copy_layer.hpp>
#include "gna_graph_tools.hpp"
#include "gna_pass_manager.hpp"
#include "layers/gna_layer_info.hpp"
@ -703,7 +704,8 @@ void InsertCopyLayerPass::run() {
};
if (LayerInfo(l).isMemory()) {
if (LayerInfo(prevIndirectLayer).isConcat() || LayerInfo(prevIndirectLayer).isCrop()) { bInsertDelayed = true;}
if (LayerInfo(prevIndirectLayer).isConcat() || LayerInfo(prevIndirectLayer).isCrop()
|| LayerInfo(prevIndirectLayer).isSplit()) { bInsertDelayed = true;}
// memory usualy preceded by either activation or split, or other layers in order to have 2b precision
for (auto && inputto : getInputTo(prevLayers[i].first->outData[prevLayers[i].second])) {
// if preceding layer is common for memory and concat

View File

@ -0,0 +1,24 @@
// Copyright (C) 2020 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
#include <vector>
#include "subgraph_tests/delayed_copy_layer.hpp"
#include "common_test_utils/test_constants.hpp"
#include "gna/gna_config.hpp"
using namespace LayerTestsDefinitions;
namespace {
std::vector<InferenceEngine::Precision> netPrecisions = {InferenceEngine::Precision::FP32,
};
std::map<std::string, std::string> additional_config = {
{"GNA_COMPACT_MODE", "NO"}
};
INSTANTIATE_TEST_CASE_P(delayed_copy_layer, DelayedCopyTest,
::testing::Combine(
::testing::ValuesIn(netPrecisions),
::testing::Values(CommonTestUtils::DEVICE_GNA),
::testing::Values(additional_config)),
DelayedCopyTest::getTestCaseName);
} // namespace

View File

@ -0,0 +1,33 @@
// Copyright (C) 2020 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include <tuple>
#include <string>
#include <vector>
#include <memory>
#include "functional_test_utils/layer_test_utils.hpp"
#include "ngraph_functions/utils/ngraph_helpers.hpp"
#include "ngraph_functions/builders.hpp"
namespace LayerTestsDefinitions {
typedef std::tuple<
InferenceEngine::Precision, //Network precision
std::string, //Device name
std::map<std::string, std::string> //Configuration
> ConcatSplitReluTuple;
class DelayedCopyTest
: public testing::WithParamInterface<ConcatSplitReluTuple>,
public LayerTestsUtils::LayerTestsCommon {
private:
void switchToNgraphFriendlyModel();
public:
static std::string getTestCaseName(const testing::TestParamInfo<ConcatSplitReluTuple> &obj);
protected:
void SetUp() override;
void Run() override;
};
} // namespace LayerTestsDefinitions

View File

@ -0,0 +1,82 @@
// Copyright (C) 2020 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <tuple>
#include <string>
#include <vector>
#include <memory>
#include <debug.h>
#include "common_test_utils/common_utils.hpp"
#include "functional_test_utils/precision_utils.hpp"
#include "functional_test_utils/skip_tests_config.hpp"
#include "subgraph_tests/delayed_copy_layer.hpp"
namespace LayerTestsDefinitions {
std::string DelayedCopyTest::getTestCaseName(const testing::TestParamInfo<ConcatSplitReluTuple> &obj) {
InferenceEngine::Precision netPrecision;
std::string targetName;
std::map<std::string, std::string> additional_config;
std::tie(netPrecision, targetName, additional_config) = obj.param;
std::ostringstream results;
results << "netPRC=" << netPrecision.name() << "_";
results << "targetDevice=" << targetName << "_";
return results.str();
}
void DelayedCopyTest::SetUp() {
InferenceEngine::Precision netPrecision;
std::map<std::string, std::string> additional_config;
std::tie(netPrecision, targetDevice, additional_config) = this->GetParam();
configuration.insert(additional_config.begin(), additional_config.end());
auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision);
auto input = ngraph::builder::makeParams(ngPrc, {{1, 384}});
auto mem_c = std::make_shared<ngraph::op::Constant>(ngPrc, ngraph::Shape{1, 128}, std::vector<float>{0});
auto mem_r = std::make_shared<ngraph::opset3::ReadValue>(mem_c, "id");
auto concat = std::make_shared<ngraph::opset1::Concat>(ngraph::OutputVector{mem_r, input[0]}, 1);
auto split = ngraph::builder::makeVariadicSplit(concat, {384, 128}, 1);
auto mem_w = std::make_shared<ngraph::opset3::Assign>(split->output(1), "id");
auto VariadicSplit = ngraph::builder::makeVariadicSplit(concat, {64, 448}, 1);
auto relu2 = std::make_shared<ngraph::opset1::Sigmoid>(VariadicSplit->output(1));
mem_w->add_control_dependency(mem_r);
relu2->add_control_dependency(mem_w);
function = std::make_shared<ngraph::Function>(relu2, input, "delayed_copy_layer_memory");
}
void DelayedCopyTest::switchToNgraphFriendlyModel() {
InferenceEngine::Precision netPrecision;
std::map<std::string, std::string> config;
std::map<std::string, std::string> additional_config;
std::tie(netPrecision, targetDevice, additional_config) = this->GetParam();
auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision);
auto input = ngraph::builder::makeParams(ngPrc, {{1, 384}});
auto mem_c = std::make_shared<ngraph::op::Constant>(ngPrc, ngraph::Shape{1, 128}, std::vector<float>{0});
auto concat = std::make_shared<ngraph::opset1::Concat>(ngraph::OutputVector{mem_c, input[0]}, 1);
auto split = ngraph::builder::makeVariadicSplit(concat, {384, 128}, 1);
auto VariadicSplit = ngraph::builder::makeVariadicSplit(concat, {64, 448}, 1);
auto relu2 = std::make_shared<ngraph::opset1::Sigmoid>(VariadicSplit->output(1));
function = std::make_shared<ngraph::Function>(relu2, input, "delayed_copy_layer_nonmemory");
}
void DelayedCopyTest::Run() {
SKIP_IF_CURRENT_TEST_IS_DISABLED()
LoadNetwork();
Infer();
switchToNgraphFriendlyModel();
Validate();
}
TEST_P(DelayedCopyTest, CompareWithRefs) {
Run();
};
} // namespace LayerTestsDefinitions