12
12
#include " transformations/rt_info/primitives_priority_attribute.hpp"
13
13
#include " utils/general_utils.h"
14
14
#include " utils/rt_info/memory_formats_attribute.hpp"
15
+ #if defined(OPENVINO_ARCH_X86) || defined(OPENVINO_ARCH_X86_64)
16
+ # include < xbyak/xbyak_util.h>
17
+ #endif
15
18
16
19
namespace CPUTestUtils {
17
20
const char * CPUTestsBase::any_type = " any_type" ;
@@ -45,6 +48,22 @@ const char* CPUTestsBase::cpu_fmt2str(cpu_memory_format_t v) {
45
48
return " undef" ;
46
49
}
47
50
51
+ #if defined(OPENVINO_ARCH_X86) || defined(OPENVINO_ARCH_X86_64)
52
+ static Xbyak::util::Cpu& get_cpu_info () {
53
+ static Xbyak::util::Cpu cpu;
54
+ return cpu;
55
+ }
56
+ bool with_cpu_x86_avx2_vnni_2 () {
57
+ return get_cpu_info ().has (Xbyak::util::Cpu::tAVX2 | Xbyak::util::Cpu::tAVX_VNNI) &&
58
+ get_cpu_info ().has (Xbyak::util::Cpu::tAVX_VNNI_INT8) &&
59
+ get_cpu_info ().has (Xbyak::util::Cpu::tAVX_NE_CONVERT);
60
+ }
61
+ #else // OPENVINO_ARCH_X86 || OPENVINO_ARCH_X86_64
62
+ bool with_cpu_x86_avx2_vnni_2 () {
63
+ return false ;
64
+ }
65
+ #endif // OPENVINO_ARCH_X86 || OPENVINO_ARCH_X86_64
66
+
48
67
cpu_memory_format_t CPUTestsBase::cpu_str2fmt (const char * str) {
49
68
#define CASE (_fmt ) \
50
69
do { \
@@ -473,8 +492,9 @@ CPUTestsBase::deduce_expected_precision(const ov::element::Type& opPrecision,
473
492
auto inferencePrecisionConfig = it->second .as <ov::element::Type>();
474
493
inferencePrecisionSetExplicitly = true ;
475
494
if ((inferencePrecisionConfig == ov::element::bf16 &&
476
- (ov::with_cpu_x86_avx512_core () || ov::with_cpu_x86_avx2_vnni_2 ())) ||
477
- (inferencePrecisionConfig == ov::element::f16 && ov::with_cpu_x86_float16 ()) ||
495
+ (ov::with_cpu_x86_avx512_core () || with_cpu_x86_avx2_vnni_2 ())) ||
496
+ (inferencePrecisionConfig == ov::element::f16 &&
497
+ (ov::with_cpu_x86_avx512_core_fp16 () || with_cpu_x86_avx2_vnni_2 ())) ||
478
498
(inferencePrecisionConfig == ov::element::f32) || (inferencePrecisionConfig == ov::element::dynamic)) {
479
499
inferencePrecision = inferencePrecisionConfig;
480
500
}
@@ -484,7 +504,7 @@ CPUTestsBase::deduce_expected_precision(const ov::element::Type& opPrecision,
484
504
const auto & configIt = configuration.find (executionModeKey);
485
505
if (configIt != configuration.end () && configIt->second .as <ov::hint::ExecutionMode>() == ov::hint::ExecutionMode::PERFORMANCE) {
486
506
inferencePrecision = ov::element::f32;
487
- if (ov::with_cpu_x86_bfloat16 () && ! ov::with_cpu_x86_avx2_vnni_2 () ) {
507
+ if (ov::with_cpu_x86_bfloat16 ()) {
488
508
inferencePrecision = ov::element::bf16;
489
509
}
490
510
} else {
@@ -496,7 +516,7 @@ CPUTestsBase::deduce_expected_precision(const ov::element::Type& opPrecision,
496
516
// enforceInferPrecision stage
497
517
if (inferencePrecision == ov::element::bf16) {
498
518
deducedType =
499
- (ov::with_cpu_x86_avx512_core () || ov:: with_cpu_x86_avx2_vnni_2 ()) ? ov::element::bf16 : ov::element::f32;
519
+ (ov::with_cpu_x86_avx512_core () || with_cpu_x86_avx2_vnni_2 ()) ? ov::element::bf16 : ov::element::f32;
500
520
}
501
521
502
522
// ngraph transform pipeline stage
@@ -507,7 +527,7 @@ CPUTestsBase::deduce_expected_precision(const ov::element::Type& opPrecision,
507
527
}
508
528
if (deducedType == ov::element::bf16) {
509
529
deducedType =
510
- (ov::with_cpu_x86_avx512_core () || ov:: with_cpu_x86_avx2_vnni_2 ()) ? ov::element::bf16 : ov::element::f32;
530
+ (ov::with_cpu_x86_avx512_core () || with_cpu_x86_avx2_vnni_2 ()) ? ov::element::bf16 : ov::element::f32;
511
531
} else if (deducedType == ov::element::f16) {
512
532
if (inferencePrecision != ov::element::f16 && inferencePrecision != ov::element::dynamic) {
513
533
deducedType = ov::element::f32;
0 commit comments