[PT FE]: revert usage mo.convert_model in pt layer tests (#16573)

* [PT FE]: revert usage mo.convert_model in tests

* fix failed test
This commit is contained in:
Ekaterina Aidova 2023-03-28 16:06:21 +04:00 committed by GitHub
parent 49d150b3b8
commit 6fc0b6479e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 12 deletions

View File

@ -104,7 +104,7 @@ class TorchScriptPythonDecoder (Decoder):
else: else:
self.graph_element = graph_element self.graph_element = graph_element
self.pt_module = pt_module 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()) self.raw_outputs = list(self.graph_element.outputs())
if self._input_signature is not None and self.raw_inputs[0].debugName() == "self": if self._input_signature is not None and self.raw_inputs[0].debugName() == "self":
self._input_signature.insert(0, "self") self._input_signature.insert(0, "self")
@ -171,7 +171,7 @@ class TorchScriptPythonDecoder (Decoder):
return self._raw_input(index).debugName() return self._raw_input(index).debugName()
def get_input_signature_name(self, index: int) -> str: 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._input_signature[index]
return self.get_input_debug_name(index) return self.get_input_debug_name(index)

View File

@ -26,7 +26,7 @@ OutputVector translate_add(const NodeContext& context) {
// Case when two lists gets concatenated // Case when two lists gets concatenated
FRONT_END_OP_CONVERSION_CHECK(false, "aten::add is used for concatenation of lists, not possible to convert"); 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)) { if (!context.input_is_none(2)) {
auto converted_alpha = context.mark_node(std::make_shared<ov::op::v1::ConvertLike>(context.get_input(2), rhs)); auto converted_alpha = context.mark_node(std::make_shared<ov::op::v1::ConvertLike>(context.get_input(2), rhs));
rhs = context.mark_node(std::make_shared<ov::op::v1::Multiply>(converted_alpha, rhs)); rhs = context.mark_node(std::make_shared<ov::op::v1::Multiply>(converted_alpha, rhs));

View File

@ -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."); 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 lhs = context.get_input(0);
auto rhs = context.get_input(1); 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<T>(lhs, rhs))}; return {context.mark_node(std::make_shared<T>(lhs, rhs))};
} }

View File

@ -52,15 +52,8 @@ class PytorchLayerTest:
inp, np.ndarray) else inp for inp in inputs] inp, np.ndarray) else inp for inp in inputs]
trace_model = kwargs.get('trace_model', False) trace_model = kwargs.get('trace_model', False)
freeze_model = kwargs.get('freeze_model', True) freeze_model = kwargs.get('freeze_model', True)
use_mo_convert = kwargs.get("use_mo_convert", True) model, converted_model = self.convert_directly_via_frontend(model, torch_inputs, trace_model, dynamic_shapes, inputs, freeze_model)
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)
graph = model.inlined_graph graph = model.inlined_graph
print(graph)
if kind is not None and not isinstance(kind, (tuple, list)): if kind is not None and not isinstance(kind, (tuple, list)):
kind = [kind] kind = [kind]
@ -181,6 +174,7 @@ class PytorchLayerTest:
model = torch.jit.trace(model, example_input) model = torch.jit.trace(model, example_input)
else: else:
model = torch.jit.script(model) model = torch.jit.script(model)
print(model.inlined_graph)
decoder = TorchScriptPythonDecoder(model, freeze=freeze_model) decoder = TorchScriptPythonDecoder(model, freeze=freeze_model)
im = fe.load(decoder) im = fe.load(decoder)
om = fe.convert(im) om = fe.convert(im)