OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[ONNX FE] SplitToSequence and SequenceAt Operation (#32377)
Szymon Gutaj30c6b69ac780
diff --git a/src/frontends/common/include/openvino/frontend/sequence_mark.hpp b/src/frontends/common/include/openvino/frontend/sequence_mark.hppnew file mode 100644index 00000000000..5e3636ad6e8--- /dev/null+++ b/src/frontends/common/include/openvino/frontend/sequence_mark.hpp@@ -0,0 +1,36 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include <vector>++#include "openvino/core/node_vector.hpp"+#include "openvino/frontend/visibility.hpp"+#include "openvino/op/util/framework_node.hpp"++namespace ov {+namespace frontend {++/// \brief SequenceMark serves to mark places that require a sequence type propagation+class FRONTEND_API SequenceMark : public ov::op::util::FrameworkNode {+public:+ OPENVINO_OP("SequenceMark", "util", ov::op::util::FrameworkNode);++ /// \brief Constructors for SequenceMark node forwarded from FrameworkNode+ using ov::op::util::FrameworkNode::FrameworkNode;++ std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& inputs) const override;++ /// @brief Get the sequence of tensors+ /// @return Collection of inputs representing the sequence+ ov::OutputVector get_sequence() const;+};++inline ov::OutputVector SequenceMark::get_sequence() const {+ return input_values();+}++} // namespace frontend+} // namespace ovdiff --git a/src/frontends/common/src/sequence_mark.cpp b/src/frontends/common/src/sequence_mark.cppnew file mode 100644index 00000000000..94a17d1a388--- /dev/null+++ b/src/frontends/common/src/sequence_mark.cpp@@ -0,0 +1,15 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "openvino/frontend/sequence_mark.hpp"++namespace ov {+namespace frontend {++std::shared_ptr<Node> SequenceMark::clone_with_new_inputs(const OutputVector& inputs) const {+ return std::make_shared<SequenceMark>(inputs);+}++} // namespace frontend+} // namespace ovdiff --git a/src/frontends/onnx/docs/supported_ops.md b/src/frontends/onnx/docs/supported_ops.mdindex 8f57c0f75e5..c919f8f476c 100644--- a/src/frontends/onnx/docs/supported_ops.md+++ b/src/frontends/onnx/docs/supported_ops.md@@ -163,7 +163,7 @@ OpenVINO provides support for operations of Default Opset (empty in table below)| |ScatterElements |11 |18, 16, 13, 11 | || |ScatterND |11 |18, 16, 13, 11 | || |Selu |1 |22, 6, 1 | |-| |SequenceAt | |11 | |+| |SequenceAt |11 |11 | || |SequenceConstruct | |11 | || |SequenceEmpty | |11 | || |SequenceErase | |11 | |@@ -185,7 +185,7 @@ OpenVINO provides support for operations of Default Opset (empty in table below)| |Softsign |1 |22, 1 | || |SpaceToDepth |1 |13, 1 | || |Split |18, 13, 1 |18, 13, 11, 2, 1 | |-| |SplitToSequence | |11 | |+| |SplitToSequence |11 |11 | || |Sqrt |1 |13, 6, 1 | || |Squeeze |13, 1 |21, 13, 11, 1 | || |StringConcat | |20 | |diff --git a/src/frontends/onnx/frontend/src/op/sequence_at.cpp b/src/frontends/onnx/frontend/src/op/sequence_at.cppnew file mode 100644index 00000000000..2c813ae5ac1--- /dev/null+++ b/src/frontends/onnx/frontend/src/op/sequence_at.cpp@@ -0,0 +1,64 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include <memory>++#include "core/operator_set.hpp"+#include "exceptions.hpp"+#include "openvino/core/type.hpp"+#include "openvino/core/validation_util.hpp"+#include "openvino/frontend/exception.hpp"+#include "openvino/frontend/sequence_mark.hpp"+#include "openvino/op/add.hpp"+#include "openvino/op/constant.hpp"+#include "utils/common.hpp"++namespace ov {+namespace frontend {+namespace onnx {+namespace ai_onnx {+namespace opset_11 {++/// @brief Implements the SequenceAt operator+/// @param node Input ONNX node. Must have two inputs: a sequence and a position.+/// Sequence is represented as a SequenceMark node.+/// @return The tensor at the specified position in the input sequence+ov::OutputVector sequence_at(const ov::frontend::onnx::Node& node) {+ constexpr auto input_sequence_and_position = 2;++ common::default_op_checks(node, input_sequence_and_position, input_sequence_and_position);++ const auto& inputs = node.get_ov_inputs();++ const auto& input_sequence = as_type_ptr<SequenceMark>(inputs[0].get_node_shared_ptr());+ OPENVINO_ASSERT(input_sequence, "SequenceAt: 'input' must be a sequence");++ auto position = inputs[1];+ OPENVINO_ASSERT(position.get_partial_shape().rank().compatible(0), "SequenceAt: 'position' input must be a scalar");++ const auto position_const = ov::util::get_constant_from_source(position);+ OPENVINO_ASSERT(position_const, "SequenceAt: 'position' input must be constant");++ const auto position_value = position_const->cast_vector<std::int64_t>()[0];++ const auto input_sequence_length = static_cast<std::int64_t>(input_sequence->get_sequence().size());++ const auto position_value_normalized = position_value < 0 ? position_value + input_sequence_length : position_value;+ OPENVINO_ASSERT(position_value_normalized >= 0 && position_value_normalized < input_sequence_length,+ "SequenceAt: 'position' is out of bounds");++ return {input_sequence->get_sequence().at(position_value_normalized)};+}++/// @brief Registers the SequenceAt operator implementation in the ONNX frontend+/// @remark The operator is available since ONNX opset 11.+/// Registering as available since opset 1 for compatibility with existing tests.+ONNX_OP("SequenceAt", OPSET_SINCE(1), ai_onnx::opset_11::sequence_at);++} // namespace opset_11++} // namespace ai_onnx+} // namespace onnx+} // namespace frontend+} // namespace ovdiff --git a/src/frontends/onnx/frontend/src/op/split_to_sequence.cpp b/src/frontends/onnx/frontend/src/op/split_to_sequence.cppnew file mode 100644index 00000000000..82824d51e3e--- /dev/null+++ b/src/frontends/onnx/frontend/src/op/split_to_sequence.cpp@@ -0,0 +1,192 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include <cmath>+#include <cstdint>+#include <memory>+#include <vector>++#include "core/operator_set.hpp"+#include "exceptions.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/validation_util.hpp"+#include "openvino/frontend/sequence_mark.hpp"+#include "openvino/op/constant.hpp"+#include "openvino/op/convert.hpp"+#include "openvino/op/split.hpp"+#include "openvino/op/squeeze.hpp"+#include "openvino/op/variadic_split.hpp"+#include "utils/common.hpp"++namespace {++/// @brief Gets and validates the 'axis' attribute from the node+/// @param node Input ONNX node+/// @param partial_shape Partial shape of the input tensor to be split+/// @return The validated axis value+std::int64_t get_axis(const ov::frontend::onnx::Node& node, const ov::PartialShape& partial_shape) {+ const auto input_rank = partial_shape.rank();+ OPENVINO_ASSERT(input_rank.is_static(), "SplitToSequence: requires static input rank");++ auto axis = node.get_attribute_value<std::int64_t>("axis", 0);++ if (axis < 0) {+ axis += input_rank.get_length();+ }+ OPENVINO_ASSERT(0 <= axis && axis < input_rank.get_length(), "SplitToSequence: axis is out of range");++ return axis;+}++/// @brief Gets and validates the split axis length+/// @param partial_shape Partial shape of the input tensor to be split+/// @param axis The split axis+/// @return The validated axis length+std::int64_t get_axis_length(const ov::PartialShape& partial_shape, std::int64_t axis) {+ const auto axis_dimension = partial_shape[axis];+ OPENVINO_ASSERT(axis_dimension.is_static(),+ "SplitToSequence: scalar 'split' input requires static dimension on the split axis");++ return axis_dimension.get_length();+}++/// @brief Implements the SplitToSequence operator with scalar 'split' input+/// @param node Input ONNX node+/// @param inputs Input tensors+/// @return A sequence of tensors obtained by splitting the input tensor in form of a SequenceMark node+ov::OutputVector split_with_scalar_split(const ov::frontend::onnx::Node& node, const ov::OutputVector& inputs) {+ const auto& input = inputs[0];+ const auto& partial_shape = input.get_partial_shape();+ const auto axis = get_axis(node, partial_shape);+ const auto& split = inputs[1];++ const auto split_const = ov::util::get_constant_from_source(split);+ OPENVINO_ASSERT(split_const != nullptr, "SplitToSequence: 'split' input must be a constant");+ const auto split_values = split_const->cast_vector<std::int64_t>();+ OPENVINO_ASSERT(!split_values.empty(), "SplitToSequence: 'split' input cannot be empty");++ const std::int64_t chunk = split_values.front();+ OPENVINO_ASSERT(chunk > 0, "SplitToSequence: scalar 'split' must be positive");++ const std::int64_t axis_length = get_axis_length(partial_shape, axis);++ std::vector<std::int64_t> lengths;+ lengths.reserve(static_cast<std::size_t>((axis_length + chunk - 1) / chunk));++ for (std::int64_t offset = 0; offset < axis_length; offset += chunk) {+ lengths.push_back(std::min(chunk, axis_length - offset));+ }++ const auto axis_const = ov::op::v0::Constant::create(ov::element::i64, {}, {axis});+ const auto split_lengths = ov::op::v0::Constant::create(ov::element::i64, {lengths.size()}, lengths);++ return std::make_shared<ov::op::v1::VariadicSplit>(input, axis_const, split_lengths)->outputs();+}++/// @brief Implements the SplitToSequence operator with 1D 'split' input+/// @param node Input ONNX node+/// @param inputs Input tensors+/// @return A sequence of tensors obtained by splitting the input tensor in form of a SequenceMark node+ov::OutputVector split_with_1d_split(const ov::frontend::onnx::Node& node, const ov::OutputVector& inputs) {+ const auto& input = inputs[0];+ const auto& split = inputs[1];+ const auto axis = node.get_attribute_as_constant<std::int64_t>("axis", 0);++ return std::make_shared<ov::op::v1::VariadicSplit>(input, axis, split)->outputs();+}++/// @brief Implements the SplitToSequence operator with explicit 'split' input+/// @param node Input ONNX node+/// @return A sequence of tensors obtained by splitting the input tensor in form of a SequenceMark node+ov::OutputVector split_with_explicit_split(const ov::frontend::onnx::Node& node) {+ const auto& inputs = node.get_ov_inputs();++ const auto& split = inputs[1];++ const auto rank = split.get_partial_shape().rank().get_length();++ if (0 == rank) {+ return split_with_scalar_split(node, inputs);+ } else if (1 == rank) {+ return split_with_1d_split(node, inputs);+ } else {+ OPENVINO_THROW("SplitToSequence: 'split' input must be a scalar or 1-D tensor");+ }+}++/// @brief Implements the SplitToSequence operator with default 'split' input+/// @param node Input ONNX node+/// @return A sequence of tensors obtained by splitting the input tensor in form of a SequenceMark node+ov::OutputVector split_with_default_split(const ov::frontend::onnx::Node& node) {+ const auto& inputs = node.get_ov_inputs();+ const auto& input = inputs[0];+ const auto& partial_shape = input.get_partial_shape();+ const auto axis = get_axis(node, partial_shape);++ const std::int64_t axis_length = get_axis_length(partial_shape, axis);++ ov::OutputVector output_sequence;++ if (0 == axis_length) {+ return output_sequence;+ }++ output_sequence.reserve(axis_length);++ const auto axis_const = ov::op::v0::Constant::create(ov::element::i64, {}, {axis});++ auto split_op = std::make_shared<ov::op::v1::Split>(input, axis_const, static_cast<std::size_t>(axis_length));++ const auto keepdims = node.get_attribute_value<std::int64_t>("keepdims", 1) == 1;++ const auto squeeze_axes = ov::op::v0::Constant::create(ov::element::i64, {1}, {axis});++ for (std::int64_t offset = 0; offset < axis_length; ++offset) {+ auto element = split_op->output(static_cast<std::size_t>(offset));++ if (!keepdims) {+ element = std::make_shared<ov::op::v15::Squeeze>(element, squeeze_axes);+ }+ output_sequence.push_back(std::move(element));+ }++ return output_sequence;+}++} // namespace++namespace ov {+namespace frontend {+namespace onnx {+namespace ai_onnx {+namespace opset_11 {++/// @brief Implements the SplitToSequence operator+/// @param node Input ONNX node+/// @return A sequence of tensors obtained by splitting the input tensor in form of a SequenceMark node+ov::OutputVector split_to_sequence(const ov::frontend::onnx::Node& node) {+ constexpr auto input_only = 1;+ constexpr auto input_and_split = 2;++ common::default_op_checks(node, input_only, input_and_split);++ constexpr auto split_input_index = 1;++ const auto output_sequence = common::is_input_valid(node, split_input_index) ? split_with_explicit_split(node)+ : split_with_default_split(node);++ return {std::make_shared<ov::frontend::SequenceMark>(output_sequence)};+}++/// @brief Registers the SplitToSequence operator implementation in the ONNX frontend+/// @remark The operator is available since ONNX opset 11.+/// Registering as available since opset 1 for compatibility with existing tests.+ONNX_OP("SplitToSequence", OPSET_SINCE(1), ai_onnx::opset_11::split_to_sequence);++} // namespace opset_11++} // namespace ai_onnx+} // namespace onnx+} // namespace frontend+} // namespace ovdiff --git a/src/frontends/onnx/tests/models/sequence_at_3x2_explicit_split_scalar_position0.prototxt b/src/frontends/onnx/tests/models/sequence_at_3x2_explicit_split_scalar_position0.prototxtnew file mode 100644index 00000000000..c14954f60a2--- /dev/null+++ b/src/frontends/onnx/tests/models/sequence_at_3x2_explicit_split_scalar_position0.prototxt@@ -0,0 +1,71 @@+ir_version: 10+graph {+ node {+ input: "input"+ input: "split_sizes"+ output: "sequence"+ op_type: "SplitToSequence"+ attribute {+ name: "axis"+ i: 0+ type: INT+ }+ attribute {+ name: "keepdims"+ i: 1+ type: INT+ }+ }+ node {+ input: "sequence"+ input: "position"+ output: "output"+ op_type: "SequenceAt"+ }+ name: "sequence_at_model"+ initializer {+ data_type: 7+ int64_data: 0+ name: "position"+ }+ initializer {+ data_type: 7+ int64_data: 2+ name: "split_sizes"+ }+ input {+ name: "input"+ type {+ tensor_type {+ elem_type: 1+ shape {+ dim {+ dim_value: 3+ }+ dim {+ dim_value: 2+ }+ }+ }+ }+ }+ output {+ name: "output"+ type {+ tensor_type {+ elem_type: 1+ shape {+ dim {+ dim_value: 2+ }+ dim {+ dim_value: 2+ }+ }+ }+ }+ }+}+opset_import {+ version: 11+}diff --git a/src/frontends/onnx/tests/models/sequence_at_3x2_explicit_split_scalar_position1.prototxt b/src/frontends/onnx/tests/models/sequence_at_3x2_explicit_split_scalar_position1.prototxtnew file mode 100644index 00000000000..f2c257b3a40--- /dev/null+++ b/src/frontends/onnx/tests/models/sequence_at_3x2_explicit_split_scalar_position1.prototxt@@ -0,0 +1,71 @@+ir_version: 10+graph {+ node {+ input: "input"+ input: "split_sizes"+ output: "sequence"+ op_type: "SplitToSequence"+ attribute {+ name: "axis"+ i: 0+ type: INT+ }+ attribute {+ name: "keepdims"+ i: 1+ type: INT+ }+ }+ node {+ input: "sequence"+ input: "position"+ output: "output"+ op_type: "SequenceAt"+ }+ name: "sequence_at_model"+ initializer {+ data_type: 7+ int64_data: 1+ name: "position"+ }+ initializer {+ data_type: 7+ int64_data: 2+ name: "split_sizes"+ }+ input {+ name: "input"+ type {+ tensor_type {+ elem_type: 1+ shape {+ dim {+ dim_value: 3+ }+ dim {+ dim_value: 2+ }+ }+ }+ }+ }+ output {+ name: "output"+ type {+ tensor_type {+ elem_type: 1+ shape {+ dim {+ dim_value: 1+ }+ dim {+ dim_value: 2+ }+ }+ }+ }+ }+}+opset_import {+ version: 11+}diff --git a/src/frontends/onnx/tests/models/sequence_at_3x2_negative_position.prototxt b/src/frontends/onnx/tests/models/sequence_at_3x2_negative_position.prototxtnew file mode 100644index 00000000000..661211d02af--- /dev/null+++ b/src/frontends/onnx/tests/models/sequence_at_3x2_negative_position.prototxt@@ -0,0 +1,65 @@+ir_version: 10+graph {+ node {+ input: "input"+ output: "sequence"+ op_type: "SplitToSequence"+ attribute {+ name: "axis"+ i: 0+ type: INT+ }+ attribute {+ name: "keepdims"+ i: 1+ type: INT+ }+ }+ node {+ input: "sequence"+ input: "position"+ output: "output"+ op_type: "SequenceAt"+ }+ name: "sequence_at_model"+ initializer {+ data_type: 7+ int64_data: -1+ name: "position"+ }+ input {+ name: "input"+ type {+ tensor_type {+ elem_type: 1+ shape {+ dim {+ dim_value: 3+ }+ dim {+ dim_value: 2+ }+ }+ }+ }+ }+ output {+ name: "output"+ type {+ tensor_type {+ elem_type: 1+ shape {+ dim {+ dim_value: 1+ }+ dim {+ dim_value: 2+ }+ }+ }+ }+ }+}+opset_import {+ version: 11+}diff --git a/src/frontends/onnx/tests/models/sequence_at_3x2_no_keepdims.prototxt b/src/frontends/onnx/tests/models/sequence_at_3x2_no_keepdims.prototxtnew file mode 100644index 00000000000..27056954b97--- /dev/null+++ b/src/frontends/onnx/tests/models/sequence_at_3x2_no_keepdims.prototxt@@ -0,0 +1,62 @@+ir_version: 10+graph {+ node {+ input: "input"+ output: "sequence"+ op_type: "SplitToSequence"+ attribute {+ name: "axis"+ i: 0+ type: INT+ }+ attribute {+ name: "keepdims"+ i: 0+ type: INT+ }+ }+ node {+ input: "sequence"+ input: "position"+ output: "output"+ op_type: "SequenceAt"+ }+ name: "sequence_at_model"+ initializer {+ data_type: 7+ int64_data: 0+ name: "position"+ }+ input {+ name: "input"+ type {+ tensor_type {+ elem_type: 1+ shape {+ dim {+ dim_value: 3+ }+ dim {+ dim_value: 2+ }+ }+ }+ }+ }+ output {+ name: "output"+ type {+ tensor_type {+ elem_type: 1+ shape {+ dim {+ dim_value: 2+ }+ }+ }+ }+ }+}+opset_import {+ version: 11+}diff --git a/src/frontends/onnx/tests/models/sequence_at_3x2_position0.prototxt b/src/frontends/onnx/tests/models/sequence_at_3x2_position0.prototxtnew file mode 100644index 00000000000..927c2eeb2e3--- /dev/null+++ b/src/frontends/onnx/tests/models/sequence_at_3x2_position0.prototxt@@ -0,0 +1,65 @@+ir_version: 10+graph {+ node {+ input: "input"+ output: "sequence"+ op_type: "SplitToSequence"+ attribute {+ name: "axis"+ i: 0+ type: INT+ }+ attribute {+ name: "keepdims"+ i: 1+ type: INT+ }+ }+ node {+ input: "sequence"+ input: "position"+ output: "output"+ op_type: "SequenceAt"+ }+ name: "sequence_at_model"+ initializer {+ data_type: 7+ int64_data: 0+ name: "position"+ }+ input {+ name: "input"+ type {+ tensor_type {+ elem_type: 1+ shape {+ dim {+ dim_value: 3+ }+ dim {+ dim_value: 2+ }+ }+ }+ }+ }+ output {+ name: "output"+ type {+ tensor_type {+ elem_type: 1+ shape {+ dim {+ dim_value: 1+ }+ dim {+ dim_value: 2+ }+ }+ }+ }+ }+}+opset_import {+ version: 11+}diff --git a/src/frontends/onnx/tests/models/sequence_at_3x2_position0_axis1.prototxt b/src/frontends/onnx/tests/models/sequence_at_3x2_position0_axis1.prototxtnew file mode 100644index 00000000000..ba817f59ce7--- /dev/null+++ b/src/frontends/onnx/tests/models/sequence_at_3x2_position0_axis1.prototxt@@ -0,0 +1,65 @@+ir_version: 10+graph {+ node {+ input: "input"+ output: "sequence"+ op_type: "SplitToSequence"+ attribute {+ name: "axis"+ i: 1+ type: INT+ }+ attribute {+ name: "keepdims"+ i: 1+ type: INT+ }+ }+ node {+ input: "sequence"+ input: "position"+ output: "output"+ op_type: "SequenceAt"+ }+ name: "sequence_at_model"+ initializer {+ data_type: 7+ int64_data: 0+ name: "position"+ }+ input {+ name: "input"+ type {+ tensor_type {+ elem_type: 1+ shape {+ dim {+ dim_value: 3+ }+ dim {+ dim_value: 2+ }+ }+ }+ }+ }+ output {+ name: "output"+ type {+ tensor_type {+ elem_type: 1+ shape {+ dim {+ dim_value: 3+ }+ dim {+ dim_value: 1+ }+ }+ }+ }+ }+}+opset_import {+ version: 11+}diff --git a/src/frontends/onnx/tests/models/sequence_at_3x2_position1.prototxt b/src/frontends/onnx/tests/models/sequence_at_3x2_position1.prototxtnew file mode 100644index 00000000000..729353bdee9--- /dev/null+++ b/src/frontends/onnx/tests/models/sequence_at_3x2_position1.prototxt@@ -0,0 +1,65 @@+ir_version: 10+graph {+ node {+ input: "input"+ output: "sequence"+ op_type: "SplitToSequence"+ attribute {+ name: "axis"+ i: 0+ type: INT+ }+ attribute {+ name: "keepdims"+ i: 1+ type: INT+ }+ }+ node {+ input: "sequence"+ input: "position"+ output: "output"+ op_type: "SequenceAt"+ }+ name: "sequence_at_model"+ initializer {+ data_type: 7+ int64_data: 1+ name: "position"+ }+ input {+ name: "input"+ type {+ tensor_type {+ elem_type: 1+ shape {+ dim {+ dim_value: 3+ }+ dim {+ dim_value: 2+ }+ }+ }+ }+ }+ output {+ name: "output"+ type {+ tensor_type {+ elem_type: 1+ shape {+ dim {+ dim_value: 1+ }+ dim {+ dim_value: 2+ }+ }+ }+ }+ }+}+opset_import {+ version: 11+}diff --git a/src/frontends/onnx/tests/models/sequence_at_3x2_position1_axis1.prototxt b/src/frontends/onnx/tests/models/sequence_at_3x2_position1_axis1.prototxtnew file mode 100644index 00000000000..e5ac9dc702b--- /dev/null+++ b/src/frontends/onnx/tests/models/sequence_at_3x2_position1_axis1.prototxt@@ -0,0 +1,65 @@+ir_version: 10+graph {+ node {+ input: "input"+ output: "sequence"+ op_type: "SplitToSequence"+ attribute {+ name: "axis"+ i: 1+ type: INT+ }+ attribute {+ name: "keepdims"+ i: 1+ type: INT+ }+ }+ node {+ input: "sequence"+ input: "position"+ output: "output"+ op_type: "SequenceAt"+ }+ name: "sequence_at_model"+ initializer {+ data_type: 7+ int64_data: 1+ name: "position"+ }+ input {+ name: "input"+ type {+ tensor_type {+ elem_type: 1+ shape {+ dim {+ dim_value: 3+ }+ dim {+ dim_value: 2+ }+ }+ }+ }+ }+ output {+ name: "output"+ type {+ tensor_type {+ elem_type: 1+ shape {+ dim {+ dim_value: 3+ }+ dim {+ dim_value: 1+ }+ }+ }+ }+ }+}+opset_import {+ version: 11+}diff --git a/src/frontends/onnx/tests/models/sequence_at_4x2_explicit_split_1d.prototxt b/src/frontends/onnx/tests/models/sequence_at_4x2_explicit_split_1d.prototxtnew file mode 100644index 00000000000..c9693b1668d--- /dev/null+++ b/src/frontends/onnx/tests/models/sequence_at_4x2_explicit_split_1d.prototxt@@ -0,0 +1,73 @@+ir_version: 10+graph {+ node {+ input: "input"+ input: "split_sizes"+ output: "sequence"+ op_type: "SplitToSequence"+ attribute {+ name: "axis"+ i: 0+ type: INT+ }+ attribute {+ name: "keepdims"+ i: 1+ type: INT+ }+ }+ node {+ input: "sequence"+ input: "position"+ output: "output"+ op_type: "SequenceAt"+ }+ name: "sequence_at_model"+ initializer {+ data_type: 7+ int64_data: 0+ name: "position"+ }+ initializer {+ dims: 2+ data_type: 7+ int64_data: 2+ int64_data: 2+ name: "split_sizes"+ }+ input {+ name: "input"+ type {+ tensor_type {+ elem_type: 1+ shape {+ dim {+ dim_value: 4+ }+ dim {+ dim_value: 2+ }+ }+ }+ }+ }+ output {+ name: "output"+ type {+ tensor_type {+ elem_type: 1+ shape {+ dim {+ dim_value: 2+ }+ dim {+ dim_value: 2+ }+ }+ }+ }+ }+}+opset_import {+ version: 11+}diff --git a/src/frontends/onnx/tests/onnx_import.in.cpp b/src/frontends/onnx/tests/onnx_import.in.cppindex a56b019a438..a129c9059ed 100644--- a/src/frontends/onnx/tests/onnx_import.in.cpp+++ b/src/frontends/onnx/tests/onnx_import.in.cpp@@ -7024,4 +7024,152 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_float8e4m3fn_constant) {test_case.add_expected_output<ov::float8_e4m3>({-1.0f, 0.0f, 1.0f, NAN, 256.f, -256.f});test_case.run();-}\ No newline at end of file+}++/// @brief Testing ONNX SplitToSequence operator with implicit split (num_splits is not provided)+/// Model sequence_at_3x2_position0.onnx was generated in the following way:+/// - input shape: feeding SplitToSequence with a 3x2 tensor+/// - position: indexing the element 0 with SequenceAt operation+/// - axis: splitting along first dimension (index 0)+/// - keepdims: true, keeping output dimensions 1x2+OPENVINO_TEST(${BACKEND_NAME}, onnx_split_to_sequence_implicit_split_position0) {+ const auto model = convert_model("sequence_at_3x2_position0.onnx");+ auto test_case = test::TestCase(model, s_device);++ test_case.add_input<float>(Shape{3, 2}, {1., 2., 3., 4., 5., 6.});+ test_case.add_expected_output<float>(Shape{1, 2}, {1., 2.});++ test_case.run();+}++/// @brief Testing ONNX SplitToSequence operator with implicit split (num_splits is not provided)+/// Model sequence_at_3x2_position1.onnx was generated in the following way:+/// - input shape: feeding SplitToSequence with a 3x2 tensor+/// - position: indexing the element 1 with SequenceAt operation+/// - axis: splitting along first dimension (index 0)+/// - keepdims: true, keeping output dimensions 1x2+OPENVINO_TEST(${BACKEND_NAME}, onnx_split_to_sequence_implicit_split_position1) {+ const auto model = convert_model("sequence_at_3x2_position1.onnx");+ auto test_case = test::TestCase(model, s_device);++ test_case.add_input<float>(Shape{3, 2}, {1., 2., 3., 4., 5., 6.});+ test_case.add_expected_output<float>(Shape{1, 2}, {3., 4.});++ test_case.run();+}++/// @brief Testing ONNX SplitToSequence operator with implicit split (num_splits is not provided)+/// Model sequence_at_3x2_negative_position.onnx was generated in the following way:+/// - input shape: feeding SplitToSequence with a 3x2 tensor+/// - position: indexing the element -1 with SequenceAt operation+/// - axis: splitting along first dimension (index 0)+/// - keepdims: true, keeping output dimensions 1x2+OPENVINO_TEST(${BACKEND_NAME}, onnx_split_to_sequence_negative_position) {+ const auto model = convert_model("sequence_at_3x2_negative_position.onnx");+ auto test_case = test::TestCase(model, s_device);++ test_case.add_input<float>(Shape{3, 2}, {1., 2., 3., 4., 5., 6.});+ test_case.add_expected_output<float>(Shape{1, 2}, {5., 6.});++ test_case.run();+}++/// @brief Testing ONNX SplitToSequence operator with implicit split (num_splits is not provided)+/// Model sequence_at_3x2_no_keepdims.onnx was generated in the following way:+/// - input shape: feeding SplitToSequence with a 3x2 tensor+/// - position: indexing the element 0 with SequenceAt operation+/// - axis: splitting along first dimension (index 0)+/// - keepdims: false, keeping output dimensions 2x0+OPENVINO_TEST(${BACKEND_NAME}, onnx_split_to_sequence_no_keepdims) {+ const auto model = convert_model("sequence_at_3x2_no_keepdims.onnx");+ auto test_case = test::TestCase(model, s_device);++ test_case.add_input<float>(Shape{3, 2}, {1., 2., 3., 4., 5., 6.});+ test_case.add_expected_output<float>(Shape{2}, {1., 2.});++ test_case.run();+}++/// @brief Testing ONNX SplitToSequence operator with implicit split (num_splits is not provided)+/// Model sequence_at_3x2_position0_axis1.onnx was generated in the following way:+/// - input shape: feeding SplitToSequence with a 3x2 tensor+/// - position: indexing the element 0 with SequenceAt operation+/// - axis: splitting along second dimension (index 1)+/// - keepdims: true, keeping output dimensions 3x1+OPENVINO_TEST(${BACKEND_NAME}, onnx_split_to_sequence_implicit_split_position0_axis1) {+ const auto model = convert_model("sequence_at_3x2_position0_axis1.onnx");+ auto test_case = test::TestCase(model, s_device);++ test_case.add_input<float>(Shape{3, 2}, {1., 2., 3., 4., 5., 6.});+ test_case.add_expected_output<float>(Shape{3, 1}, {1., 3., 5.});++ test_case.run();+}++/// @brief Testing ONNX SplitToSequence operator with implicit split (num_splits is not provided)+/// Model sequence_at_3x2_position1_axis1.onnx was generated in the following way:+/// - input shape: feeding SplitToSequence with a 3x2 tensor+/// - position: indexing the element 1 with SequenceAt operation+/// - axis: splitting along second dimension (index 1)+/// - keepdims: true, keeping output dimensions 3x1+OPENVINO_TEST(${BACKEND_NAME}, onnx_split_to_sequence_implicit_split_position1_axis1) {+ const auto model = convert_model("sequence_at_3x2_position1_axis1.onnx");+ auto test_case = test::TestCase(model, s_device);++ test_case.add_input<float>(Shape{3, 2}, {1., 2., 3., 4., 5., 6.});+ test_case.add_expected_output<float>(Shape{3, 1}, {2., 4., 6.});++ test_case.run();+}++/// @brief Testing ONNX SplitToSequence operator with explicit split (num_splits is provided)+/// Model sequence_at_3x2_explicit_split_scalar.onnx was generated in the following way:+/// - input shape: feeding SplitToSequence with a 3x2 tensor+/// - position: indexing the element 0 with SequenceAt operation+/// - axis: splitting along first dimension (index 0)+/// - split: scalar input with value 2+/// - keepdims: ignored due to explicit "split"+OPENVINO_TEST(${BACKEND_NAME}, onnx_split_to_sequence_explicit_split_scalar_position0) {+ const auto model = convert_model("sequence_at_3x2_explicit_split_scalar_position0.onnx");+ auto test_case = test::TestCase(model, s_device);++ test_case.add_input<float>(Shape{3, 2}, {1., 2., 3., 4., 5., 6.});+ test_case.add_expected_output<float>(Shape{2, 2}, {1., 2., 3., 4.});++ test_case.run();+}++/// @brief Testing ONNX SplitToSequence operator with explicit split (num_splits is provided)+/// Model sequence_at_3x2_explicit_split_scalar_position1.onnx was generated in the following way:+/// - input shape: feeding SplitToSequence with a 3x2 tensor+/// - position: indexing the element 1 with SequenceAt operation+/// - axis: splitting along first dimension (index 0)+/// - split: scalar input with value 2+/// - keepdims: ignored due to explicit "split"+OPENVINO_TEST(${BACKEND_NAME}, onnx_split_to_sequence_explicit_split_scalar_position1) {+ const auto model = convert_model("sequence_at_3x2_explicit_split_scalar_position1.onnx");+ auto test_case = test::TestCase(model, s_device);++ test_case.add_input<float>(Shape{3, 2}, {1., 2., 3., 4., 5., 6.});+ // NOTE: The last slice has only one element due to input shape 3 not being divisible by split size 2+ test_case.add_expected_output<float>(Shape{1, 2}, {5., 6.});++ test_case.run();+}++/// @brief Testing ONNX SplitToSequence operator with explicit 1-D split+/// Model sequence_at_4x2_explicit_split_1d.onnx was generated in the following way:+/// - input shape: feeding SplitToSequence with a 4x2 tensor+/// - position: indexing the element 0 with SequenceAt operation+/// - axis: splitting along first dimension (index 0)+/// - split: 1-D input with value [2, 2]+/// - keepdims: ignored due to explicit "split"+OPENVINO_TEST(${BACKEND_NAME}, onnx_split_to_sequence_explicit_split_1d) {+ const auto model = convert_model("sequence_at_4x2_explicit_split_1d.onnx");+ auto test_case = test::TestCase(model, s_device);++ test_case.add_input<float>(Shape{4, 2}, {1., 2., 3., 4., 5., 6., 7., 8.});+ test_case.add_expected_output<float>(Shape{2, 2}, {1., 2., 3., 4.});++ test_case.run();+}diff --git a/src/frontends/onnx/tests/tests_python/test_backend.py b/src/frontends/onnx/tests/tests_python/test_backend.pyindex 398aa2f93bb..57feb3c3c0a 100644--- a/src/frontends/onnx/tests/tests_python/test_backend.py+++ b/src/frontends/onnx/tests/tests_python/test_backend.py@@ -158,7 +158,6 @@ tests_expected_to_fail = [(xfail_issue_33596,"OnnxBackendSimpleModelTest.test_sequence_model5_cpu",- "OnnxBackendSimpleModelTest.test_sequence_model7_cpu","OnnxBackendSimpleModelTest.test_sequence_model1_cpu","OnnxBackendSimpleModelTest.test_sequence_model3_cpu","OnnxBackendSimpleModelTest.test_sequence_model6_cpu",