Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[ONNX][Attention] Enable conversion of ONNX Attention by function (#33316)

Katarzyna Mitrus6bf1d0f2dc9c
diff --git a/src/frontends/onnx/frontend/CMakeLists.txt b/src/frontends/onnx/frontend/CMakeLists.txt
index 09350fc211e..0757af6e455 100644
--- a/src/frontends/onnx/frontend/CMakeLists.txt
+++ b/src/frontends/onnx/frontend/CMakeLists.txt
@@ -77,7 +77,7 @@ ov_add_frontend(NAME onnx
FILEDESCRIPTION "FrontEnd to load and convert ONNX file format"
LINK_LIBRARIES openvino_onnx_common openvino::core::dev)
-set(ONNX_OPSET_VERSION 21 CACHE INTERNAL "Supported version of ONNX operator set")
+set(ONNX_OPSET_VERSION 23 CACHE INTERNAL "Supported version of ONNX operator set")
target_compile_definitions(${TARGET_NAME} PRIVATE ONNX_OPSET_VERSION=${ONNX_OPSET_VERSION})
if(BUILD_SHARED_LIBS)
diff --git a/src/frontends/onnx/frontend/src/core/transform.cpp b/src/frontends/onnx/frontend/src/core/transform.cpp
index 46d2607c74f..ece99747be4 100644
--- a/src/frontends/onnx/frontend/src/core/transform.cpp
+++ b/src/frontends/onnx/frontend/src/core/transform.cpp
@@ -94,8 +94,7 @@ void ov::frontend::onnx::transform::expand_onnx_functions(ModelProto& model_prot
// Retrieve the operation schema from ONNX library
int opset_version = static_cast<int>(get_opset_version(model_proto, node.domain()));
- const auto* schema_registry = OpSchemaRegistry::Instance();
- const auto node_op_schema = schema_registry->GetSchema(node.op_type(), opset_version, node.domain());
+ const auto node_op_schema = OpSchemaRegistry::Schema(node.op_type(), opset_version, node.domain());
// Check if operation schema found
if (!node_op_schema) {
diff --git a/src/frontends/onnx/frontend/src/core/transform.hpp b/src/frontends/onnx/frontend/src/core/transform.hpp
index 0ecde83786d..028cd4bcb7b 100644
--- a/src/frontends/onnx/frontend/src/core/transform.hpp
+++ b/src/frontends/onnx/frontend/src/core/transform.hpp
@@ -13,7 +13,7 @@ namespace transform {
using ::ONNX_NAMESPACE::ModelProto;
-static const std::vector<std::string> onnx_functions_to_expand = {"Bernoulli"};
+static const std::vector<std::string> onnx_functions_to_expand = {"Bernoulli", "Attention"};
/// \brief Replace nodes with expanded body of ONNX functions
///
diff --git a/src/frontends/onnx/tests/__init__.py b/src/frontends/onnx/tests/__init__.py
index 2f14437570e..8309e2f0614 100644
--- a/src/frontends/onnx/tests/__init__.py
+++ b/src/frontends/onnx/tests/__init__.py
@@ -177,7 +177,6 @@ xfail_issue_139938 = xfail_test(reason = "QLinearMatMul accuracy fails")
skip_issue_119896 = pytest.mark.skip(reason="Unsupported element type: FLOAT8")
# ONNX 1.18
-xfail_issue_171766 = pytest.mark.skip(reason="Unsupported feature: Attention")
xfail_issue_171767 = pytest.mark.skip(reason="Unsupported element type: FLOAT4E2M1")
xfail_issue_171768 = pytest.mark.skip(reason="Unsupported feature: RMSNormalization")
xfail_issue_171770 = pytest.mark.skip(reason="Unsupported feature: RotaryEmbedding")
diff --git a/src/frontends/onnx/tests/tests_python/test_backend.py b/src/frontends/onnx/tests/tests_python/test_backend.py
index 2a904a3d147..7beaf5c5e89 100644
--- a/src/frontends/onnx/tests/tests_python/test_backend.py
+++ b/src/frontends/onnx/tests/tests_python/test_backend.py
@@ -71,7 +71,6 @@ from tests import (
xfail_issue_139936,
xfail_issue_139937,
xfail_issue_139938,
- xfail_issue_171766,
xfail_issue_171767,
xfail_issue_171768,
xfail_issue_171770,
@@ -629,56 +628,6 @@ tests_expected_to_fail = [
"OnnxBackendNodeModelTest.test_qlinearmatmul_2D_int8_float32_cpu",
"OnnxBackendNodeModelTest.test_qlinearmatmul_2D_uint8_float16_cpu",
),
- (
- xfail_issue_171766,
- "OnnxBackendNodeModelTest.test_attention_3d_attn_mask_cpu",
- "OnnxBackendNodeModelTest.test_attention_3d_causal_cpu",
- "OnnxBackendNodeModelTest.test_attention_3d_cpu",
- "OnnxBackendNodeModelTest.test_attention_3d_diff_heads_sizes_attn_mask_cpu",
- "OnnxBackendNodeModelTest.test_attention_3d_diff_heads_sizes_causal_cpu",
- "OnnxBackendNodeModelTest.test_attention_3d_diff_heads_sizes_cpu",
- "OnnxBackendNodeModelTest.test_attention_3d_diff_heads_sizes_scaled_cpu",
- "OnnxBackendNodeModelTest.test_attention_3d_diff_heads_sizes_softcap_cpu",
- "OnnxBackendNodeModelTest.test_attention_3d_diff_heads_with_past_and_present_cpu",
- "OnnxBackendNodeModelTest.test_attention_3d_gqa_attn_mask_cpu",
- "OnnxBackendNodeModelTest.test_attention_3d_gqa_causal_cpu",
- "OnnxBackendNodeModelTest.test_attention_3d_gqa_cpu",
- "OnnxBackendNodeModelTest.test_attention_3d_gqa_scaled_cpu",
- "OnnxBackendNodeModelTest.test_attention_3d_gqa_softcap_cpu",
- "OnnxBackendNodeModelTest.test_attention_3d_gqa_with_past_and_present_cpu",
- "OnnxBackendNodeModelTest.test_attention_3d_scaled_cpu",
- "OnnxBackendNodeModelTest.test_attention_3d_softcap_cpu",
- "OnnxBackendNodeModelTest.test_attention_3d_with_past_and_present_cpu",
- "OnnxBackendNodeModelTest.test_attention_3d_with_past_and_present_qk_matmul_bias_cpu",
- "OnnxBackendNodeModelTest.test_attention_3d_with_past_and_present_qk_matmul_cpu",
- "OnnxBackendNodeModelTest.test_attention_3d_with_past_and_present_qk_matmul_softcap_cpu",
- "OnnxBackendNodeModelTest.test_attention_3d_with_past_and_present_qk_matmul_softmax_cpu",
- "OnnxBackendNodeModelTest.test_attention_4d_attn_mask_bool_cpu",
- "OnnxBackendNodeModelTest.test_attention_4d_attn_mask_cpu",
- "OnnxBackendNodeModelTest.test_attention_4d_causal_cpu",
- "OnnxBackendNodeModelTest.test_attention_4d_cpu",
- "OnnxBackendNodeModelTest.test_attention_4d_diff_heads_sizes_attn_mask_cpu",
- "OnnxBackendNodeModelTest.test_attention_4d_diff_heads_sizes_causal_cpu",
- "OnnxBackendNodeModelTest.test_attention_4d_diff_heads_sizes_cpu",
- "OnnxBackendNodeModelTest.test_attention_4d_diff_heads_sizes_scaled_cpu",
- "OnnxBackendNodeModelTest.test_attention_4d_diff_heads_sizes_softcap_cpu",
- "OnnxBackendNodeModelTest.test_attention_4d_diff_heads_with_past_and_present_cpu",
- "OnnxBackendNodeModelTest.test_attention_4d_gqa_attn_mask_cpu",
- "OnnxBackendNodeModelTest.test_attention_4d_gqa_causal_cpu",
- "OnnxBackendNodeModelTest.test_attention_4d_gqa_cpu",
- "OnnxBackendNodeModelTest.test_attention_4d_gqa_scaled_cpu",
- "OnnxBackendNodeModelTest.test_attention_4d_gqa_softcap_cpu",
- "OnnxBackendNodeModelTest.test_attention_4d_gqa_with_past_and_present_cpu",
- "OnnxBackendNodeModelTest.test_attention_4d_scaled_cpu",
- "OnnxBackendNodeModelTest.test_attention_4d_softcap_cpu",
- "OnnxBackendNodeModelTest.test_attention_4d_with_past_and_present_cpu",
- "OnnxBackendNodeModelTest.test_attention_4d_with_past_and_present_qk_matmul_bias_cpu",
- "OnnxBackendNodeModelTest.test_attention_4d_with_past_and_present_qk_matmul_cpu",
- "OnnxBackendNodeModelTest.test_attention_4d_with_qk_matmul_bias_cpu",
- "OnnxBackendNodeModelTest.test_attention_4d_with_qk_matmul_cpu",
- "OnnxBackendNodeModelTest.test_attention_4d_with_qk_matmul_softcap_cpu",
- "OnnxBackendNodeModelTest.test_attention_4d_with_qk_matmul_softmax_cpu",
- ),
(
xfail_issue_171767,
"OnnxBackendNodeModelTest.test_cast_FLOAT16_to_FLOAT4E2M1_cpu",