From 6fc0b6479ee8e6b0fbcc779f2d24542a9a0c251c Mon Sep 17 00:00:00 2001 From: Ekaterina Aidova Date: Tue, 28 Mar 2023 16:06:21 +0400 Subject: [PATCH] [PT FE]: revert usage mo.convert_model in pt layer tests (#16573) * [PT FE]: revert usage mo.convert_model in tests * fix failed test --- .../python/src/openvino/frontend/pytorch/decoder.py | 4 ++-- src/frontends/pytorch/src/op/add.cpp | 2 +- src/frontends/pytorch/src/utils.hpp | 2 +- .../pytorch_tests/pytorch_layer_test_class.py | 10 ++-------- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/bindings/python/src/openvino/frontend/pytorch/decoder.py b/src/bindings/python/src/openvino/frontend/pytorch/decoder.py index b30fc0934d3..d994a771de8 100644 --- a/src/bindings/python/src/openvino/frontend/pytorch/decoder.py +++ b/src/bindings/python/src/openvino/frontend/pytorch/decoder.py @@ -104,7 +104,7 @@ class TorchScriptPythonDecoder (Decoder): else: self.graph_element = graph_element self.pt_module = pt_module - self.raw_inputs = [inp for inp in self.graph_element.inputs()] + self.raw_inputs = list(self.graph_element.inputs()) self.raw_outputs = list(self.graph_element.outputs()) if self._input_signature is not None and self.raw_inputs[0].debugName() == "self": self._input_signature.insert(0, "self") @@ -171,7 +171,7 @@ class TorchScriptPythonDecoder (Decoder): return self._raw_input(index).debugName() def get_input_signature_name(self, index: int) -> str: - if self._input_signature is not None: + if self._input_signature is not None and index < len(self._input_signature): return self._input_signature[index] return self.get_input_debug_name(index) diff --git a/src/frontends/pytorch/src/op/add.cpp b/src/frontends/pytorch/src/op/add.cpp index 65ecfe021c5..f0a997b6f8f 100644 --- a/src/frontends/pytorch/src/op/add.cpp +++ b/src/frontends/pytorch/src/op/add.cpp @@ -26,7 +26,7 @@ OutputVector translate_add(const NodeContext& context) { // Case when two lists gets concatenated FRONT_END_OP_CONVERSION_CHECK(false, "aten::add is used for concatenation of lists, not possible to convert"); } - align_eltwise_input_types(context, lhs, rhs); + align_eltwise_input_types(context, lhs, rhs, true); if (!context.input_is_none(2)) { auto converted_alpha = context.mark_node(std::make_shared(context.get_input(2), rhs)); rhs = context.mark_node(std::make_shared(converted_alpha, rhs)); diff --git a/src/frontends/pytorch/src/utils.hpp b/src/frontends/pytorch/src/utils.hpp index 029b349c77b..bf83fa95ac3 100644 --- a/src/frontends/pytorch/src/utils.hpp +++ b/src/frontends/pytorch/src/utils.hpp @@ -92,7 +92,7 @@ OutputVector translate_1to1_match_2_inputs_align_types(const NodeContext& contex FRONT_END_OP_CONVERSION_CHECK(!context.input_is_none(0) && !context.input_is_none(1), "Inputs should not be None."); auto lhs = context.get_input(0); auto rhs = context.get_input(1); - align_eltwise_input_types(context, lhs, rhs); + align_eltwise_input_types(context, lhs, rhs, true); return {context.mark_node(std::make_shared(lhs, rhs))}; } diff --git a/tests/layer_tests/pytorch_tests/pytorch_layer_test_class.py b/tests/layer_tests/pytorch_tests/pytorch_layer_test_class.py index eec93596006..a5ad7748f91 100644 --- a/tests/layer_tests/pytorch_tests/pytorch_layer_test_class.py +++ b/tests/layer_tests/pytorch_tests/pytorch_layer_test_class.py @@ -52,15 +52,8 @@ class PytorchLayerTest: inp, np.ndarray) else inp for inp in inputs] trace_model = kwargs.get('trace_model', False) freeze_model = kwargs.get('freeze_model', True) - use_mo_convert = kwargs.get("use_mo_convert", True) - if not freeze_model or not use_mo_convert: - model, converted_model = self.convert_directly_via_frontend( - model, torch_inputs, trace_model, dynamic_shapes, inputs, freeze_model) - else: - model, converted_model = self.convert_via_mo( - model, torch_inputs, trace_model, dynamic_shapes, inputs) + model, converted_model = self.convert_directly_via_frontend(model, torch_inputs, trace_model, dynamic_shapes, inputs, freeze_model) graph = model.inlined_graph - print(graph) if kind is not None and not isinstance(kind, (tuple, list)): kind = [kind] @@ -181,6 +174,7 @@ class PytorchLayerTest: model = torch.jit.trace(model, example_input) else: model = torch.jit.script(model) + print(model.inlined_graph) decoder = TorchScriptPythonDecoder(model, freeze=freeze_model) im = fe.load(decoder) om = fe.convert(im)