Fix nightly cl_image not supported issue

Resolves: COMPMID-4813

Signed-off-by: Sheri Zhang <sheri.zhang@arm.com>
Change-Id: I773e5b1be2951431e072012fe393993411f68b66
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/6269
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Gunes Bayir <gunes.bayir@arm.com>
Reviewed-by: Giorgio Arena <giorgio.arena@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
diff --git a/tests/validation/fixtures/DepthwiseConvolutionLayerFixture.h b/tests/validation/fixtures/DepthwiseConvolutionLayerFixture.h
index ddbab7f..cecccc8 100644
--- a/tests/validation/fixtures/DepthwiseConvolutionLayerFixture.h
+++ b/tests/validation/fixtures/DepthwiseConvolutionLayerFixture.h
@@ -446,6 +446,19 @@
 
     void configure_target()
     {
+#if defined(ARM_COMPUTE_OPENCL_ENABLED)
+        if(_export_to_cl_image)
+        {
+            _validate_output &= image2d_from_buffer_supported(CLKernelLibrary::get().get_device());
+            _validate_output &= (get_cl_image_pitch_alignment(CLKernelLibrary::get().get_device()) != 0);
+        }
+#endif // ARM_COMPUTE_OPENCL_ENABLED
+
+        if(!_validate_output)
+        {
+            return;
+        }
+
         TensorShape input_shape   = _input_shape;
         TensorShape weights_shape = _weights_shape;
 
@@ -471,14 +484,6 @@
         dwc_info.m0                         = _conv_info.stride().first == 1 && _dilation.x() == 1 ? 8 : 1;
         dwc_info.export_weights_to_cl_image = _export_to_cl_image;
 
-#if defined(ARM_COMPUTE_OPENCL_ENABLED)
-        if(_export_to_cl_image)
-        {
-            _validate_output |= image2d_from_buffer_supported(CLKernelLibrary::get().get_device());
-            _validate_output |= (get_cl_image_pitch_alignment(CLKernelLibrary::get().get_device()) != 0);
-        }
-#endif // ARM_COMPUTE_OPENCL_ENABLED
-
         const ConvolutionInfo conv_kernel_info
         {
             _conv_info, _depth_multiplier, _act_info, _dilation
@@ -498,6 +503,11 @@
 
     void allocate_and_run_target()
     {
+        if(!_validate_output)
+        {
+            return;
+        }
+
         // Allocate tensors
         _src.allocator()->allocate();
         _weights.allocator()->allocate();
@@ -525,10 +535,7 @@
         }
 
         // Compute function
-        if(_validate_output)
-        {
-            _dwc.run();
-        }
+        _dwc.run();
 
         // Reinstating original data layout for the test suite to properly check the values
         if(!_in_place)
@@ -539,6 +546,11 @@
 
     void compute_reference()
     {
+        if(!_validate_output)
+        {
+            return;
+        }
+
         SimpleTensor<T> src{ _input_shape, _data_type };
         SimpleTensor<T> weights{ _weights_shape, _data_type };
         SimpleTensor<T> biases{ _biases_shape, _data_type };
@@ -549,10 +561,7 @@
 
         const ConvolutionInfo info{ _conv_info, _depth_multiplier, _act_info, _dilation };
         const TensorShape     dst_shape = compute_depthwise_convolution_shape(TensorInfo(_input_shape, 1, _data_type), TensorInfo(_weights_shape, 1, _data_type), info);
-        if(_validate_output)
-        {
-            _reference = reference::activation_layer(reference::depthwise_convolution(src, weights, biases, dst_shape, _conv_info, _depth_multiplier, _dilation), _act_info);
-        }
+        _reference                      = reference::activation_layer(reference::depthwise_convolution(src, weights, biases, dst_shape, _conv_info, _depth_multiplier, _dilation), _act_info);
     }
 
 protected: