IVGCVSW-4449 Add missing QLstm nullptr checks
[platform/upstream/armnn.git] / src / armnn / Network.cpp
index c2bf27a..a047297 100644 (file)
@@ -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