|
|
|
@@ -56,7 +56,7 @@ def make_pt_model_two_inputs():
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def forward(self, x, y):
|
|
|
|
|
logits = self.linear_relu_stack(x + y)
|
|
|
|
|
logits = self.linear_relu_stack(x * y)
|
|
|
|
|
return logits
|
|
|
|
|
|
|
|
|
|
return NeuralNetwork()
|
|
|
|
@@ -83,8 +83,8 @@ def make_ref_pt_model_two_inputs(shape, dtype=np.float32):
|
|
|
|
|
shape = PartialShape(shape)
|
|
|
|
|
param1 = ov.opset8.parameter(shape, name="input_0", dtype=dtype)
|
|
|
|
|
param2 = ov.opset8.parameter(shape, name="input_1", dtype=dtype)
|
|
|
|
|
add = ov.opset8.add(param1, param2)
|
|
|
|
|
relu = ov.opset8.relu(add)
|
|
|
|
|
mul = ov.opset8.multiply(param1, param2)
|
|
|
|
|
relu = ov.opset8.relu(mul)
|
|
|
|
|
sigm = ov.opset8.sigmoid(relu)
|
|
|
|
|
|
|
|
|
|
parameter_list = [param1, param2]
|
|
|
|
@@ -100,8 +100,8 @@ def create_pytorch_nn_module_case1(tmp_dir):
|
|
|
|
|
sample_input2 = torch.zeros(1, 3, 10, 10)
|
|
|
|
|
sample_input = sample_input1, sample_input2
|
|
|
|
|
|
|
|
|
|
return pt_model, ref_model, {'input_shape': [PartialShape([-1, 3, -1, -1]), PartialShape([-1, 3, -1, -1])],
|
|
|
|
|
'example_input': sample_input, "use_legacy_frontend": True}
|
|
|
|
|
return pt_model, ref_model, {'input': [([-1, 3, -1, -1], np.float32), ([-1, 3, -1, -1], np.float32)],
|
|
|
|
|
'example_input': sample_input}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_case2(tmp_dir):
|
|
|
|
@@ -113,7 +113,8 @@ def create_pytorch_nn_module_case2(tmp_dir):
|
|
|
|
|
sample_input = sample_input1, sample_input2
|
|
|
|
|
|
|
|
|
|
return pt_model, ref_model, {'input_shape': ["[?,3,?,?]", PartialShape([-1, 3, -1, -1])],
|
|
|
|
|
'example_input': sample_input, 'onnx_opset_version': 11, "use_legacy_frontend": True}
|
|
|
|
|
'input': [np.float32, np.float32],
|
|
|
|
|
'example_input': sample_input}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_case3(tmp_dir):
|
|
|
|
@@ -124,7 +125,9 @@ def create_pytorch_nn_module_case3(tmp_dir):
|
|
|
|
|
sample_input2 = torch.zeros(1, 3, 10, 10)
|
|
|
|
|
sample_input = tuple([sample_input1, sample_input2])
|
|
|
|
|
|
|
|
|
|
return pt_model, ref_model, {'input_shape': "[?,3,?,?],[?,3,?,?]", 'example_input': sample_input, "use_legacy_frontend": True}
|
|
|
|
|
return pt_model, ref_model, {'input_shape': "[?,3,?,?],[?,3,?,?]",
|
|
|
|
|
'input': [np.float32, np.float32],
|
|
|
|
|
'example_input': sample_input}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_case4(tmp_dir):
|
|
|
|
@@ -132,9 +135,10 @@ def create_pytorch_nn_module_case4(tmp_dir):
|
|
|
|
|
|
|
|
|
|
sample_input = torch.zeros(1, 3, 10, 10)
|
|
|
|
|
|
|
|
|
|
ref_model = make_ref_pt_model_one_input([1, 3, 10, 10])
|
|
|
|
|
ref_model = make_ref_pt_model_one_input(PartialShape.dynamic())
|
|
|
|
|
|
|
|
|
|
return pt_model, ref_model, {'example_input': sample_input, "use_legacy_frontend": True}
|
|
|
|
|
return pt_model, ref_model, {'input': [np.float32],
|
|
|
|
|
'example_input': sample_input}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_case5(tmp_dir):
|
|
|
|
@@ -144,7 +148,7 @@ def create_pytorch_nn_module_case5(tmp_dir):
|
|
|
|
|
|
|
|
|
|
sample_input = torch.zeros(3, 3, 10, 10)
|
|
|
|
|
return pt_model, ref_model, {'example_input': sample_input,
|
|
|
|
|
'input_shape': inp_shape, "use_legacy_frontend": True}
|
|
|
|
|
'input': (inp_shape, np.float32)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_case6(tmp_dir):
|
|
|
|
@@ -152,14 +156,14 @@ def create_pytorch_nn_module_case6(tmp_dir):
|
|
|
|
|
shape = PartialShape([1, 3, Dimension(2, -1), Dimension(-1, 10)])
|
|
|
|
|
ref_model = make_ref_pt_model_one_input(shape)
|
|
|
|
|
|
|
|
|
|
return pt_model, ref_model, {'input_shape': shape, "use_legacy_frontend": True}
|
|
|
|
|
return pt_model, ref_model, {'input': (shape, np.float32)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_torch_size(tmp_dir):
|
|
|
|
|
pt_model = make_pt_model_one_input()
|
|
|
|
|
ref_model = make_ref_pt_model_one_input([1, 3, 2, 10])
|
|
|
|
|
|
|
|
|
|
return pt_model, ref_model, {'input_shape': torch.Size([1, 3, 2, 10]), "use_legacy_frontend": True}
|
|
|
|
|
return pt_model, ref_model, {'input': (torch.Size([1, 3, 2, 10]), np.float32)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_sample_input_int32(tmp_dir):
|
|
|
|
@@ -171,7 +175,7 @@ def create_pytorch_nn_module_sample_input_int32(tmp_dir):
|
|
|
|
|
ref_model = make_ref_pt_model_one_input(shape, dtype=numpy.int32)
|
|
|
|
|
|
|
|
|
|
return pt_model, ref_model, {'example_input': sample_input,
|
|
|
|
|
'input_shape': shape, "use_legacy_frontend": True}
|
|
|
|
|
'input': (shape, np.int32)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_sample_input_int32_two_inputs(tmp_dir):
|
|
|
|
@@ -185,105 +189,8 @@ def create_pytorch_nn_module_sample_input_int32_two_inputs(tmp_dir):
|
|
|
|
|
[PartialShape([-1, 3, -1, -1]), inp_shapes[1]], dtype=np.int32)
|
|
|
|
|
|
|
|
|
|
return pt_model, ref_model, {'input_shape': inp_shapes,
|
|
|
|
|
'example_input': sample_input, 'onnx_opset_version': 11, "use_legacy_frontend": True}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_compare_convert_paths_case1(tmp_dir):
|
|
|
|
|
from openvino.tools.mo import convert_model
|
|
|
|
|
pt_model = make_pt_model_one_input()
|
|
|
|
|
|
|
|
|
|
sample_input = torch.zeros(1, 3, 10, 10, dtype=torch.int32)
|
|
|
|
|
onnx_model_path = os.path.join(tmp_dir, 'export.onnx')
|
|
|
|
|
torch.onnx.export(pt_model, sample_input,
|
|
|
|
|
onnx_model_path, opset_version=16)
|
|
|
|
|
|
|
|
|
|
ref_model = convert_model(onnx_model_path)
|
|
|
|
|
return pt_model, ref_model, {'example_input': sample_input, 'onnx_opset_version': 16, "use_legacy_frontend": True}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_compare_convert_paths_case2(tmp_dir):
|
|
|
|
|
from openvino.tools.mo import convert_model
|
|
|
|
|
pt_model = make_pt_model_one_input()
|
|
|
|
|
|
|
|
|
|
sample_input = torch.zeros(1, 3, 10, 10, dtype=torch.int32)
|
|
|
|
|
onnx_model_path = os.path.join(tmp_dir, 'export.onnx')
|
|
|
|
|
torch.onnx.export(pt_model, sample_input,
|
|
|
|
|
onnx_model_path, opset_version=16)
|
|
|
|
|
|
|
|
|
|
ref_model = convert_model(onnx_model_path)
|
|
|
|
|
return pt_model, ref_model, {'example_input': sample_input,
|
|
|
|
|
'input_shape': [1, 3, 10, 10],
|
|
|
|
|
'onnx_opset_version': 16,
|
|
|
|
|
"use_legacy_frontend": True
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_compare_convert_paths_case3(tmp_dir):
|
|
|
|
|
from openvino.tools.mo import convert_model
|
|
|
|
|
pt_model = make_pt_model_one_input()
|
|
|
|
|
|
|
|
|
|
sample_input = torch.zeros(1, 3, 10, 10, dtype=torch.float32)
|
|
|
|
|
onnx_model_path = os.path.join(tmp_dir, 'export.onnx')
|
|
|
|
|
torch.onnx.export(pt_model, sample_input,
|
|
|
|
|
onnx_model_path, opset_version=16)
|
|
|
|
|
|
|
|
|
|
ref_model = convert_model(onnx_model_path)
|
|
|
|
|
return pt_model, ref_model, {'input_shape': [1, 3, 10, 10],
|
|
|
|
|
'onnx_opset_version': 16, "use_legacy_frontend": True}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_compare_convert_paths_case4(tmp_dir):
|
|
|
|
|
from openvino.tools.mo import convert_model
|
|
|
|
|
pt_model = make_pt_model_two_inputs()
|
|
|
|
|
|
|
|
|
|
sample_input1 = torch.zeros(1, 3, 10, 10, dtype=torch.int32)
|
|
|
|
|
sample_input2 = torch.zeros(1, 3, 10, 10, dtype=torch.int32)
|
|
|
|
|
sample_input = (sample_input1, sample_input2)
|
|
|
|
|
|
|
|
|
|
onnx_model_path = os.path.join(tmp_dir, 'export.onnx')
|
|
|
|
|
torch.onnx.export(pt_model, sample_input,
|
|
|
|
|
onnx_model_path, opset_version=16)
|
|
|
|
|
|
|
|
|
|
ref_model = convert_model(onnx_model_path)
|
|
|
|
|
|
|
|
|
|
return pt_model, ref_model, {'example_input': sample_input, 'onnx_opset_version': 16, "use_legacy_frontend": True}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_compare_convert_paths_case5(tmp_dir):
|
|
|
|
|
from openvino.tools.mo import convert_model
|
|
|
|
|
pt_model = make_pt_model_two_inputs()
|
|
|
|
|
|
|
|
|
|
sample_input1 = torch.zeros(1, 3, 10, 10, dtype=torch.int32)
|
|
|
|
|
sample_input2 = torch.zeros(1, 3, 10, 10, dtype=torch.int32)
|
|
|
|
|
sample_input = tuple([sample_input1, sample_input2])
|
|
|
|
|
|
|
|
|
|
onnx_model_path = os.path.join(tmp_dir, 'export.onnx')
|
|
|
|
|
torch.onnx.export(pt_model, sample_input,
|
|
|
|
|
onnx_model_path, opset_version=16)
|
|
|
|
|
|
|
|
|
|
ref_model = convert_model(onnx_model_path)
|
|
|
|
|
|
|
|
|
|
return pt_model, ref_model, {'example_input': sample_input,
|
|
|
|
|
'input_shape': [torch.Size([1, 3, 10, 10]), PartialShape([1, 3, 10, 10])],
|
|
|
|
|
'onnx_opset_version': 16, "use_legacy_frontend": True}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_compare_convert_paths_case6(tmp_dir):
|
|
|
|
|
from openvino.tools.mo import convert_model
|
|
|
|
|
pt_model = make_pt_model_two_inputs()
|
|
|
|
|
|
|
|
|
|
sample_input1 = torch.zeros(1, 3, 10, 10, dtype=torch.float32)
|
|
|
|
|
sample_input2 = torch.zeros(1, 3, 10, 10, dtype=torch.float32)
|
|
|
|
|
sample_input = tuple([sample_input1, sample_input2])
|
|
|
|
|
|
|
|
|
|
onnx_model_path = os.path.join(tmp_dir, 'export.onnx')
|
|
|
|
|
torch.onnx.export(pt_model, sample_input,
|
|
|
|
|
onnx_model_path, opset_version=16)
|
|
|
|
|
|
|
|
|
|
ref_model = convert_model(onnx_model_path)
|
|
|
|
|
|
|
|
|
|
return pt_model, ref_model, {'input_shape': [torch.Size([1, 3, 10, 10]), torch.Size([1, 3, 10, 10])],
|
|
|
|
|
'onnx_opset_version': 16, "use_legacy_frontend": True}
|
|
|
|
|
'input': [np.int32, np.int32],
|
|
|
|
|
'example_input': sample_input}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_jit_script_module(tmp_dir):
|
|
|
|
@@ -293,7 +200,7 @@ def create_pytorch_jit_script_module(tmp_dir):
|
|
|
|
|
scripted_model = torch.jit.script(net)
|
|
|
|
|
|
|
|
|
|
model_ref = make_ref_pt_model_two_inputs([1, 3, 5, 5])
|
|
|
|
|
return scripted_model, model_ref, {'input_shape': [PartialShape([1, 3, 5, 5]), PartialShape([1, 3, 5, 5])], "use_legacy_frontend": True}
|
|
|
|
|
return scripted_model, model_ref, {'input': [([1, 3, 5, 5], np.float32), ([1, 3, 5, 5], np.float32)]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_jit_script_function(tmp_dir):
|
|
|
|
@@ -301,108 +208,13 @@ def create_pytorch_jit_script_function(tmp_dir):
|
|
|
|
|
|
|
|
|
|
@torch.jit.script
|
|
|
|
|
def scripted_fn(x: torch.Tensor, y: torch.Tensor):
|
|
|
|
|
return torch.sigmoid(torch.relu(x + y))
|
|
|
|
|
return torch.sigmoid(torch.relu(x * y))
|
|
|
|
|
|
|
|
|
|
inp_shape = PartialShape([Dimension(1, -1), Dimension(-1, 5), 10])
|
|
|
|
|
ref_model = make_ref_pt_model_two_inputs(inp_shape)
|
|
|
|
|
return scripted_fn, ref_model, {'input_shape': [inp_shape, inp_shape], "use_legacy_frontend": True}
|
|
|
|
|
return scripted_fn, ref_model, {'input': [(inp_shape, np.float32), (inp_shape, np.float32)]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_sample_input_numpy(tmp_dir):
|
|
|
|
|
from openvino.tools.mo import convert_model
|
|
|
|
|
pt_model = make_pt_model_one_input()
|
|
|
|
|
|
|
|
|
|
example_inputs = np.array(torch.zeros(1, 3, 10, 10, dtype=torch.int32))
|
|
|
|
|
onnx_model_path = os.path.join(tmp_dir, 'export.onnx')
|
|
|
|
|
torch.onnx.export(pt_model, torch.zeros(
|
|
|
|
|
1, 3, 10, 10, dtype=torch.int32), onnx_model_path, opset_version=16)
|
|
|
|
|
|
|
|
|
|
ref_model = convert_model(onnx_model_path)
|
|
|
|
|
return pt_model, ref_model, {'example_input': example_inputs,
|
|
|
|
|
'input_shape': [1, 3, 10, 10],
|
|
|
|
|
'onnx_opset_version': 16, "use_legacy_frontend": True}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_sample_input_dict(tmp_dir):
|
|
|
|
|
from openvino.tools.mo import convert_model
|
|
|
|
|
pt_model = make_pt_model_one_input()
|
|
|
|
|
|
|
|
|
|
example_inputs = {"x": np.array(
|
|
|
|
|
torch.zeros(1, 3, 10, 10, dtype=torch.int32))}
|
|
|
|
|
onnx_model_path = os.path.join(tmp_dir, 'export.onnx')
|
|
|
|
|
torch.onnx.export(pt_model, torch.zeros(
|
|
|
|
|
1, 3, 10, 10, dtype=torch.int32), onnx_model_path, opset_version=16)
|
|
|
|
|
|
|
|
|
|
ref_model = convert_model(onnx_model_path)
|
|
|
|
|
return pt_model, ref_model, {'example_input': example_inputs,
|
|
|
|
|
'onnx_opset_version': 16, "use_legacy_frontend": True}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_sample_input_dict_two_inputs(tmp_dir):
|
|
|
|
|
from openvino.tools.mo import convert_model
|
|
|
|
|
pt_model = make_pt_model_two_inputs()
|
|
|
|
|
|
|
|
|
|
example_inputs = {"y": np.array(torch.zeros(1, 3, 10, 10, dtype=torch.int32)),
|
|
|
|
|
"x": np.array(torch.zeros(1, 3, 10, 10, dtype=torch.int32))}
|
|
|
|
|
onnx_model_path = os.path.join(tmp_dir, 'export.onnx')
|
|
|
|
|
torch.onnx.export(pt_model, {"y": torch.zeros(1, 3, 10, 10, dtype=torch.int32),
|
|
|
|
|
"x": torch.zeros(1, 3, 10, 10, dtype=torch.int32)}, onnx_model_path, opset_version=16)
|
|
|
|
|
|
|
|
|
|
ref_model = convert_model(onnx_model_path)
|
|
|
|
|
return pt_model, ref_model, {'example_input': example_inputs,
|
|
|
|
|
'onnx_opset_version': 16, "use_legacy_frontend": True}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_sample_list_of_tensors(tmp_dir):
|
|
|
|
|
from openvino.tools.mo import convert_model
|
|
|
|
|
pt_model = make_pt_model_one_input()
|
|
|
|
|
|
|
|
|
|
example_inputs = [torch.zeros(3, 10, 10, dtype=torch.float32)]
|
|
|
|
|
|
|
|
|
|
onnx_model_path = os.path.join(tmp_dir, 'export.onnx')
|
|
|
|
|
torch.onnx.export(pt_model, torch.unsqueeze(
|
|
|
|
|
example_inputs[0], 0), onnx_model_path, opset_version=16)
|
|
|
|
|
|
|
|
|
|
ref_model = convert_model(onnx_model_path)
|
|
|
|
|
return pt_model, ref_model, {'example_input': example_inputs,
|
|
|
|
|
'onnx_opset_version': 16, "use_legacy_frontend": True}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_sample_input_ov_host_tensor(tmp_dir):
|
|
|
|
|
from openvino.tools.mo import convert_model
|
|
|
|
|
from openvino.runtime import Tensor
|
|
|
|
|
pt_model = make_pt_model_one_input()
|
|
|
|
|
|
|
|
|
|
sample_input = Tensor(np.zeros([1, 3, 10, 10], dtype=np.int32))
|
|
|
|
|
onnx_model_path = os.path.join(tmp_dir, 'export.onnx')
|
|
|
|
|
torch.onnx.export(pt_model, torch.zeros(
|
|
|
|
|
1, 3, 10, 10, dtype=torch.int32), onnx_model_path, opset_version=16)
|
|
|
|
|
|
|
|
|
|
ref_model = convert_model(onnx_model_path)
|
|
|
|
|
return pt_model, ref_model, {'example_input': sample_input,
|
|
|
|
|
'input_shape': [1, 3, 10, 10],
|
|
|
|
|
'onnx_opset_version': 16, "use_legacy_frontend": True}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_sample_input_ov_host_tensor_two_inputs(tmp_dir):
|
|
|
|
|
from openvino.tools.mo import convert_model
|
|
|
|
|
from openvino.runtime import Tensor
|
|
|
|
|
pt_model = make_pt_model_two_inputs()
|
|
|
|
|
|
|
|
|
|
sample_input1 = Tensor(np.zeros([1, 3, 10, 10], dtype=np.int32))
|
|
|
|
|
sample_input2 = Tensor(np.zeros([1, 3, 10, 10], dtype=np.int32))
|
|
|
|
|
sample_input = sample_input1, sample_input2
|
|
|
|
|
|
|
|
|
|
onnx_model_path = os.path.join(tmp_dir, 'export.onnx')
|
|
|
|
|
torch.onnx.export(pt_model, tuple([torch.zeros(1, 3, 10, 10, dtype=torch.int32),
|
|
|
|
|
torch.zeros(1, 3, 10, 10, dtype=torch.int32)]),
|
|
|
|
|
onnx_model_path, opset_version=16)
|
|
|
|
|
|
|
|
|
|
ref_model = convert_model(onnx_model_path)
|
|
|
|
|
|
|
|
|
|
return pt_model, ref_model, {'example_input': sample_input,
|
|
|
|
|
'onnx_opset_version': 16, "use_legacy_frontend": True}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_layout_list(tmp_dir):
|
|
|
|
|
from openvino.runtime import Layout
|
|
|
|
@@ -416,7 +228,7 @@ def create_pytorch_nn_module_layout_list(tmp_dir):
|
|
|
|
|
|
|
|
|
|
return pt_model, ref_model, {
|
|
|
|
|
'input_shape': [shape, shape], 'layout': ['nchw', Layout('nhwc')],
|
|
|
|
|
"input": [np.float32, np.float32]
|
|
|
|
|
'input': [np.float32, np.float32]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -432,7 +244,7 @@ def create_pytorch_nn_module_layout_list_case2(tmp_dir):
|
|
|
|
|
|
|
|
|
|
return pt_model, ref_model, {
|
|
|
|
|
'input_shape': [shape, shape], 'layout': ('nchw', Layout('nhwc')),
|
|
|
|
|
"input": [np.float32, np.float32]}
|
|
|
|
|
'input': [np.float32, np.float32]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_mean_list(tmp_dir):
|
|
|
|
@@ -446,8 +258,8 @@ def create_pytorch_nn_module_mean_list(tmp_dir):
|
|
|
|
|
const2 = ov.opset8.constant([[[[-0.0, -0.0, -0.0]]]], dtype=np.float32)
|
|
|
|
|
add1 = ov.opset8.add(param1, const1)
|
|
|
|
|
add2 = ov.opset8.add(param2, const2)
|
|
|
|
|
add3 = ov.opset8.add(add1, add2)
|
|
|
|
|
relu = ov.opset8.relu(add3)
|
|
|
|
|
mul = ov.opset8.multiply(add1, add2)
|
|
|
|
|
relu = ov.opset8.relu(mul)
|
|
|
|
|
sigm = ov.opset8.sigmoid(relu)
|
|
|
|
|
|
|
|
|
|
parameter_list = [param1, param2]
|
|
|
|
@@ -455,7 +267,7 @@ def create_pytorch_nn_module_mean_list(tmp_dir):
|
|
|
|
|
|
|
|
|
|
return pt_model, ref_model, {
|
|
|
|
|
'input_shape': [shape, shape], 'mean_values': [[0, 0, 0], [0, 0, 0]], 'compress_to_fp16': False,
|
|
|
|
|
"input": [np.float32, np.float32]}
|
|
|
|
|
'input': [np.float32, np.float32]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_mean_list_default_no_compression(tmp_dir):
|
|
|
|
@@ -470,17 +282,17 @@ def create_pytorch_nn_module_mean_list_default_no_compression(tmp_dir):
|
|
|
|
|
const2 = ov.opset8.constant([[[[-0.0, -0.0, -0.0]]]], dtype=np.float32)
|
|
|
|
|
add1 = ov.opset8.add(param1, const1)
|
|
|
|
|
add2 = ov.opset8.add(param2, const2)
|
|
|
|
|
add3 = ov.opset8.add(add1, add2)
|
|
|
|
|
relu = ov.opset8.relu(add3)
|
|
|
|
|
mul = ov.opset8.multiply(add1, add2)
|
|
|
|
|
relu = ov.opset8.relu(mul)
|
|
|
|
|
sigm = ov.opset8.sigmoid(relu)
|
|
|
|
|
|
|
|
|
|
parameter_list = [param1, param2]
|
|
|
|
|
ref_model = Model([sigm], parameter_list, "test")
|
|
|
|
|
|
|
|
|
|
return pt_model, ref_model, {'input_shape': [shape, shape], 'mean_values': [[0, 0, 0], [0, 0, 0]], "input": [np.float32, np.float32]}
|
|
|
|
|
return pt_model, ref_model, {'input_shape': [shape, shape], 'mean_values': [[0, 0, 0], [0, 0, 0]], 'input': [np.float32, np.float32]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_mean_list_compressin_enabled(tmp_dir):
|
|
|
|
|
def create_pytorch_nn_module_mean_list_compression_enabled(tmp_dir):
|
|
|
|
|
pt_model = make_pt_model_two_inputs()
|
|
|
|
|
shape = [1, 10, 10, 3]
|
|
|
|
|
|
|
|
|
@@ -491,8 +303,8 @@ def create_pytorch_nn_module_mean_list_compressin_enabled(tmp_dir):
|
|
|
|
|
const2 = ov.opset8.constant([[[[-0.0, -0.0, -0.0]]]], dtype=np.float32)
|
|
|
|
|
add1 = ov.opset8.add(param1, const1)
|
|
|
|
|
add2 = ov.opset8.add(param2, const2)
|
|
|
|
|
add3 = ov.opset8.add(add1, add2)
|
|
|
|
|
relu = ov.opset8.relu(add3)
|
|
|
|
|
mul = ov.opset8.multiply(add1, add2)
|
|
|
|
|
relu = ov.opset8.relu(mul)
|
|
|
|
|
sigm = ov.opset8.sigmoid(relu)
|
|
|
|
|
|
|
|
|
|
parameter_list = [param1, param2]
|
|
|
|
@@ -500,7 +312,7 @@ def create_pytorch_nn_module_mean_list_compressin_enabled(tmp_dir):
|
|
|
|
|
|
|
|
|
|
return pt_model, ref_model, {
|
|
|
|
|
'input_shape': [shape, shape], 'mean_values': [[0, 0, 0], [0, 0, 0]],
|
|
|
|
|
'compress_to_fp16': False, "input": [np.float32, np.float32]}
|
|
|
|
|
'compress_to_fp16': False, 'input': [np.float32, np.float32]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_scale_list(tmp_dir):
|
|
|
|
@@ -514,14 +326,14 @@ def create_pytorch_nn_module_scale_list(tmp_dir):
|
|
|
|
|
const2 = ov.opset8.constant([[[[1, 1, 1]]]], dtype=np.float32)
|
|
|
|
|
sub1 = ov.opset8.multiply(param1, const1)
|
|
|
|
|
sub2 = ov.opset8.multiply(param2, const2)
|
|
|
|
|
add = ov.opset8.add(sub1, sub2)
|
|
|
|
|
relu = ov.opset8.relu(add)
|
|
|
|
|
mul = ov.opset8.multiply(sub1, sub2)
|
|
|
|
|
relu = ov.opset8.relu(mul)
|
|
|
|
|
sigm = ov.opset8.sigmoid(relu)
|
|
|
|
|
|
|
|
|
|
parameter_list = [param1, param2]
|
|
|
|
|
ref_model = Model([sigm], parameter_list, "test")
|
|
|
|
|
|
|
|
|
|
return pt_model, ref_model, {'input_shape': [shape, shape], 'scale_values': [[1, 1, 1], [1, 1, 1]], 'compress_to_fp16': False, "input": [np.float32, np.float32]}
|
|
|
|
|
return pt_model, ref_model, {'input_shape': [shape, shape], 'scale_values': [[1, 1, 1], [1, 1, 1]], 'compress_to_fp16': False, 'input': [np.float32, np.float32]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_scale_list_default_no_compression(tmp_dir):
|
|
|
|
@@ -536,14 +348,14 @@ def create_pytorch_nn_module_scale_list_default_no_compression(tmp_dir):
|
|
|
|
|
const2 = ov.opset8.constant([[[[1, 1, 1]]]], dtype=np.float32)
|
|
|
|
|
sub1 = ov.opset8.multiply(param1, const1)
|
|
|
|
|
sub2 = ov.opset8.multiply(param2, const2)
|
|
|
|
|
add = ov.opset8.add(sub1, sub2)
|
|
|
|
|
relu = ov.opset8.relu(add)
|
|
|
|
|
mul = ov.opset8.multiply(sub1, sub2)
|
|
|
|
|
relu = ov.opset8.relu(mul)
|
|
|
|
|
sigm = ov.opset8.sigmoid(relu)
|
|
|
|
|
|
|
|
|
|
parameter_list = [param1, param2]
|
|
|
|
|
ref_model = Model([sigm], parameter_list, "test")
|
|
|
|
|
|
|
|
|
|
return pt_model, ref_model, {'input_shape': [shape, shape], 'scale_values': [[1, 1, 1], [1, 1, 1]], "input": [np.float32, np.float32]}
|
|
|
|
|
return pt_model, ref_model, {'input_shape': [shape, shape], 'scale_values': [[1, 1, 1], [1, 1, 1]], 'input': [np.float32, np.float32]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_scale_list_compression_enabled(tmp_dir):
|
|
|
|
@@ -557,16 +369,16 @@ def create_pytorch_nn_module_scale_list_compression_enabled(tmp_dir):
|
|
|
|
|
const1_decompressed = ov.opset8.convert(const1, destination_type=np.float32)
|
|
|
|
|
const2 = ov.opset8.constant([[[[1, 1, 1]]]], dtype=np.float16)
|
|
|
|
|
const2_decompressed = ov.opset8.convert(const2, destination_type=np.float32)
|
|
|
|
|
sub1 = ov.opset8.multiply(param1, const1_decompressed)
|
|
|
|
|
sub2 = ov.opset8.multiply(param2, const2_decompressed)
|
|
|
|
|
add = ov.opset8.add(sub1, sub2)
|
|
|
|
|
relu = ov.opset8.relu(add)
|
|
|
|
|
mul1 = ov.opset8.multiply(param1, const1_decompressed)
|
|
|
|
|
mul2 = ov.opset8.multiply(param2, const2_decompressed)
|
|
|
|
|
mul3 = ov.opset8.multiply(mul1, mul2)
|
|
|
|
|
relu = ov.opset8.relu(mul3)
|
|
|
|
|
sigm = ov.opset8.sigmoid(relu)
|
|
|
|
|
|
|
|
|
|
parameter_list = [param1, param2]
|
|
|
|
|
ref_model = Model([sigm], parameter_list, "test")
|
|
|
|
|
|
|
|
|
|
return pt_model, ref_model, {'input_shape': [shape, shape], 'scale_values': [[1, 1, 1], [1, 1, 1]], "input": [np.float32, np.float32],
|
|
|
|
|
return pt_model, ref_model, {'input_shape': [shape, shape], 'scale_values': [[1, 1, 1], [1, 1, 1]], 'input': [np.float32, np.float32],
|
|
|
|
|
'compress_to_fp16': True}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -574,14 +386,14 @@ def create_pytorch_nn_module_shapes_list_static(tmp_dir):
|
|
|
|
|
pt_model = make_pt_model_two_inputs()
|
|
|
|
|
ref_model = make_ref_pt_model_two_inputs([1, 3, 20, 20])
|
|
|
|
|
|
|
|
|
|
return pt_model, ref_model, {'input_shape': [[1, 3, 20, 20], [1, 3, 20, 20]], "input": [np.float32, np.float32]}
|
|
|
|
|
return pt_model, ref_model, {'input_shape': [[1, 3, 20, 20], [1, 3, 20, 20]], 'input': [np.float32, np.float32]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_shapes_list_static_via_input(tmp_dir):
|
|
|
|
|
pt_model = make_pt_model_two_inputs()
|
|
|
|
|
ref_model = make_ref_pt_model_two_inputs([1, 3, 20, 20])
|
|
|
|
|
|
|
|
|
|
return pt_model, ref_model, {"input": [([1, 3, 20, 20], np.float32), ([1, 3, 20, 20], np.float32)]}
|
|
|
|
|
return pt_model, ref_model, {'input': [([1, 3, 20, 20], np.float32), ([1, 3, 20, 20], np.float32)]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_shapes_list_dynamic(tmp_dir):
|
|
|
|
@@ -593,13 +405,13 @@ def create_pytorch_nn_module_shapes_list_dynamic(tmp_dir):
|
|
|
|
|
inp_shapes[0]), name="x", dtype=np.float32)
|
|
|
|
|
param2 = ov.opset8.parameter(PartialShape(
|
|
|
|
|
inp_shapes[1]), name="y", dtype=np.float32)
|
|
|
|
|
add = ov.opset8.add(param1, param2)
|
|
|
|
|
relu = ov.opset8.relu(add)
|
|
|
|
|
mul = ov.opset8.multiply(param1, param2)
|
|
|
|
|
relu = ov.opset8.relu(mul)
|
|
|
|
|
sigm = ov.opset8.sigmoid(relu)
|
|
|
|
|
|
|
|
|
|
parameter_list = [param1, param2]
|
|
|
|
|
ref_model = Model([sigm], parameter_list, "test")
|
|
|
|
|
return pt_model, ref_model, {'input_shape': inp_shapes, "input": [np.float32, np.float32]}
|
|
|
|
|
return pt_model, ref_model, {'input_shape': inp_shapes, 'input': [np.float32, np.float32]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_shapes_list_dynamic_via_input(tmp_dir):
|
|
|
|
@@ -611,41 +423,41 @@ def create_pytorch_nn_module_shapes_list_dynamic_via_input(tmp_dir):
|
|
|
|
|
inp_shapes[0]), name="x", dtype=np.float32)
|
|
|
|
|
param2 = ov.opset8.parameter(PartialShape(
|
|
|
|
|
inp_shapes[1]), name="y", dtype=np.float32)
|
|
|
|
|
add = ov.opset8.add(param1, param2)
|
|
|
|
|
relu = ov.opset8.relu(add)
|
|
|
|
|
mul = ov.opset8.multiply(param1, param2)
|
|
|
|
|
relu = ov.opset8.relu(mul)
|
|
|
|
|
sigm = ov.opset8.sigmoid(relu)
|
|
|
|
|
|
|
|
|
|
parameter_list = [param1, param2]
|
|
|
|
|
ref_model = Model([sigm], parameter_list, "test")
|
|
|
|
|
return pt_model, ref_model, {"input": [(inp_shapes[0], np.float32), (inp_shapes[1], np.float32)]}
|
|
|
|
|
return pt_model, ref_model, {'input': [(inp_shapes[0], np.float32), (inp_shapes[1], np.float32)]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_shapes_list_dynamic_single_input(tmp_dir):
|
|
|
|
|
pt_model = make_pt_model_one_input()
|
|
|
|
|
inp_shapes = [[Dimension(-1), 3, 20, Dimension(20, -1)]]
|
|
|
|
|
ref_model = make_ref_pt_model_one_input(inp_shapes[0])
|
|
|
|
|
return pt_model, ref_model, {'input_shape': inp_shapes, "input": np.float32}
|
|
|
|
|
return pt_model, ref_model, {'input_shape': inp_shapes, 'input': np.float32}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_shapes_list_dynamic_single_input_via_input(tmp_dir):
|
|
|
|
|
pt_model = make_pt_model_one_input()
|
|
|
|
|
inp_shapes = [Dimension(-1), 3, 20, Dimension(20, -1)]
|
|
|
|
|
ref_model = make_ref_pt_model_one_input(inp_shapes)
|
|
|
|
|
return pt_model, ref_model, {"input": InputCutInfo(shape=inp_shapes, type=np.float32)}
|
|
|
|
|
return pt_model, ref_model, {'input': InputCutInfo(shape=inp_shapes, type=np.float32)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_shapes_list_static_single_input(tmp_dir):
|
|
|
|
|
pt_model = make_pt_model_one_input()
|
|
|
|
|
inp_shapes = [[1, 3, 20, 20]]
|
|
|
|
|
ref_model = make_ref_pt_model_one_input(inp_shapes[0])
|
|
|
|
|
return pt_model, ref_model, {'input_shape': inp_shapes, "input": np.float32}
|
|
|
|
|
return pt_model, ref_model, {'input_shape': inp_shapes, 'input': np.float32}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_shapes_list_static_single_input_via_input(tmp_dir):
|
|
|
|
|
pt_model = make_pt_model_one_input()
|
|
|
|
|
inp_shapes = [1, 3, 20, 20]
|
|
|
|
|
ref_model = make_ref_pt_model_one_input(inp_shapes)
|
|
|
|
|
return pt_model, ref_model, {"input": (inp_shapes, np.float32)}
|
|
|
|
|
return pt_model, ref_model, {'input': (inp_shapes, np.float32)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_nn_module_convert_pytorch_frontend1(tmp_dir):
|
|
|
|
@@ -660,7 +472,7 @@ def create_pytorch_nn_module_convert_pytorch_frontend1(tmp_dir):
|
|
|
|
|
ref_model = Model([sigm], parameter_list, "test")
|
|
|
|
|
return pt_model, ref_model, {
|
|
|
|
|
"example_input": torch.zeros((1, 3, 10, 10)),
|
|
|
|
|
"input": [InputCutInfo(shape=[-1, -1, -1, -1], type="f32")]
|
|
|
|
|
'input': [InputCutInfo(shape=[-1, -1, -1, -1], type="f32")]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -678,7 +490,7 @@ def create_pytorch_nn_module_convert_pytorch_frontend2(tmp_dir):
|
|
|
|
|
ref_model.validate_nodes_and_infer_types()
|
|
|
|
|
return pt_model, ref_model, {
|
|
|
|
|
"example_input": torch.zeros((1, 3, 10, 10), dtype=torch.int32),
|
|
|
|
|
"input": [InputCutInfo(shape=[-1, -1, -1, -1], type="i32")]
|
|
|
|
|
'input': [InputCutInfo(shape=[-1, -1, -1, -1], type="i32")]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -688,15 +500,15 @@ def create_pytorch_nn_module_convert_pytorch_frontend3(tmp_dir):
|
|
|
|
|
shape = PartialShape(shape)
|
|
|
|
|
param1 = ov.opset10.parameter(shape, dtype=np.float32)
|
|
|
|
|
param2 = ov.opset10.parameter(shape, dtype=np.float32)
|
|
|
|
|
add = ov.opset10.add(param1, param2)
|
|
|
|
|
relu = ov.opset10.relu(add)
|
|
|
|
|
mul = ov.opset10.multiply(param1, param2)
|
|
|
|
|
relu = ov.opset10.relu(mul)
|
|
|
|
|
sigm = ov.opset10.sigmoid(relu)
|
|
|
|
|
|
|
|
|
|
parameter_list = [param1, param2]
|
|
|
|
|
ref_model = Model([sigm], parameter_list, "test")
|
|
|
|
|
return pt_model, ref_model, {
|
|
|
|
|
"example_input": [torch.zeros((1, 3, 10, 10)), torch.ones((1, 3, 10, 10))],
|
|
|
|
|
"input": [InputCutInfo(shape=[-1, -1, -1, -1], type="f32"), InputCutInfo(shape=[-1, -1, -1, -1], type="f32")]
|
|
|
|
|
'input': [InputCutInfo(shape=[-1, -1, -1, -1], type="f32"), InputCutInfo(shape=[-1, -1, -1, -1], type="f32")]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -706,15 +518,15 @@ def create_pytorch_nn_module_convert_pytorch_frontend4(tmp_dir):
|
|
|
|
|
shape = PartialShape(shape)
|
|
|
|
|
param1 = ov.opset10.parameter(shape, dtype=np.float32)
|
|
|
|
|
param2 = ov.opset10.parameter(shape, dtype=np.float32)
|
|
|
|
|
add = ov.opset10.add(param1, param2)
|
|
|
|
|
relu = ov.opset10.relu(add)
|
|
|
|
|
mul = ov.opset10.multiply(param1, param2)
|
|
|
|
|
relu = ov.opset10.relu(mul)
|
|
|
|
|
sigm = ov.opset10.sigmoid(relu)
|
|
|
|
|
|
|
|
|
|
parameter_list = [param1, param2]
|
|
|
|
|
ref_model = Model([sigm], parameter_list, "test")
|
|
|
|
|
return pt_model, ref_model, {
|
|
|
|
|
"example_input": {"x": torch.zeros((1, 3, 10, 10), dtype=torch.float32), "y": torch.ones((1, 3, 10, 10), dtype=torch.float32)},
|
|
|
|
|
"input": [InputCutInfo(shape=[-1, -1, -1, -1], type="f32"), InputCutInfo(shape=[-1, -1, -1, -1], type="f32")]
|
|
|
|
|
'input': [InputCutInfo(shape=[-1, -1, -1, -1], type="f32"), InputCutInfo(shape=[-1, -1, -1, -1], type="f32")]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -727,14 +539,14 @@ def create_pytorch_jit_script_module_convert_pytorch_frontend(tmp_dir):
|
|
|
|
|
shape = PartialShape(shape)
|
|
|
|
|
param1 = ov.opset10.parameter(shape, dtype=np.float32)
|
|
|
|
|
param2 = ov.opset10.parameter(shape, dtype=np.float32)
|
|
|
|
|
add = ov.opset10.add(param1, param2)
|
|
|
|
|
relu = ov.opset10.relu(add)
|
|
|
|
|
mul = ov.opset10.multiply(param1, param2)
|
|
|
|
|
relu = ov.opset10.relu(mul)
|
|
|
|
|
sigm = ov.opset10.sigmoid(relu)
|
|
|
|
|
parameter_list = [param1, param2]
|
|
|
|
|
ref_model = Model([sigm], parameter_list, "test")
|
|
|
|
|
return scripted_model, ref_model, {
|
|
|
|
|
"example_input": {"x": torch.zeros((1, 3, 10, 10)), "y": torch.ones((1, 3, 10, 10))},
|
|
|
|
|
"input": [InputCutInfo(shape=[-1, -1, -1, -1], type="f32"), InputCutInfo(shape=[-1, -1, -1, -1], type="f32")]}
|
|
|
|
|
'input': [InputCutInfo(shape=[-1, -1, -1, -1], type="f32"), InputCutInfo(shape=[-1, -1, -1, -1], type="f32")]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_jit_trace_module_convert_pytorch_frontend(tmp_dir):
|
|
|
|
@@ -747,15 +559,39 @@ def create_pytorch_jit_trace_module_convert_pytorch_frontend(tmp_dir):
|
|
|
|
|
shape = PartialShape(shape)
|
|
|
|
|
param1 = ov.opset10.parameter(shape, dtype=np.float32)
|
|
|
|
|
param2 = ov.opset10.parameter(shape, dtype=np.float32)
|
|
|
|
|
add = ov.opset10.add(param1, param2)
|
|
|
|
|
relu = ov.opset10.relu(add)
|
|
|
|
|
mul = ov.opset10.multiply(param1, param2)
|
|
|
|
|
relu = ov.opset10.relu(mul)
|
|
|
|
|
sigm = ov.opset10.sigmoid(relu)
|
|
|
|
|
parameter_list = [param1, param2]
|
|
|
|
|
ref_model = Model([sigm], parameter_list, "test")
|
|
|
|
|
return scripted_model, ref_model, {"example_input": example_input, "input": [
|
|
|
|
|
return scripted_model, ref_model, {"example_input": example_input, 'input': [
|
|
|
|
|
InputCutInfo(shape=[-1, -1, -1, -1], type="f32"), InputCutInfo(shape=[-1, -1, -1, -1], type="f32")]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_pytorch_module_convert_pytorch_frontend_oob(tmp_dir):
|
|
|
|
|
import torch
|
|
|
|
|
import torch.nn.functional as F
|
|
|
|
|
|
|
|
|
|
class ConvModel(torch.nn.Module):
|
|
|
|
|
def __init__(self):
|
|
|
|
|
super(ConvModel, self).__init__()
|
|
|
|
|
self.weights = torch.rand([1, 3, 3, 3])
|
|
|
|
|
|
|
|
|
|
def forward(self, x):
|
|
|
|
|
return F.conv2d(x, self.weights)
|
|
|
|
|
|
|
|
|
|
net = ConvModel()
|
|
|
|
|
shape = PartialShape([-1, 3, -1, -1])
|
|
|
|
|
param1 = ov.opset10.parameter(shape, dtype=np.float32)
|
|
|
|
|
weights = ov.opset10.constant(net.weights.numpy(force=True))
|
|
|
|
|
conv = ov.opset10.convolution(param1, weights, strides=[1, 1],
|
|
|
|
|
pads_begin=[0, 0], pads_end=[0, 0],
|
|
|
|
|
dilations=[1, 1])
|
|
|
|
|
parameter_list = [param1]
|
|
|
|
|
ref_model = Model([conv], parameter_list, "test")
|
|
|
|
|
return net, ref_model, {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestMoConvertPyTorch(CommonMOConvertTest):
|
|
|
|
|
test_data = [
|
|
|
|
|
create_pytorch_nn_module_case1,
|
|
|
|
@@ -767,24 +603,13 @@ class TestMoConvertPyTorch(CommonMOConvertTest):
|
|
|
|
|
create_pytorch_nn_module_torch_size,
|
|
|
|
|
create_pytorch_nn_module_sample_input_int32,
|
|
|
|
|
create_pytorch_nn_module_sample_input_int32_two_inputs,
|
|
|
|
|
create_pytorch_nn_module_compare_convert_paths_case1,
|
|
|
|
|
create_pytorch_nn_module_compare_convert_paths_case2,
|
|
|
|
|
create_pytorch_nn_module_compare_convert_paths_case4,
|
|
|
|
|
create_pytorch_nn_module_compare_convert_paths_case5,
|
|
|
|
|
create_pytorch_nn_module_compare_convert_paths_case6,
|
|
|
|
|
create_pytorch_nn_module_sample_input_numpy,
|
|
|
|
|
create_pytorch_nn_module_sample_input_ov_host_tensor,
|
|
|
|
|
create_pytorch_nn_module_sample_input_ov_host_tensor_two_inputs,
|
|
|
|
|
create_pytorch_nn_module_sample_input_dict,
|
|
|
|
|
create_pytorch_nn_module_sample_input_dict_two_inputs,
|
|
|
|
|
create_pytorch_nn_module_sample_list_of_tensors,
|
|
|
|
|
create_pytorch_jit_script_module,
|
|
|
|
|
create_pytorch_jit_script_function,
|
|
|
|
|
create_pytorch_nn_module_layout_list,
|
|
|
|
|
create_pytorch_nn_module_layout_list_case2,
|
|
|
|
|
create_pytorch_nn_module_mean_list,
|
|
|
|
|
create_pytorch_nn_module_mean_list_default_no_compression,
|
|
|
|
|
create_pytorch_nn_module_mean_list_compressin_enabled,
|
|
|
|
|
create_pytorch_nn_module_mean_list_compression_enabled,
|
|
|
|
|
create_pytorch_nn_module_scale_list,
|
|
|
|
|
create_pytorch_nn_module_scale_list_default_no_compression,
|
|
|
|
|
create_pytorch_nn_module_scale_list_compression_enabled,
|
|
|
|
@@ -801,7 +626,8 @@ class TestMoConvertPyTorch(CommonMOConvertTest):
|
|
|
|
|
create_pytorch_nn_module_convert_pytorch_frontend3,
|
|
|
|
|
create_pytorch_nn_module_convert_pytorch_frontend4,
|
|
|
|
|
create_pytorch_jit_script_module_convert_pytorch_frontend,
|
|
|
|
|
create_pytorch_jit_trace_module_convert_pytorch_frontend
|
|
|
|
|
create_pytorch_jit_trace_module_convert_pytorch_frontend,
|
|
|
|
|
create_pytorch_module_convert_pytorch_frontend_oob
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
@ pytest.mark.parametrize("create_model", test_data)
|
|
|
|
@@ -835,17 +661,6 @@ def create_pt_model_with_custom_op():
|
|
|
|
|
return MyModel()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ConvertONNXFallthroughTest(unittest.TestCase):
|
|
|
|
|
def test_onnx_fallthrough(self):
|
|
|
|
|
from openvino.tools.mo import convert_model
|
|
|
|
|
pytorch_model = create_pt_model_with_custom_op()
|
|
|
|
|
|
|
|
|
|
# Check that ONNX conversion passed, so ONNX frontend raises error message of unsupported op.
|
|
|
|
|
with self.assertRaisesRegex(RuntimeError, ".*OpenVINO does not support the following ONNX operations: MyTorchOp.*"):
|
|
|
|
|
convert_model(pytorch_model, input_shape=[
|
|
|
|
|
1, 2, 3], use_legacy_frontend=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ConvertRaisesExampleInputs(unittest.TestCase):
|
|
|
|
|
def test_example_inputs(self):
|
|
|
|
|
from openvino.tools.mo import convert_model
|
|
|
|
|