MLCE-91 LSTM doesn't support optional input

    * Add fix for optional NO_VALUE operands in ConversionUtils.hpp
    * Remove fail message for optional NO_VALUE in ConversionUtils.hpp
    * Add to existing tests and test helper to cover optional NO_VALUE

Signed-off-by: Kevin May <kevin.may@arm.com>
Change-Id: Icf36af1fc00d3fb33cdd77ff6d6618cc4700d3fd
diff --git a/ConversionUtils.hpp b/ConversionUtils.hpp
index c86ad93..ca1f0ae 100644
--- a/ConversionUtils.hpp
+++ b/ConversionUtils.hpp
@@ -488,13 +488,16 @@
         return ConstTensorPin();
     }
 
-    if (operand.lifetime != OperandLifeTime::CONSTANT_COPY && operand.lifetime != OperandLifeTime::CONSTANT_REFERENCE)
+    if (!optional &&
+        operand.lifetime != OperandLifeTime::CONSTANT_COPY &&
+        operand.lifetime != OperandLifeTime::CONSTANT_REFERENCE &&
+        operand.lifetime != OperandLifeTime::NO_VALUE)
     {
         Fail("%s: invalid operand lifetime: %s", __func__, toString(operand.lifetime).c_str());
         return ConstTensorPin();
     }
 
-    const void* const valueStart = GetOperandValueReadOnlyAddress(operand, model, data);
+    const void* const valueStart = GetOperandValueReadOnlyAddress(operand, model, data, optional);
     if (!valueStart)
     {
         if (optional)
@@ -539,7 +542,8 @@
 }
 
 template<typename HalModel>
-const void* GetOperandValueReadOnlyAddress(const Operand& operand, const HalModel& model, const ConversionData& data)
+const void* GetOperandValueReadOnlyAddress(const Operand& operand, const HalModel& model, const ConversionData& data,
+                                           bool optional = false)
 {
     const void* valueStart = nullptr;
 
@@ -557,6 +561,15 @@
             valueStart = GetMemoryFromPool(operand.location, data.m_MemPools);
             break;
         }
+        case OperandLifeTime::NO_VALUE:
+        {
+            // An optional input tensor with no values is not an error so should not register as a fail
+            if (optional)
+            {
+                valueStart = nullptr;
+                break;
+            }
+        }
         default:
         {
             // Unsupported/invalid (e.g. can't get value of an input to the model)