Wrap Flatten layer over reshape

Flatten layer is lowered into a Reshape layer.
Remove (CL/NE)FlatternLayerKernel.

Partially Resolves: COMPMID-3996

Signed-off-by: Georgios Pinitas <georgios.pinitas@arm.com>
Change-Id: Id9e2ddfe2e2dd793541badff3490c05e4c908f88
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/4660
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com>
diff --git a/src/runtime/CL/functions/CLFlattenLayer.cpp b/src/runtime/CL/functions/CLFlattenLayer.cpp
index c10e91b..b2860ea 100644
--- a/src/runtime/CL/functions/CLFlattenLayer.cpp
+++ b/src/runtime/CL/functions/CLFlattenLayer.cpp
@@ -23,11 +23,16 @@
  */
 #include "arm_compute/runtime/CL/functions/CLFlattenLayer.h"
 
+#include "arm_compute/core/CL/CLKernelLibrary.h"
+#include "arm_compute/core/CL/ICLTensor.h"
+#include "arm_compute/core/TensorInfo.h"
+#include "arm_compute/core/Validate.h"
+#include "arm_compute/core/utils/misc/ShapeCalculator.h"
 #include "arm_compute/runtime/CL/CLScheduler.h"
-#include "src/core/CL/kernels/CLFlattenLayerKernel.h"
+#include "src/core/helpers/AutoConfiguration.h"
 
-using namespace arm_compute;
-
+namespace arm_compute
+{
 void CLFlattenLayer::configure(const ICLTensor *input, ICLTensor *output)
 {
     configure(CLKernelLibrary::get().get_compile_context(), input, output);
@@ -35,13 +40,24 @@
 
 void CLFlattenLayer::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output)
 {
-    auto k = std::make_unique<CLFlattenLayerKernel>();
-    k->configure(compile_context, input, output);
-    _kernel = std::move(k);
-    CLScheduler::get().tune_kernel_static(*_kernel);
+    ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
+    auto_init_if_empty(*output->info(), input->info()->clone()->set_tensor_shape(misc::shape_calculator::compute_flatten_shape(input->info())));
+    _reshape.configure(compile_context, input, output);
 }
 
 Status CLFlattenLayer::validate(const ITensorInfo *input, const ITensorInfo *output)
 {
-    return CLFlattenLayerKernel::validate(input, output);
+    // Checks performed when output is configured
+    if(output->total_size() != 0)
+    {
+        const TensorInfo tensor_info_output = input->clone()->set_tensor_shape(misc::shape_calculator::compute_flatten_shape(input));
+        ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(output, &tensor_info_output);
+    }
+    return CLReshapeLayer::validate(input, output);
 }
+
+void CLFlattenLayer::run()
+{
+    _reshape.run();
+}
+} // namespace arm_compute
\ No newline at end of file