From 1fd2df6e0d03d756dd1ad55014bac8cb2c5f2cd6 Mon Sep 17 00:00:00 2001 From: Anastasia Kuporosova Date: Fri, 11 Sep 2020 12:56:57 +0300 Subject: [PATCH] [PYTHON API TESTS] Add ngraph tests (#2132) Co-authored-by: Alexander Zhogov --- .../ie_bridges/python/tests/test_NGraph.py | 43 +++++++++++++++------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/inference-engine/ie_bridges/python/tests/test_NGraph.py b/inference-engine/ie_bridges/python/tests/test_NGraph.py index 4987a54..2380b18 100644 --- a/inference-engine/ie_bridges/python/tests/test_NGraph.py +++ b/inference-engine/ie_bridges/python/tests/test_NGraph.py @@ -1,23 +1,13 @@ from openvino.inference_engine import IECore, IENetwork - -try: - import ngraph as ng - from ngraph.impl.op import Parameter - from ngraph.impl import Function, Shape, Type - ngraph_available=True -except: - ngraph_available=False - -import pytest +import ngraph as ng +from ngraph.impl.op import Parameter +from ngraph.impl import Function, Shape, Type from conftest import model_path test_net_xml, test_net_bin = model_path() -if not ngraph_available: - pytest.skip("NGraph is not installed, skip", allow_module_level=True) - def test_create_IENetwork_from_nGraph(): element_type = Type.f32 @@ -58,3 +48,30 @@ def test_get_ops_from_IENetwork(): '28/Reshape/Cast_1955_const', '28/Reshape', 'onnx_initializer_node_17/Output_0/Data__const', '29/WithoutBiases', 'onnx_initializer_node_18/Output_0/Data_/copy_const', '29', 'fc_out', 'fc_out/sink_port_0'] + + +def test_get_type_name(): + ie = IECore() + net = ie.read_network(model=test_net_xml, weights=test_net_bin) + func = ng.function_from_cnn(net) + ops = func.get_ordered_ops() + assert ops[2].get_type_name() == "Convolution" + + +def test_getting_shapes(): + ie = IECore() + net = ie.read_network(model=test_net_xml, weights=test_net_bin) + func = ng.function_from_cnn(net) + ops = func.get_ordered_ops() + shapes = [sh for sh in ops[2].shape] + assert shapes == [1, 16, 32, 32] + + +def test_get_set_rt_info(): + ie = IECore() + net = ie.read_network(model=test_net_xml, weights=test_net_bin) + func = ng.function_from_cnn(net) + ops = func.get_ordered_ops() + rt_info = ops[14].get_rt_info() + rt_info["affinity"] = "test_affinity" + assert ops[14].get_rt_info()["affinity"] == "test_affinity" -- 2.7.4