From 5b075d8575fafcbdfac848a61e135245304871e4 Mon Sep 17 00:00:00 2001 From: Egor Duplensky Date: Fri, 15 Oct 2021 18:05:23 +0300 Subject: [PATCH] [CPU] Enable back INT32 for MatMul (#7898) - Also enabled ngraph onnx matmul integer tests --- .../src/mkldnn_plugin/nodes/mkldnn_matmul_node.cpp | 7 +++++++ ngraph/test/runtime/ie/unit_test.manifest | 10 ---------- .../bindings/python/tests/test_onnx/test_backend.py | 1 - 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_matmul_node.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_matmul_node.cpp index 20b89924e74..8da70c508fd 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_matmul_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_matmul_node.cpp @@ -4,6 +4,7 @@ #include "mkldnn_matmul_node.h" +#include "ie_precision.hpp" #include "memory_desc/cpu_blocked_memory_desc.h" #include "cpu_types.h" #include "mkldnn_eltwise_node.h" @@ -120,6 +121,12 @@ void MKLDNNMatMulNode::getSupportedDescriptors() { if (firstInPortPrec.size() != secondInPortPrec.size()) firstInPortPrec = secondInPortPrec = getMaxPrecision(getOriginalInputPrecisions()); + // fallback to fp32 for any precision that cannot be handled natively + if ((!one_of(firstInPortPrec , Precision::U8, Precision::I8, Precision::BF16, Precision::FP32) || + !one_of(secondInPortPrec , Precision::I8, Precision::BF16, Precision::FP32))) { + outPortPrec = firstInPortPrec = secondInPortPrec = Precision::FP32; + } + if (!fusedWith.empty()) { outPortPrec = fusedWith[fusedWith.size() - 1]->getOriginalOutputPrecisionAtPort(0); } diff --git a/ngraph/test/runtime/ie/unit_test.manifest b/ngraph/test/runtime/ie/unit_test.manifest index 079fff34c8f..6aa3b9fb30b 100644 --- a/ngraph/test/runtime/ie/unit_test.manifest +++ b/ngraph/test/runtime/ie/unit_test.manifest @@ -31,16 +31,6 @@ onnx_model_conv_integer_no_zero_point onnx_model_conv_integer_pads # Unsupported operator detected in the graph: QuantizedDot -onnx_model_matmul_integer_2d_simple_zero_point -onnx_model_matmul_integer_int8 -onnx_model_matmul_integer_vectorized_zero_point -onnx_model_matmul_integer_no_zero_point -onnx_model_matmul_integer_2d_x_3d -onnx_model_matmul_integer_3d_x_2d -onnx_model_matmul_integer_3d -onnx_model_matmul_integer_4d -onnx_model_matmul_integer_4d_zero_point -onnx_model_matmul_integer_matrix_zero_point onnx_model_qlinear_matmul onnx_model_qlinear_matmul_3d diff --git a/runtime/bindings/python/tests/test_onnx/test_backend.py b/runtime/bindings/python/tests/test_onnx/test_backend.py index e20d0cc099a..6fd59dd924c 100644 --- a/runtime/bindings/python/tests/test_onnx/test_backend.py +++ b/runtime/bindings/python/tests/test_onnx/test_backend.py @@ -333,7 +333,6 @@ tests_expected_to_fail = [ ), ( xfail_issue_38722, - "OnnxBackendNodeModelTest.test_matmulinteger_cpu", "OnnxBackendNodeModelTest.test_qlinearmatmul_2D_cpu", "OnnxBackendNodeModelTest.test_qlinearmatmul_3D_cpu", ),