aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2021-07-28 13:18:46 +0100
committerGeorgios Pinitas <georgios.pinitas@arm.com>2021-07-28 17:25:14 +0000
commit8e2f64f214fa3ce5834db966222fa3b804e236a2 (patch)
treea5259b9930a6791ce2d7c01403c4376b12f2080a
parenta86433a64ab25c2ea8e274bd2f357a9709636f5b (diff)
downloadComputeLibrary-8e2f64f214fa3ce5834db966222fa3b804e236a2.tar.gz
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>
-rw-r--r--SConstruct12
-rw-r--r--scripts/arm_compute_library_nn_driver.go1
-rw-r--r--src/core/CPP/Validate.h14
3 files changed, 21 insertions, 6 deletions
diff --git a/SConstruct b/SConstruct
index 8dbb68952c..60d220ee2f 100644
--- a/SConstruct
+++ b/SConstruct
@@ -222,10 +222,13 @@ elif 'v8' in env['arch']:
else:
env.Append(CXXFLAGS = ['-march=armv8-a'])
- if 'v8.6-a' in env['arch'] or env['fat_binary']:
+ if 'v8.6-a' in env['arch']:
env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_I8MM', 'ARM_COMPUTE_ENABLE_BF16'])
if "disable_mmla_fp" not in env['custom_options']:
env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_SVEF32MM'])
+ if 'v8.' in env['arch']:
+ env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_FP16'])
+
elif 'x86' in env['arch']:
if env['estate'] == '32':
env.Append(CCFLAGS = ['-m32'])
@@ -309,9 +312,10 @@ if env['fat_binary']:
if env['arch'] != 'armv8.2-a':
print("Currently fat binary is only supported with armv8.2-a")
Exit(1)
- env.Append(CXXFLAGS = ['-DENABLE_SVE', '-DARM_COMPUTE_ENABLE_SVE',
- '-DARM_COMPUTE_ENABLE_BF16', '-DARM_COMPUTE_ENABLE_I8MM', '-DARM_COMPUTE_ENABLE_SVEF32MM'])
- env.Append(CXXFLAGS = ['-DENABLE_NEON', '-DARM_COMPUTE_ENABLE_NEON'])
+ env.Append(CXXFLAGS = ['-DENABLE_NEON', '-DARM_COMPUTE_ENABLE_NEON',
+ '-DENABLE_SVE', '-DARM_COMPUTE_ENABLE_SVE',
+ '-DARM_COMPUTE_ENABLE_FP16', '-DARM_COMPUTE_ENABLE_BF16',
+ '-DARM_COMPUTE_ENABLE_I8MM', '-DARM_COMPUTE_ENABLE_SVEF32MM'])
if env['data_type_support']:
if any(i in env['data_type_support'] for i in ['all', 'fp16']):
diff --git a/scripts/arm_compute_library_nn_driver.go b/scripts/arm_compute_library_nn_driver.go
index 2461838d4f..689aa3b8f2 100644
--- a/scripts/arm_compute_library_nn_driver.go
+++ b/scripts/arm_compute_library_nn_driver.go
@@ -25,6 +25,7 @@ func globalFlags(ctx android.BaseContext) []string {
theArch := a.ArchType.String()
if theArch == "armv8-2a" {
cppflags = append(cppflags, "-march=armv8.2-a+fp16")
+ cppflags = append(cppflags, "-DARM_COMPUTE_ENABLE_FP16")
}
}
}
diff --git a/src/core/CPP/Validate.h b/src/core/CPP/Validate.h
index 4a97e4789e..df192b5131 100644
--- a/src/core/CPP/Validate.h
+++ b/src/core/CPP/Validate.h
@@ -41,8 +41,13 @@ namespace arm_compute
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_fp16(const char *function, const char *fi
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{};
}