Skip to content

Commit 93d94a1

Browse files
committed
Nodes which not support bf16/f16 on avx2_vnni_2 platforms will fall back to f32
1 parent 95bf159 commit 93d94a1

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

src/plugins/intel_cpu/src/nodes/topk.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "onednn/dnnl.h"
1919
#include "openvino/core/parallel.hpp"
2020
#include "openvino/op/topk.hpp"
21+
#include "utils/cpu_utils.hpp"
2122
#include "utils/ngraph_utils.hpp"
2223

2324
using namespace dnnl;
@@ -1985,11 +1986,14 @@ void TopK::initSupportedPrimitiveDescriptors() {
19851986
ov::element::u8};
19861987

19871988
ov::element::Type dataPrecision = getOriginalOutputPrecisionAtPort(TOPK_DATA);
1988-
if (dataPrecision == ov::element::bf16 && !mayiuse(avx512_core)) {
1989-
THROW_CPU_NODE_ERR("gets incorrect isa for BF16! AVX512 must be supported!");
1989+
if (dataPrecision == ov::element::bf16 && !hasHardwareSupport(ov::element::bf16)) {
1990+
THROW_CPU_NODE_ERR("gets incorrect isa for BF16!");
19901991
}
19911992
bool precisionSupported = std::find(std::begin(supportedPrecision), std::end(supportedPrecision), dataPrecision) !=
19921993
std::end(supportedPrecision);
1994+
// BF16 is not supported for AVX2_VNNI_2 platforms
1995+
precisionSupported =
1996+
(dataPrecision == ov::element::bf16 && mayiuse(cpu::x64::avx2_vnni_2)) ? false : precisionSupported;
19931997
if (!precisionSupported) {
19941998
if (dataPrecision.is_real()) {
19951999
dataPrecision = ov::element::f32;

src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/normalize.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,13 @@ class NormalizeL2LayerCPUTest : public testing::WithParamInterface<NormalizeL2La
6464
if (selectedType.empty()) {
6565
selectedType = getPrimitiveType();
6666
}
67-
selectedType = makeSelectedTypeStr("unknown", inType);
67+
// BF16 is not supported for NormalizeL2 on AVX2_VNNI_2 platforms
68+
if (ov::with_cpu_x86_avx2_vnni_2() && inType == ElementType::bf16) {
69+
selectedType = makeSelectedTypeStr("unknown", ElementType::f32);
70+
} else {
71+
selectedType = makeSelectedTypeStr("unknown", inType);
72+
}
73+
6874
targetDevice = ov::test::utils::DEVICE_CPU;
6975
init_input_shapes({shapes});
7076

src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/roi_pooling.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,12 @@ class ROIPoolingCPULayerTest : public testing::WithParamInterface<ROIPoolingCPUT
194194
selectedType = getPrimitiveType();
195195
}
196196
selectedType.push_back('_');
197-
selectedType += netPrecision.to_string();
197+
// BF16 is not supported for ROIPooling on AVX2_VNNI_2 platforms
198+
if (ov::with_cpu_x86_avx2_vnni_2() && netPrecision == ElementType::bf16) {
199+
selectedType += ov::element::f32.to_string();
200+
} else {
201+
selectedType += netPrecision.to_string();
202+
}
198203

199204
if (netPrecision == ov::element::bf16) {
200205
rel_threshold = 1e-2;

src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/topk.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,12 @@ class TopKLayerCPUTest : public testing::WithParamInterface<TopKLayerCPUTestPara
102102
inPrc = outPrc = netPrecision;
103103
configuration.insert(additionalConfig.begin(), additionalConfig.end());
104104

105-
selectedType = getPrimitiveType() + "_" + ov::element::Type(netPrecision).get_type_name();
105+
// BF16 is not supported for TopK on AVX2_VNNI_2 platforms
106+
if (ov::with_cpu_x86_avx2_vnni_2() && netPrecision == ElementType::bf16) {
107+
selectedType = makeSelectedTypeStr(getPrimitiveType(), ElementType::f32);
108+
} else {
109+
selectedType = makeSelectedTypeStr(getPrimitiveType(), netPrecision);
110+
}
106111

107112
staticShape = inputShape.first.rank() == 0;
108113
if (staticShape) {

0 commit comments

Comments
 (0)