Пример #1
0
def test_init_class():
    mapping_config = 'mapping_config.json'
    exec_net = None
    net = MockedNet(inputs={'input': MockedIOInfo('FP32', [1, 1, 1], 'NCHW')},
                    outputs={'output': MockedIOInfo('FP32', [1, 1], 'NCHW')})
    batching_info = BatchingInfo(None)
    shape_info = ShapeInfo(None, net.inputs)
    plugin = None
    requests_queue = queue.Queue()
    free_ireq_index_queue = queue.Queue(maxsize=1)
    free_ireq_index_queue.put(0)
    engine = IrEngine(model_name='test',
                      model_version=1,
                      mapping_config=mapping_config,
                      exec_net=exec_net,
                      net=net,
                      plugin=plugin,
                      batching_info=batching_info,
                      shape_info=shape_info,
                      num_ireq=1,
                      free_ireq_index_queue=free_ireq_index_queue,
                      requests_queue=requests_queue,
                      target_device='CPU',
                      plugin_config=None)
    assert exec_net == engine.exec_net
    assert list(net.inputs.keys()) == engine.input_tensor_names
    assert list(net.outputs.keys()) == engine.output_tensor_names
    assert engine.free_ireq_index_queue.qsize() == 1
def test_prepare_get_metadata_output():
    inputs = {'tensor_input': MockedIOInfo('FP32', (1, 1, 1), 'NCHW')}
    outputs = {'tensor_output': MockedIOInfo('FP32', (1, 1, 1), 'NCHW')}
    model_keys = {
        'inputs': {
            'name': 'tensor_input'
        },
        'outputs': {
            'output_name': 'tensor_output'
        }
    }
    output = prepare_get_metadata_output(inputs=inputs,
                                         outputs=outputs,
                                         model_keys=model_keys)

    assert "tensorflow/serving/predict" == output.method_name
def test_init_class():
    mapping_config = 'mapping_config.json'
    exec_net = None
    net = MockedNet(inputs={'input': MockedIOInfo('FP32', [1, 1, 1], 'NCHW')},
                    outputs={'output': MockedIOInfo('FP32', [1, 1], 'NCHW')})
    batching_info = BatchingInfo(None)
    shape_info = ShapeInfo(None, net.inputs)
    plugin = None
    engine = IrEngine(model_name='test', model_version=1,
                      mapping_config=mapping_config,
                      exec_net=exec_net,
                      net=net, plugin=plugin, batching_info=batching_info,
                      shape_info=shape_info)
    assert exec_net == engine.exec_net
    assert list(net.inputs.keys()) == engine.input_tensor_names
    assert list(net.outputs.keys()) == engine.output_tensor_names
Пример #4
0
def test_scan_input_shapes(get_fake_ir_engine, net_inputs_shapes, data,
                           expected_output):
    engine = get_fake_ir_engine

    # update network with desired inputs
    new_inputs = {}
    for input_name, input_shape in net_inputs_shapes.items():
        new_inputs.update({input_name: MockedIOInfo('FP32', list(input_shape),
                                                    'NCHW')})
    engine.net.inputs = new_inputs

    output = engine.scan_input_shapes(data)
    assert output == expected_output
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

from tensorflow.python.framework import dtypes as dtypes
import numpy as np
import pytest
from ie_serving.server.get_model_metadata_utils import \
    _prepare_signature, prepare_get_metadata_output
from conftest import MockedIOInfo


@pytest.mark.parametrize("layers, tensor_key, np_type", [
    ({
        'tensor': MockedIOInfo('FP32', (1, 1, 1), 'NCHW'),
        'test_tensor': MockedIOInfo('FP32', (1, 1, 1), 'NCHW')
    }, {
        'new_key': 'tensor',
        'client_key': 'test_tensor'
    }, np.float32),
    ({
        'tensor': MockedIOInfo('I32', (1, 1, 1), 'NCHW')
    }, {
        'new_key': 'tensor'
    }, np.int32),
])
def test_prepare_signature(layers, tensor_key, np_type):
    dtype_model = dtypes.as_dtype(np_type)
    output = _prepare_signature(layers=layers, model_keys=tensor_key)