diff options
author | mathad01 <matthew.haddon@arm.com> | 2021-04-26 10:09:37 +0100 |
---|---|---|
committer | matthew.haddon <matthew.haddon@arm.com> | 2021-05-04 11:05:44 +0000 |
commit | c21025dc3c07d60568dd27d816bcdf0575f7695a (patch) | |
tree | c0a09ab03a644769dd915531e09980fad64100f5 /src | |
parent | df25859fe99ce721958d197534d6df11445b9d36 (diff) | |
download | armnn-c21025dc3c07d60568dd27d816bcdf0575f7695a.tar.gz |
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 <matthew.haddon@arm.com>
Change-Id: I0db8cfe04874979382edcf2bed336339700e3538
Diffstat (limited to 'src')
-rw-r--r-- | src/armnnTfLiteParser/TfLiteParser.cpp | 19 |
1 files 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<unsigned int> AsUnsignedVector(const std::vector<int32_t> & 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; i<inputCount; ++i) { - uint32_t inputId = CHECKED_NON_NEGATIVE(operatorPtr->inputs[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; } |