Skip to content

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

[ONNX] Added a new attribute support for Split-18 operation (#31921)

liang3ed616229b18
diff --git a/src/frontends/onnx/docs/supported_ops.md b/src/frontends/onnx/docs/supported_ops.md
index d70f6a068fb..3ae500e66dc 100644
--- a/src/frontends/onnx/docs/supported_ops.md
+++ b/src/frontends/onnx/docs/supported_ops.md
@@ -184,7 +184,7 @@ OpenVINO provides support for operations of Default Opset (empty in table below)
| |Softplus |1 |22, 1 | |
| |Softsign |1 |22, 1 | |
| |SpaceToDepth |1 |13, 1 | |
-| |Split |13, 1 |18, 13, 11, 2, 1 | |
+| |Split |18, 13, 1 |18, 13, 11, 2, 1 | |
| |SplitToSequence | |11 | |
| |Sqrt |1 |13, 6, 1 | |
| |Squeeze |13, 1 |21, 13, 11, 1 | |
diff --git a/src/frontends/onnx/frontend/src/op/split.cpp b/src/frontends/onnx/frontend/src/op/split.cpp
index c66a616e023..f48f91cf458 100644
--- a/src/frontends/onnx/frontend/src/op/split.cpp
+++ b/src/frontends/onnx/frontend/src/op/split.cpp
@@ -45,8 +45,22 @@ ov::OutputVector split(const ov::frontend::onnx::Node& node) {
}
}
-ONNX_OP("Split", OPSET_SINCE(13), ai_onnx::opset_13::split);
+ONNX_OP("Split", OPSET_RANGE(13, 18), ai_onnx::opset_13::split);
} // namespace opset_13
+
+namespace opset_18 {
+ov::OutputVector split(const ov::frontend::onnx::Node& node) {
+ if (node.has_attribute("num_outputs")) {
+ const auto inputs = node.get_ov_inputs();
+ const auto outputs_number = node.get_attribute_value<int64_t>("num_outputs", 0);
+ const auto axis = node.get_attribute_value<int64_t>("axis", 0);
+ return ov::op::util::make_split(inputs.at(0), outputs_number, axis);
+ }
+ return ai_onnx::opset_13::split(node);
+}
+
+ONNX_OP("Split", OPSET_SINCE(18), ai_onnx::opset_18::split);
+} // namespace opset_18
} // namespace ai_onnx
} // namespace onnx
} // namespace frontend
diff --git a/src/frontends/onnx/frontend/src/utils/split.cpp b/src/frontends/onnx/frontend/src/utils/split.cpp
index a1ba848b619..4700e70b23d 100644
--- a/src/frontends/onnx/frontend/src/utils/split.cpp
+++ b/src/frontends/onnx/frontend/src/utils/split.cpp
@@ -31,6 +31,9 @@ OutputVector make_split(const Output<ov::Node>& value, int64_t num_splits, int64
if (axis_len % num_splits) {
auto avg_axis = (axis_len + num_splits - 1) / num_splits; // Round up division
auto last_output_value = axis_len % avg_axis;
+ if (last_output_value == 0) {
+ FRONT_END_THROW("The split number is invalid");
+ }
std::vector<int64_t> split_lengths(num_splits, avg_axis);
split_lengths.back() = last_output_value;
return make_split(value, split_lengths, axis);
diff --git a/src/frontends/onnx/tests/tests_python/test_backend.py b/src/frontends/onnx/tests/tests_python/test_backend.py
index fbd11cf37b6..8e461a24d10 100644
--- a/src/frontends/onnx/tests/tests_python/test_backend.py
+++ b/src/frontends/onnx/tests/tests_python/test_backend.py
@@ -560,6 +560,8 @@ tests_expected_to_fail = [
),
(
xfail_issue_125485,
+ "OnnxBackendNodeModelTest.test_affine_grid_2d_align_corners_expanded_cpu",
+ "OnnxBackendNodeModelTest.test_affine_grid_2d_expanded_cpu",
"OnnxBackendNodeModelTest.test_affine_grid_3d_align_corners_expanded_cpu",
"OnnxBackendNodeModelTest.test_affine_grid_3d_expanded_cpu",
),