IVGCVSW-3522 Support dynamic output shape in hal_1_2::HalPolicy::ConvertResize

Signed-off-by: Aron Virginas-Tar <Aron.Virginas-Tar@arm.com>
Change-Id: I962f9759679f539566f7bc3aa75ed3e0bffe7c9f
diff --git a/OutputShapeUtils.cpp b/OutputShapeUtils.cpp
index 285e25f..6c936ee 100644
--- a/OutputShapeUtils.cpp
+++ b/OutputShapeUtils.cpp
@@ -144,6 +144,28 @@
     return CalculateMaxShape(inputShape, alphaShape);
 }
 
+TensorShape InferResizeOutputShape(const TensorShape& inputShape, const ResizeDescriptor& descriptor)
+{
+    if (inputShape.GetNumDimensions() != 4)
+    {
+        throw InvalidArgumentException("Input shape for Resize must be 4D");
+    }
+
+    armnnUtils::DataLayoutIndexed dataLayoutIndexed(descriptor.m_DataLayout);
+
+    const unsigned int cIndex = dataLayoutIndexed.GetChannelsIndex();
+    const unsigned int wIndex = dataLayoutIndexed.GetWidthIndex();
+    const unsigned int hIndex = dataLayoutIndexed.GetHeightIndex();
+
+    TensorShape outputShape(4);
+    outputShape[0]      = inputShape[0];
+    outputShape[cIndex] = inputShape[cIndex];
+    outputShape[wIndex] = descriptor.m_TargetWidth;
+    outputShape[hIndex] = descriptor.m_TargetHeight;
+
+    return outputShape;
+}
+
 TensorShape InferSubOutputShape(const TensorShape& input0Shape, const TensorShape& input1Shape)
 {
     return CalculateMaxShape(input0Shape, input1Shape);