def test_incorrect_reshape(): function = create_relu([1, 3, 22, 22]) net = ng.function_to_cnn(function) with pytest.raises(ValueError) as e: net.reshape({"data": [(2, 4, 6), 3, 22, 22]}) assert "Incorrect PartialShape dimension definition '(2, 4, 6)' " \ "in shape '[(2, 4, 6), 3, 22, 22]', expected one or two values for a dimension! " in str(e.value)
def test_is_dynamic(): function = create_relu([-1, 3, 20, 20]) net = ng.function_to_cnn(function) ie = IECore() ie.register_plugin("openvino_template_plugin", "TEMPLATE") exec_net = ie.load_network(net, "TEMPLATE") assert exec_net.outputs["out"].is_dynamic p_shape = ng.partial_shape_from_data(exec_net.outputs["out"]) assert isinstance(p_shape, ng.impl.PartialShape) with pytest.raises(RuntimeError) as e: exec_net.outputs["out"].shape assert "Cannot return dims for Data with dynamic shapes!" in str(e.value)
def test_create_two_exec_net(): function = create_relu([ ng.Dimension(0, 5), ng.Dimension(4), ng.Dimension(20), ng.Dimension(20) ]) net = ng.function_to_cnn(function) ie_core = IECore() ie_core.register_plugin("openvino_template_plugin", "TEMPLATE") exec_net1 = ie_core.load_network(net, "TEMPLATE", num_requests=2) assert ng.function_from_cnn(net) != None exec_net2 = ie_core.load_network(net, "TEMPLATE", num_requests=2) assert ng.function_from_cnn(net) != None
def test_reshape_with_partial_shape(device, shape, p_shape): function = create_relu(shape) net = ng.function_to_cnn(function) net.reshape({"data": p_shape}) changedFunction = ng.function_from_cnn(net) p_shape = ng.impl.PartialShape(p_shape) assert changedFunction.get_parameters()[0].get_partial_shape().is_dynamic assert changedFunction.get_results()[0].get_output_partial_shape( 0).is_dynamic assert function.get_parameters()[0].get_partial_shape().is_dynamic assert function.get_results()[0].get_output_partial_shape(0).is_dynamic assert changedFunction.get_parameters()[0].get_partial_shape() == p_shape assert changedFunction.get_results()[0].get_output_partial_shape( 0) == p_shape assert function.get_parameters()[0].get_partial_shape() == p_shape assert function.get_results()[0].get_output_partial_shape(0) == p_shape