[GNA] Fix for concat layer with >2 inputs (#1475)

* Fix for concat layer with more than 2 inputs

Signed-off-by: Bartosz Sochacki <bartosz.sochacki@intel.com>

* Fixed check if affine is used for crop layer

Signed-off-by: Bartosz Sochacki <bartosz.sochacki@intel.com>

* code cleanup for fix affine layer check

Signed-off-by: Bartosz Sochacki <bartosz.sochacki@intel.com>

* added test for concat layer with multiple inputs

* simplified test to use less number of layers

* fixed code style

* fixed coding style

* addressed review comments and one more issue that appeared during testing

* fixed code style errors

* scale factor propagation for concat layer with multiple inputs

* fix for a case when all inputs to concat are activation layers

* fix for linux compilation - C++14 is not enabled and fails on lambda with auto parameters

* corrected current year in headers in concat multi input tests

* fixes for code review issues raised by Denis Orlov

* enabled integer mode computation in GNA concat multi input test

* removed 1 space per review comment

* a fix to fail when not all scale factors are equal

* added GNA_DEVICE_MODE config to concat multi input test

* corrected searching for a next input to concat layer

* changed selection of 2nd candidate for source quant value

* code style fix - else and brackets should be in the same line

* small code improvement

* fix for mixing line endings

* addressed with endless requantization loop and fixed failing tests
This commit is contained in:
Bartosz Sochacki
2020-09-09 13:55:07 +02:00
committed by GitHub
parent 135ae12b0d
commit 8b87e1a477
7 changed files with 384 additions and 160 deletions

View File

@@ -0,0 +1,34 @@
// Copyright (C) 2020 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <tuple>
#include <vector>
#include <string>
#include <memory>
#include "functional_test_utils/layer_test_utils.hpp"
#include "ngraph_functions/utils/ngraph_helpers.hpp"
#include "ngraph_functions/builders.hpp"
typedef std::tuple<
std::vector<std::vector<size_t>>, // Input shapes
InferenceEngine::Precision, // Network Precision
std::string, // Target Device
std::map<std::string, std::string> // Config
> concatMultiParams;
namespace LayerTestsDefinitions {
class ConcatMultiInput : public testing::WithParamInterface<concatMultiParams>,
virtual public LayerTestsUtils::LayerTestsCommon {
public:
static std::string getTestCaseName(testing::TestParamInfo<concatMultiParams> obj);
protected:
void SetUp() override;
};
} // namespace LayerTestsDefinitions

View File

@@ -0,0 +1,88 @@
// Copyright (C) 2020 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <memory>
#include <tuple>
#include <vector>
#include <string>
#include <ie_core.hpp>
#include "common_test_utils/common_utils.hpp"
#include "functional_test_utils/plugin_cache.hpp"
#include "functional_test_utils/layer_test_utils.hpp"
#include "functional_test_utils/blob_utils.hpp"
#include "ngraph_functions/pass/convert_prc.hpp"
#include "subgraph_tests/concat_multi_input.hpp"
namespace LayerTestsDefinitions {
std::string ConcatMultiInput::getTestCaseName(testing::TestParamInfo<concatMultiParams> obj) {
std::vector<std::vector<size_t>> inputShapes;
InferenceEngine::Precision netPrecision;
std::string targetDevice;
std::map<std::string, std::string> additional_config;
std::tie(inputShapes, netPrecision, targetDevice, additional_config) = obj.param;
std::ostringstream result;
result << "IS=" << CommonTestUtils::vec2str(inputShapes) << "_";
result << "netPRC=" << netPrecision.name() << "_";
result << "targetDevice=" << targetDevice;
return result.str();
}
void ConcatMultiInput::SetUp() {
std::vector<std::vector<size_t>> inputShapes;
InferenceEngine::Precision netPrecision;
std::map<std::string, std::string> additional_config;
std::tie(inputShapes, netPrecision, targetDevice, additional_config) = this->GetParam();
configuration.insert(additional_config.begin(), additional_config.end());
auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision);
std::vector<size_t> paramSize = { 1, 0 };
for (const auto& val : inputShapes) {
paramSize[1] += val[1];
}
auto params = ngraph::builder::makeParams(ngPrc, { paramSize });
auto stride = std::make_shared<ngraph::op::Constant>(ngraph::element::i64, ngraph::Shape{ 2 }, std::vector<int64_t>{ 1, 1 });
std::vector<int64_t> newAxis = { 0, 0 };
std::vector<int64_t> begin_mask = { 0, 0 };
std::vector<int64_t> end_mask = { 0, 0 };
std::vector<std::shared_ptr<ngraph::opset1::StridedSlice>> ssArray;
ngraph::OutputVector concatInput;
auto relu = std::make_shared<ngraph::opset1::Relu>(params[0]);
std::vector<int64_t> startOffset = { 0, 0 };
for (size_t i = 0; i < inputShapes.size(); ++i) {
std::vector<int64_t> shape = { static_cast<int64_t>(inputShapes[i][0]),
static_cast<int64_t>(inputShapes[i][1]) };
std::vector<int64_t> endoffset = { static_cast<int64_t>(inputShapes[i][0]) + startOffset[0],
static_cast<int64_t>(inputShapes[i][1]) + startOffset[1]};
auto begin = std::make_shared<ngraph::op::Constant>(ngraph::element::i64, ngraph::Shape{ 2 }, startOffset);
auto end = std::make_shared<ngraph::op::Constant>(ngraph::element::i64, ngraph::Shape{ 2 }, endoffset);
auto ss = std::make_shared<ngraph::opset1::StridedSlice>(relu, begin, end, stride, begin_mask, end_mask, newAxis);
ssArray.push_back(ss);
concatInput.push_back(ssArray[i]);
startOffset[1] += shape[1];
}
auto concat = std::make_shared<ngraph::opset1::Concat>(concatInput, 1);
ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(concat) };
function = std::make_shared<ngraph::Function>(results, params, "ConcatMultiInput");
}
TEST_P(ConcatMultiInput, CompareWithRefImpl) {
Run();
};
} // namespace LayerTestsDefinitions