diff --git a/.ci/azure/linux.yml b/.ci/azure/linux.yml index ff50aa40a83..e0409bd9cb3 100644 --- a/.ci/azure/linux.yml +++ b/.ci/azure/linux.yml @@ -112,10 +112,10 @@ jobs: sudo apt --assume-yes install openjdk-11-jdk # For opencv-python: python3-setuptools and pip upgrade python3 -m pip install --upgrade pip - python3 -m pip install -r $(REPO_DIR)/inference-engine/ie_bridges/python/requirements.txt + python3 -m pip install -r $(REPO_DIR)/src/bindings/python/src/compatibility/openvino/requirements.txt python3 -m pip install -r $(REPO_DIR)/src/bindings/python/wheel/requirements-dev.txt # For running Python API tests - python3 -m pip install -r $(REPO_DIR)/inference-engine/ie_bridges/python/src/requirements-dev.txt + python3 -m pip install -r $(REPO_DIR)/src/bindings/python/src/compatibility/openvino/requirements-dev.txt # For running Paddle frontend unit tests python3 -m pip install -r $(REPO_DIR)/src/core/tests/frontend/paddle/requirements_dev.txt # For running ONNX frontend unit tests @@ -344,7 +344,7 @@ jobs: - script: | export DATA_PATH=$(MODELS_PATH) export MODELS_PATH=$(MODELS_PATH) - cd $(REPO_DIR)/inference-engine/ie_bridges/python/tests + cd $(REPO_DIR)/src/bindings/python/tests_compatibility/test_inference_engine . $(SETUPVARS) -pyver 3.8 && python3 -m pytest --junitxml=TEST-PythonAPI.xml $(PYTHON_STATIC_ARGS) displayName: 'Python API Tests' continueOnError: false diff --git a/.ci/azure/linux_conditional_compilation.yml b/.ci/azure/linux_conditional_compilation.yml index d60bc412cc9..6c23df40060 100644 --- a/.ci/azure/linux_conditional_compilation.yml +++ b/.ci/azure/linux_conditional_compilation.yml @@ -63,7 +63,7 @@ jobs: - script: | set -e $(REPO_DIR)/install_build_dependencies.sh - python3 -m pip install -r $(REPO_DIR)/inference-engine/ie_bridges/python/requirements.txt + python3 -m pip install -r $(REPO_DIR)/src/bindings/python/src/compatibility/openvino/requirements.txt # Speed up build wget https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-linux.zip unzip ninja-linux.zip diff --git a/.ci/azure/linux_onnxruntime.yml b/.ci/azure/linux_onnxruntime.yml index 9897bbd4416..d738515c03c 100644 --- a/.ci/azure/linux_onnxruntime.yml +++ b/.ci/azure/linux_onnxruntime.yml @@ -73,9 +73,9 @@ jobs: set -e $(REPO_DIR)/install_build_dependencies.sh python3 -m pip install --upgrade pip - python3 -m pip install -r $(REPO_DIR)/inference-engine/ie_bridges/python/requirements.txt + python3 -m pip install -r $(REPO_DIR)/src/bindings/python/src/compatibility/openvino/requirements.txt # For running Python API tests - python3 -m pip install -r $(REPO_DIR)/inference-engine/ie_bridges/python/src/requirements-dev.txt + python3 -m pip install -r $(REPO_DIR)/src/bindings/python/src/compatibility/openvino/requirements-dev.txt # Speed up build wget https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-linux.zip unzip ninja-linux.zip diff --git a/.ci/azure/windows.yml b/.ci/azure/windows.yml index ba98e373f92..153af1b67e8 100644 --- a/.ci/azure/windows.yml +++ b/.ci/azure/windows.yml @@ -108,8 +108,8 @@ jobs: - script: | python -m pip install --upgrade pip rem For running Python API tests - python -m pip install -r $(REPO_DIR)\inference-engine\ie_bridges\python\src\requirements-dev.txt - python -m pip install -r $(REPO_DIR)\inference-engine\ie_bridges\python\wheel\requirements-dev.txt + python -m pip install -r $(REPO_DIR)\src\bindings\python\src\compatibility\openvino\requirements-dev.txt + python -m pip install -r $(REPO_DIR)\src\bindings\python\wheel\requirements-dev.txt rem For running Paddle frontend unit tests python -m pip install -r $(REPO_DIR)\src\core\tests\frontend\paddle\requirements_dev.txt rem For running ONNX frontend unit tests diff --git a/.github/workflows/code_style.yml b/.github/workflows/code_style.yml index e693f88fcaf..603157f0b87 100644 --- a/.github/workflows/code_style.yml +++ b/.github/workflows/code_style.yml @@ -19,9 +19,9 @@ jobs: sudo apt update sudo apt --assume-yes install libusb-1.0-0-dev python3 -m pip install --upgrade pip - python3 -m pip install -r ./inference-engine/ie_bridges/python/requirements.txt + python3 -m pip install -r ./src/bindings/python/src/compatibility/openvino/requirements.txt # Add for -DENABLE_PYTHON=ON, no cython - python3 -m pip install -r ./inference-engine/ie_bridges/python/src/requirements-dev.txt + python3 -m pip install -r ./src/bindings/python/src/compatibility/openvino/requirements-dev.txt # Run cmake with -DENABLE_PROFILING_ITT=ON -DSELECTIVE_BUILD=COLLECT in order to enable codestyle check for ITT collector - name: CMake @@ -60,7 +60,7 @@ jobs: sudo apt --assume-yes install shellcheck - name: Install dependencies - run: python3 -m pip install -r ./inference-engine/ie_bridges/python/requirements.txt + run: python3 -m pip install -r ./src/bindings/python/src/compatibility/openvino/requirements.txt - name: CMake run: | diff --git a/.github/workflows/py_checks.yml b/.github/workflows/py_checks.yml index 5d0c756978d..6cec72ac5e6 100644 --- a/.github/workflows/py_checks.yml +++ b/.github/workflows/py_checks.yml @@ -4,11 +4,11 @@ on: workflow_dispatch: push: paths: - - 'inference-engine/ie_bridges/python/**' + - 'src/bindings/python/**' - 'samples/python/**' pull_request: paths: - - 'inference-engine/ie_bridges/python/**' + - 'src/bindings/python/**' - 'samples/python/**' jobs: linters: @@ -23,7 +23,7 @@ jobs: with: python-version: '3.6' - name: Install dependencies - run: python -m pip install -r inference-engine/ie_bridges/python/requirements_dev.txt + run: python -m pip install -r src/bindings/python/src/compatibility/openvino/requirements_dev.txt - name: Run Flake on samples run: python -m flake8 ./ --config=setup.cfg working-directory: samples/python @@ -39,14 +39,14 @@ jobs: name: samples_diff path: samples_diff.diff - name: Run Flake on src - run: python -m flake8 ./ --config=../setup.cfg - working-directory: inference-engine/ie_bridges/python/src + run: python -m flake8 ./ --config=setup.cfg + working-directory: src/bindings/python/src/compatibility/openvino - name: Create code style diff for Python src if: failure() run: | python -m black -l 160 -S ./ git diff > src_diff.diff - working-directory: inference-engine/ie_bridges/python/src + working-directory: src/bindings/python/src/compatibility/openvino - uses: actions/upload-artifact@v2 if: failure() with: @@ -69,9 +69,9 @@ jobs: - name: Run MyPy run: python -m mypy ./ --config-file ./setup.cfg - working-directory: inference-engine/ie_bridges/python + working-directory: src/bindings/python/src/compatibility/openvino - name: Run Bandit run: python -m bandit -r ./ -f screen - working-directory: inference-engine/ie_bridges/python + working-directory: src/bindings/python/src/compatibility/openvino \ No newline at end of file diff --git a/.gitignore b/.gitignore index 01cb8775871..c208937e682 100644 --- a/.gitignore +++ b/.gitignore @@ -28,7 +28,6 @@ temp/ docs/template_plugin/html/ CMakeLists.txt.user docs/IE_PLUGIN_DG/html/ -inference-engine/ie_bridges/python/wheel/.env *.project *.cproject diff --git a/CODEOWNERS b/CODEOWNERS index da724680262..0c57bec4be0 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -29,7 +29,7 @@ Jenkinsfile @openvinotoolkit/openvino-admins # IE Core: /inference-engine/ @openvinotoolkit/openvino-ie-maintainers -/inference-engine/ie_bridges/python @openvinotoolkit/openvino-ie-python-api-maintainers +/src/bindings/python/ @openvinotoolkit/openvino-ie-python-api-maintainers /src/common/transformations/ @GlebKazantaev @ilyachur /src/common/legacy/ @openvinotoolkit/openvino-ngraph-maintainers /src/common/ @openvinotoolkit/openvino-ie-maintainers diff --git a/inference-engine/CMakeLists.txt b/inference-engine/CMakeLists.txt index f3be7a83246..182f24ef87d 100644 --- a/inference-engine/CMakeLists.txt +++ b/inference-engine/CMakeLists.txt @@ -3,7 +3,3 @@ # project(InferenceEngine) - -if(ENABLE_PYTHON) - add_subdirectory(ie_bridges/python) -endif() diff --git a/inference-engine/ie_bridges/python/src/.clang-format b/inference-engine/ie_bridges/python/src/.clang-format deleted file mode 100644 index ebe747b7838..00000000000 --- a/inference-engine/ie_bridges/python/src/.clang-format +++ /dev/null @@ -1,28 +0,0 @@ -BasedOnStyle: Google -IndentWidth: 4 -UseTab: Never -ColumnLimit: 120 - -Language: Cpp -Standard: Cpp11 - -AccessModifierOffset: -4 -AlignConsecutiveMacros: true -AllowAllArgumentsOnNextLine: false -AllowAllConstructorInitializersOnNextLine: false -AllowAllParametersOfDeclarationOnNextLine: false -AllowShortFunctionsOnASingleLine: Empty -AllowShortIfStatementsOnASingleLine: Never -AllowShortLambdasOnASingleLine: Empty -AllowShortLoopsOnASingleLine: false -AlwaysBreakBeforeMultilineStrings: false -BinPackArguments: false -BinPackParameters: false -CommentPragmas: '^#' -DerivePointerAlignment: false -FixNamespaceComments: true -IndentCaseLabels: false -IndentPPDirectives: AfterHash -ForEachMacros: - - foreach - - FOREACH_CHILD diff --git a/inference-engine/ie_bridges/python/tests/conftest.py b/inference-engine/ie_bridges/python/tests/conftest.py deleted file mode 100644 index 3afe4df0a89..00000000000 --- a/inference-engine/ie_bridges/python/tests/conftest.py +++ /dev/null @@ -1,90 +0,0 @@ -# Copyright (C) 2018-2022 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 - -import os -import pytest -import numpy as np - -import ngraph as ng - - -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 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 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) - - -@pytest.fixture(scope='session') -def device(): - return os.environ.get("TEST_DEVICE") if os.environ.get("TEST_DEVICE") else "CPU" - - -def pytest_configure(config): - # register an additional markers - config.addinivalue_line("markers", "template_plugin: Skip test on Template plugin") - config.addinivalue_line("markers", "dynamic_library: Runs tests only in dynamic libraries case") - - -def create_encoder(input_shape, levels = 4): - # input - input_node = ng.parameter(input_shape, np.float32, name="data") - - padding_begin = padding_end = [0, 0] - strides = [1, 1] - dilations = [1, 1] - input_channels = [input_shape[1]] - last_output = input_node - - # convolution layers - for i in range(levels): - input_c = input_channels[-1] - output_c = input_c * 2 - conv_w = np.random.uniform(0, 1, [output_c, input_c, 5, 5]).astype(np.float32) - conv_node = ng.convolution(last_output, conv_w, strides, padding_begin, padding_end, dilations) - input_channels.append(output_c) - last_output = conv_node - - # deconvolution layers - for i in range(levels): - input_c = input_channels[-2] - output_c = input_channels.pop(-1) - deconv_w = np.random.uniform(0, 1, [output_c, input_c, 5, 5]).astype(np.float32) - deconv_node = ng.convolution_backprop_data(last_output, deconv_w, strides) - last_output = deconv_node - - # result - last_output.set_friendly_name("out") - result_node = ng.result(last_output) - return ng.Function(result_node, [input_node], "Encoder") - - -def create_relu(input_shape): - input_shape = ng.impl.PartialShape(input_shape) - param = ng.parameter(input_shape, dtype=np.float32, name="data") - result = ng.relu(param, name="out") - function = ng.Function(result, [param], "TestFunction") - return function diff --git a/src/bindings/python/CMakeLists.txt b/src/bindings/python/CMakeLists.txt index b48adeed7cc..f634ca49c51 100644 --- a/src/bindings/python/CMakeLists.txt +++ b/src/bindings/python/CMakeLists.txt @@ -10,11 +10,15 @@ if(NOT DEFINED OpenVINO_SOURCE_DIR) find_package(InferenceEngineDeveloperPackage REQUIRED) endif() +set(LIBRARY_OUTPUT_DIRECTORY_BIN ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) +set(PYTHON_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src) + +add_subdirectory(src/compatibility/openvino) + add_subdirectory(thirdparty/pybind11 EXCLUDE_FROM_ALL) -set(LIBRARY_OUTPUT_DIRECTORY_BIN ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) - -add_subdirectory(src) +add_subdirectory(src/compatibility/pyngraph) +add_subdirectory(src/pyopenvino) if(ENABLE_WHEEL) add_subdirectory(wheel) diff --git a/src/bindings/python/src/CMakeLists.txt b/src/bindings/python/src/CMakeLists.txt index 028ce74cda1..1815a620489 100644 --- a/src/bindings/python/src/CMakeLists.txt +++ b/src/bindings/python/src/CMakeLists.txt @@ -2,7 +2,6 @@ # SPDX-License-Identifier: Apache-2.0 # -set(PYTHON_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) add_subdirectory(compatibility) add_subdirectory(pyopenvino) diff --git a/src/bindings/python/src/compatibility/CMakeLists.txt b/src/bindings/python/src/compatibility/CMakeLists.txt index 8fa81384a1c..c01569d2e15 100644 --- a/src/bindings/python/src/compatibility/CMakeLists.txt +++ b/src/bindings/python/src/compatibility/CMakeLists.txt @@ -3,3 +3,4 @@ # add_subdirectory(pyngraph) +add_subdirectory(openvino) diff --git a/src/bindings/python/src/compatibility/ngraph/helpers.py b/src/bindings/python/src/compatibility/ngraph/helpers.py index 3966a2c42d0..64156d3e4fa 100644 --- a/src/bindings/python/src/compatibility/ngraph/helpers.py +++ b/src/bindings/python/src/compatibility/ngraph/helpers.py @@ -6,7 +6,7 @@ from typing import Union from ngraph.impl import Function, PartialShape -from openvino.inference_engine import IENetwork, DataPtr, CDataPtr +from openvino.inference_engine import IENetwork, DataPtr, CDataPtr # type: ignore def function_from_cnn(cnn_network: IENetwork) -> Function: diff --git a/inference-engine/ie_bridges/python/.bandit b/src/bindings/python/src/compatibility/openvino/.bandit similarity index 100% rename from inference-engine/ie_bridges/python/.bandit rename to src/bindings/python/src/compatibility/openvino/.bandit diff --git a/inference-engine/ie_bridges/python/CMakeLists.txt b/src/bindings/python/src/compatibility/openvino/CMakeLists.txt similarity index 81% rename from inference-engine/ie_bridges/python/CMakeLists.txt rename to src/bindings/python/src/compatibility/openvino/CMakeLists.txt index 4d7a2cc3655..5e730606686 100644 --- a/inference-engine/ie_bridges/python/CMakeLists.txt +++ b/src/bindings/python/src/compatibility/openvino/CMakeLists.txt @@ -31,13 +31,7 @@ else() message(STATUS "Found Cython version ${CYTHON_VERSION}") endif() -if(PYTHONLIBS_VERSION_STRING MATCHES "^([0-9]+)\.([0-9]+).*") - set(PYTHON_VERSION_MAJOR ${CMAKE_MATCH_1}) - set(PYTHON_VERSION_MINOR ${CMAKE_MATCH_2}) - set(PYTHON_VERSION python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) -else() - message(FATAL_ERROR "Failed to extract python major.minor from ${PYTHONLIBS_VERSION_STRING}") -endif() +set(PYTHON_VERSION python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) if(ENABLE_CONDA_FOLDER) set(PYTHON_COMPONENT conda_${PYTHON_VERSION}) @@ -63,7 +57,7 @@ function(ov_python_disable_intel_warnings target) endfunction() set (PYTHON_BRIDGE_SRC_ROOT ${CMAKE_CURRENT_SOURCE_DIR}) -add_subdirectory (src/openvino/inference_engine) +add_subdirectory (inference_engine) if(TARGET _pyngraph) add_dependencies(ie_api _pyngraph) @@ -77,10 +71,6 @@ install(FILES requirements.txt DESTINATION ${PYTHON_BRIDGE_CPACK_PATH}/${PYTHON_VERSION} COMPONENT ${PYTHON_COMPONENT}) -install(PROGRAMS ${PYTHON_BRIDGE_SRC_ROOT}/src/openvino/__init__.py +install(PROGRAMS ${PYTHON_BRIDGE_SRC_ROOT}/__init__.py DESTINATION ${PYTHON_BRIDGE_CPACK_PATH}/${PYTHON_VERSION}/openvino COMPONENT ${PYTHON_COMPONENT}) - -# package Python samples - -ie_cpack(${PYTHON_COMPONENT}) diff --git a/inference-engine/ie_bridges/python/README.md b/src/bindings/python/src/compatibility/openvino/README.md similarity index 100% rename from inference-engine/ie_bridges/python/README.md rename to src/bindings/python/src/compatibility/openvino/README.md diff --git a/inference-engine/ie_bridges/python/src/openvino/__init__.py b/src/bindings/python/src/compatibility/openvino/__init__.py similarity index 100% rename from inference-engine/ie_bridges/python/src/openvino/__init__.py rename to src/bindings/python/src/compatibility/openvino/__init__.py diff --git a/inference-engine/ie_bridges/python/cmake/CythonConfig.cmake b/src/bindings/python/src/compatibility/openvino/cmake/CythonConfig.cmake similarity index 100% rename from inference-engine/ie_bridges/python/cmake/CythonConfig.cmake rename to src/bindings/python/src/compatibility/openvino/cmake/CythonConfig.cmake diff --git a/inference-engine/ie_bridges/python/cmake/UseCython.cmake b/src/bindings/python/src/compatibility/openvino/cmake/UseCython.cmake similarity index 98% rename from inference-engine/ie_bridges/python/cmake/UseCython.cmake rename to src/bindings/python/src/compatibility/openvino/cmake/UseCython.cmake index 9d60e2b48b3..f14662ad502 100644 --- a/inference-engine/ie_bridges/python/cmake/UseCython.cmake +++ b/src/bindings/python/src/compatibility/openvino/cmake/UseCython.cmake @@ -88,7 +88,9 @@ find_package( Cython REQUIRED PATHS "${CMAKE_CURRENT_SOURCE_DIR}/cmake" NO_CMAKE_FIND_ROOT_PATH NO_DEFAULT_PATH ) -find_package(PythonLibs 3 REQUIRED) + +find_package(PythonInterp 3 REQUIRED) +find_package(PythonLibs ${PYTHON_VERSION_STRING} EXACT REQUIRED) set( CYTHON_CXX_EXTENSION "cxx" ) set( CYTHON_C_EXTENSION "c" ) @@ -283,8 +285,8 @@ function( cython_add_module _name ) endif() endforeach() compile_pyx( ${_name} generated_file ${pyx_module_sources} ) + include_directories( ${PYTHON_INCLUDE_DIRS} ) python_add_module ( ${_name} ${generated_file} ${other_module_sources} ) - target_include_directories( ${_name} PRIVATE ${PYTHON_INCLUDE_DIRS}) # set_target_properties(${_name} PROPERTIES PREFIX "" SUFFIX "${PYTHON_MODULE_EXTENSION}") if( APPLE ) set_target_properties( ${_name} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup" ) diff --git a/inference-engine/ie_bridges/python/src/openvino/inference_engine/CMakeLists.txt b/src/bindings/python/src/compatibility/openvino/inference_engine/CMakeLists.txt similarity index 98% rename from inference-engine/ie_bridges/python/src/openvino/inference_engine/CMakeLists.txt rename to src/bindings/python/src/compatibility/openvino/inference_engine/CMakeLists.txt index 5e3dbe032f0..63fd23f6ebd 100644 --- a/inference-engine/ie_bridges/python/src/openvino/inference_engine/CMakeLists.txt +++ b/src/bindings/python/src/compatibility/openvino/inference_engine/CMakeLists.txt @@ -60,8 +60,6 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") target_compile_options(${TARGET_NAME} PRIVATE "-Wno-error=register") endif() -find_package(Python COMPONENTS Interpreter Development) - # perform copy add_custom_command(TARGET ${TARGET_NAME} POST_BUILD diff --git a/inference-engine/ie_bridges/python/src/openvino/inference_engine/__init__.py b/src/bindings/python/src/compatibility/openvino/inference_engine/__init__.py similarity index 100% rename from inference-engine/ie_bridges/python/src/openvino/inference_engine/__init__.py rename to src/bindings/python/src/compatibility/openvino/inference_engine/__init__.py diff --git a/inference-engine/ie_bridges/python/src/openvino/inference_engine/constants.pyx b/src/bindings/python/src/compatibility/openvino/inference_engine/constants.pyx similarity index 100% rename from inference-engine/ie_bridges/python/src/openvino/inference_engine/constants.pyx rename to src/bindings/python/src/compatibility/openvino/inference_engine/constants.pyx diff --git a/inference-engine/ie_bridges/python/src/openvino/inference_engine/ie_api.pxd b/src/bindings/python/src/compatibility/openvino/inference_engine/ie_api.pxd similarity index 100% rename from inference-engine/ie_bridges/python/src/openvino/inference_engine/ie_api.pxd rename to src/bindings/python/src/compatibility/openvino/inference_engine/ie_api.pxd diff --git a/inference-engine/ie_bridges/python/src/openvino/inference_engine/ie_api.pyx b/src/bindings/python/src/compatibility/openvino/inference_engine/ie_api.pyx similarity index 100% rename from inference-engine/ie_bridges/python/src/openvino/inference_engine/ie_api.pyx rename to src/bindings/python/src/compatibility/openvino/inference_engine/ie_api.pyx diff --git a/inference-engine/ie_bridges/python/src/openvino/inference_engine/ie_api_impl.cpp b/src/bindings/python/src/compatibility/openvino/inference_engine/ie_api_impl.cpp similarity index 100% rename from inference-engine/ie_bridges/python/src/openvino/inference_engine/ie_api_impl.cpp rename to src/bindings/python/src/compatibility/openvino/inference_engine/ie_api_impl.cpp diff --git a/inference-engine/ie_bridges/python/src/openvino/inference_engine/ie_api_impl.hpp b/src/bindings/python/src/compatibility/openvino/inference_engine/ie_api_impl.hpp similarity index 100% rename from inference-engine/ie_bridges/python/src/openvino/inference_engine/ie_api_impl.hpp rename to src/bindings/python/src/compatibility/openvino/inference_engine/ie_api_impl.hpp diff --git a/inference-engine/ie_bridges/python/src/openvino/inference_engine/ie_api_impl_defs.pxd b/src/bindings/python/src/compatibility/openvino/inference_engine/ie_api_impl_defs.pxd similarity index 100% rename from inference-engine/ie_bridges/python/src/openvino/inference_engine/ie_api_impl_defs.pxd rename to src/bindings/python/src/compatibility/openvino/inference_engine/ie_api_impl_defs.pxd diff --git a/inference-engine/ie_bridges/python/src/requirements-dev.txt b/src/bindings/python/src/compatibility/openvino/requirements-dev.txt similarity index 100% rename from inference-engine/ie_bridges/python/src/requirements-dev.txt rename to src/bindings/python/src/compatibility/openvino/requirements-dev.txt diff --git a/inference-engine/ie_bridges/python/requirements.txt b/src/bindings/python/src/compatibility/openvino/requirements.txt similarity index 100% rename from inference-engine/ie_bridges/python/requirements.txt rename to src/bindings/python/src/compatibility/openvino/requirements.txt diff --git a/inference-engine/ie_bridges/python/requirements_dev.txt b/src/bindings/python/src/compatibility/openvino/requirements_dev.txt similarity index 100% rename from inference-engine/ie_bridges/python/requirements_dev.txt rename to src/bindings/python/src/compatibility/openvino/requirements_dev.txt diff --git a/inference-engine/ie_bridges/python/setup.cfg b/src/bindings/python/src/compatibility/openvino/setup.cfg similarity index 100% rename from inference-engine/ie_bridges/python/setup.cfg rename to src/bindings/python/src/compatibility/openvino/setup.cfg diff --git a/src/bindings/python/tests_compatibility/conftest.py b/src/bindings/python/tests_compatibility/conftest.py index d565086ed3f..34f6b08e74a 100644 --- a/src/bindings/python/tests_compatibility/conftest.py +++ b/src/bindings/python/tests_compatibility/conftest.py @@ -3,7 +3,9 @@ import os import pytest +import numpy as np +import ngraph as ng import tests_compatibility from pathlib import Path @@ -78,6 +80,8 @@ def pytest_configure(config): 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") + config.addinivalue_line("markers", "template_plugin") + config.addinivalue_line("markers", "dynamic_library: Runs tests only in dynamic libraries case") def pytest_collection_modifyitems(config, items): @@ -112,3 +116,44 @@ def pytest_collection_modifyitems(config, items): @pytest.fixture(scope="session") def device(): return os.environ.get("TEST_DEVICE") if os.environ.get("TEST_DEVICE") else "CPU" + + +def create_encoder(input_shape, levels=4): + # input + input_node = ng.parameter(input_shape, np.float32, name="data") + + padding_begin = padding_end = [0, 0] + strides = [1, 1] + dilations = [1, 1] + input_channels = [input_shape[1]] + last_output = input_node + + # convolution layers + for _ in range(levels): + input_c = input_channels[-1] + output_c = input_c * 2 + conv_w = np.random.uniform(0, 1, [output_c, input_c, 5, 5]).astype(np.float32) + conv_node = ng.convolution(last_output, conv_w, strides, padding_begin, padding_end, dilations) + input_channels.append(output_c) + last_output = conv_node + + # deconvolution layers + for _ in range(levels): + input_c = input_channels[-2] + output_c = input_channels.pop(-1) + deconv_w = np.random.uniform(0, 1, [output_c, input_c, 5, 5]).astype(np.float32) + deconv_node = ng.convolution_backprop_data(last_output, deconv_w, strides) + last_output = deconv_node + + # result + last_output.set_friendly_name("out") + result_node = ng.result(last_output) + return ng.Function(result_node, [input_node], "Encoder") + + +def create_relu(input_shape): + input_shape = ng.impl.PartialShape(input_shape) + param = ng.parameter(input_shape, dtype=np.float32, name="data") + result = ng.relu(param, name="out") + function = ng.Function(result, [param], "TestFunction") + return function diff --git a/src/bindings/python/tests_compatibility/test_inference_engine/__init__.py b/src/bindings/python/tests_compatibility/test_inference_engine/__init__.py new file mode 100644 index 00000000000..46a1a3756d2 --- /dev/null +++ b/src/bindings/python/tests_compatibility/test_inference_engine/__init__.py @@ -0,0 +1,2 @@ +# Copyright (C) 2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 diff --git a/inference-engine/ie_bridges/python/tests/test_Blob.py b/src/bindings/python/tests_compatibility/test_inference_engine/test_Blob.py similarity index 98% rename from inference-engine/ie_bridges/python/tests/test_Blob.py rename to src/bindings/python/tests_compatibility/test_inference_engine/test_Blob.py index 9196028ef98..89f1b464160 100644 --- a/inference-engine/ie_bridges/python/tests/test_Blob.py +++ b/src/bindings/python/tests_compatibility/test_inference_engine/test_Blob.py @@ -7,7 +7,7 @@ import numpy as np import os from openvino.inference_engine import TensorDesc, Blob, IECore -from conftest import image_path, create_encoder +from tests_compatibility.conftest import image_path, create_encoder import ngraph as ng diff --git a/inference-engine/ie_bridges/python/tests/test_CDataPtr.py b/src/bindings/python/tests_compatibility/test_inference_engine/test_CDataPtr.py similarity index 97% rename from inference-engine/ie_bridges/python/tests/test_CDataPtr.py rename to src/bindings/python/tests_compatibility/test_inference_engine/test_CDataPtr.py index 7782fe460ca..290d6d8e251 100644 --- a/inference-engine/ie_bridges/python/tests/test_CDataPtr.py +++ b/src/bindings/python/tests_compatibility/test_inference_engine/test_CDataPtr.py @@ -4,7 +4,7 @@ import pytest from openvino.inference_engine import CDataPtr, IECore -from conftest import model_path, create_relu +from tests_compatibility.conftest import model_path, create_relu import ngraph as ng diff --git a/inference-engine/ie_bridges/python/tests/test_DataPtr.py b/src/bindings/python/tests_compatibility/test_inference_engine/test_DataPtr.py similarity index 97% rename from inference-engine/ie_bridges/python/tests/test_DataPtr.py rename to src/bindings/python/tests_compatibility/test_inference_engine/test_DataPtr.py index 898fc9e1f8c..8c997e36f76 100644 --- a/inference-engine/ie_bridges/python/tests/test_DataPtr.py +++ b/src/bindings/python/tests_compatibility/test_inference_engine/test_DataPtr.py @@ -4,7 +4,7 @@ import pytest from openvino.inference_engine import IECore, DataPtr -from conftest import model_path, create_relu +from tests_compatibility.conftest import model_path, create_relu import ngraph as ng diff --git a/inference-engine/ie_bridges/python/tests/test_ExecutableNetwork.py b/src/bindings/python/tests_compatibility/test_inference_engine/test_ExecutableNetwork.py similarity index 99% rename from inference-engine/ie_bridges/python/tests/test_ExecutableNetwork.py rename to src/bindings/python/tests_compatibility/test_inference_engine/test_ExecutableNetwork.py index aa4bad79905..3e586604186 100644 --- a/inference-engine/ie_bridges/python/tests/test_ExecutableNetwork.py +++ b/src/bindings/python/tests_compatibility/test_inference_engine/test_ExecutableNetwork.py @@ -8,7 +8,7 @@ import warnings import time from openvino.inference_engine import ie_api as ie -from conftest import model_path, image_path +from tests_compatibility.conftest import model_path, image_path is_myriad = os.environ.get("TEST_DEVICE") == "MYRIAD" diff --git a/inference-engine/ie_bridges/python/tests/test_IECore.py b/src/bindings/python/tests_compatibility/test_inference_engine/test_IECore.py similarity index 99% rename from inference-engine/ie_bridges/python/tests/test_IECore.py rename to src/bindings/python/tests_compatibility/test_inference_engine/test_IECore.py index da027a07d0b..05f18f7f5ee 100644 --- a/inference-engine/ie_bridges/python/tests/test_IECore.py +++ b/src/bindings/python/tests_compatibility/test_inference_engine/test_IECore.py @@ -11,7 +11,7 @@ from time import sleep, time from queue import Queue from openvino.inference_engine import IENetwork, IECore, ExecutableNetwork -from conftest import model_path, plugins_path, model_onnx_path +from tests_compatibility.conftest import model_path, plugins_path, model_onnx_path import ngraph as ng diff --git a/inference-engine/ie_bridges/python/tests/test_IENetwork.py b/src/bindings/python/tests_compatibility/test_inference_engine/test_IENetwork.py similarity index 99% rename from inference-engine/ie_bridges/python/tests/test_IENetwork.py rename to src/bindings/python/tests_compatibility/test_inference_engine/test_IENetwork.py index 4215958e27c..3279eaf5a24 100644 --- a/inference-engine/ie_bridges/python/tests/test_IENetwork.py +++ b/src/bindings/python/tests_compatibility/test_inference_engine/test_IENetwork.py @@ -6,7 +6,7 @@ import pytest import ngraph as ng from openvino.inference_engine import IECore, IENetwork, DataPtr, InputInfoPtr, PreProcessInfo -from conftest import model_path, create_relu +from tests_compatibility.conftest import model_path, create_relu test_net_xml, test_net_bin = model_path() diff --git a/inference-engine/ie_bridges/python/tests/test_InferRequest.py b/src/bindings/python/tests_compatibility/test_inference_engine/test_InferRequest.py similarity index 99% rename from inference-engine/ie_bridges/python/tests/test_InferRequest.py rename to src/bindings/python/tests_compatibility/test_inference_engine/test_InferRequest.py index 0bc7dc6aca3..3003e27eef8 100644 --- a/inference-engine/ie_bridges/python/tests/test_InferRequest.py +++ b/src/bindings/python/tests_compatibility/test_inference_engine/test_InferRequest.py @@ -9,7 +9,7 @@ from datetime import datetime import time from openvino.inference_engine import ie_api as ie -from conftest import model_path, image_path, create_encoder +from tests_compatibility.conftest import model_path, image_path, create_encoder import ngraph as ng from ngraph.impl import Function, Type diff --git a/inference-engine/ie_bridges/python/tests/test_InputInfoCPtr.py b/src/bindings/python/tests_compatibility/test_inference_engine/test_InputInfoCPtr.py similarity index 97% rename from inference-engine/ie_bridges/python/tests/test_InputInfoCPtr.py rename to src/bindings/python/tests_compatibility/test_inference_engine/test_InputInfoCPtr.py index e770a829b6f..eb42b507ea7 100644 --- a/inference-engine/ie_bridges/python/tests/test_InputInfoCPtr.py +++ b/src/bindings/python/tests_compatibility/test_inference_engine/test_InputInfoCPtr.py @@ -4,7 +4,7 @@ import pytest from openvino.inference_engine import InputInfoCPtr, DataPtr, IECore, TensorDesc -from conftest import model_path +from tests_compatibility.conftest import model_path test_net_xml, test_net_bin = model_path() diff --git a/inference-engine/ie_bridges/python/tests/test_InputInfoPtr.py b/src/bindings/python/tests_compatibility/test_inference_engine/test_InputInfoPtr.py similarity index 97% rename from inference-engine/ie_bridges/python/tests/test_InputInfoPtr.py rename to src/bindings/python/tests_compatibility/test_inference_engine/test_InputInfoPtr.py index 5aeed9c2097..0e9efe79842 100644 --- a/inference-engine/ie_bridges/python/tests/test_InputInfoPtr.py +++ b/src/bindings/python/tests_compatibility/test_inference_engine/test_InputInfoPtr.py @@ -4,7 +4,7 @@ import pytest from openvino.inference_engine import InputInfoPtr, PreProcessInfo, DataPtr, IECore, TensorDesc, ColorFormat -from conftest import model_path +from tests_compatibility.conftest import model_path test_net_xml, test_net_bin = model_path() diff --git a/inference-engine/ie_bridges/python/tests/test_NGraph.py b/src/bindings/python/tests_compatibility/test_inference_engine/test_NGraph.py similarity index 96% rename from inference-engine/ie_bridges/python/tests/test_NGraph.py rename to src/bindings/python/tests_compatibility/test_inference_engine/test_NGraph.py index a9bc9f3f129..b30be9266a3 100644 --- a/inference-engine/ie_bridges/python/tests/test_NGraph.py +++ b/src/bindings/python/tests_compatibility/test_inference_engine/test_NGraph.py @@ -6,7 +6,7 @@ import ngraph as ng from ngraph.impl.op import Parameter from ngraph.impl import Function, Shape, Type -from conftest import model_path, create_relu +from tests_compatibility.conftest import model_path, create_relu test_net_xml, test_net_bin = model_path() diff --git a/inference-engine/ie_bridges/python/tests/test_PreProcessInfo.py b/src/bindings/python/tests_compatibility/test_inference_engine/test_PreProcessInfo.py similarity index 99% rename from inference-engine/ie_bridges/python/tests/test_PreProcessInfo.py rename to src/bindings/python/tests_compatibility/test_inference_engine/test_PreProcessInfo.py index 8cb7ae4d520..bd339e75071 100644 --- a/inference-engine/ie_bridges/python/tests/test_PreProcessInfo.py +++ b/src/bindings/python/tests_compatibility/test_inference_engine/test_PreProcessInfo.py @@ -5,7 +5,7 @@ import pytest from openvino.inference_engine import PreProcessInfo, IECore, TensorDesc, Blob, PreProcessChannel,\ MeanVariant, ResizeAlgorithm, ColorFormat -from conftest import model_path +from tests_compatibility.conftest import model_path test_net_xml, test_net_bin = model_path() diff --git a/inference-engine/ie_bridges/python/tests/test_TensorDesc.py b/src/bindings/python/tests_compatibility/test_inference_engine/test_TensorDesc.py similarity index 100% rename from inference-engine/ie_bridges/python/tests/test_TensorDesc.py rename to src/bindings/python/tests_compatibility/test_inference_engine/test_TensorDesc.py diff --git a/src/bindings/python/tox.ini b/src/bindings/python/tox.ini index 9f16d05aca0..bd9568bf07d 100644 --- a/src/bindings/python/tox.ini +++ b/src/bindings/python/tox.ini @@ -17,11 +17,11 @@ passenv = commands= {envbindir}/python setup.py bdist_wheel {envbindir}/pip install --no-index --pre --find-links=dist/ openvino - flake8 {posargs:src/ setup.py} - flake8 --ignore=D100,D101,D102,D103,D104,D105,D107,D212,W503 tests/ tests_compatibility/ # ignore lack of docs in tests - mypy --config-file=tox.ini {posargs:src/} + flake8 {posargs:src/ setup.py} --exclude=src/compatibility/openvino + flake8 --ignore=D100,D101,D102,D103,D104,D105,D107,D212,W503 tests/ tests_compatibility/ --exclude=tests_compatibility/test_inference_engine # ignore lack of docs in tests + mypy --config-file=tox.ini {posargs:src/} --exclude=src/compatibility/openvino pytest --backend={env:NGRAPH_BACKEND} tests -v -k 'not _cuda' --ignore=tests/test_onnx/test_zoo_models.py --ignore=tests/test_utils --ignore=tests/test_inference_engine - pytest --backend={env:NGRAPH_BACKEND} tests_compatibility -v -k 'not _cuda' --ignore=tests_compatibility/test_onnx/test_zoo_models.py + pytest --backend={env:NGRAPH_BACKEND} tests_compatibility/test_ngraph -v -k 'not _cuda' --ignore=tests_compatibility/test_onnx/test_zoo_models.py [testenv:zoo_models] commands= @@ -73,6 +73,3 @@ line_length=100 default_section=FIRSTPARTY sections=FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER known_third_party=openvino - -[pytest] -addopts = --strict-markers