MLCE-753 Expand Tensorshape for relevent layers before verifying support

   Previously we were adding a reshape layer to "broadcast" tensors
   for elementwise operations. This broadcast was happening too late
   and was really just an expand dims. This was breaking the constant
   attributes of tensors and layer support of certain backends.

 * Remove addition of reshape layer when expanding dimensions
 * Replace broadcast function with expand dims to equal rank function
 * Fix some error status checks in various layers
 * Add new TensorUtil function that expands dims to a defined rank
 * Add unit tests to new TensorUtil function

Signed-off-by: Ryan OShea <ryan.oshea3@arm.com>
Change-Id: I31aca47c98075fef4f86864a15470f5faa55ab8d
diff --git a/delegate/src/Comparison.hpp b/delegate/src/Comparison.hpp
index 80354e8..688f90c 100644
--- a/delegate/src/Comparison.hpp
+++ b/delegate/src/Comparison.hpp
@@ -57,10 +57,17 @@
         return kTfLiteError;
     }
 
-    const armnn::TensorInfo& inputTensorInfo0 = GetTensorInfoForTfLiteTensor(tfLiteInputTensor0);
-    const armnn::TensorInfo& inputTensorInfo1 = GetTensorInfoForTfLiteTensor(tfLiteInputTensor1);
+    armnn::TensorInfo inputTensorInfo0 = GetTensorInfoForTfLiteTensor(tfLiteInputTensor0);
+    armnn::TensorInfo inputTensorInfo1 = GetTensorInfoForTfLiteTensor(tfLiteInputTensor1);
     const armnn::TensorInfo& outputTensorInfo = GetTensorInfoForTfLiteTensor(tfLiteOutputTensor, true);
 
+    // Check if we need to expand the dims of any of the input tensor infos.
+    // This is required for a few of the backends.
+    if(inputTensorInfo0.GetNumDimensions() != inputTensorInfo1.GetNumDimensions())
+    {
+        ExpandTensorRankToEqual(inputTensorInfo0, inputTensorInfo1);
+    }
+
     armnn::ComparisonOperation comparisonOperation = armnn::ComparisonOperation::Equal;
     switch(tfLiteComparisonOperatorCode)
     {
@@ -122,17 +129,7 @@
         return kTfLiteError;
     }
 
-    auto reshapeLayer = BroadcastTensor(inputTensorInfo0,
-                                        inputTensorInfo1,
-                                        comparisonLayer,
-                                        tfLiteContext,
-                                        tfLiteNode,
-                                        delegateData);
-    if (!reshapeLayer)
-    {
-        return kTfLiteError;
-    }
-    return kTfLiteOk;
+    return Connect(comparisonLayer, tfLiteNode, delegateData);
 }
 
 } // namespace armnnDelegate