From 5671ca2cf58f84c42fdc9b10d5164f58fe69a6ac Mon Sep 17 00:00:00 2001 From: Alexey Lebedev Date: Sat, 19 Feb 2022 20:19:28 +0300 Subject: [PATCH] add test (#10531) --- .../test_infer_request.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/bindings/python/tests/test_inference_engine/test_infer_request.py b/src/bindings/python/tests/test_inference_engine/test_infer_request.py index abe51c294b6..4119637c04e 100644 --- a/src/bindings/python/tests/test_inference_engine/test_infer_request.py +++ b/src/bindings/python/tests/test_inference_engine/test_infer_request.py @@ -10,7 +10,7 @@ import time import openvino.runtime.opset8 as ops from openvino.runtime import Core, AsyncInferQueue, Tensor, ProfilingInfo, Model -from openvino.runtime import Type, Shape, Layout +from openvino.runtime import Type, PartialShape, Shape, Layout from openvino.preprocess import PrePostProcessor from ..conftest import model_path, read_image @@ -656,3 +656,20 @@ def test_invalid_inputs_container(device): with pytest.raises(TypeError) as e: request.infer(inputs) assert "Inputs should be either list or dict! Current type:" in str(e.value) + + +def test_infer_dynamic_model(device): + core = Core() + param = ops.parameter(PartialShape([-1, -1])) + model = Model(ops.relu(param), [param]) + compiled = core.compile_model(model, device) + assert compiled.input().partial_shape.is_dynamic + request = compiled.create_infer_request() + + shape1 = [1, 28] + request.infer([np.random.normal(size=shape1)]) + assert request.get_input_tensor().shape == Shape(shape1) + + shape2 = [1, 32] + request.infer([np.random.normal(size=shape2)]) + assert request.get_input_tensor().shape == Shape(shape2)