[PYTHON API] move frontend bindings to pyopenvino + move MO to use new Python API (#8301)
* move frontend folder to pyopenvino * rename includes and add compile options * include frontend to pyopenvino * move __init__.py * move tests * remove mock from tests_compatibility * rename import module * Fix code style cpp * refactor a few lines * update few lines in mo * Add pyopenvino to dependencies * Fix mock * update docstring * Fix mo test * remove module local * fix code style * update comment * fix return type * update docs * fix code style * fix building * fix code style * try to move MO to use new api * Export more enum names from nrgaph * [Python API] quick fix of packaging * update tests * fix setup.py * small fix * small fixes according to comments * skip mo frontend tests * update mo to new imports * try to fix win wheel * fix win wheel * fix code style Co-authored-by: Anastasia Kuporosova <anastasia.kuporosova@intel.com> Co-authored-by: y <ilya.lavrenov@intel.com>
This commit is contained in:
113
src/bindings/python/tests/test_frontend/test_frontend_onnx.py
Normal file
113
src/bindings/python/tests/test_frontend/test_frontend_onnx.py
Normal file
@@ -0,0 +1,113 @@
|
||||
# Copyright (C) 2021 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import os
|
||||
import onnx
|
||||
import numpy as np
|
||||
from onnx.helper import make_graph, make_model, make_tensor_value_info
|
||||
import pytest
|
||||
|
||||
from openvino.frontend import FrontEndManager
|
||||
from tests.runtime import get_runtime
|
||||
|
||||
|
||||
def create_onnx_model():
|
||||
add = onnx.helper.make_node("Add", inputs=["x", "y"], outputs=["z"])
|
||||
const_tensor = onnx.helper.make_tensor("const_tensor", onnx.TensorProto.FLOAT, (2, 2), [0.5, 1, 1.5, 2.0])
|
||||
const_node = onnx.helper.make_node("Constant", [], outputs=["const_node"],
|
||||
value=const_tensor, name="const_node")
|
||||
mul = onnx.helper.make_node("Mul", inputs=["z", "const_node"], outputs=["out"])
|
||||
input_tensors = [
|
||||
make_tensor_value_info("x", onnx.TensorProto.FLOAT, (2, 2)),
|
||||
make_tensor_value_info("y", onnx.TensorProto.FLOAT, (2, 2)),
|
||||
]
|
||||
output_tensors = [make_tensor_value_info("out", onnx.TensorProto.FLOAT, (2, 2))]
|
||||
graph = make_graph([add, const_node, mul], "graph", input_tensors, output_tensors)
|
||||
return make_model(graph, producer_name="ngraph ONNX Importer")
|
||||
|
||||
|
||||
def run_function(function, *inputs, expected):
|
||||
runtime = get_runtime()
|
||||
computation = runtime.computation(function)
|
||||
actual = computation(*inputs)
|
||||
assert len(actual) == len(expected)
|
||||
for i in range(len(actual)):
|
||||
np.testing.assert_allclose(expected[i], actual[i], rtol=1e-3, atol=1e-6)
|
||||
|
||||
|
||||
fem = FrontEndManager()
|
||||
onnx_model_filename = "model.onnx"
|
||||
ONNX_FRONTEND_NAME = "onnx"
|
||||
|
||||
|
||||
def setup_module():
|
||||
onnx.save_model(create_onnx_model(), onnx_model_filename)
|
||||
|
||||
|
||||
def teardown_module():
|
||||
os.remove(onnx_model_filename)
|
||||
|
||||
|
||||
def skip_if_onnx_frontend_is_disabled():
|
||||
front_ends = fem.get_available_front_ends()
|
||||
if ONNX_FRONTEND_NAME not in front_ends:
|
||||
pytest.skip()
|
||||
|
||||
|
||||
def test_convert():
|
||||
skip_if_onnx_frontend_is_disabled()
|
||||
|
||||
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
|
||||
assert fe
|
||||
|
||||
model = fe.load(onnx_model_filename)
|
||||
assert model
|
||||
|
||||
function = fe.convert(model)
|
||||
assert function
|
||||
|
||||
a = np.array([[1, 2], [3, 4]], dtype=np.float32)
|
||||
b = np.array([[2, 3], [4, 5]], dtype=np.float32)
|
||||
expected = np.array([[1.5, 5], [10.5, 18]], dtype=np.float32)
|
||||
run_function(function, a, b, expected=[expected])
|
||||
|
||||
|
||||
def test_decode_and_convert():
|
||||
skip_if_onnx_frontend_is_disabled()
|
||||
|
||||
fe = fem.load_by_framework(framework=ONNX_FRONTEND_NAME)
|
||||
assert fe
|
||||
|
||||
model = fe.load(onnx_model_filename)
|
||||
assert model
|
||||
|
||||
decoded_function = fe.decode(model)
|
||||
assert decoded_function
|
||||
for op in decoded_function.get_ordered_ops():
|
||||
assert op.get_type_name() in ["Parameter", "Constant", "ONNXFrameworkNode",
|
||||
"ONNXSubgraphFrameworkNode", "Result"]
|
||||
|
||||
fe.convert(decoded_function)
|
||||
assert decoded_function
|
||||
for op in decoded_function.get_ordered_ops():
|
||||
assert op.get_type_name() not in ["ONNXFrameworkNode", "ONNXSubgraphFrameworkNode"]
|
||||
|
||||
a = np.array([[1, 2], [3, 4]], dtype=np.float32)
|
||||
b = np.array([[2, 3], [4, 5]], dtype=np.float32)
|
||||
expected = np.array([[1.5, 5], [10.5, 18]], dtype=np.float32)
|
||||
run_function(decoded_function, a, b, expected=[expected])
|
||||
|
||||
|
||||
def test_load_by_model():
|
||||
skip_if_onnx_frontend_is_disabled()
|
||||
|
||||
fe = fem.load_by_model(onnx_model_filename)
|
||||
assert fe
|
||||
assert fe.get_name() == "onnx"
|
||||
model = fe.load(onnx_model_filename)
|
||||
assert model
|
||||
decoded_function = fe.decode(model)
|
||||
assert decoded_function
|
||||
|
||||
assert not fem.load_by_model("test.xx")
|
||||
assert not fem.load_by_model("onnx.yy")
|
||||
1207
src/bindings/python/tests/test_frontend/test_frontend_onnx_editor.py
Normal file
1207
src/bindings/python/tests/test_frontend/test_frontend_onnx_editor.py
Normal file
File diff suppressed because it is too large
Load Diff
593
src/bindings/python/tests/test_frontend/test_frontendmanager.py
Normal file
593
src/bindings/python/tests/test_frontend/test_frontendmanager.py
Normal file
@@ -0,0 +1,593 @@
|
||||
# Copyright (C) 2018-2021 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import pickle
|
||||
|
||||
from openvino.runtime import PartialShape
|
||||
from openvino.frontend import FrontEndManager, InitializationFailure
|
||||
from openvino.runtime.utils.types import get_element_type
|
||||
|
||||
import numpy as np
|
||||
|
||||
import pytest
|
||||
|
||||
mock_available = True
|
||||
try:
|
||||
from pybind_mock_frontend import get_fe_stat, get_mdl_stat, get_place_stat
|
||||
except Exception:
|
||||
print("No mock frontend available")
|
||||
mock_available = False
|
||||
|
||||
# FrontEndManager shall be initialized and destroyed after all tests finished
|
||||
# This is because destroy of FrontEndManager will unload all plugins, no objects shall exist after this
|
||||
fem = FrontEndManager()
|
||||
|
||||
mock_needed = pytest.mark.skipif(not mock_available,
|
||||
reason="mock fe is not available")
|
||||
|
||||
|
||||
# ---------- FrontEnd tests ---------------
|
||||
def test_pickle():
|
||||
pickle.dumps(fem)
|
||||
|
||||
|
||||
def test_load_by_unknown_framework():
|
||||
frontEnds = fem.get_available_front_ends()
|
||||
assert not ("UnknownFramework" in frontEnds)
|
||||
try:
|
||||
fem.load_by_framework("UnknownFramework")
|
||||
except InitializationFailure as exc:
|
||||
print(exc)
|
||||
else:
|
||||
raise AssertionError("Unexpected exception.")
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_load():
|
||||
fe = fem.load_by_framework(framework="mock_py")
|
||||
assert fe is not None
|
||||
model = fe.load("abc.bin")
|
||||
assert model is not None
|
||||
stat = get_fe_stat(fe)
|
||||
assert "abc.bin" in stat.load_paths
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_load_by_model():
|
||||
fe = fem.load_by_model(model_path="abc.test_mock_py_mdl")
|
||||
assert fe is not None
|
||||
assert fe.get_name() == "mock_py"
|
||||
stat = get_fe_stat(fe)
|
||||
assert stat.get_name == 1
|
||||
assert stat.supported == 1
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_convert_model():
|
||||
fe = fem.load_by_framework(framework="mock_py")
|
||||
assert fe is not None
|
||||
model = fe.load(path="")
|
||||
func = fe.convert(model=model)
|
||||
assert func is not None
|
||||
stat = get_fe_stat(fe)
|
||||
assert stat.convert_model == 1
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_convert_partially():
|
||||
fe = fem.load_by_framework(framework="mock_py")
|
||||
assert fe is not None
|
||||
model = fe.load(path="")
|
||||
func = fe.convert_partially(model=model)
|
||||
stat = get_fe_stat(fe)
|
||||
assert stat.convert_partially == 1
|
||||
fe.convert(function=func)
|
||||
stat = get_fe_stat(fe)
|
||||
assert stat.convert == 1
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_decode_and_normalize():
|
||||
fe = fem.load_by_framework(framework="mock_py")
|
||||
assert fe is not None
|
||||
model = fe.load(path="")
|
||||
func = fe.decode(model=model)
|
||||
stat = get_fe_stat(fe)
|
||||
assert stat.decode == 1
|
||||
fe.normalize(function=func)
|
||||
stat = get_fe_stat(fe)
|
||||
assert stat.normalize == 1
|
||||
assert stat.decode == 1
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_get_name():
|
||||
fe = fem.load_by_framework(framework="mock_py")
|
||||
assert fe is not None
|
||||
name = fe.get_name()
|
||||
assert name == "mock_py"
|
||||
stat = get_fe_stat(fe)
|
||||
assert stat.get_name == 1
|
||||
|
||||
|
||||
# --------InputModel tests-----------------
|
||||
@mock_needed
|
||||
def init_model():
|
||||
fe = fem.load_by_framework(framework="mock_py")
|
||||
model = fe.load(path="")
|
||||
return model
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_model_get_inputs():
|
||||
model = init_model()
|
||||
for i in range(1, 10):
|
||||
model.get_inputs()
|
||||
stat = get_mdl_stat(model)
|
||||
assert stat.get_inputs == i
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_model_get_outputs():
|
||||
model = init_model()
|
||||
for i in range(1, 10):
|
||||
model.get_outputs()
|
||||
stat = get_mdl_stat(model)
|
||||
assert stat.get_outputs == i
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_model_get_place_by_tensor_name():
|
||||
model = init_model()
|
||||
for i in range(1, 10):
|
||||
name = str(i)
|
||||
model.get_place_by_tensor_name(tensorName=name)
|
||||
stat = get_mdl_stat(model)
|
||||
assert stat.get_place_by_tensor_name == i
|
||||
assert stat.lastArgString == name
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_model_get_place_by_operation_name():
|
||||
model = init_model()
|
||||
for i in range(1, 10):
|
||||
name = str(i)
|
||||
model.get_place_by_operation_name(operationName=name)
|
||||
stat = get_mdl_stat(model)
|
||||
assert stat.get_place_by_operation_name == i
|
||||
assert stat.lastArgString == name
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_model_get_place_by_operation_name_and_input_port():
|
||||
model = init_model()
|
||||
for i in range(1, 10):
|
||||
name = str(i)
|
||||
model.get_place_by_operation_name_and_input_port(operationName=name, inputPortIndex=i * 2)
|
||||
stat = get_mdl_stat(model)
|
||||
assert stat.get_place_by_operation_and_input_port == i
|
||||
assert stat.lastArgString == name
|
||||
assert stat.lastArgInt == i * 2
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_model_get_place_by_operation_name_and_output_port():
|
||||
model = init_model()
|
||||
for i in range(1, 10):
|
||||
name = str(i)
|
||||
model.get_place_by_operation_name_and_output_port(operationName=name, outputPortIndex=i * 2)
|
||||
stat = get_mdl_stat(model)
|
||||
assert stat.get_place_by_operation_and_output_port == i
|
||||
assert stat.lastArgString == name
|
||||
assert stat.lastArgInt == i * 2
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_model_set_name_for_tensor():
|
||||
model = init_model()
|
||||
place = model.get_place_by_tensor_name(tensorName="")
|
||||
model.set_name_for_tensor(tensor=place, newName="1234")
|
||||
stat = get_mdl_stat(model)
|
||||
assert stat.set_name_for_tensor == 1
|
||||
assert stat.lastArgString == "1234"
|
||||
assert stat.lastArgPlace == place
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_model_add_name_for_tensor():
|
||||
model = init_model()
|
||||
place = model.get_place_by_tensor_name(tensorName="")
|
||||
model.add_name_for_tensor(tensor=place, newName="1234")
|
||||
stat = get_mdl_stat(model)
|
||||
assert stat.add_name_for_tensor == 1
|
||||
assert stat.lastArgString == "1234"
|
||||
assert stat.lastArgPlace == place
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_model_set_name_for_operation():
|
||||
model = init_model()
|
||||
place = model.get_place_by_operation_name(operationName="")
|
||||
model.set_name_for_operation(operation=place, newName="1111")
|
||||
stat = get_mdl_stat(model)
|
||||
assert stat.set_name_for_operation == 1
|
||||
assert stat.lastArgString == "1111"
|
||||
assert stat.lastArgPlace == place
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_model_free_name_for_tensor():
|
||||
model = init_model()
|
||||
model.free_name_for_tensor(name="2222")
|
||||
stat = get_mdl_stat(model)
|
||||
assert stat.free_name_for_tensor == 1
|
||||
assert stat.lastArgString == "2222"
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_model_free_name_for_operation():
|
||||
model = init_model()
|
||||
model.free_name_for_operation(name="3333")
|
||||
stat = get_mdl_stat(model)
|
||||
assert stat.free_name_for_operation == 1
|
||||
assert stat.lastArgString == "3333"
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_model_set_name_for_dimension():
|
||||
model = init_model()
|
||||
place = model.get_place_by_operation_name(operationName="")
|
||||
model.set_name_for_dimension(place=place, dimIndex=123, dimName="4444")
|
||||
stat = get_mdl_stat(model)
|
||||
assert stat.set_name_for_dimension == 1
|
||||
assert stat.lastArgString == "4444"
|
||||
assert stat.lastArgInt == 123
|
||||
assert stat.lastArgPlace == place
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_model_cut_and_add_new_input():
|
||||
model = init_model()
|
||||
place = model.get_place_by_operation_name("")
|
||||
model.cut_and_add_new_input(place=place, newName="5555")
|
||||
stat = get_mdl_stat(model)
|
||||
assert stat.cut_and_add_new_input == 1
|
||||
assert stat.lastArgString == "5555"
|
||||
assert stat.lastArgPlace == place
|
||||
model.cut_and_add_new_input(place=place)
|
||||
stat = get_mdl_stat(model)
|
||||
assert stat.cut_and_add_new_input == 2
|
||||
assert stat.lastArgString == ""
|
||||
assert stat.lastArgPlace == place
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_model_cut_and_add_new_output():
|
||||
model = init_model()
|
||||
place = model.get_place_by_operation_name("")
|
||||
model.cut_and_add_new_output(place=place, newName="5555")
|
||||
stat = get_mdl_stat(model)
|
||||
assert stat.cut_and_add_new_output == 1
|
||||
assert stat.lastArgString == "5555"
|
||||
assert stat.lastArgPlace == place
|
||||
model.cut_and_add_new_output(place=place)
|
||||
stat = get_mdl_stat(model)
|
||||
assert stat.cut_and_add_new_output == 2
|
||||
assert stat.lastArgString == ""
|
||||
assert stat.lastArgPlace == place
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_model_add_output():
|
||||
model = init_model()
|
||||
place = model.get_place_by_operation_name("")
|
||||
place2 = model.add_output(place=place)
|
||||
assert place2 is not None
|
||||
stat = get_mdl_stat(model)
|
||||
assert stat.add_output == 1
|
||||
assert stat.lastArgPlace == place
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_model_remove_output():
|
||||
model = init_model()
|
||||
place = model.get_place_by_operation_name("")
|
||||
model.remove_output(place=place)
|
||||
stat = get_mdl_stat(model)
|
||||
assert stat.remove_output == 1
|
||||
assert stat.lastArgPlace == place
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_model_set_partial_shape():
|
||||
model = init_model()
|
||||
place = model.get_place_by_tensor_name(tensorName="")
|
||||
test_shape = PartialShape([1, 2, 3, 4])
|
||||
model.set_partial_shape(place=place, shape=test_shape)
|
||||
stat = get_mdl_stat(model)
|
||||
assert stat.set_partial_shape == 1
|
||||
assert stat.lastArgPlace == place
|
||||
assert stat.lastArgPartialShape == test_shape
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_model_get_partial_shape():
|
||||
model = init_model()
|
||||
place = model.get_place_by_tensor_name(tensorName="")
|
||||
shape = model.get_partial_shape(place=place)
|
||||
assert shape is not None
|
||||
stat = get_mdl_stat(model)
|
||||
assert stat.get_partial_shape == 1
|
||||
assert stat.lastArgPlace == place
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_model_override_all_inputs():
|
||||
model = init_model()
|
||||
place1 = model.get_place_by_tensor_name(tensorName="p1")
|
||||
place2 = model.get_place_by_tensor_name(tensorName="p2")
|
||||
model.override_all_inputs(inputs=[place1, place2])
|
||||
stat = get_mdl_stat(model)
|
||||
assert stat.override_all_inputs == 1
|
||||
assert len(stat.lastArgInputPlaces) == 2
|
||||
assert stat.lastArgInputPlaces[0] == place1
|
||||
assert stat.lastArgInputPlaces[1] == place2
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_model_override_all_outputs():
|
||||
model = init_model()
|
||||
place1 = model.get_place_by_tensor_name(tensorName="p1")
|
||||
place2 = model.get_place_by_tensor_name(tensorName="p2")
|
||||
model.override_all_outputs(outputs=[place1, place2])
|
||||
stat = get_mdl_stat(model)
|
||||
assert stat.override_all_outputs == 1
|
||||
assert len(stat.lastArgOutputPlaces) == 2
|
||||
assert stat.lastArgOutputPlaces[0] == place1
|
||||
assert stat.lastArgOutputPlaces[1] == place2
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_model_extract_subgraph():
|
||||
model = init_model()
|
||||
place1 = model.get_place_by_tensor_name(tensorName="p1")
|
||||
place2 = model.get_place_by_tensor_name(tensorName="p2")
|
||||
place3 = model.get_place_by_tensor_name(tensorName="p3")
|
||||
place4 = model.get_place_by_tensor_name(tensorName="p4")
|
||||
model.extract_subgraph(inputs=[place1, place2], outputs=[place3, place4])
|
||||
stat = get_mdl_stat(model)
|
||||
assert stat.extract_subgraph == 1
|
||||
assert len(stat.lastArgInputPlaces) == 2
|
||||
assert stat.lastArgInputPlaces[0] == place1
|
||||
assert stat.lastArgInputPlaces[1] == place2
|
||||
assert len(stat.lastArgOutputPlaces) == 2
|
||||
assert stat.lastArgOutputPlaces[0] == place3
|
||||
assert stat.lastArgOutputPlaces[1] == place4
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_model_set_element_type():
|
||||
model = init_model()
|
||||
place = model.get_place_by_tensor_name(tensorName="")
|
||||
model.set_element_type(place=place, type=get_element_type(np.int32))
|
||||
stat = get_mdl_stat(model)
|
||||
assert stat.set_element_type == 1
|
||||
assert stat.lastArgPlace == place
|
||||
assert stat.lastArgElementType == get_element_type(np.int32)
|
||||
|
||||
|
||||
# ----------- Place test ------------
|
||||
@mock_needed
|
||||
def init_place():
|
||||
fe = fem.load_by_framework(framework="mock_py")
|
||||
model = fe.load(path="")
|
||||
place = model.get_place_by_tensor_name(tensorName="")
|
||||
return model, place
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_place_is_input():
|
||||
_, place = init_place()
|
||||
assert place.is_input() is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.is_input == 1
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_place_is_output():
|
||||
_, place = init_place()
|
||||
assert place.is_output() is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.is_output == 1
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_place_get_names():
|
||||
_, place = init_place()
|
||||
assert place.get_names() is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.get_names == 1
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_place_is_equal():
|
||||
model, place = init_place()
|
||||
place2 = model.get_place_by_tensor_name("2")
|
||||
assert place.is_equal(other=place2) is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.is_equal == 1
|
||||
assert stat.lastArgPlace == place2
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_place_is_equal_data():
|
||||
model, place = init_place()
|
||||
place2 = model.get_place_by_tensor_name("2")
|
||||
assert place.is_equal_data(other=place2) is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.is_equal_data == 1
|
||||
assert stat.lastArgPlace == place2
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_place_get_consuming_operations():
|
||||
_, place = init_place()
|
||||
assert place.get_consuming_operations(outputPortIndex=22) is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.get_consuming_operations == 1
|
||||
assert stat.lastArgInt == 22
|
||||
assert place.get_consuming_operations() is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.get_consuming_operations == 2
|
||||
assert stat.lastArgInt == -1
|
||||
assert place.get_consuming_operations(outputName="2") is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.get_consuming_operations == 3
|
||||
assert stat.lastArgInt == -1
|
||||
assert stat.lastArgString == "2"
|
||||
assert place.get_consuming_operations(outputName="3", outputPortIndex=33) is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.get_consuming_operations == 4
|
||||
assert stat.lastArgInt == 33
|
||||
assert stat.lastArgString == "3"
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_place_get_target_tensor():
|
||||
_, place = init_place()
|
||||
assert place.get_target_tensor(outputPortIndex=22) is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.get_target_tensor == 1
|
||||
assert stat.lastArgInt == 22
|
||||
assert place.get_target_tensor() is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.get_target_tensor == 2
|
||||
assert stat.lastArgInt == -1
|
||||
assert place.get_target_tensor(outputName="2") is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.get_target_tensor == 3
|
||||
assert stat.lastArgInt == -1
|
||||
assert stat.lastArgString == "2"
|
||||
assert place.get_target_tensor(outputName="3", outputPortIndex=33) is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.get_target_tensor == 4
|
||||
assert stat.lastArgInt == 33
|
||||
assert stat.lastArgString == "3"
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_place_get_producing_operation():
|
||||
_, place = init_place()
|
||||
assert place.get_producing_operation(inputPortIndex=22) is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.get_producing_operation == 1
|
||||
assert stat.lastArgInt == 22
|
||||
assert place.get_producing_operation() is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.get_producing_operation == 2
|
||||
assert stat.lastArgInt == -1
|
||||
assert place.get_producing_operation(inputName="2") is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.get_producing_operation == 3
|
||||
assert stat.lastArgInt == -1
|
||||
assert stat.lastArgString == "2"
|
||||
assert place.get_producing_operation(inputName="3", inputPortIndex=33) is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.get_producing_operation == 4
|
||||
assert stat.lastArgInt == 33
|
||||
assert stat.lastArgString == "3"
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_place_get_producing_port():
|
||||
_, place = init_place()
|
||||
assert place.get_producing_port() is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.get_producing_port == 1
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_place_get_input_port():
|
||||
_, place = init_place()
|
||||
assert place.get_input_port() is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.get_input_port == 1
|
||||
assert stat.lastArgInt == -1
|
||||
assert place.get_input_port(inputPortIndex=22) is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.get_input_port == 2
|
||||
assert stat.lastArgInt == 22
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_place_get_input_port2():
|
||||
_, place = init_place()
|
||||
assert place.get_input_port(inputName="abc") is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.get_input_port == 1
|
||||
assert stat.lastArgInt == -1
|
||||
assert stat.lastArgString == "abc"
|
||||
assert place.get_input_port(inputName="abcd", inputPortIndex=22) is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.get_input_port == 2
|
||||
assert stat.lastArgInt == 22
|
||||
assert stat.lastArgString == "abcd"
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_place_get_output_port():
|
||||
_, place = init_place()
|
||||
assert place.get_output_port() is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.get_output_port == 1
|
||||
assert stat.lastArgInt == -1
|
||||
assert place.get_output_port(outputPortIndex=22) is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.get_output_port == 2
|
||||
assert stat.lastArgInt == 22
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_place_get_output_port2():
|
||||
_, place = init_place()
|
||||
assert place.get_output_port(outputName="abc") is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.get_output_port == 1
|
||||
assert stat.lastArgInt == -1
|
||||
assert stat.lastArgString == "abc"
|
||||
assert place.get_output_port(outputName="abcd", outputPortIndex=22) is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.get_output_port == 2
|
||||
assert stat.lastArgInt == 22
|
||||
assert stat.lastArgString == "abcd"
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_place_get_consuming_ports():
|
||||
_, place = init_place()
|
||||
assert place.get_consuming_ports() is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.get_consuming_ports == 1
|
||||
|
||||
|
||||
@mock_needed
|
||||
def test_place_get_source_tensor():
|
||||
_, place = init_place()
|
||||
assert place.get_source_tensor() is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.get_source_tensor == 1
|
||||
assert stat.lastArgInt == -1
|
||||
assert place.get_source_tensor(inputPortIndex=22) is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.get_source_tensor == 2
|
||||
assert stat.lastArgInt == 22
|
||||
assert place.get_source_tensor(inputName="2") is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.get_source_tensor == 3
|
||||
assert stat.lastArgInt == -1
|
||||
assert stat.lastArgString == "2"
|
||||
assert place.get_source_tensor(inputName="3", inputPortIndex=33) is not None
|
||||
stat = get_place_stat(place)
|
||||
assert stat.get_source_tensor == 4
|
||||
assert stat.lastArgInt == 33
|
||||
assert stat.lastArgString == "3"
|
||||
Reference in New Issue
Block a user