Files
openvino/runtime/bindings/python/tests/conftest.py
T
cdb3e17763 [New Python API] Add new python API based on pybind11 (#7752)
* Mk/ov pybind poc (#48)

* Move _pyngraph module to ngraph.pyngraph

* Stub for IECore and IENetwork classes

* Additional API classes

* passing test, extended functions and added blob

* worksave

* [POC Python API] Add IECore methods

* [POC Python API] Add iecore tests

* ienetwork

* ienet, input_info, dataptr

* irequest and exeecnet

* adapted benchmark

* Move _pyngraph module to ngraph.pyngraph

* Stub for IECore and IENetwork classes

* Additional API classes

* passing test, extended functions and added blob

* worksave

* [POC Python API] Add IECore methods

* [POC Python API] Add iecore tests

* ienetwork

* ienet, input_info, dataptr

* irequest and exeecnet

* adapted benchmark

* Added suport for InputInfo bindings

* Add Blob support for different types

* fix typo

* Fixed InputInfo maps

* Add keys() to inputs maps

* add uint8 blob

* return read_network as it should be

* return read_network as it should be

* fix blob buffer

* remove const input_info files and fix codestyle

* add mode parameter in benchmark app

* return _pyngraph

* delete benchmark copy

* return pyngraph as in master

* fix benchmark working

* add comment with api which need to implement

* remove unnecessary code from benchmark

* remove hardcoded path from setup.py

* Rename vars in setup.py

* working wheel

* fix wheel building

* Revert "working wheel"

This reverts commit 11d03a1833.

* fix tests

* Added async infer

* pass by ref

* add ccompiler to requirements

* fix blob creation and view

* replace abscent method with working code in benchmark

* fix building

* worksave

* worksave queue

* no-deadlock async infer

* add lock handle in waitAll

* fix building issues with includes

* update of setup and cmakelist

* fix setup.py way of building

* add new methods for ie_core

* add ienetwork methods: serizlize and getfunction

* add methods for exec net and infer request class

* remove ccompiler from requirements

* remove set from cmake

* Update Blob class with precisions

* Rewrite test_write_numpy_scalar_int64

* Generic Blob casting in infer queue

* implementation of preprocess_info

* update license

* add set_blob method

* worksave

* added template for setblob

* Added blob convert in infer request

* move blob casting to common namespace

* add_outputs method

* work with func from pyopenvino

* add user_id to callbacks

* remove hardcoded root dir

* refactor code and comments

* [Python API] use parametrize in blob tests

* move common functions to conftest file

* Add tests for blob

* Update test_blob and test_network

* add parametrize in blob tests

* blob refactoring

* Fix sync in InferQueue and add default callbacks

* patch for protobuf cmake

* blob refactoring

* rename convert_to_blob to cast_to_blob

* rename to cast_to_blob in infer queue

* add missing cast_to_blob

* remove boost

* change license

* undo in cmake

* fix building

* [IE PYTHON API POC] Add fixed InferQueue and modification in async part of benchmark

* Add read_network(model,blob)

* Add blob_from_file helper

* Add read from Path

* Add tests

* Add read_network from bytes

* Error throwing in Common IE functions

* Cleaning samples

* Changes in ConstInputInfoWrapper class

* Add StatusCode to callback function for InferRequest

* Add random image generation and model path getting

* Move example model to examples path

* Adapt sync and async examples to new helpers

* Return request info containing StatusCode and ID from InferQueue for top idle request.

* Update benchmark app to use new API with request info

* Update examples to use two different approaches to InferQueue

* reset new line

* Add is_ready() to InferQueue

* fix building

* remove benchmark

* temporary add separate flag for building poc

* refactoring

* Remove GIL acquire in default callback and latencies

* Adapt benchmark to Core()

* Codestyle

* fix building

* [Python API] Move ngraph python api to the new destination

* fix building tests

* fix code-style checks

* building in azure

* fix building wheels

* apply fixes

* new structure

* fix building

* Add support for InferRequest::Cancel in pyopenvino

* fixes

remove gil release
add async infer after cancel

* remove extra files

* remove examples and benchmark

* fix code style

* fix building

* fix tests

* merge inits from old and new api

* fix azure ci

* fix setup.py

* fix setup.py building

* try to fix mac

Co-authored-by: Michal Karzynski <michal.karzynski@intel.com>
Co-authored-by: jiwaszki <jan.iwaszkiewicz@intel.com>
Co-authored-by: anastasia.kuporosova <akuporos@akuporos.inn.intel.com>
Co-authored-by: Alexey Lebedev <alexey.lebedev@intel.com>
Co-authored-by: Mateusz Tabaka <mateusz.tabaka@intel.com>

* Fix comments

* fix comments: cmakelist

* fix building on arm

* permission for merge script

* permission for merge script

Co-authored-by: Michal Karzynski <michal.karzynski@intel.com>
Co-authored-by: jiwaszki <jan.iwaszkiewicz@intel.com>
Co-authored-by: anastasia.kuporosova <akuporos@akuporos.inn.intel.com>
Co-authored-by: Alexey Lebedev <alexey.lebedev@intel.com>
Co-authored-by: Mateusz Tabaka <mateusz.tabaka@intel.com>
2021-10-05 13:55:54 +03:00

115 lines
4.0 KiB
Python

# Copyright (C) 2018-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import pytest
import tests
from pathlib import Path
def image_path():
path_to_repo = os.environ["DATA_PATH"]
path_to_img = os.path.join(path_to_repo, "validation_set", "224x224", "dog.bmp")
return path_to_img
def model_path(is_myriad=False):
path_to_repo = os.environ["MODELS_PATH"]
if not is_myriad:
test_xml = os.path.join(path_to_repo, "models", "test_model", "test_model_fp32.xml")
test_bin = os.path.join(path_to_repo, "models", "test_model", "test_model_fp32.bin")
else:
test_xml = os.path.join(path_to_repo, "models", "test_model", "test_model_fp16.xml")
test_bin = os.path.join(path_to_repo, "models", "test_model", "test_model_fp16.bin")
return (test_xml, test_bin)
def model_onnx_path():
path_to_repo = os.environ["MODELS_PATH"]
test_onnx = os.path.join(path_to_repo, "models", "test_model", "test_model.onnx")
return test_onnx
def plugins_path():
path_to_repo = os.environ["DATA_PATH"]
plugins_xml = os.path.join(path_to_repo, "ie_class", "plugins.xml")
plugins_win_xml = os.path.join(path_to_repo, "ie_class", "plugins_win.xml")
plugins_osx_xml = os.path.join(path_to_repo, "ie_class", "plugins_apple.xml")
return (plugins_xml, plugins_win_xml, plugins_osx_xml)
def _get_default_model_zoo_dir():
return Path(os.getenv("ONNX_HOME", Path.home() / ".onnx/model_zoo"))
def pytest_addoption(parser):
parser.addoption(
"--backend",
default="CPU",
choices=["CPU", "GPU", "HDDL", "MYRIAD", "HETERO", "TEMPLATE"],
help="Select target device",
)
parser.addoption(
"--model_zoo_dir",
default=_get_default_model_zoo_dir(),
type=str,
help="location of the model zoo",
)
parser.addoption(
"--model_zoo_xfail",
action="store_true",
help="treat model zoo known issues as xfails instead of failures",
)
def pytest_configure(config):
backend_name = config.getvalue("backend")
tests.BACKEND_NAME = backend_name
tests.MODEL_ZOO_DIR = Path(config.getvalue("model_zoo_dir"))
tests.MODEL_ZOO_XFAIL = config.getvalue("model_zoo_xfail")
# register additional markers
config.addinivalue_line("markers", "skip_on_cpu: Skip test on CPU")
config.addinivalue_line("markers", "skip_on_gpu: Skip test on GPU")
config.addinivalue_line("markers", "skip_on_hddl: Skip test on HDDL")
config.addinivalue_line("markers", "skip_on_myriad: Skip test on MYRIAD")
config.addinivalue_line("markers", "skip_on_hetero: Skip test on HETERO")
config.addinivalue_line("markers", "skip_on_template: Skip test on TEMPLATE")
config.addinivalue_line("markers", "onnx_coverage: Collect ONNX operator coverage")
def pytest_collection_modifyitems(config, items):
backend_name = config.getvalue("backend")
tests.MODEL_ZOO_DIR = Path(config.getvalue("model_zoo_dir"))
tests.MODEL_ZOO_XFAIL = config.getvalue("model_zoo_xfail")
keywords = {
"CPU": "skip_on_cpu",
"GPU": "skip_on_gpu",
"HDDL": "skip_on_hddl",
"MYRIAD": "skip_on_myriad",
"HETERO": "skip_on_hetero",
"TEMPLATE": "skip_on_template",
}
skip_markers = {
"CPU": pytest.mark.skip(reason="Skipping test on the CPU backend."),
"GPU": pytest.mark.skip(reason="Skipping test on the GPU backend."),
"HDDL": pytest.mark.skip(reason="Skipping test on the HDDL backend."),
"MYRIAD": pytest.mark.skip(reason="Skipping test on the MYRIAD backend."),
"HETERO": pytest.mark.skip(reason="Skipping test on the HETERO backend."),
"TEMPLATE": pytest.mark.skip(reason="Skipping test on the TEMPLATE backend."),
}
for item in items:
skip_this_backend = keywords[backend_name]
if skip_this_backend in item.keywords:
item.add_marker(skip_markers[backend_name])
@pytest.fixture(scope="session")
def device():
return os.environ.get("TEST_DEVICE") if os.environ.get("TEST_DEVICE") else "CPU"