From d04873f16c261e166b0d90cecd77ae8e736e2e67 Mon Sep 17 00:00:00 2001 From: Teresa Charlin Date: Tue, 23 May 2023 14:16:28 +0100 Subject: BugFix: check for options!=null before adding fused activation in TfLite parser Signed-off-by: Teresa Charlin Change-Id: I96fd26559450690fbe99a0e8fbe193ddf5d3a34b --- src/armnnTfLiteParser/TfLiteParser.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/armnnTfLiteParser/TfLiteParser.cpp b/src/armnnTfLiteParser/TfLiteParser.cpp index 5075da41c2..8b2d7a25bc 100644 --- a/src/armnnTfLiteParser/TfLiteParser.cpp +++ b/src/armnnTfLiteParser/TfLiteParser.cpp @@ -2444,8 +2444,10 @@ void TfLiteParserImpl::ParseSub(size_t subgraphIndex, size_t operatorIndex) auto inputTensorIndexes = AsUnsignedVector(GetInputTensorIds(m_Model, subgraphIndex, operatorIndex)); RegisterInputSlots(subgraphIndex, operatorIndex, layer, {inputTensorIndexes[0], inputTensorIndexes[1]}); - - layer = AddFusedActivationLayer(layer, 0, options->fused_activation_function); + if (options) + { + layer = AddFusedActivationLayer(layer, 0, options->fused_activation_function); + } auto outputTensorIndexes = AsUnsignedVector(GetOutputTensorIds(m_Model, subgraphIndex, operatorIndex)); RegisterOutputSlots(subgraphIndex, operatorIndex, layer, {outputTensorIndexes[0]}); @@ -2476,7 +2478,10 @@ void TfLiteParserImpl::ParseDiv(size_t subgraphIndex, size_t operatorIndex) auto inputTensorIndexes = AsUnsignedVector(GetInputTensorIds(m_Model, subgraphIndex, operatorIndex)); RegisterInputSlots(subgraphIndex, operatorIndex, layer, {inputTensorIndexes[0], inputTensorIndexes[1]}); - layer = AddFusedActivationLayer(layer, 0, options->fused_activation_function); + if (options) + { + layer = AddFusedActivationLayer(layer, 0, options->fused_activation_function); + } auto outputTensorIndexes = AsUnsignedVector(GetOutputTensorIds(m_Model, subgraphIndex, operatorIndex)); RegisterOutputSlots(subgraphIndex, operatorIndex, layer, {outputTensorIndexes[0]}); @@ -2535,7 +2540,10 @@ void TfLiteParserImpl::ParseAdd(size_t subgraphIndex, size_t operatorIndex) auto inputTensorIndexes = AsUnsignedVector(GetInputTensorIds(m_Model, subgraphIndex, operatorIndex)); RegisterInputSlots(subgraphIndex, operatorIndex, layer, {inputTensorIndexes[0], inputTensorIndexes[1]}); - layer = AddFusedActivationLayer(layer, 0, options->fused_activation_function); + if (options) + { + layer = AddFusedActivationLayer(layer, 0, options->fused_activation_function); + } auto outputTensorIndexes = AsUnsignedVector(GetOutputTensorIds(m_Model, subgraphIndex, operatorIndex)); RegisterOutputSlots(subgraphIndex, operatorIndex, layer, {outputTensorIndexes[0]}); @@ -2566,7 +2574,10 @@ void TfLiteParserImpl::ParseMul(size_t subgraphIndex, size_t operatorIndex) auto inputTensorIndexes = AsUnsignedVector(GetInputTensorIds(m_Model, subgraphIndex, operatorIndex)); RegisterInputSlots(subgraphIndex, operatorIndex, layer, {inputTensorIndexes[0], inputTensorIndexes[1]}); - layer = AddFusedActivationLayer(layer, 0, options->fused_activation_function); + if (options) + { + layer = AddFusedActivationLayer(layer, 0, options->fused_activation_function); + } auto outputTensorIndexes = AsUnsignedVector(GetOutputTensorIds(m_Model, subgraphIndex, operatorIndex)); RegisterOutputSlots(subgraphIndex, operatorIndex, layer, {outputTensorIndexes[0]}); -- cgit v1.2.1