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
[PT FE] Support complex Rope pattern (#30528)
Maxim Vafina93f9ed05c78
diff --git a/src/frontends/pytorch/src/frontend.cpp b/src/frontends/pytorch/src/frontend.cppindex e22a64cf2a8..947f5c037b7 100644--- a/src/frontends/pytorch/src/frontend.cpp+++ b/src/frontends/pytorch/src/frontend.cpp@@ -71,7 +71,14 @@ std::map<std::string, std::string> get_unconverted_types_from_model(const std::s} else if (const auto& fw_node = ov::as_type_ptr<ov::op::util::FrameworkNode>(node)) {auto op_type = std::string(fw_node->get_type_name());if (!unconverted_ops_types.count(op_type)) {- unconverted_ops_types.emplace(op_type, "This is OpenVINO internal type.");+ std::stringstream consumer;+ if (fw_node->get_output_size() > 0) {+ auto inputs = fw_node->output(0).get_target_inputs();+ if (inputs.size() > 0) {+ consumer << " Consumer: " << *(inputs.begin()->get_node());+ }+ }+ unconverted_ops_types.emplace(op_type, "This is OpenVINO internal type." + consumer.str());}}if (const auto& fw_node = ov::as_type_ptr<ov::op::util::MultiSubGraphOp>(node)) {diff --git a/src/frontends/pytorch/src/op/cat.cpp b/src/frontends/pytorch/src/op/cat.cppindex 0298aaa80af..a795ae24d81 100644--- a/src/frontends/pytorch/src/op/cat.cpp+++ b/src/frontends/pytorch/src/op/cat.cpp@@ -2,6 +2,7 @@// SPDX-License-Identifier: Apache-2.0//+#include "openvino/frontend/complex_type_mark.hpp"#include "openvino/frontend/pytorch/node_context.hpp"#include "openvino/op/concat.hpp"#include "openvino/op/convert_like.hpp"@@ -59,6 +60,26 @@ OutputVector translate_cat_common(const NodeContext& context,return {context.mark_node(std::make_shared<v1::Reshape>(tensor, new_shape, false))};}+ // Resolve complex types+ OutputVector inputs_vec;+ bool is_complex =+ std::any_of(std::next(list_elems.begin()), list_elems.end(), [](const ov::Output<ov::Node>& input) {+ return ov::as_type_ptr<ComplexTypeMark>(input.get_node_shared_ptr()) != nullptr;+ });+ if (is_complex) {+ // axis that couts from end, needs to be increased by 1 dimension+ if (axis < 0)+ axis -= 1;+ for (const auto& elem : list_elems) {+ // Remove complex type marks+ auto elem_node = elem.get_node_shared_ptr();+ PYTORCH_OP_CONVERSION_CHECK(as_type_ptr<ComplexTypeMark>(elem_node),+ "Mixing complex and non-complex is not supported in aten::cat.");+ inputs_vec.push_back(elem_node->get_input_source_output(0));+ }+ } else {+ inputs_vec = OutputVector(list_elems.begin(), list_elems.end());+ }const auto first_in_type = list_elems.front().get_element_type();const bool is_mixed_type =list_elems.size() > 1 && (std::any_of(std::next(list_elems.begin()),@@ -67,11 +88,10 @@ OutputVector translate_cat_common(const NodeContext& context,return input.get_element_type() != first_in_type ||input.get_element_type() == ov::element::dynamic;}));- auto inputs_vec = OutputVector(list_elems.begin(), list_elems.end());if (is_mixed_type) {auto node_of_type = inputs_vec[0];for (size_t i = 1; i < inputs_vec.size(); ++i) {- auto cpt = context.mark_node(std::make_shared<v14::ConvertPromoteTypes>(node_of_type, list_elems[i], true));+ auto cpt = context.mark_node(std::make_shared<v14::ConvertPromoteTypes>(node_of_type, inputs_vec[i], true));node_of_type = cpt->output(0);inputs_vec[i] = cpt->output(1);}@@ -81,14 +101,15 @@ OutputVector translate_cat_common(const NodeContext& context,for (size_t i = 1; i < inputs_vec.size(); ++i) {if (inputs_vec[i].get_element_type() != unified_type ||inputs_vec[i].get_element_type() == ov::element::dynamic) {- inputs_vec[i] = context.mark_node(std::make_shared<v1::ConvertLike>(list_elems[i], node_of_type));+ inputs_vec[i] = context.mark_node(std::make_shared<v1::ConvertLike>(inputs_vec[i], node_of_type));}}- auto concat = std::make_shared<v0::Concat>(inputs_vec, axis);- return {context.mark_node(concat)};}-- return {context.mark_node(std::make_shared<v0::Concat>(inputs_vec, axis))};+ auto concat = context.mark_node(std::make_shared<v0::Concat>(inputs_vec, axis));+ if (is_complex) {+ concat = context.mark_node(std::make_shared<ComplexTypeMark>(concat));+ }+ return {concat};}OutputVector translate_cat(const NodeContext& context) {diff --git a/src/frontends/pytorch/src/op/expand.cpp b/src/frontends/pytorch/src/op/expand.cppindex 84dfffe1d07..46bf1c299a1 100644--- a/src/frontends/pytorch/src/op/expand.cpp+++ b/src/frontends/pytorch/src/op/expand.cpp@@ -2,10 +2,12 @@// SPDX-License-Identifier: Apache-2.0//+#include "openvino/frontend/complex_type_mark.hpp"#include "openvino/frontend/pytorch/node_context.hpp"#include "openvino/op/abs.hpp"#include "openvino/op/broadcast.hpp"#include "openvino/op/concat.hpp"+#include "openvino/op/convert_like.hpp"#include "openvino/op/reshape.hpp"#include "openvino/op/shape_of.hpp"#include "utils.hpp"@@ -19,14 +21,29 @@ using namespace ov::op;namespace {OutputVector base_expand(const NodeContext& context, const Output<Node>& x, const Output<Node>& sizes) {- auto shape = context.mark_node(std::make_shared<v0::Abs>(sizes));- return {context.mark_node(std::make_shared<v3::Broadcast>(x, shape, BroadcastType::BIDIRECTIONAL))};+ auto data = x;+ Output<Node> shape = context.mark_node(std::make_shared<v0::Abs>(sizes));+ auto complex = as_type_ptr<ComplexTypeMark>(data.get_node_shared_ptr());+ bool is_complex = complex != nullptr;+ if (is_complex) {+ data = complex->get_input_source_output(0);+ auto two = context.mark_node(v0::Constant::create(element::i32, Shape{1}, {2}));+ if (shape.get_element_type() != element::i32) {+ two = context.mark_node(std::make_shared<v1::ConvertLike>(two, shape));+ }+ shape = context.mark_node(std::make_shared<v0::Concat>(OutputVector{shape, two}, 0));+ }+ auto res = context.mark_node(std::make_shared<v3::Broadcast>(data, shape, BroadcastType::BIDIRECTIONAL));+ if (is_complex) {+ res = context.mark_node(std::make_shared<ComplexTypeMark>(res));+ }+ return {res};};} // namespaceOutputVector translate_expand(const NodeContext& context) {// aten::expand(Tensor(a) self, SymInt[] size, *, bool implicit=False) -> Tensor(a)- num_inputs_check(context, 2, 3);+ num_inputs_check(context, 2, 3, true);auto x = context.get_input(0);auto sizes = get_input_concat_if_list(context, 1);// TODO: figure out what implicit meansdiff --git a/src/frontends/pytorch/src/op/list_unpack.cpp b/src/frontends/pytorch/src/op/list_unpack.cppindex 5bf19dfe4f8..9050ea2ece9 100644--- a/src/frontends/pytorch/src/op/list_unpack.cpp+++ b/src/frontends/pytorch/src/op/list_unpack.cpp@@ -2,6 +2,7 @@// SPDX-License-Identifier: Apache-2.0//+#include "openvino/frontend/complex_type_mark.hpp"#include "openvino/frontend/pytorch/node_context.hpp"#include "utils.hpp"#include "utils_quantize.hpp"@@ -14,27 +15,46 @@ namespace op {using namespace ov::op;OutputVector translate_list_unpack(const NodeContext& context) {- const auto& outputs =- make_framework_node(context, "Lists are not supported yet and can be resolved only in specific cases.");- OutputVector res;- const auto& input = context.get_input(0);- const auto& input_node = input.get_node_shared_ptr();- const auto& quantized_node = input_node->input_value(0);- if (const auto& quantized_pt_node = cast_quantized_fw_node(quantized_node.get_node_shared_ptr())) {- if (const auto& chunk_node = cast_fw_node(input_node, "aten::chunk")) {- for (const auto& output : outputs) {- res.push_back(context.mark_node(std::make_shared<QuantizedPtNode>(quantized_pt_node->get_type(),- output,- quantized_pt_node->get_scale(),- quantized_pt_node->get_zero_point(),- quantized_pt_node->get_dtype())));+ auto input = context.get_input(0);++ auto complex = as_type_ptr<ComplexTypeMark>(input.get_node_shared_ptr());+ bool is_complex = complex != nullptr;+ if (is_complex) {+ input = complex->get_input_source_output(0);+ }++ if (const auto& list = cast_fw_node(input.get_node_shared_ptr(), "prim::ListConstruct")) {+ // ListConstruct -> ListUnpack can be annihilated+ auto res = list->input_values();+ if (is_complex) {+ for (auto& output : res) {+ output = context.mark_node(std::make_shared<ComplexTypeMark>(output));}- return res;- } else {- PYTORCH_OP_CONVERSION_CHECK(false, "Unsupported operation type.");}+ return res;} else {- return outputs;+ const auto& outputs =+ make_framework_node(context, "Lists are not supported yet and can be resolved only in specific cases.");+ OutputVector res;+ const auto& input_node = input.get_node_shared_ptr();+ const auto& quantized_node = input_node->input_value(0);+ if (const auto& quantized_pt_node = cast_quantized_fw_node(quantized_node.get_node_shared_ptr())) {+ if (const auto& chunk_node = cast_fw_node(input_node, "aten::chunk")) {+ for (const auto& output : outputs) {+ res.push_back(+ context.mark_node(std::make_shared<QuantizedPtNode>(quantized_pt_node->get_type(),+ output,+ quantized_pt_node->get_scale(),+ quantized_pt_node->get_zero_point(),+ quantized_pt_node->get_dtype())));+ }+ return res;+ } else {+ PYTORCH_OP_CONVERSION_CHECK(false, "Unsupported operation type.");+ }+ } else {+ return outputs;+ }}};diff --git a/src/frontends/pytorch/src/op/slice.cpp b/src/frontends/pytorch/src/op/slice.cppindex eb467ac7ea8..ba601a94955 100644--- a/src/frontends/pytorch/src/op/slice.cpp+++ b/src/frontends/pytorch/src/op/slice.cpp@@ -7,6 +7,7 @@#include <climits>#include "openvino/core/validation_util.hpp"+#include "openvino/frontend/complex_type_mark.hpp"#include "openvino/frontend/pytorch/node_context.hpp"#include "openvino/op/constant.hpp"#include "openvino/op/reshape.hpp"@@ -24,6 +25,7 @@ OutputVector translate_slice_common(const NodeContext& context,const bool stop_dynamic_rank_unsqueeze = true) {// aten::slice.t(t[] l, int? start=None, int? end=None, int step=1) -> (t[])// aten::slice.Tensor(Tensor(a) self, int dim=0, int? start=None, int? end=None, int step=1) -> (Tensor(a))+ auto data = context.get_input(0);ov::Output<ov::Node> dim;int start_idx;int end_idx;@@ -88,7 +90,16 @@ OutputVector translate_slice_common(const NodeContext& context,} else {step = context.mark_node(v0::Constant::create(element::i32, Shape{1}, {1}));}- return {context.mark_node(std::make_shared<v8::Slice>(context.get_input(0), start, end, step, dim))};++ if (const auto complex = as_type_ptr<ComplexTypeMark>(data.get_node_shared_ptr())) {+ auto rank = std::get<1>(get_shape_rank(context, data, true));+ dim = normalize_axis(context, dim, rank);+ data = complex->get_input_source_output(0);+ Output<Node> slice = context.mark_node(std::make_shared<v8::Slice>(data, start, end, step, dim));+ return {context.mark_node(std::make_shared<ComplexTypeMark>(slice, slice.get_element_type()))};+ } else {+ return {context.mark_node(std::make_shared<v8::Slice>(data, start, end, step, dim))};+ }};OutputVector translate_slice(const NodeContext& context) {diff --git a/src/frontends/pytorch/src/op/split.cpp b/src/frontends/pytorch/src/op/split.cppindex 83a8bd129bc..3e29b638ba1 100644--- a/src/frontends/pytorch/src/op/split.cpp+++ b/src/frontends/pytorch/src/op/split.cpp@@ -4,8 +4,7 @@#include "openvino/op/split.hpp"-//#include <climits>-+#include "openvino/frontend/complex_type_mark.hpp"#include "openvino/frontend/pytorch/node_context.hpp"#include "openvino/op/squeeze.hpp"#include "openvino/op/util/framework_node.hpp"@@ -75,10 +74,11 @@ OutputVector translate_unbind_int_fx(const NodeContext& context) {return {context.mark_node(make_list_construct(out_vec))};}-OutputVector translate_split_with_sizes_fx(const NodeContext& context) {- num_inputs_check(context, 2, 3);+OutputVector translate_split_with_sizes(const NodeContext& context) {+ // aten::split_with_sizes(Tensor(a -> *) self, SymInt[] split_sizes, int dim=0) -> Tensor(a)[]+ num_inputs_check(context, 2, 3, true);auto data = context.get_input(0);- auto split_lengths = context.get_input(1);+ auto split_lengths = get_input_concat_if_list(context, 1);Output<Node> dim;if (context.input_is_none(2)) {dim = context.mark_node(v0::Constant::create(element::i32, Shape{}, {0}));@@ -86,9 +86,26 @@ OutputVector translate_split_with_sizes_fx(const NodeContext& context) {dim = context.get_input(2);}+ auto complex = as_type_ptr<ComplexTypeMark>(data.get_node_shared_ptr());+ bool is_complex = complex != nullptr;+ if (is_complex) {+ if (dim.get_element_type() != element::i32) {+ dim = context.mark_node(std::make_shared<v0::Convert>(dim, element::i32));+ }+ auto rank = std::get<1>(get_shape_rank(context, data, true));+ dim = normalize_axis(context, dim, rank);+ data = complex->get_input_source_output(0);+ }+auto split = context.mark_node(std::make_shared<v1::VariadicSplit>(data, dim, split_lengths));- return {context.mark_node(make_list_construct(split->outputs()))};+ auto res = split->outputs();+ if (is_complex) {+ for (auto& output : res) {+ output = context.mark_node(std::make_shared<ComplexTypeMark>(output));+ }+ }+ return {context.mark_node(make_list_construct(res))};}} // namespace opdiff --git a/src/frontends/pytorch/src/op_table.cpp b/src/frontends/pytorch/src/op_table.cppindex 8d647dc6a03..996b36d3eb3 100644--- a/src/frontends/pytorch/src/op_table.cpp+++ b/src/frontends/pytorch/src/op_table.cpp@@ -244,6 +244,7 @@ OP_CONVERTER(translate_size);OP_CONVERTER(translate_slice);OP_CONVERTER(translate_softmax);OP_CONVERTER(translate_sort);+OP_CONVERTER(translate_split_with_sizes);OP_CONVERTER(translate_square);OP_CONVERTER(translate_squeeze);OP_CONVERTER(translate_std);@@ -337,7 +338,6 @@ OP_CONVERTER(translate_slice_fx);OP_CONVERTER(translate_slice_scatter_fx);OP_CONVERTER(translate_softmax_fx);OP_CONVERTER(translate_sort_fx);-OP_CONVERTER(translate_split_with_sizes_fx);OP_CONVERTER(translate_stack_fx);OP_CONVERTER(translate_sub_fx);OP_CONVERTER(translate_sum_fx);@@ -710,7 +710,7 @@ const std::unordered_map<std::string, CreatorFunction> get_supported_ops_ts() {{"aten::special_expit",op::optional_out<op::translate_1to1_match_1_inputs_with_fp32_type_alignment<opset10::Sigmoid>, 1>},// aten::split - Supported in limited set of patterns- // aten::split_with_sizes - Supported in limited set of patterns+ {"aten::split_with_sizes", op::translate_split_with_sizes},{"aten::sqrt", op::optional_out<op::translate_1to1_match_1_inputs_with_fp32_type_alignment<opset10::Sqrt>, 1>},{"aten::sqrt_", op::inplace_op<op::translate_1to1_match_1_inputs_with_fp32_type_alignment<opset10::Sqrt>>},{"aten::square", op::translate_square},@@ -1036,8 +1036,8 @@ const std::unordered_map<std::string, CreatorFunction> get_supported_ops_fx() {{"aten.slice_scatter.default", op::translate_slice_scatter_fx},{"aten.sort.default", op::translate_sort_fx},{"aten.split.Tensor", op::translate_chunk_fx},- {"aten.split_with_sizes.default", op::translate_split_with_sizes_fx},- {"aten.split_with_sizes_copy.default", op::translate_split_with_sizes_fx},+ {"aten.split_with_sizes.default", op::translate_split_with_sizes},+ {"aten.split_with_sizes_copy.default", op::translate_split_with_sizes},{"aten.sqrt.default", op::translate_1to1_match_1_inputs_with_fp32_type_alignment<opset10::Sqrt>},{"aten.squeeze.dim", op::translate_squeeze},{"aten.squeeze.dims", op::translate_squeeze},diff --git a/src/frontends/pytorch/src/transforms/prim_list_unpack_replacer.cpp b/src/frontends/pytorch/src/transforms/prim_list_unpack_replacer.cppindex c37153acb3f..c35b8b32a4c 100644--- a/src/frontends/pytorch/src/transforms/prim_list_unpack_replacer.cpp+++ b/src/frontends/pytorch/src/transforms/prim_list_unpack_replacer.cpp@@ -78,16 +78,6 @@ PrimListUnpackReplacer::PrimListUnpackReplacer() {copy_runtime_info_and_name(list_unpack, rg.get(), {input_node});replace_node(list_unpack, split);- return true;- } else if (auto split_with_sizes = cast_fw_node(input_node, "aten::split_with_sizes")) {- auto split_lengths = concat_list_construct(split_with_sizes->get_input_source_output(1));- auto split = rg.make<v1::VariadicSplit>(split_with_sizes->get_input_source_output(0),- split_with_sizes->get_input_source_output(2),- split_lengths);-- copy_runtime_info_and_name(list_unpack, rg.get(), {input_node});- replace_node(list_unpack, split);-return true;} else if (auto chunk = cast_fw_node(input_node, {"aten::chunk", "aten::unsafe_chunk"})) {if (list_unpack->get_output_size() == 1) {diff --git a/tests/layer_tests/pytorch_tests/test_cat.py b/tests/layer_tests/pytorch_tests/test_cat.pyindex 8ca1374bf38..838f39fa630 100644--- a/tests/layer_tests/pytorch_tests/test_cat.py+++ b/tests/layer_tests/pytorch_tests/test_cat.py@@ -8,7 +8,6 @@ import numpy as npfrom pytorch_layer_test_class import PytorchLayerTest-class aten_cat(torch.nn.Module):def forward(self, x):return torch.cat(self.prepare_input(x), 1)@@ -16,10 +15,12 @@ class aten_cat(torch.nn.Module):def prepare_input(self, x):return [x, x]+class aten_cat_out(aten_cat):def forward(self, x, out):return torch.cat(self.prepare_input(x), 1, out=out), out+class aten_append_cat(aten_cat):def prepare_input(self, x):list = []@@ -27,6 +28,7 @@ class aten_append_cat(aten_cat):list.append(x)return list+class aten_append_cat_out(aten_cat_out):def prepare_input(self, x):list = []@@ -34,6 +36,7 @@ class aten_append_cat_out(aten_cat_out):list.append(x)return list+class aten_loop_append_cat(aten_cat):def prepare_input(self, x):list = []@@ -49,6 +52,7 @@ class aten_loop_append_cat_out(aten_cat_out):list.append(x)return list+class aten_add_cat(aten_cat):def forward(self, x):list1 = self.prepare_input(x)@@ -62,10 +66,19 @@ class aten_add_cat_out(aten_cat_out):list2 = self.prepare_input(x)return torch.cat(list1 + list2, dim=1, out=out)++class aten_cat_complex(torch.nn.Module):+ def forward(self, x):+ return torch.view_as_real(torch.cat(self.prepare_input(x), 1))++ def prepare_input(self, x):+ return [torch.view_as_complex(x), torch.view_as_complex(x)]++class TestCat(PytorchLayerTest):def _prepare_input(self, out=False, num_repeats=2):import numpy as np- data = np.random.randn(2, 1, 3)+ data = np.random.randn(3, 1, 2)if not out:return (data, )concat = [data for _ in range(num_repeats)]@@ -106,6 +119,13 @@ class TestCat(PytorchLayerTest):self._test(model, None, ["aten::cat", "aten::add", "prim::ListConstruct"],ie_device, precision, ir_version, freeze_model=False, kwargs_to_prepare_input={"out": out, "num_repeats": 4})+ @pytest.mark.nightly+ @pytest.mark.precommit+ def test_cat_complex(self, ie_device, precision, ir_version):+ model = aten_cat_complex()+ self._test(model, None, ["aten::cat", "prim::ListConstruct"],+ ie_device, precision, ir_version, freeze_model=False)+class TestCatAlignTypes(PytorchLayerTest):def _prepare_input(self, in_types):diff --git a/tests/layer_tests/pytorch_tests/test_expand.py b/tests/layer_tests/pytorch_tests/test_expand.pyindex 23d6eedf38b..10f19dbd674 100644--- a/tests/layer_tests/pytorch_tests/test_expand.py+++ b/tests/layer_tests/pytorch_tests/test_expand.py@@ -1,8 +1,8 @@# Copyright (C) 2018-2025 Intel Corporation# SPDX-License-Identifier: Apache-2.0-import pytestimport random+import pytestfrom pytorch_layer_test_class import PytorchLayerTest@@ -41,6 +41,7 @@ class TestExpand(PytorchLayerTest):def test_expand(self, dims, op_type, ie_device, precision, ir_version):self._test(*self.create_model(dims, op_type), ie_device, precision, ir_version)+class TestExpandCopy(PytorchLayerTest):def _prepare_input(self):import numpy as np@@ -66,6 +67,7 @@ class TestExpandCopy(PytorchLayerTest):def test_expand_copy(self, dims, ie_device, precision, ir_version):self._test(*self.create_model(dims), ie_device, precision, ir_version)+class TestExpandList(PytorchLayerTest):def _prepare_input(self, broadcast_shape):import numpy as np@@ -139,6 +141,7 @@ class TestExpandAs(PytorchLayerTest):self._test(*self.create_model(), ie_device, precision,ir_version, kwargs_to_prepare_input=kwargs_to_prepare_input)+class TestDynamicExpand(PytorchLayerTest):def _prepare_input(self):import numpy as np@@ -165,3 +168,35 @@ class TestDynamicExpand(PytorchLayerTest):@pytest.mark.precommit_fx_backenddef test_dynamic_expand(self, dims, ie_device, precision, ir_version):self._test(*self.create_model(dims), ie_device, precision, ir_version)+++class TestComplexExpand(PytorchLayerTest):+ def _prepare_input(self):+ import numpy as np+ return (np.random.randn(1, 3, 2).astype(np.float32),)++ def create_model(self, dim):+ import torch++ class aten_expand(torch.nn.Module):+ def __init__(self, dims):+ super().__init__()+ self.dims = dims++ def forward(self, x):+ x = torch.view_as_complex(x)+ x = x.expand(self.dims)+ return torch.view_as_real(x)++ return aten_expand(dim), None, "aten::expand"++ @pytest.mark.parametrize("dims", [(4, 3),+ (-1, -1),+ (1, 2, 3),+ (1, 2, 2, 3)])+ @pytest.mark.nightly+ @pytest.mark.precommit+ @pytest.mark.precommit_torch_export+ @pytest.mark.precommit_fx_backend+ def test_complex_expand(self, dims, ie_device, precision, ir_version):+ self._test(*self.create_model(dims), ie_device, precision, ir_version)diff --git a/tests/layer_tests/pytorch_tests/test_slice.py b/tests/layer_tests/pytorch_tests/test_slice.pyindex 8d7c2f63755..6bc7e99415a 100644--- a/tests/layer_tests/pytorch_tests/test_slice.py+++ b/tests/layer_tests/pytorch_tests/test_slice.py@@ -74,6 +74,34 @@ class TestSlice2D(PytorchLayerTest):)+class TestSliceComplex(PytorchLayerTest):+ def _prepare_input(self, params):+ return (np.array(range(32), np.float32).reshape(16, 2),+ np.array(params, dtype=np.int32))++ def create_model(self):+ class aten_slice(torch.nn.Module):+ def forward(self, x, params):+ x = torch.view_as_complex(x)+ x = x[params[0]: params[1]: params[2]]+ return torch.view_as_real(x)++ return aten_slice(), None, "aten::slice"++ @pytest.mark.parametrize("params", [[0, -1, 1],+ [0, -1, 3],+ [0, 5, 3],+ [2, 7, 3],+ [-7, -15, 2],+ [-1, -7, 2],+ [5, 2, 1]])+ @pytest.mark.nightly+ @pytest.mark.precommit+ def test_slice_complex(self, ie_device, precision, ir_version, params):+ self._test(*self.create_model(), ie_device, precision, ir_version,+ kwargs_to_prepare_input={"params": params})++class TestSliceAndSqueeze(PytorchLayerTest):def _prepare_input(self):return (np.random.randn(1, 1, 32).astype(np.float32),)@@ -93,5 +121,6 @@ class TestSliceAndSqueeze(PytorchLayerTest):@pytest.mark.nightly@pytest.mark.precommit+ @pytest.mark.precommit_torch_exportdef test_slice_and_squeeze(self, ie_device, precision, ir_version):self._test(*self.create_model(), ie_device, precision, ir_version, dynamic_shapes=False)diff --git a/tests/layer_tests/pytorch_tests/test_split.py b/tests/layer_tests/pytorch_tests/test_split.pyindex 3f3253ee53e..3b782c83861 100644--- a/tests/layer_tests/pytorch_tests/test_split.py+++ b/tests/layer_tests/pytorch_tests/test_split.py@@ -88,16 +88,10 @@ class TestSplitWithSizes(PytorchLayerTest):import torchclass aten_split_with_sizes(torch.nn.Module):- def __init__(self):- super(aten_split_with_sizes, self).__init__()- #self.sizes = 20-def forward(self, x, y):return x.split([y.shape[0]], dim=0)- ref_net = None-- return aten_split_with_sizes(), ref_net, ["aten::split_with_sizes", "prim::ListConstruct"]+ return aten_split_with_sizes(), None, ["aten::split_with_sizes", "prim::ListConstruct"]@pytest.mark.nightly@pytest.mark.precommit@@ -107,6 +101,7 @@ class TestSplitWithSizes(PytorchLayerTest):self._test(*self.create_model(),ie_device, precision, ir_version, trace_model=True)+class TestSplitWithSizesCopy(PytorchLayerTest):def _prepare_input(self):import numpy as np@@ -130,3 +125,32 @@ class TestSplitWithSizesCopy(PytorchLayerTest):def test_split_with_sizes_copy(self, ie_device, precision, ir_version):self._test(*self.create_model(),ie_device, precision, ir_version, trace_model=True)+++class TestSplitWithSizesComplex(PytorchLayerTest):+ def _prepare_input(self):+ import numpy as np+ return (np.random.randn(20, 2).astype(np.float32),+ np.random.randn(5).astype(np.float32))++ def create_model(self):+ import torch++ class aten_split_with_sizes(torch.nn.Module):+ def forward(self, x, y):+ x = torch.view_as_complex(x)+ x1, x2, x3, x4 = x.split([y.shape[0], y.shape[0], y.shape[0], y.shape[0]], dim=0)+ return (torch.view_as_real(x1),+ torch.view_as_real(x2),+ torch.view_as_real(x3),+ torch.view_as_real(x4))++ return aten_split_with_sizes(), None, ["aten::split_with_sizes", "prim::ListConstruct"]++ @pytest.mark.nightly+ @pytest.mark.precommit+ @pytest.mark.precommit_torch_export+ @pytest.mark.precommit_fx_backend+ def test_split_with_sizes_complex(self, ie_device, precision, ir_version):+ self._test(*self.create_model(),+ ie_device, precision, ir_version, trace_model=True)