summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Conroy <james.conroy@arm.com>2020-05-18 15:16:42 +0100
committerJames Conroy <james.conroy@arm.com>2020-05-18 15:22:15 +0100
commited324051794a262a7694acfb0a378724d6ba8401 (patch)
tree32d516998be61052492ef1555d778615ee489412
parent63b234c6f5dd1340d8a7c5f64d7e1bbbe3e2d8df (diff)
downloadarmnn-ed324051794a262a7694acfb0a378724d6ba8401.tar.gz
armnn-ed324051794a262a7694acfb0a378724d6ba8401.tar.bz2
armnn-ed324051794a262a7694acfb0a378724d6ba8401.zip
IVGCVSW-4449 Add missing QLstm nullptr checks
* Adds missing nullptr checks for peephole bias for QLstm. Signed-off-by: James Conroy <james.conroy@arm.com> Change-Id: Ib04c8352141977cc7ea11a4859f1b11d46472722
-rw-r--r--src/armnn/Network.cpp13
-rw-r--r--src/armnn/layers/QLstmLayer.cpp2
-rw-r--r--src/backends/backendsCommon/WorkloadFactory.cpp7
3 files changed, 13 insertions, 9 deletions
diff --git a/src/armnn/Network.cpp b/src/armnn/Network.cpp
index c2bf27aa9..a047297e1 100644
--- a/src/armnn/Network.cpp
+++ b/src/armnn/Network.cpp
@@ -1874,15 +1874,16 @@ IConnectableLayer* Network::AddQLstmLayer(const QLstmDescriptor& descriptor,
throw InvalidArgumentException("AddQLstmLayer: Projection Weights cannot be NULL");
}
- if(params.m_ProjectionBias == nullptr)
+ layer->m_ProjectionParameters.m_ProjectionWeights =
+ std::make_unique<ScopedCpuTensorHandle>(*(params.m_ProjectionWeights));
+
+ // Projection bias is optional even if projection is enabled
+ if(params.m_ProjectionWeights != nullptr)
{
- throw InvalidArgumentException("AddQLstmLayer: Projection Biases cannot be NULL");
+ layer->m_ProjectionParameters.m_ProjectionBias =
+ std::make_unique<ScopedCpuTensorHandle>(*(params.m_ProjectionBias));
}
- layer->m_ProjectionParameters.m_ProjectionWeights =
- std::make_unique<ScopedCpuTensorHandle>(*(params.m_ProjectionWeights));
- layer->m_ProjectionParameters.m_ProjectionBias =
- std::make_unique<ScopedCpuTensorHandle>(*(params.m_ProjectionBias));
}
// QLstm Peephole params
diff --git a/src/armnn/layers/QLstmLayer.cpp b/src/armnn/layers/QLstmLayer.cpp
index 9b940c182..7e6154817 100644
--- a/src/armnn/layers/QLstmLayer.cpp
+++ b/src/armnn/layers/QLstmLayer.cpp
@@ -232,8 +232,6 @@ void QLstmLayer::ValidateTensorShapesFromInputs()
{
ARMNN_ASSERT_MSG(m_ProjectionParameters.m_ProjectionWeights != nullptr,
"QLstmLayer: m_ProjectionParameters.m_ProjectionWeights should not be null.");
- ARMNN_ASSERT_MSG(m_ProjectionParameters.m_ProjectionBias != nullptr,
- "QLstmLayer: m_ProjectionParameters.m_ProjectionBias should not be null.");
}
if (m_Param.m_PeepholeEnabled)
diff --git a/src/backends/backendsCommon/WorkloadFactory.cpp b/src/backends/backendsCommon/WorkloadFactory.cpp
index c55c70a1f..34bfd7cea 100644
--- a/src/backends/backendsCommon/WorkloadFactory.cpp
+++ b/src/backends/backendsCommon/WorkloadFactory.cpp
@@ -795,7 +795,12 @@ bool IWorkloadFactory::IsLayerSupported(const BackendId& backendId,
if(descriptor.m_ProjectionEnabled)
{
paramsInfo.m_ProjectionWeights = &cLayer->m_ProjectionParameters.m_ProjectionWeights->GetTensorInfo();
- paramsInfo.m_ProjectionBias = &cLayer->m_ProjectionParameters.m_ProjectionBias->GetTensorInfo();
+
+ // Projection bias is optional even if projection is enabled
+ if (cLayer->m_ProjectionParameters.m_ProjectionBias != nullptr)
+ {
+ paramsInfo.m_ProjectionBias = &cLayer->m_ProjectionParameters.m_ProjectionBias->GetTensorInfo();
+ }
}
if(descriptor.m_PeepholeEnabled)