From a21b57109c422683189fc928b9d80ef7131a7a04 Mon Sep 17 00:00:00 2001 From: "joanna.wozna.intel" Date: Tue, 20 Oct 2020 04:15:24 +0200 Subject: [PATCH] Add AVX512 instruction check for C-API (#28087) * Add AVX512 instruction check for C-API * Fix formatting --- paddle/fluid/inference/api/analysis_config.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/inference/api/analysis_config.cc b/paddle/fluid/inference/api/analysis_config.cc index 07f38311103..6965a0c9041 100644 --- a/paddle/fluid/inference/api/analysis_config.cc +++ b/paddle/fluid/inference/api/analysis_config.cc @@ -14,6 +14,7 @@ #include "paddle/fluid/inference/api/paddle_analysis_config.h" #include "paddle/fluid/inference/api/paddle_pass_builder.h" +#include "paddle/fluid/platform/cpu_info.h" #include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/gpu_info.h" @@ -222,7 +223,12 @@ void AnalysisConfig::EnableMkldnnQuantizer() { void AnalysisConfig::EnableMkldnnBfloat16() { #ifdef PADDLE_WITH_MKLDNN - use_mkldnn_bfloat16_ = true; + if (platform::MayIUse(platform::cpu_isa_t::avx512_core)) { + use_mkldnn_bfloat16_ = true; + } else { + LOG(INFO) << "CPU does not support BFLOAT16 calculations"; + use_mkldnn_bfloat16_ = false; + } #else LOG(ERROR) << "Please compile with MKLDNN first to use MkldnnBfloat16"; use_mkldnn_bfloat16_ = false; -- GitLab