Create custom flags for enabling fp16 support

Resolves: COMPMID-4655

Signed-off-by: Georgios Pinitas <georgios.pinitas@arm.com>
Change-Id: I1c1398b39da6da089b288d032074b270d87510c4
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/6010
Reviewed-by: Pablo Marquez Tello <pablo.tello@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
diff --git a/src/core/CPP/Validate.h b/src/core/CPP/Validate.h
index 4a97e47..df192b5 100644
--- a/src/core/CPP/Validate.h
+++ b/src/core/CPP/Validate.h
@@ -41,8 +41,13 @@
 inline Status error_on_unsupported_cpu_fp16(const char *function, const char *file, const int line,
                                             const ITensorInfo *tensor_info)
 {
+    bool fp16_kernels_enabled = false;
+#if defined(ARM_COMPUTE_ENABLE_FP16) && defined(ENABLE_FP16_KERNELS)
+    fp16_kernels_enabled = true;
+#endif /* defined(ARM_COMPUTE_ENABLE_FP16) && defined(ENABLE_FP16_KERNELS) */
+
     ARM_COMPUTE_RETURN_ERROR_ON_LOC(tensor_info == nullptr, function, file, line);
-    ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG((tensor_info->data_type() == DataType::F16) && !CPUInfo::get().has_fp16(),
+    ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG((tensor_info->data_type() == DataType::F16) && (!CPUInfo::get().has_fp16() || !fp16_kernels_enabled),
                                         function, file, line, "This CPU architecture does not support F16 data type, you need v8.2 or above");
     return Status{};
 }
@@ -59,8 +64,13 @@
 inline Status error_on_unsupported_cpu_bf16(const char *function, const char *file, const int line,
                                             const ITensorInfo *tensor_info)
 {
+    bool bf16_kernels_enabled = false;
+#if defined(ARM_COMPUTE_ENABLE_BF16)
+    bf16_kernels_enabled = true;
+#endif /* defined(ARM_COMPUTE_ENABLE_BF16) */
+
     ARM_COMPUTE_RETURN_ERROR_ON_LOC(tensor_info == nullptr, function, file, line);
-    ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG(tensor_info->data_type() == DataType::BFLOAT16 && !CPUInfo::get().has_bf16(),
+    ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG((tensor_info->data_type() == DataType::BFLOAT16) && (!CPUInfo::get().has_bf16() || !bf16_kernels_enabled),
                                         function, file, line, "This CPU architecture does not support BFloat16 data type, you need v8.6 or above");
     return Status{};
 }