COMPMID-1918: Fixed mismatches in NEDepthConcatenateLayer

Change-Id: I8d1d65297f30d11cf2e62539d7a823ed8e409cf0
Signed-off-by: Pablo Tello <pablo.tello@arm.com>
Reviewed-on: https://review.mlplatform.org/660
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Isabella Gottardi <isabella.gottardi@arm.com>
diff --git a/tests/validation/reference/DepthConcatenateLayer.cpp b/tests/validation/reference/DepthConcatenateLayer.cpp
index 6551f0c..7775614 100644
--- a/tests/validation/reference/DepthConcatenateLayer.cpp
+++ b/tests/validation/reference/DepthConcatenateLayer.cpp
@@ -52,8 +52,25 @@
     const int out_stride_z = width_out * height_out;
     const int batches      = dst.shape().total_size_upper(3);
 
-    // Set output tensor to 0
-    std::fill_n(dst.data(), dst.num_elements(), 0);
+    if(srcs[0].data_type() == DataType::QASYMM8 && srcs[0].quantization_info() != dst.quantization_info())
+    {
+        // input tensors can have smaller width and height than the output, so for each output's slice we need to requantize 0 (as this is the value
+        // used in NEFillBorderKernel by NEDepthConcatenateLayer) using the corresponding quantization info for that particular slice/input tensor.
+        int slice = 0;
+        for(const auto &src : srcs)
+        {
+            auto ptr_slice = static_cast<T *>(dst(Coordinates(0, 0, slice)));
+            std::transform(ptr_slice, ptr_slice + dst.num_elements() / depth_out, ptr_slice, [src, dst](T t)
+            {
+                return dst.quantization_info().quantize(src.quantization_info().dequantize(0), RoundingPolicy::TO_NEAREST_UP);
+            });
+            slice += src.shape().z();
+        }
+    }
+    else
+    {
+        std::fill_n(dst.data(), dst.num_elements(), 0);
+    }
 
     for(const auto &src : srcs)
     {