[GNA] Security fixes for 2021.3 (#4538)

This commit is contained in:
Elizaveta Lobanova 2021-03-02 14:57:12 +03:00 committed by GitHub
parent 42c1c65454
commit 1eb830d083
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 8 deletions

View File

@ -161,7 +161,7 @@ inline std::pair<InferenceEngine::CNNLayerPtr, int> CNNNetCheckNextLayerSkipCer
if (bOnlyCheck) return {nullptr, 0};
THROW_GNA_LAYER_EXCEPTION(layer) << " no next output layer for outdata: " << oidx;
}
if (iidx >= getInputTo(layer->outData[oidx]).size()) {
if (getInputTo(layer->outData[oidx]).empty() || iidx >= getInputTo(layer->outData[oidx]).size()) {
if (bOnlyCheck) return {nullptr, 0};
THROW_GNA_LAYER_EXCEPTION(layer) << " no next output layer for outdata: " << oidx << " and inputTo index: " << iidx;
}

View File

@ -585,7 +585,7 @@ void GNAPlugin::ConvertModelLayoutFromNCHWToNHWC(const std::vector<CNNLayerPtr>
if (InferenceEngine::CNNNetHasPrevLayer(l.get())) {
transpositionInfo = FindTranspositionInfoFromPrevLayers(InferenceEngine::CNNNetPrevLayer(l));
// If no convolutions are found try to find them in next layers
if (!foundPartToTranspose(transpositionInfo)) {
if (!foundPartToTranspose(transpositionInfo) && !l->outData.empty() && !getInputTo(l->outData[0]).empty()) {
transpositionInfo = FindTranspositionInfoFromNextLayers(getInputTo(l->outData[0]).begin()->second);
}
}
@ -662,7 +662,7 @@ void GNAPlugin::ConvertModelLayoutFromNCHWToNHWC(const std::vector<CNNLayerPtr>
}
// Find a convolution in previous or next layers
auto transpositionInfo = FindTranspositionInfoFromPrevLayers(firstInput);
if (!foundPartToTranspose(transpositionInfo)) {
if (!foundPartToTranspose(transpositionInfo) && !l->outData.empty() && !getInputTo(l->outData[0]).empty()) {
transpositionInfo = FindTranspositionInfoFromNextLayers(getInputTo(l->outData[0]).begin()->second);
}
if (!transpositionInfo.empty()) {

View File

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation
// Copyright (C) 2020-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
@ -23,6 +23,13 @@ struct Config {
AdjustKeyMapValues();
}
Config(const Config& r) {
Copy(r);
}
Config& operator=(const Config& r) {
Copy(r);
return *this;
}
void Copy(const Config& r) {
gnaPrecision = r.gnaPrecision;
dumpXNNPath = r.dumpXNNPath;
dumpXNNGeneration = r.dumpXNNGeneration;

View File

@ -1,4 +1,4 @@
// Copyright (C) 2018-2020 Intel Corporation
// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
@ -30,7 +30,7 @@ class GNAMemory : public GNAMemRequestsQueue {
size_t _rw_section_size = 0;
size_t _ro_section_size = 0;
Allocator _allocator;
std::shared_ptr<uint8_t> heap;
std::shared_ptr<uint8_t> heap = nullptr;
size_t _page_alignment = 1;
class GNAMemRequestsReadOnlyQueue : public GNAMemRequestsQueue {

View File

@ -678,11 +678,15 @@ void RemovePermutationsNHWCToNCHWPass::run() {
data->setLayout(Layout::NHWC);
};
auto current_layer = getInputTo(pattern_start->outData[0]).begin()->second;
auto input_to = getInputTo(pattern_start->outData[0]);
IE_ASSERT(!input_to.empty());
auto current_layer = input_to.begin()->second;
setNHWCOrder(current_layer->input());
while (current_layer != pattern_end) {
setNHWCOrder(current_layer->outData[0]);
current_layer = getInputTo(current_layer->outData[0]).begin()->second;
input_to = getInputTo(current_layer->outData[0]);
IE_ASSERT(!input_to.empty());
current_layer = input_to.begin()->second;
}
if (LayerInfo(pattern_start).isPermute() && !getInputTo(pattern_start->outData.front()).empty()) {