From c21025dc3c07d60568dd27d816bcdf0575f7695a Mon Sep 17 00:00:00 2001 From: mathad01 Date: Mon, 26 Apr 2021 10:09:37 +0100 Subject: IVGCVSW-5882 Turn off Bias when data location equals -1 * Fix bug in stack layer which causes some models to seg fault. * Turn off bias input data if data location in TfLite file is set to -1. Signed-off-by: mathad01 Change-Id: I0db8cfe04874979382edcf2bed336339700e3538 --- src/armnnTfLiteParser/TfLiteParser.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/armnnTfLiteParser/TfLiteParser.cpp b/src/armnnTfLiteParser/TfLiteParser.cpp index 5070d5b22f..7c81a8f757 100644 --- a/src/armnnTfLiteParser/TfLiteParser.cpp +++ b/src/armnnTfLiteParser/TfLiteParser.cpp @@ -329,6 +329,11 @@ std::vector AsUnsignedVector(const std::vector & in) result.reserve(in.size()); for (auto & i : in) { + // If the location of the input data is -1 then the input should be ignored. + if (i == -1) + { + continue; + } result.push_back(CHECKED_NON_NEGATIVE(i)); } return result; @@ -3359,11 +3364,19 @@ TfLiteParserImpl::TensorRawPtrVector TfLiteParserImpl::GetInputs(const ModelPtr const auto & operatorPtr = subgraphPtr->operators[operatorIndex]; size_t inputCount = operatorPtr->inputs.size(); - TensorRawPtrVector result(inputCount); + TensorRawPtrVector result; for (size_t i=0; iinputs[i]); - result[i] = subgraphPtr->tensors[inputId].get(); + // If the input location is -1 then assume input is turned off. + if (operatorPtr->inputs[i] == -1) + { + continue; + } + else + { + uint32_t inputId = CHECKED_NON_NEGATIVE(operatorPtr->inputs[i]); + result.push_back(subgraphPtr->tensors[inputId].get()); + } } return result; } -- cgit v1.2.1