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 { \
@@ -472,9 +491,10 @@ CPUTestsBase::deduce_expected_precision(const ov::element::Type& opPrecision,
472
491
if (it != configuration.end ()) {
473
492
auto inferencePrecisionConfig = it->second .as <ov::element::Type>();
474
493
inferencePrecisionSetExplicitly = true ;
475
- // TODO also need to check (dnnl::impl::cpu::x64::avx2_vnni_2)
476
- if ((inferencePrecisionConfig == ov::element::bf16 && ov::with_cpu_x86_avx512_core ()) ||
477
- (inferencePrecisionConfig == ov::element::f16 && ov::with_cpu_x86_avx512_core_fp16 ()) ||
494
+ if ((inferencePrecisionConfig == ov::element::bf16 &&
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
}
@@ -495,7 +515,8 @@ CPUTestsBase::deduce_expected_precision(const ov::element::Type& opPrecision,
495
515
ov::element::Type deducedType = opPrecision;
496
516
// enforceInferPrecision stage
497
517
if (inferencePrecision == ov::element::bf16) {
498
- deducedType = ov::with_cpu_x86_avx512_core () ? ov::element::bf16 : ov::element::f32;
518
+ deducedType =
519
+ (ov::with_cpu_x86_avx512_core () || with_cpu_x86_avx2_vnni_2 ()) ? ov::element::bf16 : ov::element::f32;
499
520
}
500
521
501
522
// ngraph transform pipeline stage
@@ -505,7 +526,8 @@ CPUTestsBase::deduce_expected_precision(const ov::element::Type& opPrecision,
505
526
}
506
527
}
507
528
if (deducedType == ov::element::bf16) {
508
- deducedType = ov::with_cpu_x86_avx512_core () ? ov::element::bf16 : ov::element::f32;
529
+ deducedType =
530
+ (ov::with_cpu_x86_avx512_core () || with_cpu_x86_avx2_vnni_2 ()) ? ov::element::bf16 : ov::element::f32;
509
531
} else if (deducedType == ov::element::f16) {
510
532
if (inferencePrecision != ov::element::f16 && inferencePrecision != ov::element::dynamic) {
511
533
deducedType = ov::element::f32;
0 commit comments