diff --git a/.github/actions/setup_python/action.yml b/.github/actions/setup_python/action.yml index 2ca7668dc2d25d..6ead25c2f2e310 100644 --- a/.github/actions/setup_python/action.yml +++ b/.github/actions/setup_python/action.yml @@ -26,7 +26,10 @@ runs: - if: ${{ runner.os == 'Linux' && inputs.self-hosted-runner == 'true' }} name: Install 'actions/setup-python@v4' dependencies shell: bash - run: apt-get update && apt-get install -y ca-certificates software-properties-common + run: apt-get update && apt-get install -y ca-certificates software-properties-common gpg-agent tzdata + env: + DEBIAN_FRONTEND: noninteractive # to prevent apt-get from waiting user input + TZ: "Europe/London" # to prevent tzdata from waiting user input - if: ${{ runner.os == 'Linux' && runner.arch == 'ARM64' }} name: Setup sudo and python3 @@ -35,7 +38,7 @@ runs: - if: ${{ runner.os == 'Linux' && runner.arch == 'ARM64' }} name: Setup Python ${{ inputs.version }} - uses: akashchi/deadsnakes-action@f01521a69eee61eaca3a34440bea3ce838317846 + uses: akashchi/deadsnakes-action@92417281055a5878a0450f240a5b95883eb2d7e2 with: python-version: ${{ inputs.version }} diff --git a/.github/components.yml b/.github/components.yml index 5431054cf11c6f..f929f8cdf00b07 100644 --- a/.github/components.yml +++ b/.github/components.yml @@ -129,6 +129,7 @@ TF_FE: build: - CPU - Python_API + - TOKENIZERS TFL_FE: revalidate: @@ -143,6 +144,7 @@ PyTorch_FE: build: - CPU - Python_API + - TOKENIZERS C_API: build: @@ -225,3 +227,7 @@ NVIDIA: ONNX_RT: revalidate: [] build: [] + +TOKENIZERS: + revalidate: [] + build: [] diff --git a/.github/workflows/android_arm64.yml b/.github/workflows/android_arm64.yml index aa844ef0a4d3b4..3b52ba7e72cc11 100644 --- a/.github/workflows/android_arm64.yml +++ b/.github/workflows/android_arm64.yml @@ -129,7 +129,7 @@ jobs: echo "yes" | ./cmdline-tools/bin/sdkmanager --sdk_root=${ANDROID_TOOLS} --install "ndk-bundle" "platform-tools" "platforms;android-${{ env.ANDROID_SDK_VERSION }}" - name: Install sccache - uses: mozilla-actions/sccache-action@v0.0.3 + uses: mozilla-actions/sccache-action@v0.0.4 with: version: "v0.7.5" diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index 0ce771af1a675b..53d34680b62b5b 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -77,7 +77,7 @@ jobs: apt install --assume-yes --no-install-recommends default-jdk - name: Install sccache - uses: mozilla-actions/sccache-action@v0.0.3 + uses: mozilla-actions/sccache-action@v0.0.4 with: version: "v0.7.5" diff --git a/.github/workflows/fedora.yml b/.github/workflows/fedora.yml index 4be68f6ed02d3a..0a8298e5a17497 100644 --- a/.github/workflows/fedora.yml +++ b/.github/workflows/fedora.yml @@ -91,7 +91,7 @@ jobs: run: bash ${OPENVINO_REPO}/install_build_dependencies.sh - name: Install sccache - uses: mozilla-actions/sccache-action@v0.0.3 + uses: mozilla-actions/sccache-action@v0.0.4 with: version: "v0.7.5" @@ -247,10 +247,10 @@ jobs: python3 /usr/share/openvino/samples/python/hello_query_device/hello_query_device.py python3 -c 'from openvino import Core; Core().get_property("CPU", "AVAILABLE_DEVICES")' python3 -c 'from openvino import Core; Core().get_property("GPU", "AVAILABLE_DEVICES")' - python3 -c 'from openvino import Core; Core().get_property("AUTO", "SUPPORTED_METRICS")' - python3 -c 'from openvino import Core; Core().get_property("MULTI", "SUPPORTED_METRICS")' - python3 -c 'from openvino import Core; Core().get_property("HETERO", "SUPPORTED_METRICS")' - python3 -c 'from openvino import Core; Core().get_property("BATCH", "SUPPORTED_METRICS")' + python3 -c 'from openvino import Core; Core().get_property("AUTO", "SUPPORTED_PROPERTIES")' + python3 -c 'from openvino import Core; Core().get_property("MULTI", "SUPPORTED_PROPERTIES")' + python3 -c 'from openvino import Core; Core().get_property("HETERO", "SUPPORTED_PROPERTIES")' + python3 -c 'from openvino import Core; Core().get_property("BATCH", "SUPPORTED_PROPERTIES")' python3 -c 'from openvino.frontend import FrontEndManager; assert len(FrontEndManager().get_available_front_ends()) == 6' benchmark_app --help ovc --help diff --git a/.github/workflows/job_cpu_functional_tests.yml b/.github/workflows/job_cpu_functional_tests.yml index 26a805c210d3b3..03708246ddc4bc 100644 --- a/.github/workflows/job_cpu_functional_tests.yml +++ b/.github/workflows/job_cpu_functional_tests.yml @@ -29,8 +29,10 @@ jobs: INSTALL_TEST_DIR: ${{ github.workspace }}/install/tests PARALLEL_TEST_SCRIPT: ${{ github.workspace }}/install/tests/functional_test_utils/layer_tests_summary/run_parallel.py PARALLEL_TEST_CACHE: ${{ github.workspace }}/install/tests/test_cache.lst - if: ${{ github.event_name != 'merge_group' }} steps: + - name: Set apt retries + run: echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80-retries + - name: Download OpenVINO package uses: actions/download-artifact@v3 with: diff --git a/.github/workflows/job_cxx_unit_tests.yml b/.github/workflows/job_cxx_unit_tests.yml index 519ff962b6793f..d131674bffad1e 100644 --- a/.github/workflows/job_cxx_unit_tests.yml +++ b/.github/workflows/job_cxx_unit_tests.yml @@ -31,8 +31,10 @@ jobs: DEBIAN_FRONTEND: noninteractive # to prevent apt-get from waiting user input INSTALL_DIR: ${{ github.workspace }}/install INSTALL_TEST_DIR: ${{ github.workspace }}/install/tests - if: ${{ github.event_name != 'merge_group' }} steps: + - name: Set apt retries + run: echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80-retries + - name: Download OpenVINO package uses: actions/download-artifact@v3 with: diff --git a/.github/workflows/job_debian_packages.yml b/.github/workflows/job_debian_packages.yml index f063a7734b8aec..fe3eb18d0189dd 100644 --- a/.github/workflows/job_debian_packages.yml +++ b/.github/workflows/job_debian_packages.yml @@ -26,6 +26,8 @@ jobs: DEBIAN_FRONTEND: noninteractive # to prevent apt-get from waiting user input DEBIAN_PACKAGES_DIR: ${{ github.workspace }}/packages steps: + - name: Set apt retries + run: echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80-retries - name: Download OpenVINO debian packages uses: actions/download-artifact@v3 @@ -74,10 +76,10 @@ jobs: python3 -c 'from openvino import Core; Core().get_property("GPU", "AVAILABLE_DEVICES")' fi - python3 -c 'from openvino import Core; Core().get_property("AUTO", "SUPPORTED_METRICS")' - python3 -c 'from openvino import Core; Core().get_property("MULTI", "SUPPORTED_METRICS")' - python3 -c 'from openvino import Core; Core().get_property("HETERO", "SUPPORTED_METRICS")' - python3 -c 'from openvino import Core; Core().get_property("BATCH", "SUPPORTED_METRICS")' + python3 -c 'from openvino import Core; Core().get_property("AUTO", "SUPPORTED_PROPERTIES")' + python3 -c 'from openvino import Core; Core().get_property("MULTI", "SUPPORTED_PROPERTIES")' + python3 -c 'from openvino import Core; Core().get_property("HETERO", "SUPPORTED_PROPERTIES")' + python3 -c 'from openvino import Core; Core().get_property("BATCH", "SUPPORTED_PROPERTIES")' python3 -c 'from openvino.frontend import FrontEndManager; assert len(FrontEndManager().get_available_front_ends()) == 6' benchmark_app --help ovc --help diff --git a/.github/workflows/job_onnx_models_tests.yml b/.github/workflows/job_onnx_models_tests.yml index 25fce51699cd10..48972d64be8db2 100644 --- a/.github/workflows/job_onnx_models_tests.yml +++ b/.github/workflows/job_onnx_models_tests.yml @@ -29,9 +29,12 @@ jobs: INSTALL_TEST_DIR: ${{ github.workspace }}/install/tests ONNX_MODELS_PATH: ${{ github.workspace }}/onnx_test_models MODELS_SHARE_PATH: "/mount/onnxtestdata" - ONNX_MODEL_ZOO_SHA: "d58213534f2a4d1c4b19ba62b3bb5f544353256e" + ONNX_MODEL_ZOO_SHA: "5faef4c33eba0395177850e1e31c4a6a9e634c82" if: ${{ github.event_name != 'merge_group' }} steps: + - name: Set apt retries + run: echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80-retries + - name: Download OpenVINO package uses: actions/download-artifact@v3 with: diff --git a/.github/workflows/job_onnx_runtime.yml b/.github/workflows/job_onnx_runtime.yml index 986c1a108fa4ad..7aaeaa4a78776b 100644 --- a/.github/workflows/job_onnx_runtime.yml +++ b/.github/workflows/job_onnx_runtime.yml @@ -40,6 +40,9 @@ jobs: ONNX_RUNTIME_UTILS: ${{ github.workspace }}/install/onnxruntime ONNX_RUNTIME_BUILD_DIR: ${{ github.workspace }}/onnxruntime/build steps: + - name: Set apt retries + run: echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80-retries + - name: Download OpenVINO package uses: actions/download-artifact@v3 with: @@ -100,7 +103,7 @@ jobs: run: bash ${OPENVINO_REPO}/install_build_dependencies.sh - name: Install sccache - uses: mozilla-actions/sccache-action@v0.0.3 + uses: mozilla-actions/sccache-action@v0.0.4 with: version: "v0.7.5" diff --git a/.github/workflows/job_python_unit_tests.yml b/.github/workflows/job_python_unit_tests.yml index a04e2004eaf470..a2129b7267293e 100644 --- a/.github/workflows/job_python_unit_tests.yml +++ b/.github/workflows/job_python_unit_tests.yml @@ -37,6 +37,9 @@ jobs: INSTALL_TEST_DIR: ${{ github.workspace }}/install/tests LAYER_TESTS_INSTALL_DIR: ${{ github.workspace }}/install/tests/layer_tests steps: + - name: Set apt retries + run: echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80-retries + - name: Download OpenVINO package uses: actions/download-artifact@v3 with: @@ -216,6 +219,15 @@ jobs: TEST_DEVICE: CPU TEST_PRECISION: FP32 + - name: PyTorch torch.export Layer Tests + if: ${{ fromJSON(inputs.affected-components).PyTorch_FE.test && runner.arch != 'ARM64' }} # Ticket: 126287 + run: | + python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/pytorch_tests -m precommit_torch_export --junitxml=${INSTALL_TEST_DIR}/TEST-pytorch.xml + env: + TEST_DEVICE: CPU + TEST_PRECISION: FP32 + PYTORCH_TRACING_MODE: EXPORT + - name: PyTorch torch.compile TORCHFX Layer Tests if: ${{ fromJSON(inputs.affected-components).PyTorch_FE.test && runner.os != 'macOS' }} run: | diff --git a/.github/workflows/job_pytorch_models_tests.yml b/.github/workflows/job_pytorch_models_tests.yml index 8904b2212e9e33..0e9bf740fc4159 100644 --- a/.github/workflows/job_pytorch_models_tests.yml +++ b/.github/workflows/job_pytorch_models_tests.yml @@ -33,17 +33,30 @@ jobs: INSTALL_TEST_DIR: ${{ github.workspace }}/install/tests MODEL_HUB_TESTS_INSTALL_DIR: ${{ github.workspace }}/install/tests/model_hub_tests steps: - - name: Check sudo if: ${{ runner.os == 'Linux' }} run: if [ "$(id -u)" -eq 0 ]; then apt update && apt --assume-yes install sudo; fi + - name: Set apt retries + run: | + if [ "$(id -u)" -eq 0 ]; then + echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80-retries + else + sudo sh -c "echo 'Acquire::Retries \"10\";' >> /etc/apt/apt.conf.d/80-retries" + fi + - name: Download OpenVINO package uses: actions/download-artifact@v3 with: name: openvino_package path: ${{ env.INSTALL_DIR }} + - name: Download OpenVINO tokenizers extension + uses: actions/download-artifact@v3 + with: + name: openvino_tokenizers_wheel + path: ${{ env.INSTALL_DIR }} + - name: Download OpenVINO tests package uses: actions/download-artifact@v3 with: @@ -91,7 +104,9 @@ jobs: self-hosted-runner: ${{ contains(inputs.runner, 'aks') }} - name: Install OpenVINO Python wheels - run: python3 -m pip install ${INSTALL_DIR}/tools/openvino-* + run: | + python3 -m pip install ${INSTALL_DIR}/tools/openvino-* + python3 -m pip install ${INSTALL_DIR}/openvino_tokenizers-* - name: Install PyTorch tests requirements run: | diff --git a/.github/workflows/job_samples_tests.yml b/.github/workflows/job_samples_tests.yml index 8c1401a819d845..cb939af4cfe7f3 100644 --- a/.github/workflows/job_samples_tests.yml +++ b/.github/workflows/job_samples_tests.yml @@ -31,6 +31,9 @@ jobs: INSTALL_TEST_DIR: ${{ github.workspace }}/install/tests BUILD_DIR: ${{ github.workspace }}/build steps: + - name: Set apt retries + run: echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80-retries + - name: Download OpenVINO package uses: actions/download-artifact@v3 with: diff --git a/.github/workflows/job_tensorflow_hub_models_tests.yml b/.github/workflows/job_tensorflow_hub_models_tests.yml index 6dcecaa267e8c4..c0cad932fbb631 100644 --- a/.github/workflows/job_tensorflow_hub_models_tests.yml +++ b/.github/workflows/job_tensorflow_hub_models_tests.yml @@ -33,17 +33,30 @@ jobs: INSTALL_TEST_DIR: ${{ github.workspace }}/install/tests MODEL_HUB_TESTS_INSTALL_DIR: ${{ github.workspace }}/install/tests/model_hub_tests steps: - - name: Check sudo if: ${{ runner.os == 'Linux' }} run: if [ "$(id -u)" -eq 0 ]; then apt update && apt --assume-yes install sudo; fi + - name: Set apt retries + run: | + if [ "$(id -u)" -eq 0 ]; then + echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80-retries + else + sudo sh -c "echo 'Acquire::Retries \"10\";' >> /etc/apt/apt.conf.d/80-retries" + fi + - name: Download OpenVINO package uses: actions/download-artifact@v3 with: name: openvino_package path: ${{ env.INSTALL_DIR }} + - name: Download OpenVINO tokenizers extension + uses: actions/download-artifact@v3 + with: + name: openvino_tokenizers_wheel + path: ${{ env.INSTALL_DIR }} + - name: Download OpenVINO tests package uses: actions/download-artifact@v3 with: @@ -90,7 +103,9 @@ jobs: self-hosted-runner: ${{ contains(inputs.runner, 'aks') }} - name: Install OpenVINO Python wheels - run: python3 -m pip install ${INSTALL_DIR}/tools/openvino-* + run: | + python3 -m pip install ${INSTALL_DIR}/tools/openvino-* + python3 -m pip install ${INSTALL_DIR}/openvino_tokenizers-* - name: Install TF Hub tests requirements run: python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/tf_hub_tests/requirements.txt diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 6b4c3be5d43288..ba58d094e553ae 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -80,6 +80,9 @@ jobs: if: "!needs.smart_ci.outputs.skip_workflow" steps: + - name: Set apt retries + run: echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80-retries + - name: Install git run: | apt-get update @@ -117,7 +120,7 @@ jobs: apt install --assume-yes --no-install-recommends default-jdk - name: Install sccache - uses: mozilla-actions/sccache-action@v0.0.3 + uses: mozilla-actions/sccache-action@v0.0.4 with: version: "v0.7.5" @@ -476,7 +479,7 @@ jobs: name: TensorFlow Hub Models tests if: fromJSON(needs.smart_ci.outputs.affected_components).TF_FE.test || fromJSON(needs.smart_ci.outputs.affected_components).TFL_FE.test - needs: [ Build, Smart_CI ] + needs: [ Build, Smart_CI, Openvino_tokenizers ] uses: ./.github/workflows/job_tensorflow_hub_models_tests.yml with: runner: ${{ github.event_name == 'schedule' && 'ubuntu-20.04-16-cores' || 'ubuntu-20.04-8-cores' }} @@ -490,7 +493,7 @@ jobs: PyTorch_Models_Tests: name: PyTorch Models tests if: fromJSON(needs.smart_ci.outputs.affected_components).PyTorch_FE.test - needs: [ Build, Smart_CI ] + needs: [ Build, Smart_CI, Openvino_tokenizers ] uses: ./.github/workflows/job_pytorch_models_tests.yml with: runner: ${{ github.event_name == 'schedule' && 'ubuntu-20.04-16-cores' || 'ubuntu-20.04-8-cores' }} @@ -529,6 +532,9 @@ jobs: if: fromJSON(needs.smart_ci.outputs.affected_components).NVIDIA steps: + - name: Set apt retries + run: echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80-retries + - name: Fetch install_build_dependencies.sh uses: actions/checkout@v4 with: @@ -579,7 +585,7 @@ jobs: apt -y --no-install-recommends install software-properties-common curl - name: Install sccache - uses: mozilla-actions/sccache-action@v0.0.3 + uses: mozilla-actions/sccache-action@v0.0.4 with: version: "v0.7.5" @@ -618,6 +624,98 @@ jobs: - name: Show ccache stats run: ${SCCACHE_PATH} --show-stats + Openvino_tokenizers: + name: OpenVINO tokenizers extension + needs: [ Build, Smart_CI ] + timeout-minutes: 25 + defaults: + run: + shell: bash + runs-on: aks-linux-4-cores-16gb + container: + image: openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04 + volumes: + - /mount:/mount + env: + INSTALL_DIR: /__w/openvino/openvino/install + OPENVINO_CONTRIB_REPO: /__w/openvino/openvino/openvino_contrib + OPENVINO_TOKENIZERS_REPO: /__w/openvino/openvino/openvino_contrib/modules/custom_operations + EXTENSION_BUILD_DIR: /__w/openvino/openvino/openvino_tokenizers + if: fromJSON(needs.smart_ci.outputs.affected_components).TOKENIZERS + + steps: + - name: checkout action + uses: actions/checkout@v4 + with: + sparse-checkout: | + .github/actions/setup_python + install_build_dependencies.sh + + - name: Setup Python ${{ env.PYTHON_VERSION }} + uses: ./.github/actions/setup_python + with: + version: ${{ env.PYTHON_VERSION }} + pip-cache-path: ${{ env.PIP_CACHE_PATH }} + should-setup-pip-paths: 'true' + self-hosted-runner: 'true' + show-cache-info: 'false' + + - name: Clone OpenVINO Contrib + uses: actions/checkout@v4 + with: + repository: 'openvinotoolkit/openvino_contrib' + path: ${{ env.OPENVINO_CONTRIB_REPO }} + ref: 'master' + + - name: Download OpenVINO package + uses: actions/download-artifact@v3 + with: + name: openvino_package + path: ${{ env.INSTALL_DIR }} + + - name: Extract OpenVINO packages + run: | + pushd ${INSTALL_DIR} + tar -xzf openvino_package.tar.gz -C ${INSTALL_DIR} + popd + + # + # Dependencies + # + + - name: Install build dependencies + run: ./install_build_dependencies.sh + + - name: Install python dependencies + run: | + # wheel packaging + python3 -m pip install -r ${OPENVINO_TOKENIZERS_REPO}/requirements-build.txt + + # + # Build + # + + - name: Build tokenizers wheel + run: | + source ${INSTALL_DIR}/setupvars.sh + python -m build --wheel --outdir ${EXTENSION_BUILD_DIR} ${OPENVINO_TOKENIZERS_REPO} + env: + CMAKE_ARGS: '-DBUILD_FAST_TOKENIZERS=OFF' + CMAKE_BUILD_PARALLEL_LEVEL: '4' + CMAKE_GENERATOR: 'Unix Makefiles' + + # + # Upload build artifacts + # + + - name: Upload openvino tokenizers wheel + if: ${{ always() }} + uses: actions/upload-artifact@v3 + with: + name: openvino_tokenizers_wheel + path: ${{ env.EXTENSION_BUILD_DIR }}/*.whl + if-no-files-found: 'error' + GPU_Stub: needs: [ Build, Smart_CI ] runs-on: ubuntu-latest @@ -632,7 +730,7 @@ jobs: Overall_Status: name: ci/gha_overall_status needs: [Smart_CI, Build, Debian_Packages, Samples, Conformance, ONNX_Runtime, CXX_Unit_Tests, Python_Unit_Tests, - CPU_Functional_Tests, TensorFlow_Hub_Models_Tests, PyTorch_Models_Tests, NVIDIA_Plugin] + CPU_Functional_Tests, TensorFlow_Hub_Models_Tests, PyTorch_Models_Tests, NVIDIA_Plugin, Openvino_tokenizers] if: ${{ always() }} runs-on: ubuntu-latest steps: diff --git a/.github/workflows/linux_arm64.yml b/.github/workflows/linux_arm64.yml index d4e55ef5724394..362c36a50504e3 100644 --- a/.github/workflows/linux_arm64.yml +++ b/.github/workflows/linux_arm64.yml @@ -82,6 +82,9 @@ jobs: if: "!needs.smart_ci.outputs.skip_workflow" steps: + - name: Set apt retries + run: echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80-retries + - name: Install git run: apt-get update && apt-get install --assume-yes --no-install-recommends git ca-certificates @@ -117,7 +120,7 @@ jobs: apt install --assume-yes --no-install-recommends default-jdk - name: Install sccache - uses: mozilla-actions/sccache-action@v0.0.3 + uses: mozilla-actions/sccache-action@v0.0.4 with: version: "v0.7.5" diff --git a/.github/workflows/linux_conditional_compilation.yml b/.github/workflows/linux_conditional_compilation.yml index df6ed63521f0d6..4f2d7d8ec91bed 100644 --- a/.github/workflows/linux_conditional_compilation.yml +++ b/.github/workflows/linux_conditional_compilation.yml @@ -75,6 +75,9 @@ jobs: if: ${{ !needs.smart_ci.outputs.skip_workflow && github.event_name != 'merge_group' }} steps: + - name: Set apt retries + run: echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80-retries + - name: Install git run: | apt-get update @@ -115,7 +118,7 @@ jobs: update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100 - name: Install sccache - uses: mozilla-actions/sccache-action@v0.0.3 + uses: mozilla-actions/sccache-action@v0.0.4 with: version: "v0.7.5" @@ -249,7 +252,7 @@ jobs: CC_Build: name: Conditional Compilation needs: Build - timeout-minutes: 10 + timeout-minutes: 20 defaults: run: shell: bash @@ -273,6 +276,9 @@ jobs: SCCACHE_AZURE_KEY_PREFIX: ubuntu22_x86_64_cc_Release steps: + - name: Set apt retries + run: echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80-retries + - name: Install git run: apt-get update && apt-get install --assume-yes --no-install-recommends git ca-certificates git-lfs @@ -307,7 +313,7 @@ jobs: run: bash ${OPENVINO_REPO}/install_build_dependencies.sh - name: Install sccache - uses: mozilla-actions/sccache-action@v0.0.3 + uses: mozilla-actions/sccache-action@v0.0.4 with: version: "v0.7.5" # diff --git a/.github/workflows/linux_riscv.yml b/.github/workflows/linux_riscv.yml index 5ec550150675ba..2f1ca29890fc47 100644 --- a/.github/workflows/linux_riscv.yml +++ b/.github/workflows/linux_riscv.yml @@ -60,12 +60,15 @@ jobs: OPENVINO_REPO: /__w/openvino/openvino/openvino OPENVINO_BUILD_DIR: /__w/openvino/openvino/openvino_build INSTALL_DIR: /__w/openvino/openvino/openvino_install - CONAN_USER_HOME: /mount/caches/ccache/ubuntu22_riscv64_master_release/.conan - CCACHE_DIR: /mount/caches/ccache/ubuntu22_riscv64_master_release + CONAN_USER_HOME: /mount/caches/ccache/ubuntu22_riscv64_master/.conan + CCACHE_DIR: /mount/caches/ccache/ubuntu22_riscv64_master CCACHE_TEMPDIR: /__w/openvino/openvino/ccache_temp CCACHE_MAXSIZE: 50G if: ${{ !needs.smart_ci.outputs.skip_workflow && github.event_name != 'merge_group' }} steps: + - name: Set apt retries + run: echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80-retries + - name: Install git run: apt-get update && apt-get install --assume-yes --no-install-recommends git ca-certificates @@ -217,7 +220,7 @@ jobs: - name: Check status of all jobs if: >- ${{ - contains(needs.*.result, 'failure') || + contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} run: exit 1 diff --git a/.github/workflows/mo.yml b/.github/workflows/mo.yml index 5720855255636a..b59df07a21bafd 100644 --- a/.github/workflows/mo.yml +++ b/.github/workflows/mo.yml @@ -53,8 +53,4 @@ jobs: - name: Pylint-MO run: pylint -d C,R,W openvino/tools/mo - working-directory: tools/mo - - - name: Pylint-OVC - run: pylint -d C,R,W openvino/tools/ovc - working-directory: tools/ovc \ No newline at end of file + working-directory: tools/mo \ No newline at end of file diff --git a/.github/workflows/ovc.yml b/.github/workflows/ovc.yml new file mode 100644 index 00000000000000..74d891f8262e3a --- /dev/null +++ b/.github/workflows/ovc.yml @@ -0,0 +1,54 @@ +name: OVC +on: + merge_group: + push: + paths: + - 'tools/ovc/**' + - '.github/workflows/ovc.yml' + branches: + - 'master' + - 'releases/**' + pull_request: + paths: + - 'tools/ovc/**' + - '.github/workflows/ovc.yml' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + Pylint-UT: + runs-on: ubuntu-22.04 + steps: + - name: Clone OpenVINO + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + + - name: Cache pip + uses: actions/cache@v4 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('src/bindings/python/requirements*.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + ${{ runner.os }}- + + - name: Install dependencies + run: | + python -m pip install --upgrade pip setuptools + # For UT + pip install unittest-xml-reporting==3.0.2 + pip install pylint>=2.7.0 + pip install pyenchant>=3.0.0 + + pip install -r requirements.txt + working-directory: src/bindings/python/ + + - name: Pylint-OVC + run: pylint -d C,R,W openvino/tools/ovc + working-directory: tools/ovc \ No newline at end of file diff --git a/.github/workflows/send_workflows_to_opentelemetry.yml b/.github/workflows/send_workflows_to_opentelemetry.yml new file mode 100644 index 00000000000000..42cddd7b88d9dd --- /dev/null +++ b/.github/workflows/send_workflows_to_opentelemetry.yml @@ -0,0 +1,42 @@ +name: Send workflows to OpenTelemetry (BETA) + +on: + workflow_run: + workflows: + - Android ARM64 with vcpkg + - Documentation + - Cleanup PIP caches + - Code snippets + - Code Style + - Code coverage + - Coverity (Ubuntu 20.04, Python 3.11) + - Fedora (RHEL), Python 3.9 + - Linux (Ubuntu 20.04, Python 3.11) + - Linux ARM64 (Ubuntu 20.04, Python 3.11) + - Linux Static CC (Ubuntu 22.04, Python 3.11, Clang) + - Linux RISC-V with Conan (Ubuntu 22.04, Python 3.10) + - macOS (Python 3.11) + - macOS ARM64 (Python 3.11) + - MO + - Python API Checks + - Webassembly + - Windows (VS 2019, Python 3.11) + - Windows Conditional Compilation (VS 2022, Python 3.11) + types: + - completed + +permissions: read-all + +jobs: + otel-export-trace: + name: OpenTelemetry Export Trace + runs-on: ubuntu-latest + + steps: + - name: Export Workflow Trace + uses: inception-health/otel-export-trace-action@7eabc7de1f4753f0b45051b44bb0ba46d05a21ef + with: + otlpEndpoint: grpc://api.honeycomb.io:443/ + otlpHeaders: ${{ secrets.OTLP_HEADERS }} + githubToken: ${{ secrets.GITHUB_TOKEN }} + runId: ${{ github.event.workflow_run.id }} diff --git a/.github/workflows/webassembly.yml b/.github/workflows/webassembly.yml index 2a91705a212c30..f7ba021b2472d8 100644 --- a/.github/workflows/webassembly.yml +++ b/.github/workflows/webassembly.yml @@ -70,7 +70,7 @@ jobs: submodules: 'true' - name: Install sccache - uses: mozilla-actions/sccache-action@v0.0.3 + uses: mozilla-actions/sccache-action@v0.0.4 with: version: "v0.7.5" diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 4f76bbce04faba..871bb09c02c68c 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -123,12 +123,16 @@ jobs: python3 -m pip install certifi - name: Install sccache - uses: mozilla-actions/sccache-action@v0.0.3 + uses: mozilla-actions/sccache-action@v0.0.4 with: version: "v0.7.5" - name: Install build dependencies - run: choco install --no-progress ninja + run: | + Invoke-WebRequest https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-win.zip -OutFile ninja-win.zip -MaximumRetryCount 10 + Expand-Archive -Force ninja-win.zip + # Add it to the GitHub Path so it would be available in the subsequent steps + Add-Content -Path $env:GITHUB_PATH -Value "${{ github.workspace }}/ninja-win" # # Build @@ -159,6 +163,19 @@ jobs: - name: Clean sccache stats run: '& "$Env:SCCACHE_PATH" --zero-stats' + # to get more information on the issue + # described in the next step + - name: Show which network ports are used + run: netstat -ban + + # the case is the following: + # sccache: error: An attempt was made to access a socket in a way forbidden by its access permissions. (os error 10013) + # This looks like the attempt to use + # a port below 1024 or a port + # which is occupied by another app + - name: Stop sccache server just in case + run: '& "$Env:SCCACHE_PATH" --stop-server' + - name: Cmake build - OpenVINO run: cmake --build ${{ env.BUILD_DIR }} --parallel --config ${{ env.CMAKE_BUILD_TYPE }} --verbose @@ -201,8 +218,7 @@ jobs: cmake --build ${{ env.BUILD_DIR }} --parallel --config ${{ env.CMAKE_BUILD_TYPE }} --verbose - name: CMake configure, build and install - OpenVINO JS API - if: ${{ 'false' }} # 128689 - # if: fromJSON(needs.smart_ci.outputs.affected_components).JS_API + if: fromJSON(needs.smart_ci.outputs.affected_components).JS_API run: cmake -DCPACK_GENERATOR=NPM -DENABLE_SYSTEM_TBB=OFF -UTBB* -S ${{ env.OPENVINO_REPO }} -B ${{ env.BUILD_DIR }} @@ -236,8 +252,7 @@ jobs: if-no-files-found: 'error' - name: Upload openvino js package - if: ${{ 'false' }} # 128689 - # if: fromJSON(needs.smart_ci.outputs.affected_components).JS_API + if: fromJSON(needs.smart_ci.outputs.affected_components).JS_API uses: actions/upload-artifact@v3 with: name: openvino_js_package @@ -348,8 +363,7 @@ jobs: env: OPENVINO_JS_DIR: "${{ github.workspace }}\\openvino\\src\\bindings\\js" OPENVINO_JS_LIBS_DIR: "${{ github.workspace }}\\openvino\\src\\bindings\\js\\node\\bin" - if: ${{ 'false' }} # 128689 - # if: fromJSON(needs.smart_ci.outputs.affected_components).JS_API + if: fromJSON(needs.smart_ci.outputs.affected_components).JS_API steps: - name: Fetch OpenVINO JS sources @@ -383,6 +397,89 @@ jobs: working-directory: ${{ env.OPENVINO_JS_DIR }}/node run: call npm test + Openvino_tokenizers: + name: OpenVINO tokenizers extension + needs: [ Build, Smart_CI ] + timeout-minutes: 25 + defaults: + run: + shell: pwsh + runs-on: aks-win-4-cores-8gb + env: + INSTALL_DIR: "${{ github.workspace }}\\install" + OPENVINO_CONTRIB_REPO: "${{ github.workspace }}\\openvino_contrib" + OPENVINO_TOKENIZERS_REPO: "${{ github.workspace }}\\openvino_contrib\\modules\\custom_operations" + EXTENSION_BUILD_DIR: "${{ github.workspace }}\\build\\openvino_tokenizers" + if: fromJSON(needs.smart_ci.outputs.affected_components).TOKENIZERS + + steps: + - name: checkout action + uses: actions/checkout@v4 + with: + sparse-checkout: | + .github/actions/setup_python + + - name: Setup Python ${{ env.PYTHON_VERSION }} + uses: ./.github/actions/setup_python + with: + version: ${{ env.PYTHON_VERSION }} + pip-cache-path: ${{ env.PIP_CACHE_PATH }} + should-setup-pip-paths: 'true' + self-hosted-runner: 'true' + show-cache-info: 'false' + + - name: Clone OpenVINO Contrib + uses: actions/checkout@v4 + with: + repository: 'openvinotoolkit/openvino_contrib' + path: ${{ env.OPENVINO_CONTRIB_REPO }} + ref: 'master' + + - name: Download OpenVINO package + uses: actions/download-artifact@v3 + with: + name: openvino_package + path: ${{ env.INSTALL_DIR }} + + - name: Extract OpenVINO packages + run: | + pushd ${{ env.INSTALL_DIR }} + Expand-Archive openvino_package.zip -DestinationPath "${{ env.INSTALL_DIR }}" + popd + + # + # Dependencies + # + + - name: Install python dependencies + run: | + # wheel packaging + python3 -m pip install -r ${env:OPENVINO_TOKENIZERS_REPO}/requirements-build.txt + + # + # Build + # + + - name: Build tokenizers wheel + run: | + . "${{ env.INSTALL_DIR }}/setupvars.ps1" + python3 -m build --wheel --outdir ${env:EXTENSION_BUILD_DIR} ${env:OPENVINO_TOKENIZERS_REPO} + env: + CMAKE_ARGS: '-DBUILD_FAST_TOKENIZERS=OFF' + CMAKE_BUILD_PARALLEL_LEVEL: '4' + + # + # Upload build artifacts + # + + - name: Upload openvino tokenizers wheel + if: ${{ always() }} + uses: actions/upload-artifact@v3 + with: + name: openvino_tokenizers_wheel + path: ${{ env.EXTENSION_BUILD_DIR }}/*.whl + if-no-files-found: 'error' + Python_Unit_Tests: name: Python unit tests needs: [ Build, Smart_CI ] @@ -894,7 +991,7 @@ jobs: Overall_Status: name: ci/gha_overall_status_windows - needs: [ Smart_CI, Build, Samples, CXX_Unit_Tests, Python_Unit_Tests, CPU_Functional_Tests ] + needs: [ Smart_CI, Build, Samples, CXX_Unit_Tests, Python_Unit_Tests, CPU_Functional_Tests, Openvino_tokenizers ] if: ${{ always() }} runs-on: ubuntu-latest steps: diff --git a/.github/workflows/windows_conditional_compilation.yml b/.github/workflows/windows_conditional_compilation.yml index 988bc177636c59..6a47f620e73b30 100644 --- a/.github/workflows/windows_conditional_compilation.yml +++ b/.github/workflows/windows_conditional_compilation.yml @@ -104,12 +104,16 @@ jobs: self-hosted-runner: 'false' - name: Install sccache - uses: mozilla-actions/sccache-action@v0.0.3 + uses: mozilla-actions/sccache-action@v0.0.4 with: - version: "v0.5.4" + version: "v0.7.5" - name: Install build dependencies - run: choco install --no-progress ninja + run: | + Invoke-WebRequest https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-win.zip -OutFile ninja-win.zip -MaximumRetryCount 10 + Expand-Archive -Force ninja-win.zip + # Add it to the GitHub Path so it would be available in the subsequent steps + Add-Content -Path $env:GITHUB_PATH -Value "${{ github.workspace }}/ninja-win" - name: Install python dependencies run: | @@ -312,7 +316,7 @@ jobs: self-hosted-runner: 'false' - name: Install sccache - uses: mozilla-actions/sccache-action@v0.0.3 + uses: mozilla-actions/sccache-action@v0.0.4 with: version: "v0.5.4" diff --git a/cmake/developer_package/compile_flags/os_flags.cmake b/cmake/developer_package/compile_flags/os_flags.cmake index 2e2e52b015c58d..5a1625349ac206 100644 --- a/cmake/developer_package/compile_flags/os_flags.cmake +++ b/cmake/developer_package/compile_flags/os_flags.cmake @@ -142,7 +142,7 @@ macro(ov_avx512_optimization_flags flags) set(${flags} -xCOMMON-AVX512) endif() elseif(OV_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCXX) - set(${flags} -mavx512f -mfma -mf16c) + set(${flags} -mavx512f -mavx512bw -mavx512vl -mfma -mf16c) else() message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}") endif() diff --git a/cmake/developer_package/version.cmake b/cmake/developer_package/version.cmake index cfefa2303d8fba..f6114ab58c304d 100644 --- a/cmake/developer_package/version.cmake +++ b/cmake/developer_package/version.cmake @@ -108,7 +108,7 @@ macro(ov_parse_ci_build_number repo_root) endforeach() endfunction() - # detect OpenVINO version via openvino/core/version.hpp and ie_version.hpp + # detect OpenVINO version via openvino/core/version.hpp ov_compare_version_with_headers() # detect commit number diff --git a/cmake/features.cmake b/cmake/features.cmake index aadd1db976e3d0..9e4e507600e1af 100644 --- a/cmake/features.cmake +++ b/cmake/features.cmake @@ -177,8 +177,7 @@ ov_dependent_option (ENABLE_SYSTEM_SNAPPY "Enables use of system version of Snap ov_dependent_option (ENABLE_PYTHON_PACKAGING "Enables packaging of Python API in APT / YUM" OFF "ENABLE_PYTHON;UNIX" OFF) -ov_dependent_option (ENABLE_JS "Enables JS API building" ON - "NOT WIN32" OFF) +ov_option(ENABLE_JS "Enables JS API building" ON) ov_option(ENABLE_OPENVINO_DEBUG "Enable output for OPENVINO_DEBUG statements" OFF) diff --git a/docs/articles_en/documentation/openvino_extensibility.rst b/docs/articles_en/documentation/openvino_extensibility.rst index 783c94b6f220cd..64f62c923986da 100644 --- a/docs/articles_en/documentation/openvino_extensibility.rst +++ b/docs/articles_en/documentation/openvino_extensibility.rst @@ -5,8 +5,8 @@ OpenVINO Extensibility Mechanism .. meta:: - :description: Explore OpenVINO™ Extensibility API, which allows adding - support for models with custom operations and their further implementation + :description: Explore OpenVINO™ Extensibility API, which allows adding + support for models with custom operations and their further implementation in applications. .. toctree:: @@ -16,18 +16,18 @@ OpenVINO Extensibility Mechanism openvino_docs_Extensibility_UG_add_openvino_ops openvino_docs_Extensibility_UG_Frontend_Extensions openvino_docs_Extensibility_UG_GPU - + .. toctree:: :maxdepth: 1 :hidden: - + openvino_docs_transformations OpenVINO Plugin Developer Guide The Intel® Distribution of OpenVINO™ toolkit supports neural-network models trained with various frameworks, including -TensorFlow, PyTorch, ONNX, TensorFlow Lite, and PaddlePaddle (OpenVINO support for Apache MXNet, Caffe, and Kaldi is currently -being deprecated and will be removed entirely in the future). The list of supported operations is different for each of the supported frameworks. +TensorFlow, PyTorch, ONNX, TensorFlow Lite, and PaddlePaddle (OpenVINO support for Apache MXNet, Caffe, and Kaldi is currently +being deprecated and will be removed entirely in the future). The list of supported operations is different for each of the supported frameworks. To see the operations supported by your framework, refer to :doc:`Supported Framework Operations `. Custom operations, which are not included in the list, are not recognized by OpenVINO out-of-the-box. The need for custom operation may appear in two cases: @@ -80,32 +80,32 @@ Registering Extensions A custom operation class and a new mapping frontend extension class object should be registered to be usable in OpenVINO runtime. -.. note:: +.. note:: This documentation is derived from the `Template extension `__, which demonstrates the details of extension development. It is based on minimalistic ``Identity`` operation that is a placeholder for your real custom operation. Review the complete, fully compilable code to see how it works. -Use the ``:ref:`ov::Core::add_extension ``` method to load the extensions to the ``:ref:`ov::Core ``` object. This method allows loading library with extensions or extensions from the code. +Use the ``ov::Core::add_extension`` method to load the extensions to the ``ov::Core`` object. This method allows loading library with extensions or extensions from the code. Load Extensions to Core +++++++++++++++++++++++ -Extensions can be loaded from a code with the ``:ref:`ov::Core::add_extension ``` method: +Extensions can be loaded from a code with the ``ov::Core::add_extension`` method: .. tab-set:: .. tab-item:: Python :sync: py - + .. doxygensnippet:: docs/snippets/ov_extensions.py :language: python :fragment: [add_extension] .. tab-item:: C++ :sync: cpp - + .. doxygensnippet:: docs/snippets/ov_extensions.cpp :language: cpp :fragment: [add_extension] - + The ``Identity`` is a custom operation class defined in :doc:`Custom Operation Guide `. This is sufficient to enable reading OpenVINO IR which uses the ``Identity`` extension operation emitted by Model Optimizer. In order to load original model directly to the runtime, add a mapping extension: @@ -130,7 +130,7 @@ When Python API is used, there is no way to implement a custom OpenVINO operatio Python can still be used to map and decompose operations when only operations from the standard OpenVINO operation set are used. .. _create_a_library_with_extensions: - + Create a Library with Extensions ++++++++++++++++++++++++++++++++ @@ -142,7 +142,7 @@ An extension library should be created in the following cases: To create an extension library, for example, to load the extensions into Model Optimizer, perform the following: -1. Create an entry point for extension library. OpenVINO provides the ``:ref:`OPENVINO_CREATE_EXTENSIONS() ``` macro, which allows to define an entry point to a library with OpenVINO Extensions. +1. Create an entry point for extension library. OpenVINO provides the ``OPENVINO_CREATE_EXTENSIONS()`` macro, which allows to define an entry point to a library with OpenVINO Extensions. This macro should have a vector of all OpenVINO Extensions as an argument. Based on that, the declaration of an extension class might look like the following: @@ -162,7 +162,7 @@ This CMake script finds OpenVINO, using the ``find_package`` CMake command. 3. Build the extension library, running the commands below: .. code-block:: sh - + $ cd src/core/template_extension/new $ mkdir build $ cd build @@ -173,16 +173,16 @@ This CMake script finds OpenVINO, using the ``find_package`` CMake command. 4. After the build, you may use the path to your extension library to load your extensions to OpenVINO Runtime: .. tab-set:: - + .. tab-item:: Python :sync: py - + .. doxygensnippet:: docs/snippets/ov_extensions.py :language: python :fragment: [add_extension_lib] .. tab-item:: C++ - :sync: cpp + :sync: cpp .. doxygensnippet:: docs/snippets/ov_extensions.cpp :language: cpp diff --git a/docs/articles_en/documentation/openvino_extensibility/GPU_Extensibility.rst b/docs/articles_en/documentation/openvino_extensibility/GPU_Extensibility.rst index 082823330684f1..e9ff4af6a319cf 100644 --- a/docs/articles_en/documentation/openvino_extensibility/GPU_Extensibility.rst +++ b/docs/articles_en/documentation/openvino_extensibility/GPU_Extensibility.rst @@ -5,7 +5,7 @@ How to Implement Custom GPU Operations .. meta:: - :description: Learn the details of custom kernel support for the GPU device to + :description: Learn the details of custom kernel support for the GPU device to enable operations not supported by OpenVINO. @@ -16,20 +16,20 @@ The GPU codepath abstracts many details about OpenCL. You need to provide the ke There are two options for using the custom operation configuration file: * Include a section with your kernels into the automatically-loaded ``/cldnn_global_custom_kernels/cldnn_global_custom_kernels.xml`` file. -* Call the ``:ref:`ov::Core::set_property() ``` method from your application with the ``"CONFIG_FILE"`` key and the configuration file name as a value before loading the network that uses custom operations to the plugin: +* Call the ``ov::Core::set_property()`` method from your application with the ``"CONFIG_FILE"`` key and the configuration file name as a value before loading the network that uses custom operations to the plugin: .. tab-set:: .. tab-item:: Python :sync: py - + .. doxygensnippet:: docs/snippets/gpu/custom_kernels_api.py :language: python :fragment: [part0] .. tab-item:: C++ :sync: cpp - + .. doxygensnippet:: docs/snippets/gpu/custom_kernels_api.cpp :language: cpp :fragment: [part0] @@ -43,10 +43,10 @@ feature a dedicated command-line option ``-c`` to load custom kernels. For examp $ ./classification_sample -m /bvlc_alexnet_fp16.xml -i ./validation_set/daily/227x227/apron.bmp -d GPU -c /custom_layer_example.xml -.. _config-file-format: +.. _config-file-format: Configuration File Format -######################### +######################### The configuration file is expected to follow the ``.xml`` file structure with a node of the type ``CustomLayer`` for every custom operation you provide. @@ -344,7 +344,7 @@ Example Kernel .. _debugging-tips: -.. note:: +.. note:: As described in the previous section, all items such as the ``INPUT0_TYPE`` are actually defined as OpenCL (pre-)compiler inputs by OpenVINO for efficiency reasons. See the `Debugging Tips <#debugging-tips>`__ below for information on debugging the results. Debugging Tips diff --git a/docs/articles_en/documentation/openvino_extensibility/add_openvino_ops.rst b/docs/articles_en/documentation/openvino_extensibility/add_openvino_ops.rst index 9df891732643ff..dafa52da350731 100644 --- a/docs/articles_en/documentation/openvino_extensibility/add_openvino_ops.rst +++ b/docs/articles_en/documentation/openvino_extensibility/add_openvino_ops.rst @@ -5,8 +5,8 @@ Custom OpenVINO™ Operations .. meta:: - :description: Explore OpenVINO™ Extension API which enables registering - custom operations to support models with operations + :description: Explore OpenVINO™ Extension API which enables registering + custom operations to support models with operations not supported by OpenVINO. OpenVINO™ Extension API allows you to register custom operations to support models with operations which OpenVINO™ does not support out-of-the-box. This capability requires writing code in C++, so if you are using Python to develop your application you need to build a separate shared library implemented in C++ first and load it in Python using ``add_extension`` API. Please refer to :ref:`Create library with extensions ` for more details on library creation and usage. The remining part of this document describes how to implement an operation class. @@ -14,7 +14,7 @@ OpenVINO™ Extension API allows you to register custom operations to support mo Operation Class ############### -To add your custom operation, create a new class that extends ``ov::Op``, which is in turn derived from ``:ref:`ov::Node ```, the base class for all graph operations in OpenVINO™. To add ``ov::Op``, include the next file: +To add your custom operation, create a new class that extends ``ov::Op``, which is in turn derived from ``ov::Node``, the base class for all graph operations in OpenVINO™. To add ``ov::Op``, include the next file: .. doxygensnippet:: ./src/core/template_extension/new/identity.hpp :language: cpp @@ -24,9 +24,9 @@ Follow the steps below to add a custom operation: 1. Add the ``OPENVINO_OP`` macro which defines a ``NodeTypeInfo`` object that identifies the type of the operation to the graph users and helps with dynamic type resolution. The type info of an operation currently consists of a string operation identifier and a string for operation version. -2. Implement default constructor and constructors that optionally take the operation inputs and attributes as parameters. +2. Implement default constructor and constructors that optionally take the operation inputs and attributes as parameters. -3. Override the shape inference method ``validate_and_infer_types``. This method is called multiple times during graph manipulations to determine the shapes and element types of the operations outputs. To access the input shapes and input element types, use the ``get_input_partial_shape()`` and ``get_input_element_type()`` methods of ``:ref:`ov::Node ```. Set the inferred shape and element type of the output using ``set_output_type``. +3. Override the shape inference method ``validate_and_infer_types``. This method is called multiple times during graph manipulations to determine the shapes and element types of the operations outputs. To access the input shapes and input element types, use the ``get_input_partial_shape()`` and ``get_input_element_type()`` methods of ``ov::Node``. Set the inferred shape and element type of the output using ``set_output_type``. 4. Override the ``clone_with_new_inputs`` method, which enables graph manipulation routines to create copies of this operation and connect it to different nodes during optimization. @@ -40,9 +40,9 @@ Based on that, declaration of an operation class can look as follows: Operation Constructors ++++++++++++++++++++++ -OpenVINO™ operation contains two constructors: +OpenVINO™ operation contains two constructors: -* Default constructor, which enables you to create an operation without attributes +* Default constructor, which enables you to create an operation without attributes * Constructor that creates and validates an operation with specified inputs and attributes .. doxygensnippet:: ./src/core/template_extension/new/identity.cpp @@ -52,7 +52,7 @@ OpenVINO™ operation contains two constructors: ``validate_and_infer_types()`` ++++++++++++++++++++++++++++++ -``:ref:`ov::Node::validate_and_infer_types ``` method validates operation attributes and calculates output shapes using attributes of the operation. +``ov::Node::validate_and_infer_types`` method validates operation attributes and calculates output shapes using attributes of the operation. .. doxygensnippet:: ./src/core/template_extension/new/identity.cpp :language: cpp @@ -61,7 +61,7 @@ OpenVINO™ operation contains two constructors: ``clone_with_new_inputs()`` +++++++++++++++++++++++++++ -``:ref:`ov::Node::clone_with_new_inputs ``` method creates a copy of the operation with new inputs. +``ov::Node::clone_with_new_inputs`` method creates a copy of the operation with new inputs. .. doxygensnippet:: ./src/core/template_extension/new/identity.cpp :language: cpp @@ -70,7 +70,7 @@ OpenVINO™ operation contains two constructors: ``visit_attributes()`` ++++++++++++++++++++++ -``:ref:`ov::Node::visit_attributes ``` method enables you to visit all operation attributes. +``ov::Node::visit_attributes`` method enables you to visit all operation attributes. .. doxygensnippet:: ./src/core/template_extension/new/identity.cpp :language: cpp @@ -79,7 +79,7 @@ OpenVINO™ operation contains two constructors: ``evaluate() and has_evaluate()`` +++++++++++++++++++++++++++++++++ -``:ref:`ov::Node::evaluate ``` method enables you to apply constant folding to an operation. +``ov::Node::evaluate`` method enables you to apply constant folding to an operation. .. doxygensnippet:: ./src/core/template_extension/new/identity.cpp :language: cpp diff --git a/docs/articles_en/documentation/openvino_extensibility/openvino_plugin_library/detailed_guides/low_precision_transformations/step2_markup.rst b/docs/articles_en/documentation/openvino_extensibility/openvino_plugin_library/detailed_guides/low_precision_transformations/step2_markup.rst index 467f4451f141b7..7c0383492ffef8 100644 --- a/docs/articles_en/documentation/openvino_extensibility/openvino_plugin_library/detailed_guides/low_precision_transformations/step2_markup.rst +++ b/docs/articles_en/documentation/openvino_extensibility/openvino_plugin_library/detailed_guides/low_precision_transformations/step2_markup.rst @@ -5,7 +5,7 @@ Step 2. Markup Transformations .. meta:: - :description: Learn about markup transformations, which are used to create + :description: Learn about markup transformations, which are used to create attributes for input and output ports and operations during runtime. .. toctree:: @@ -21,7 +21,7 @@ Step 2. Markup Transformations PropagatePrecisions AlignQuantizationIntervals AlignQuantizationParameters - + CreateAttribute CreatePrecisionsDependentAttribute PropagateThroughPrecisionPreserved @@ -31,13 +31,13 @@ Step 2. Markup Transformations This step defines the optimal ``FakeQuantize`` decomposition precisions for the best inference performance via operations markup with runtime attribute instances. Attributes are created for input and output ports and operations. Transformations do not change the operation output port precisions. A model markup low precision logic is decomposed and implemented into the following common markup transformations. The order of transformations is important: 1. :doc:`MarkupBias ` -2. :doc:`MarkupCanBeQuantized ` -3. :doc:`MarkupPrecisions ` -4. :doc:`MarkupPerTensorQuantization ` -5. :doc:`MarkupAvgPoolPrecisionPreserved ` -6. :doc:`PropagatePrecisions ` -7. :doc:`AlignQuantizationIntervals ` -8. :doc:`AlignQuantizationParameters ` +2. :doc:`MarkupCanBeQuantized ` +3. :doc:`MarkupPrecisions ` +4. :doc:`MarkupPerTensorQuantization ` +5. :doc:`MarkupAvgPoolPrecisionPreserved ` +6. :doc:`PropagatePrecisions ` +7. :doc:`AlignQuantizationIntervals ` +8. :doc:`AlignQuantizationParameters ` .. list-table:: :header-rows: 1 @@ -47,16 +47,16 @@ This step defines the optimal ``FakeQuantize`` decomposition precisions for the - Use attributes * - MarkupBias - Bias - - + - * - MarkupCanBeQuantized - Precisions - - + - * - MarkupPrecisions - Precisions,PrecisionPreserved - - + - * - MarkupPerTensorQuantization - PerTensorQuantization - - + - * - MarkupAvgPoolPrecisionPreserved - AvgPoolPrecisionPreserved - Precisions, PrecisionPreserved @@ -70,16 +70,16 @@ This step defines the optimal ``FakeQuantize`` decomposition precisions for the - QuantizationAlignment - PrecisionPreserved, PerTensorQuantization -.. note:: +.. note:: The same type of attribute instances can be created in different transformations. This approach is the result of the transformation single-responsibility principle. For example, ``Precision`` attribute instances are created in ``MarkupCanBeQuantized`` and ``MarkupPrecisions`` transformations, but the reasons for their creation are different Common markup transformations can be decomposed into simpler utility markup transformations. The order of Markup utility transformations is not important: -* :doc:`CreateAttribute ` -* :doc:`CreatePrecisionsDependentAttribute ` -* :doc:`PropagateThroughPrecisionPreserved ` -* :doc:`PropagateToInput ` -* :doc:`UpdateSharedPrecisionPreserved ` +* :doc:`CreateAttribute ` +* :doc:`CreatePrecisionsDependentAttribute ` +* :doc:`PropagateThroughPrecisionPreserved ` +* :doc:`PropagateToInput ` +* :doc:`UpdateSharedPrecisionPreserved ` Let's explore all transformations and their relations in detail, using one and the same model: @@ -90,12 +90,12 @@ The original model key features: * The first ``concat1`` concatenation operation has not quantized ``convolution1`` consumer. -* The second ``concat2`` concatenation operation has quantized ``convolution2`` consumer with requirements: - +* The second ``concat2`` concatenation operation has quantized ``convolution2`` consumer with requirements: + * support ``unsigned int8`` on activations, * per-tensor quantization. -* Between the ``concat2`` concatenation operation and ``Convolution`` there is an ``AvgPool`` operation, which mathematically should return an ``f32`` tensor. But the ``MarkupAvgPoolPrecisionPreserved`` transformation is active. This allows the low precision transformation, that goes after the ``AvgPool``, to propagate low precision tensor to the next consumer. +* Between the ``concat2`` concatenation operation and ``Convolution`` there is an ``AvgPool`` operation, which mathematically should return an ``f32`` tensor. But the ``MarkupAvgPoolPrecisionPreserved`` transformation is active. This allows the low precision transformation, that goes after the ``AvgPool``, to propagate low precision tensor to the next consumer. Transformations are run with the following parameters: @@ -127,8 +127,8 @@ Model display features (here and below): The transformation is required and includes two tasks: -1. Mark operation input ports (create ``Precision`` attribute instance) by provided restrictions: input port index and required precisions. Restrictions are provided as input argument in ``:ref:`ov::pass::low_precision::LowPrecision ``` constructor. -2. Mark precision preserved operations. +1. Mark operation input ports (create ``Precision`` attribute instance) by provided restrictions: input port index and required precisions. Restrictions are provided as input argument in ``ov::pass::low_precision::LowPrecision`` constructor. +2. Mark precision preserved operations. No attributes are required before the transformation. Changes in the example model after ``MarkupPrecisions`` transformation: @@ -191,7 +191,7 @@ Result model: .. image:: _static/images/step2_markup5.svg :alt: PropagatePrecisions -.. note:: +.. note:: ``AlignQuantizationIntervals`` and ``AlignQuantizationParameters`` transformations are required if the model has quantized concatenation operations. 6. AlignQuantizationIntervals diff --git a/docs/articles_en/documentation/openvino_extensibility/ov_transformations.rst b/docs/articles_en/documentation/openvino_extensibility/ov_transformations.rst index c138ac5ba930e4..9bcb1f778f0b53 100644 --- a/docs/articles_en/documentation/openvino_extensibility/ov_transformations.rst +++ b/docs/articles_en/documentation/openvino_extensibility/ov_transformations.rst @@ -5,7 +5,7 @@ Overview of Transformations API .. meta:: - :description: Learn how to apply additional model optimizations or transform + :description: Learn how to apply additional model optimizations or transform unsupported subgraphs and operations, using OpenVINO™ Transformations API. @@ -17,19 +17,19 @@ Overview of Transformations API openvino_docs_Extensibility_UG_matcher_pass openvino_docs_Extensibility_UG_graph_rewrite_pass -OpenVINO Transformation mechanism allows to develop transformation passes to modify ``:ref:`ov::Model ```. You can use this mechanism to apply additional optimizations to the original Model or transform unsupported subgraphs and operations to new operations which are supported by the plugin. +OpenVINO Transformation mechanism allows to develop transformation passes to modify ``ov::Model``. You can use this mechanism to apply additional optimizations to the original Model or transform unsupported subgraphs and operations to new operations which are supported by the plugin. This guide contains all necessary information that you need to start implementing OpenVINO™ transformations. Working with Model ################## -Before the moving to transformation part it is needed to say several words about functions which allow to modify ``:ref:`ov::Model ```. -This chapter extends the :doc:`model representation guide ` and shows an API that allows us to manipulate with ``:ref:`ov::Model ```. +Before the moving to transformation part it is needed to say several words about functions which allow to modify ``ov::Model``. +This chapter extends the :doc:`model representation guide ` and shows an API that allows us to manipulate with ``ov::Model``. Working with node input and output ports ++++++++++++++++++++++++++++++++++++++++ -First of all let's talk about ``:ref:`ov::Node ``` input/output ports. Each OpenVINO™ operation has input and output ports except cases when operation has ``Parameter`` or ``Constant`` type. +First of all let's talk about ``ov::Node`` input/output ports. Each OpenVINO™ operation has input and output ports except cases when operation has ``Parameter`` or ``Constant`` type. Every port belongs to its node, so using a port we can access parent node, get shape and type for particular input/output, get all consumers in case of output port, and get producer node in case of input port. With output port we can set inputs for newly created operations. @@ -49,13 +49,13 @@ Let's start with OpenVINO™ helper functions. The most popular function is ``ov We will review real replacement case where Negative operation is replaced with Multiply. -.. image:: ./_static/images/ngraph_replace_node.png +.. image:: ./_static/images/ngraph_replace_node.png .. doxygensnippet:: docs/snippets/ov_model_snippets.cpp :language: cpp :fragment: [ov:replace_node] -``:ref:`ov::replace_node ``` has a constraint that number of output ports for both of ops must be the same; otherwise, it raises an exception. +``ov::replace_node`` has a constraint that number of output ports for both of ops must be the same; otherwise, it raises an exception. The alternative way to do the same replacement is the following: @@ -71,7 +71,7 @@ Another transformation example is insertion. :language: cpp :fragment: [ov:insert_node] -The alternative way to the insert operation is to make a node copy and use ``:ref:`ov::replace_node() ```: +The alternative way to the insert operation is to make a node copy and use ``ov::replace_node()``: .. doxygensnippet:: docs/snippets/ov_model_snippets.cpp :language: cpp @@ -88,16 +88,16 @@ To eliminate operation, OpenVINO™ has special method that considers all limita :language: cpp :fragment: [ov:eliminate_node] -``:ref:`ov::replace_output_update_name() ``` in case of successful replacement it automatically preserves friendly name and runtime info. +``ov::replace_output_update_name()`` in case of successful replacement it automatically preserves friendly name and runtime info. .. _transformations_types: -Transformations types +Transformations types ##################### OpenVINO™ Runtime has three main transformation types: -* :doc:`Model pass ` - straightforward way to work with ``:ref:`ov::Model ``` directly +* :doc:`Model pass ` - straightforward way to work with ``ov::Model`` directly * :doc:`Matcher pass ` - pattern-based transformation approach * :doc:`Graph rewrite pass ` - container for matcher passes needed for efficient execution @@ -108,12 +108,12 @@ Transformation conditional compilation Transformation library has two internal macros to support conditional compilation feature. -* ``:ref:`MATCHER_SCOPE(region) ``` - allows to disable the MatcherPass if matcher isn't used. The region name should be unique. This macro creates a local variable ``matcher_name`` which you should use as a matcher name. -* ``:ref:`RUN_ON_MODEL_SCOPE(region) ``` - allows to disable run_on_model pass if it isn't used. The region name should be unique. +* ``MATCHER_SCOPE(region)`` - allows to disable the MatcherPass if matcher isn't used. The region name should be unique. This macro creates a local variable ``matcher_name`` which you should use as a matcher name. +* ``RUN_ON_MODEL_SCOPE(region)`` - allows to disable run_on_model pass if it isn't used. The region name should be unique. .. _transformation_writing_essentials: -Transformation writing essentials +Transformation writing essentials ################################# When developing a transformation, you need to follow these transformation rules: @@ -121,7 +121,7 @@ When developing a transformation, you need to follow these transformation rules: 1. Friendly Names +++++++++++++++++ -Each ``:ref:`ov::Node ``` has an unique name and a friendly name. In transformations we care only about friendly name because it represents the name from the model. +Each ``ov::Node`` has an unique name and a friendly name. In transformations we care only about friendly name because it represents the name from the model. To avoid losing friendly name when replacing node with other node or subgraph, set the original friendly name to the latest node in replacing subgraph. See the example below. .. doxygensnippet:: docs/snippets/ov_model_snippets.cpp @@ -133,8 +133,8 @@ In more advanced cases, when replaced operation has several outputs and we add a 2. Runtime Info +++++++++++++++ -Runtime info is a map ``std::map`>`` located inside ``:ref:`ov::Node ``` class. It represents additional attributes in ``:ref:`ov::Node ```. -These attributes can be set by users or by plugins and when executing transformation that changes ``:ref:`ov::Model ``` we need to preserve these attributes as they will not be automatically propagated. +Runtime info is a map ``std::map`` located inside ``ov::Node`` class. It represents additional attributes in ``ov::Node``. +These attributes can be set by users or by plugins and when executing transformation that changes ``ov::Model`` we need to preserve these attributes as they will not be automatically propagated. In most cases, transformations have the following types: 1:1 (replace node with another node), 1:N (replace node with a sub-graph), N:1 (fuse sub-graph into a single node), N:M (any other transformation). Currently, there is no mechanism that automatically detects transformation types, so we need to propagate this runtime information manually. See the examples below. @@ -143,21 +143,21 @@ Currently, there is no mechanism that automatically detects transformation types :language: cpp :fragment: [ov:copy_runtime_info] -When transformation has multiple fusions or decompositions, ``:ref:`ov::copy_runtime_info ``` must be called multiple times for each case. +When transformation has multiple fusions or decompositions, ``ov::copy_runtime_info`` must be called multiple times for each case. .. note:: ``copy_runtime_info`` removes ``rt_info`` from destination nodes. If you want to keep it, you need to specify them in source nodes like this: ``copy_runtime_info({a, b, c}, {a, b})`` 3. Constant Folding +++++++++++++++++++ -If your transformation inserts constant sub-graphs that need to be folded, do not forget to use ``:ref:`ov::pass::ConstantFolding() ``` after your transformation or call constant folding directly for operation. +If your transformation inserts constant sub-graphs that need to be folded, do not forget to use ``ov::pass::ConstantFolding()`` after your transformation or call constant folding directly for operation. The example below shows how constant subgraph can be constructed. .. doxygensnippet:: docs/snippets/ov_model_snippets.cpp :language: cpp :fragment: [ov:constant_subgraph] -Manual constant folding is more preferable than ``:ref:`ov::pass::ConstantFolding() ``` because it is much faster. +Manual constant folding is more preferable than ``ov::pass::ConstantFolding()`` because it is much faster. Below you can find an example of manual constant folding: @@ -167,28 +167,28 @@ Below you can find an example of manual constant folding: .. _common_mistakes: -Common mistakes in transformations +Common mistakes in transformations ################################## In transformation development process: * Do not use deprecated OpenVINO™ API. Deprecated methods has the ``OPENVINO_DEPRECATED`` macros in its definition. * Do not pass ``shared_ptr`` as an input for other node if type of node is unknown or it has multiple outputs. Use explicit output port. -* If you replace node with another node that produces different shape, remember that new shape will not be propagated until the first ``validate_nodes_and_infer_types`` call for ``:ref:`ov::Model ```. If you are using ``:ref:`ov::pass::Manager ```, it will automatically call this method after each transformation execution. -* Do not forget to call the ``:ref:`ov::pass::ConstantFolding ``` pass if your transformation creates constant subgraphs. +* If you replace node with another node that produces different shape, remember that new shape will not be propagated until the first ``validate_nodes_and_infer_types`` call for ``ov::Model``. If you are using ``ov::pass::Manager``, it will automatically call this method after each transformation execution. +* Do not forget to call the ``ov::pass::ConstantFolding`` pass if your transformation creates constant subgraphs. * Use latest OpSet if you are not developing downgrade transformation pass. -* When developing a callback for ``:ref:`ov::pass::MatcherPass ```, do not change nodes that come after the root node in topological order. +* When developing a callback for ``ov::pass::MatcherPass``, do not change nodes that come after the root node in topological order. .. _using_pass_manager: Using pass manager ################## -``:ref:`ov::pass::Manager ``` is a container class that can store the list of transformations and execute them. The main idea of this class is to have high-level representation for grouped list of transformations. +``ov::pass::Manager`` is a container class that can store the list of transformations and execute them. The main idea of this class is to have high-level representation for grouped list of transformations. It can register and apply any `transformation pass <#transformations_types>`__ on model. -In addition, ``:ref:`ov::pass::Manager ``` has extended debug capabilities (find more information in the `how to debug transformations <#how_to_debug_transformations>`__ section). +In addition, ``ov::pass::Manager`` has extended debug capabilities (find more information in the `how to debug transformations <#how_to_debug_transformations>`__ section). -The example below shows basic usage of ``:ref:`ov::pass::Manager ``` +The example below shows basic usage of ``ov::pass::Manager`` .. doxygensnippet:: docs/snippets/template_pattern_transformation.cpp :language: cpp @@ -199,16 +199,16 @@ Another example shows how multiple matcher passes can be united into single Grap .. doxygensnippet:: docs/snippets/template_pattern_transformation.cpp :language: cpp :fragment: [matcher_pass:manager2] - -.. _how_to_debug_transformations: -How to debug transformations +.. _how_to_debug_transformations: + +How to debug transformations ############################ If you are using ``ov::pass::Manager`` to run sequence of transformations, you can get additional debug capabilities by using the following environment variables: .. code-block:: cpp - + OV_PROFILE_PASS_ENABLE=1 - enables performance measurement for each transformation and prints execution status OV_ENABLE_VISUALIZE_TRACING=1 - enables visualization after each transformation. By default, it saves dot and svg files. @@ -218,6 +218,6 @@ If you are using ``ov::pass::Manager`` to run sequence of transformations, you c See Also ######## -* :doc:`OpenVINO™ Model Representation ` +* :doc:`OpenVINO™ Model Representation ` * :doc:`OpenVINO™ Extensions ` diff --git a/docs/articles_en/documentation/openvino_extensibility/ov_transformations/graph_rewrite_pass.rst b/docs/articles_en/documentation/openvino_extensibility/ov_transformations/graph_rewrite_pass.rst index 621d0d23e319ac..d3f84abadbfef1 100644 --- a/docs/articles_en/documentation/openvino_extensibility/ov_transformations/graph_rewrite_pass.rst +++ b/docs/articles_en/documentation/openvino_extensibility/ov_transformations/graph_rewrite_pass.rst @@ -5,11 +5,11 @@ OpenVINO Graph Rewrite Pass .. meta:: - :description: Get to know how Graph Rewrite handles running multiple matcher passes on + :description: Get to know how Graph Rewrite handles running multiple matcher passes on ov::Model in a single graph traversal. -``:ref:`ov::pass::GraphRewrite ``` serves for running multiple matcher passes on ``:ref:`ov::Model ``` in a single graph traversal. +``ov::pass::GraphRewrite`` serves for running multiple matcher passes on ``ov::Model`` in a single graph traversal. Example: .. doxygensnippet:: docs/snippets/template_pattern_transformation.cpp @@ -18,13 +18,13 @@ Example: In addition, GraphRewrite handles nodes that were registered by MatcherPasses during their execution. This nodes will be added to the beginning of the sequence with nodes for pattern matching. -.. note:: +.. note:: - When using ``:ref:`ov::pass::Manager ``` temporary GraphRewrite is used to execute single MatcherPass. + When using ``ov::pass::Manager`` temporary GraphRewrite is used to execute single MatcherPass. GraphRewrite has two algorithms for MatcherPasses execution. First algorithm is straightforward. It applies each MatcherPass in registration order to current node. -.. image:: ./_static/images/graph_rewrite_execution.png +.. image:: ./_static/images/graph_rewrite_execution.png But it is not really efficient when you have a lot of registered passes. So first of all GraphRewrite checks that all MatcherPass patterns has type-based root node (it means that type of this node is not hidden into predicate). And then creates map from registered MatcherPasses. That helps to avoid additional cost of applying each MatcherPass for each node. diff --git a/docs/articles_en/documentation/openvino_extensibility/ov_transformations/matcher_pass.rst b/docs/articles_en/documentation/openvino_extensibility/ov_transformations/matcher_pass.rst index 3f9a31331c45ac..1943a5e5635480 100644 --- a/docs/articles_en/documentation/openvino_extensibility/ov_transformations/matcher_pass.rst +++ b/docs/articles_en/documentation/openvino_extensibility/ov_transformations/matcher_pass.rst @@ -5,11 +5,11 @@ OpenVINO Matcher Pass .. meta:: - :description: Learn how to create a pattern, implement a callback, register - the pattern and Matcher to execute MatcherPass transformation + :description: Learn how to create a pattern, implement a callback, register + the pattern and Matcher to execute MatcherPass transformation on a model. -``:ref:`ov::pass::MatcherPass ``` is used for pattern-based transformations. +``ov::pass::MatcherPass`` is used for pattern-based transformations. Template for MatcherPass transformation class @@ -22,7 +22,7 @@ Template for MatcherPass transformation class :fragment: [graph_rewrite:template_transformation_cpp] -To use ``:ref:`ov::pass::MatcherPass ```, you need to complete these steps: +To use ``ov::pass::MatcherPass``, you need to complete these steps: 1. Create a pattern 2. Implement a callback @@ -34,10 +34,10 @@ So let's go through each of these steps. Create a pattern ################ -Pattern is a single root ``:ref:`ov::Model ```. But the only difference is that you do not need to create a model object, you just need to create and connect opset or special pattern operations. +Pattern is a single root ``ov::Model``. But the only difference is that you do not need to create a model object, you just need to create and connect opset or special pattern operations. Then you need to take the last created operation and put it as a root of the pattern. This root node will be used as a root node in pattern matching. -.. note:: +.. note:: Any nodes in a pattern that have no consumers and are not registered as root will not be used in pattern matching. .. doxygensnippet:: docs/snippets/ov_model_snippets.cpp @@ -60,13 +60,13 @@ Callback is an action applied to every pattern entrance. In general, callback is The example above shows the callback structure and how Matcher can be used for accessing nodes detected by pattern. Callback return value is ``true`` if root node was replaced and another pattern cannot be applied to the same root node; otherwise, it is ``false``. -.. note:: +.. note:: It is not recommended to manipulate with nodes that are under root node. This may affect GraphRewrite execution as it is expected that all nodes that come after root node in topological order are valid and can be used in pattern matching. MatcherPass also provides functionality that allows reporting of the newly created nodes that can be used in additional pattern matching. -If MatcherPass was registered in ``:ref:`ov::pass::Manager ``` or ``:ref:`ov::pass::GraphRewrite ```, these registered nodes will be added for additional pattern matching. -That means that matcher passes registered in ``:ref:`ov::pass::GraphRewrite ``` will be applied to these nodes. +If MatcherPass was registered in ``ov::pass::Manager`` or ``ov::pass::GraphRewrite``, these registered nodes will be added for additional pattern matching. +That means that matcher passes registered in ``ov::pass::GraphRewrite`` will be applied to these nodes. The example below shows how single MatcherPass can fuse sequence of operations using the ``register_new_node`` method. @@ -74,7 +74,7 @@ The example below shows how single MatcherPass can fuse sequence of operations u :language: cpp :fragment: [matcher_pass:relu_fusion] -.. note:: +.. note:: If you register multiple nodes, please add them in topological order. We do not topologically sort these nodes as it is a time-consuming operation. Register pattern and Matcher @@ -82,12 +82,12 @@ Register pattern and Matcher The last step is to register Matcher and callback inside the MatcherPass pass. To do this, call the ``register_matcher`` method. -.. note:: +.. note:: Only one matcher can be registered for a single MatcherPass class. .. code-block:: cpp - + // Register matcher and callback register_matcher(m, callback); @@ -103,13 +103,13 @@ MatcherPass has multiple ways to be executed: :language: cpp :fragment: [matcher_pass:run_on_node] -* Run on ``:ref:`ov::Model ``` using GraphRewrite - this approach gives ability to run MatcherPass on whole ``:ref:`ov::Model ```. Moreover, multiple MatcherPass transformation can be registered in a single GraphRewite to be executed in a single graph traversal. +* Run on ``ov::Model`` using GraphRewrite - this approach gives ability to run MatcherPass on whole ``ov::Model``. Moreover, multiple MatcherPass transformation can be registered in a single GraphRewite to be executed in a single graph traversal. .. doxygensnippet:: docs/snippets/template_pattern_transformation.cpp :language: cpp :fragment: [matcher_pass:graph_rewrite] -* Run on ``:ref:`ov::Model ``` using ``:ref:`ov::pass::Manager ``` - this approach helps you to register MatcherPass for execution on ``:ref:`ov::Model ``` as another transformation types. +* Run on ``ov::Model`` using ``ov::pass::Manager`` - this approach helps you to register MatcherPass for execution on ``ov::Model`` as another transformation types. .. doxygensnippet:: docs/snippets/template_pattern_transformation.cpp :language: cpp @@ -125,8 +125,8 @@ And for these cases OpenVINO™ provides additional helpers to construct pattern There are two main helpers: -1. ``:ref:`ov::pass::pattern::any_input ``` - helps to express inputs if their types are undefined. -2. ``:ref:`ov::pass::pattern::wrap_type ``` - helps to express nodes of pattern without specifying node attributes. +1. ``ov::pass::pattern::any_input`` - helps to express inputs if their types are undefined. +2. ``ov::pass::pattern::wrap_type `` - helps to express nodes of pattern without specifying node attributes. Let's go through the example to have better understanding of how it works: diff --git a/docs/articles_en/documentation/openvino_extensibility/ov_transformations/model_pass.rst b/docs/articles_en/documentation/openvino_extensibility/ov_transformations/model_pass.rst index f79dc9dcf69ee0..eb09d2986939e0 100644 --- a/docs/articles_en/documentation/openvino_extensibility/ov_transformations/model_pass.rst +++ b/docs/articles_en/documentation/openvino_extensibility/ov_transformations/model_pass.rst @@ -5,25 +5,25 @@ OpenVINO Model Pass .. meta:: - :description: Learn how to use Model Pass transformation class to take entire + :description: Learn how to use Model Pass transformation class to take entire ov::Model as input and process it. -``:ref:`ov::pass::ModelPass ``` is used for transformations that take entire ``:ref:`ov::Model ``` as an input and process it. +``ov::pass::ModelPass`` is used for transformations that take entire ``ov::Model`` as an input and process it. Template for ModelPass transformation class -.. doxygensnippet:: docs/snippets/template_model_transformation.hpp - :language: cpp +.. doxygensnippet:: docs/snippets/template_model_transformation.hpp + :language: cpp :fragment: [model_pass:template_transformation_hpp] .. doxygensnippet:: docs/snippets/template_model_transformation.cpp :language: cpp :fragment: [model_pass:template_transformation_cpp] -Using ``:ref:`ov::pass::ModelPass ```, you need to override the ``run_on_model`` method where you will write the transformation code. +Using ``ov::pass::ModelPass``, you need to override the ``run_on_model`` method where you will write the transformation code. Return value is ``true`` if the original model has changed during transformation (new operation was added, or operations replacement was made, or node attributes were changed); otherwise, it is ``false``. -Also ``:ref:`ov::pass::ModelPass ``` based transformations can be executed via ``:ref:`ov::pass::Manager ```. +Also ``ov::pass::ModelPass`` based transformations can be executed via ``ov::pass::Manager``. See Also ######## diff --git a/docs/articles_en/documentation/openvino_ir/operation_sets/operations_specifications/quantization/FakeConvert_13.rst b/docs/articles_en/documentation/openvino_ir/operation_sets/operations_specifications/quantization/FakeConvert_13.rst index d58eefc16f3983..93e56c4b4ce2a2 100644 --- a/docs/articles_en/documentation/openvino_ir/operation_sets/operations_specifications/quantization/FakeConvert_13.rst +++ b/docs/articles_en/documentation/openvino_ir/operation_sets/operations_specifications/quantization/FakeConvert_13.rst @@ -29,9 +29,9 @@ Each element of the output is defined as the result of the following expression: .. code-block:: py :force: - data = (data + shift) / scale - ConvertLike(Convert(data, destination_type), data) data = data * scale - shift + ConvertLike(Convert(data, destination_type), data) + data = (data + shift) / scale **Attributes** diff --git a/docs/articles_en/get_started/installing-openvino-overview/installing-openvino-linux-header/installing-openvino-from-archive-linux.rst b/docs/articles_en/get_started/installing-openvino-overview/installing-openvino-linux-header/installing-openvino-from-archive-linux.rst index 0453db1b403e20..351ca99aeb0f61 100644 --- a/docs/articles_en/get_started/installing-openvino-overview/installing-openvino-linux-header/installing-openvino-from-archive-linux.rst +++ b/docs/articles_en/get_started/installing-openvino-overview/installing-openvino-linux-header/installing-openvino-from-archive-linux.rst @@ -187,7 +187,7 @@ Step 1: Download and Install the OpenVINO Core Components .. code-block:: sh - curl -L https://storage.openvinotoolkit.org/repositories/openvino/packages/nightly/2024.0.0-13770-9b52171d290/l_openvino_toolkit_ubuntu18_2023.3.0.13775.ceeafaf64f3_arm64.tgz -O openvino_2023.3.0.tgz + curl -L https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.3/linux/l_openvino_toolkit_ubuntu18_2023.3.0.13775.ceeafaf64f3_arm64.tgz -O openvino_2023.3.0.tgz tar -xf openvino_2023.3.0.tgz sudo mv l_openvino_toolkit_ubuntu18_2023.3.0.13775.ceeafaf64f3_arm64 /opt/intel/openvino_2023.3.0 diff --git a/docs/articles_en/learn_openvino/openvino_samples/bert_benchmark.rst b/docs/articles_en/learn_openvino/openvino_samples/bert_benchmark.rst index ce82c582e97f5b..691e6cbfc8fef9 100644 --- a/docs/articles_en/learn_openvino/openvino_samples/bert_benchmark.rst +++ b/docs/articles_en/learn_openvino/openvino_samples/bert_benchmark.rst @@ -9,7 +9,7 @@ Bert Benchmark Python Sample This sample demonstrates how to estimate performance of a Bert model using Asynchronous -Inference Request API. Unlike :doc:`demos ` this sample does not have +Inference Request API. Unlike `demos `__ this sample does not have configurable command line arguments. Feel free to modify sample's source code to try out different options. diff --git a/docs/articles_en/learn_openvino/openvino_samples/hello_classification.rst b/docs/articles_en/learn_openvino/openvino_samples/hello_classification.rst index b6eef4b762a031..c51b4545b4919f 100644 --- a/docs/articles_en/learn_openvino/openvino_samples/hello_classification.rst +++ b/docs/articles_en/learn_openvino/openvino_samples/hello_classification.rst @@ -14,8 +14,8 @@ Synchronous Inference Request API. Before using the sample, refer to the followi - Models with only one input and output are supported. - The sample accepts any file format supported by ``core.read_model``. -- The sample has been validated with: :doc:`alexnet `, - :doc:`googlenet-v1 ` models. +- The sample has been validated with: `alexnet `__, + `googlenet-v1 `__ models. - To build the sample, use instructions available at :ref:`Build the Sample Applications ` section in "Get Started with Samples" guide. diff --git a/docs/articles_en/learn_openvino/openvino_samples/hello_nv12_input_classification.rst b/docs/articles_en/learn_openvino/openvino_samples/hello_nv12_input_classification.rst index c9a53ede7229d2..183535fedddcd3 100644 --- a/docs/articles_en/learn_openvino/openvino_samples/hello_nv12_input_classification.rst +++ b/docs/articles_en/learn_openvino/openvino_samples/hello_nv12_input_classification.rst @@ -15,7 +15,7 @@ with images in NV12 color format using Synchronous Inference Request API. Before using the sample, refer to the following requirements: - The sample accepts any file format supported by ``ov::Core::read_model``. -- The sample has been validated with: :doc:`alexnet ` model and +- The sample has been validated with: `alexnet `__ model and uncompressed images in the NV12 color format - \*.yuv - To build the sample, use instructions available at :ref:`Build the Sample Applications ` section in "Get Started with Samples" guide. diff --git a/docs/articles_en/learn_openvino/openvino_samples/hello_query_device.rst b/docs/articles_en/learn_openvino/openvino_samples/hello_query_device.rst index ccb14bc3293c80..3dc1deb6e2bac3 100644 --- a/docs/articles_en/learn_openvino/openvino_samples/hello_query_device.rst +++ b/docs/articles_en/learn_openvino/openvino_samples/hello_query_device.rst @@ -81,21 +81,19 @@ For example: [ INFO ] Available devices: [ INFO ] CPU : - [ INFO ] SUPPORTED_METRICS: + [ INFO ] SUPPORTED_PROPERTIES: [ INFO ] AVAILABLE_DEVICES: [ INFO ] FULL_DEVICE_NAME: Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz [ INFO ] OPTIMIZATION_CAPABILITIES: FP32, FP16, INT8, BIN [ INFO ] RANGE_FOR_ASYNC_INFER_REQUESTS: 1, 1, 1 [ INFO ] RANGE_FOR_STREAMS: 1, 8 [ INFO ] IMPORT_EXPORT_SUPPORT: True - [ INFO ] - [ INFO ] SUPPORTED_CONFIG_KEYS (default values): [ INFO ] CACHE_DIR: - [ INFO ] CPU_BIND_THREAD: NO - [ INFO ] CPU_THREADS_NUM: 0 - [ INFO ] CPU_THROUGHPUT_STREAMS: 1 + [ INFO ] ENABLE_CPU_PINNING: NO + [ INFO ] INFERENCE_NUM_THREADS: 0 + [ INFO ] NUM_STREAMS: 1 [ INFO ] DUMP_EXEC_GRAPH_AS_DOT: - [ INFO ] ENFORCE_BF16: NO + [ INFO ] INFERENCE_PRECISION_HINT: f32 [ INFO ] EXCLUSIVE_ASYNC_REQUESTS: NO [ INFO ] PERFORMANCE_HINT: [ INFO ] PERFORMANCE_HINT_NUM_REQUESTS: 0 @@ -112,20 +110,19 @@ For example: [ INFO ] [ INFO ] Available devices: [ INFO ] CPU - [ INFO ] SUPPORTED_METRICS: + [ INFO ] SUPPORTED_PROPERTIES: [ INFO ] AVAILABLE_DEVICES : [ ] [ INFO ] FULL_DEVICE_NAME : Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz [ INFO ] OPTIMIZATION_CAPABILITIES : [ FP32 FP16 INT8 BIN ] [ INFO ] RANGE_FOR_ASYNC_INFER_REQUESTS : { 1, 1, 1 } [ INFO ] RANGE_FOR_STREAMS : { 1, 8 } [ INFO ] IMPORT_EXPORT_SUPPORT : true - [ INFO ] SUPPORTED_CONFIG_KEYS (default values): [ INFO ] CACHE_DIR : "" - [ INFO ] CPU_BIND_THREAD : NO - [ INFO ] CPU_THREADS_NUM : 0 - [ INFO ] CPU_THROUGHPUT_STREAMS : 1 + [ INFO ] ENABLE_CPU_PINNING : NO + [ INFO ] INFERENCE_NUM_THREADS : 0 + [ INFO ] NUM_STREAMS : 1 [ INFO ] DUMP_EXEC_GRAPH_AS_DOT : "" - [ INFO ] ENFORCE_BF16 : NO + [ INFO ] INFERENCE_PRECISION_HINT : f32 [ INFO ] EXCLUSIVE_ASYNC_REQUESTS : NO [ INFO ] PERFORMANCE_HINT : "" [ INFO ] PERFORMANCE_HINT_NUM_REQUESTS : 0 diff --git a/docs/articles_en/learn_openvino/openvino_samples/hello_reshape_ssd.rst b/docs/articles_en/learn_openvino/openvino_samples/hello_reshape_ssd.rst index 0b516c797a6d57..3272a6d1014988 100644 --- a/docs/articles_en/learn_openvino/openvino_samples/hello_reshape_ssd.rst +++ b/docs/articles_en/learn_openvino/openvino_samples/hello_reshape_ssd.rst @@ -16,8 +16,8 @@ using the sample, refer to the following requirements: - Models with only one input and output are supported. - The sample accepts any file format supported by ``core.read_model``. -- The sample has been validated with: :doc:`mobilenet-ssd `, - :doc:`person-detection-retail-0013 ` +- The sample has been validated with: `mobilenet-ssd `__, + `person-detection-retail-0013 `__ models and the NCHW layout format. - To build the sample, use instructions available at :ref:`Build the Sample Applications ` section in "Get Started with Samples" guide. diff --git a/docs/articles_en/learn_openvino/openvino_samples/image_classification_async.rst b/docs/articles_en/learn_openvino/openvino_samples/image_classification_async.rst index 2dad59f0ee2f97..18a8136d7600a5 100644 --- a/docs/articles_en/learn_openvino/openvino_samples/image_classification_async.rst +++ b/docs/articles_en/learn_openvino/openvino_samples/image_classification_async.rst @@ -15,7 +15,8 @@ following requirements: - Models with only one input and output are supported. - The sample accepts any file format supported by ``core.read_model``. -- The sample has been validated with: :doc:`alexnet `, :doc:`googlenet-v1 ` models. +- The sample has been validated with: `alexnet `__, + `googlenet-v1 `__ models. - To build the sample, use instructions available at :ref:`Build the Sample Applications ` section in "Get Started with Samples" guide. diff --git a/docs/articles_en/learn_openvino/openvino_samples/sync_benchmark.rst b/docs/articles_en/learn_openvino/openvino_samples/sync_benchmark.rst index 793bc11c5262e4..f2da10f65797a6 100644 --- a/docs/articles_en/learn_openvino/openvino_samples/sync_benchmark.rst +++ b/docs/articles_en/learn_openvino/openvino_samples/sync_benchmark.rst @@ -11,14 +11,15 @@ Sync Benchmark Sample This sample demonstrates how to estimate performance of a model using Synchronous Inference Request API. It makes sense to use synchronous inference only in latency oriented scenarios. Models with static input shapes are supported. Unlike -:doc:`demos ` this sample does not have other configurable command-line +`demos `__ this sample does not have other configurable command-line arguments. Feel free to modify sample's source code to try out different options. Before using the sample, refer to the following requirements: - The sample accepts any file format supported by ``core.read_model``. -- The sample has been validated with: :doc:`alexnet `, - :doc:`googlenet-v1 `, :doc:`yolo-v3-tf `, - :doc:`face-detection-0200 ` models. +- The sample has been validated with: `alexnet `__, + `googlenet-v1 `__, + `yolo-v3-tf `__, + `face-detection-0200 `__ models. - To build the sample, use instructions available at :ref:`Build the Sample Applications ` section in "Get Started with Samples" guide. diff --git a/docs/articles_en/learn_openvino/openvino_samples/throughput_benchmark.rst b/docs/articles_en/learn_openvino/openvino_samples/throughput_benchmark.rst index ff7d667ca74b1e..a2545361f7ee39 100644 --- a/docs/articles_en/learn_openvino/openvino_samples/throughput_benchmark.rst +++ b/docs/articles_en/learn_openvino/openvino_samples/throughput_benchmark.rst @@ -9,7 +9,7 @@ Throughput Benchmark Sample This sample demonstrates how to estimate performance of a model using Asynchronous -Inference Request API in throughput mode. Unlike :doc:`demos ` this sample +Inference Request API in throughput mode. Unlike `demos `__ this sample does not have other configurable command-line arguments. Feel free to modify sample's source code to try out different options. @@ -20,9 +20,10 @@ sets ``uint8``, while the sample uses default model precision which is usually ` Before using the sample, refer to the following requirements: - The sample accepts any file format supported by ``core.read_model``. -- The sample has been validated with: :doc:`alexnet `, - :doc:`googlenet-v1 `, :doc:`yolo-v3-tf `, - :doc:`face-detection-0200 ` models. +- The sample has been validated with: `alexnet `__, + `googlenet-v1 `__, + `yolo-v3-tf `__, + `face-detection-0200 `__ models. - To build the sample, use instructions available at :ref:`Build the Sample Applications ` section in "Get Started with Samples" guide. diff --git a/docs/articles_en/openvino_workflow/model_optimization_guide/ptq_introduction/basic_quantization_flow.rst b/docs/articles_en/openvino_workflow/model_optimization_guide/ptq_introduction/basic_quantization_flow.rst index 6e44f1c9c2fed6..6148b21f3dcb4d 100644 --- a/docs/articles_en/openvino_workflow/model_optimization_guide/ptq_introduction/basic_quantization_flow.rst +++ b/docs/articles_en/openvino_workflow/model_optimization_guide/ptq_introduction/basic_quantization_flow.rst @@ -156,7 +156,7 @@ Tune quantization parameters .. code-block:: sh - nncf.quantize(model, dataset, preset=nncf.Preset.MIXED) + nncf.quantize(model, dataset, preset=nncf.QuantizationPreset.MIXED) * ``fast_bias_correction`` - when set to ``False``, enables a more accurate bias (error) correction algorithm that can be used to improve the accuracy of the model. This parameter is available only for OpenVINO and ONNX representations. ``True`` is used by default to minimize quantization time. diff --git a/docs/articles_en/openvino_workflow/running_inference_with_openvino/Device_Plugins/GPU/GPU_RemoteTensor_API.rst b/docs/articles_en/openvino_workflow/running_inference_with_openvino/Device_Plugins/GPU/GPU_RemoteTensor_API.rst index 1475d62ac65bd5..60baddcfa8fd1a 100644 --- a/docs/articles_en/openvino_workflow/running_inference_with_openvino/Device_Plugins/GPU/GPU_RemoteTensor_API.rst +++ b/docs/articles_en/openvino_workflow/running_inference_with_openvino/Device_Plugins/GPU/GPU_RemoteTensor_API.rst @@ -5,13 +5,13 @@ Remote Tensor API of GPU Plugin .. meta:: - :description: The Remote Tensor API of GPU plugin in OpenVINO™ supports - interoperability with existing native APIs, such as OpenCL, + :description: The Remote Tensor API of GPU plugin in OpenVINO™ supports + interoperability with existing native APIs, such as OpenCL, Microsoft DirectX, or VAAPI. The GPU plugin implementation of the ``ov::RemoteContext`` and ``ov::RemoteTensor`` interfaces supports GPU -pipeline developers who need video memory sharing and interoperability with existing native APIs, +pipeline developers who need video memory sharing and interoperability with existing native APIs, such as OpenCL, Microsoft DirectX, or VAAPI. The ``ov::RemoteContext`` and ``ov::RemoteTensor`` interface implementation targets the need for memory sharing and @@ -57,24 +57,24 @@ of ``ov::RemoteContext`` derived classes. :sync: windows-cpp .. tab-set:: - + .. tab-item:: Create from cl_context :sync: create-from-cl-context - + .. doxygensnippet:: docs/snippets/gpu/remote_objects_creation.cpp :language: cpp :fragment: [context_from_cl_context] - + .. tab-item:: Create from cl_queue :sync: create-from-cl-queue - + .. doxygensnippet:: docs/snippets/gpu/remote_objects_creation.cpp :language: cpp :fragment: [context_from_cl_queue] - + .. tab-item:: Create from ID3D11Device :sync: create-from-id3d11device - + .. doxygensnippet:: docs/snippets/gpu/remote_objects_creation.cpp :language: cpp :fragment: [context_from_d3d_device] @@ -83,24 +83,24 @@ of ``ov::RemoteContext`` derived classes. :sync: windows-c .. tab-set:: - + .. tab-item:: Create from cl_context :sync: create-from-cl-context - + .. doxygensnippet:: docs/snippets/gpu/remote_objects_creation_c.cpp :language: c :fragment: [context_from_cl_context] - + .. tab-item:: Create from cl_queue :sync: create-from-cl-queue - + .. doxygensnippet:: docs/snippets/gpu/remote_objects_creation_c.cpp :language: c :fragment: [context_from_cl_queue] - + .. tab-item:: Create from ID3D11Device :sync: create-from-id3d11device - + .. doxygensnippet:: docs/snippets/gpu/remote_objects_creation_c.cpp :language: c :fragment: [context_from_d3d_device] @@ -109,54 +109,54 @@ of ``ov::RemoteContext`` derived classes. :sync: linux-cpp .. tab-set:: - + .. tab-item:: Create from cl_context :sync: create-from-cl-context - + .. doxygensnippet:: docs/snippets/gpu/remote_objects_creation.cpp :language: cpp :fragment: [context_from_cl_context] - + .. tab-item:: Create from cl_queue :sync: create-from-cl-queue - + .. doxygensnippet:: docs/snippets/gpu/remote_objects_creation.cpp :language: cpp :fragment: [context_from_cl_queue] - + .. tab-item:: Create from VADisplay :sync: create-from-vadisplay - + .. doxygensnippet:: docs/snippets/gpu/remote_objects_creation.cpp :language: cpp :fragment: [context_from_va_display] - + .. tab-item:: Linux/C :sync: linux-c .. tab-set:: - + .. tab-item:: Create from cl_context :sync: create-from-cl-context - + .. doxygensnippet:: docs/snippets/gpu/remote_objects_creation_c.cpp :language: c :fragment: [context_from_cl_context] - + .. tab-item:: Create from cl_queue :sync: create-from-cl-queue - + .. doxygensnippet:: docs/snippets/gpu/remote_objects_creation_c.cpp :language: c :fragment: [context_from_cl_queue] - + .. tab-item:: Create from VADisplay :sync: create-from-vadisplay - + .. doxygensnippet:: docs/snippets/gpu/remote_objects_creation_c.cpp :language: c :fragment: [context_from_va_display] - + Getting RemoteContext from the Plugin +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -173,40 +173,40 @@ To request the current default context of the plugin, use one of the following m :sync: cpp .. tab-set:: - + .. tab-item:: Get context from Core :sync: get-context-core - + .. doxygensnippet:: docs/snippets/gpu/remote_objects_creation.cpp :language: cpp :fragment: [default_context_from_core] - + .. tab-item:: Get context from compiled model :sync: get-context-compiled-model - + .. doxygensnippet:: docs/snippets/gpu/remote_objects_creation.cpp :language: cpp :fragment: [default_context_from_model] - + .. tab-item:: C :sync: c .. tab-set:: - + .. tab-item:: Get context from Core :sync: get-context-core - + .. doxygensnippet:: docs/snippets/gpu/remote_objects_creation_c.cpp :language: c :fragment: [default_context_from_core] - + .. tab-item:: Get context from compiled model :sync: get-context-compiled-model - + .. doxygensnippet:: docs/snippets/gpu/remote_objects_creation_c.cpp :language: c :fragment: [default_context_from_model] - + Memory Sharing Between Application and GPU Plugin ########################################################### @@ -359,11 +359,11 @@ Direct NV12 Video Surface Input To support the direct consumption of a hardware video decoder output, the GPU plugin accepts: -* Two-plane NV12 video surface input - calling the ``create_tensor_nv12()`` function creates - a pair of ``ov::RemoteTensor`` objects, representing the Y and UV planes. -* Single-plane NV12 video surface input - calling the ``create_tensor()`` function creates one +* Two-plane NV12 video surface input - calling the ``create_tensor_nv12()`` function creates + a pair of ``ov::RemoteTensor`` objects, representing the Y and UV planes. +* Single-plane NV12 video surface input - calling the ``create_tensor()`` function creates one ``ov::RemoteTensor`` object, representing the Y and UV planes at once (Y elements before UV elements). -* NV12 to Grey video surface input conversion - calling the ``create_tensor()`` function creates one +* NV12 to Grey video surface input conversion - calling the ``create_tensor()`` function creates one ``ov::RemoteTensor`` object, representing only the Y plane. To ensure that the plugin generates a correct execution graph, static preprocessing @@ -375,102 +375,102 @@ should be added before model compilation: :sync: two-plane .. tab-set:: - + .. tab-item:: C++ :sync: cpp - + .. doxygensnippet:: docs/snippets/gpu/preprocessing_nv12_two_planes.cpp :language: cpp :fragment: [init_preproc] - + .. tab-item:: C :sync: c - + .. doxygensnippet:: docs/snippets/gpu/preprocessing_nv12_two_planes_c.cpp :language: c :fragment: [init_preproc] - + .. tab-item:: single-plane :sync: single-plane - + .. doxygensnippet:: docs/snippets/gpu/preprocessing_nv12_single_plane.cpp :language: cpp :fragment: [init_preproc] - + .. tab-item:: NV12 to Grey :sync: nv12-grey - + .. doxygensnippet:: docs/snippets/gpu/preprocessing_nv12_to_gray.cpp :language: cpp :fragment: [init_preproc] -Since the ``ov::intel_gpu::ocl::ClImage2DTensor`` and its derived classes do not support batched surfaces, -if batching and surface sharing are required at the same time, +Since the ``ov::intel_gpu::ocl::ClImage2DTensor`` and its derived classes do not support batched surfaces, +if batching and surface sharing are required at the same time, inputs need to be set via the ``ov::InferRequest::set_tensors`` method with vector of shared surfaces for each plane: .. tab-set:: .. tab-item:: Single Batch :sync: single-batch - + .. tab-set:: .. tab-item:: two-plane :sync: two-plane .. tab-set:: - + .. tab-item:: C++ :sync: cpp - + .. doxygensnippet:: docs/snippets/gpu/preprocessing_nv12_two_planes.cpp :language: cpp :fragment: [single_batch] - + .. tab-item:: C :sync: cpp - + .. doxygensnippet:: docs/snippets/gpu/preprocessing_nv12_two_planes_c.cpp :language: c :fragment: [single_batch] - + .. tab-item:: single-plane :sync: single-plane - + .. doxygensnippet:: docs/snippets/gpu/preprocessing_nv12_single_plane.cpp :language: cpp :fragment: [single_batch] - + .. tab-item:: NV12 to Grey :sync: nv12-grey - + .. doxygensnippet:: docs/snippets/gpu/preprocessing_nv12_to_gray.cpp :language: cpp :fragment: [single_batch] - + .. tab-item:: Multiple Batches :sync: multiple-batches .. tab-set:: - + .. tab-item:: two-plane :sync: two-plane - + .. doxygensnippet:: docs/snippets/gpu/preprocessing_nv12_two_planes.cpp :language: cpp :fragment: [batched_case] - + .. tab-item:: single-plane :sync: single-plane - + .. doxygensnippet:: docs/snippets/gpu/preprocessing_nv12_single_plane.cpp :language: cpp :fragment: [batched_case] - + .. tab-item:: NV12 to Grey :sync: nv12-grey - + .. doxygensnippet:: docs/snippets/gpu/preprocessing_nv12_to_gray.cpp :language: cpp :fragment: [batched_case] @@ -524,7 +524,7 @@ To see pseudo-code of usage examples, refer to the sections below. .. NOTE:: - + For low-level parameter usage examples, see the source code of user-side wrappers from the include files mentioned above. @@ -543,19 +543,19 @@ To see pseudo-code of usage examples, refer to the sections below. :fragment: [context_sharing_user_handle] .. dropdown:: Direct Consuming of the NV12 VAAPI Video Decoder Surface on Linux - + .. tab-set:: - + .. tab-item:: C++ :sync: cpp - + .. doxygensnippet:: docs/snippets/gpu/context_sharing_va.cpp :language: cpp :fragment: [context_sharing_va] - + .. tab-item:: C :sync: c - + .. doxygensnippet:: docs/snippets/gpu/context_sharing_va_c.cpp :language: c :fragment: [context_sharing_va] @@ -563,6 +563,6 @@ To see pseudo-code of usage examples, refer to the sections below. See Also ####################################### -* ``:ref:`ov::Core ``` -* ``:ref:`ov::RemoteTensor ``` +* ``ov::Core`` +* ``ov::RemoteTensor`` diff --git a/docs/articles_en/openvino_workflow/running_inference_with_openvino/Device_Plugins/NPU.rst b/docs/articles_en/openvino_workflow/running_inference_with_openvino/Device_Plugins/NPU.rst index e8aa8989ddc43e..416225e4544898 100644 --- a/docs/articles_en/openvino_workflow/running_inference_with_openvino/Device_Plugins/NPU.rst +++ b/docs/articles_en/openvino_workflow/running_inference_with_openvino/Device_Plugins/NPU.rst @@ -96,7 +96,7 @@ offer a limited set of supported OpenVINO features. .. code-block:: - ov::caching_properties + ov::internal::caching_properties ov::enable_profiling ov::hint::performance_mode ov::hint::num_requests diff --git a/docs/dev/build_linux.md b/docs/dev/build_linux.md index 395a2dcb139ec8..2710ef094107fd 100644 --- a/docs/dev/build_linux.md +++ b/docs/dev/build_linux.md @@ -53,7 +53,10 @@ The software was validated on: cmake -DCMAKE_BUILD_TYPE=Release .. cmake --build . --parallel ``` -The process may take some time to finish. + The process may take some time to finish. If you are using a system with limited resources, it is recommended to specify a lower number of parallel jobs to avoid overloading your system. This can help maintain system responsiveness and stability during the build process. Use `nproc` to find the number of available processing units. For example, to use 8 parallel jobs, run the following command: + ```sh + cmake --build . --parallel 8 + ``` ### Additional Build Options diff --git a/docs/dev/build_mac_arm.md b/docs/dev/build_mac_arm.md index 80678bb6ce4681..fb728d18d5f040 100644 --- a/docs/dev/build_mac_arm.md +++ b/docs/dev/build_mac_arm.md @@ -33,7 +33,7 @@ The software was validated on: ``` - (arm64 only) Product and samples dependencies: ```sh - % brew install tbb pugixml flatbuffers snappy protobuf nlohmann-json zlib gflags + % brew install tbb pugixml flatbuffers snappy protobuf ``` - Additional `pip` dependencies to build OpenVINO Runtime Python API, Development tools (Model Optimizer, POT and others): ```sh diff --git a/docs/dev/build_mac_intel_cpu.md b/docs/dev/build_mac_intel_cpu.md index 606178e3f376fe..8d57aa12aae0c5 100644 --- a/docs/dev/build_mac_intel_cpu.md +++ b/docs/dev/build_mac_intel_cpu.md @@ -30,7 +30,7 @@ The software was validated on: ``` - (Optional; native compilation only, x86_64) Product and samples dependencies: ```sh - % brew install tbb pugixml flatbuffers snappy protobuf nlohmann-json zlib gflags + % brew install tbb pugixml flatbuffers snappy protobuf ``` - Additional `pip` dependencies to build OpenVINO Runtime Python API, Development tools (Model Optimizer, POT and others): ```sh diff --git a/docs/dev/build_windows.md b/docs/dev/build_windows.md index a8f906cadcd0a8..eaf695f898ba18 100644 --- a/docs/dev/build_windows.md +++ b/docs/dev/build_windows.md @@ -44,7 +44,7 @@ Supported configurations: >* `-DCMAKE_BUILD_TYPE=RelWithDebInfo`: This option generates PDB files with release information, making it suitable for debugging optimized builds.
>* `-DCMAKE_BUILD_TYPE=Debug`: This option generates PDB files optimized for debugging, providing comprehensive debugging information. -4. Build generated solution in Visual Studio or run `cmake --build . --config Release --verbose -j8` to build from the command line. Be aware that this process may take some time. +4. Build generated solution in Visual Studio or run `cmake --build . --config Release --verbose -j` to build from the command line. View the number of available processing units with `WMIC cpu get numberofLogicalProcessors`. Be aware that this process may take some time. 5. Before running the samples, add paths to the Threading Building Blocks (TBB) binaries used for the build to the `%PATH%` environment variable. By default, TBB binaries are downloaded by the CMake-based script to the `/temp/tbb/bin` folder. diff --git a/docs/dev/ci/github_actions/reusable_workflows.md b/docs/dev/ci/github_actions/reusable_workflows.md index 2f3e5734f7fc85..4d9b8ba3efd619 100644 --- a/docs/dev/ci/github_actions/reusable_workflows.md +++ b/docs/dev/ci/github_actions/reusable_workflows.md @@ -1 +1,73 @@ # Overview of the Reusable Workflows used in the OpenVINO GitHub Actions CI + +To reduce duplication and increase maintainability, the common jobs from different workflows are extracted into _reusable workflows_. + +You can find more information about reusing actions and workflows [here](https://github.com/marketplace?type=actions) and [here](https://docs.github.com/en/actions/using-workflows/reusing-workflows). + +The reusable workflows are referenced as `jobs` in several validation workflows. They are structured and behave like [normal jobs](./overview.md#single-job-overview) with their own environment, runner and steps to execute. + +This document describes the setup used in the OpenVINO GitHub Actions. + +## Workflows Organisation + +You can find all the workflows for this repository [here](../../../../.github/workflows). + +Two categories of the workflows are present: +* the workflow files starting with the OS name: e.g. [`linux.yml`](./../../../../.github/workflows/linux.yml), [`windows_conditional_compilation.yml`](./../../../../.github/workflows/windows_conditional_compilation.yml) +* the workflow files starting with the word `job`: e.g., [`job_cxx_unit_tests.yml`](./../../../../.github/workflows/job_cxx_unit_tests.yml), [`job_samples_tests.yml`](./../../../../.github/workflows/job_samples_tests.yml) + +The former are the validation workflows incorporating building and testing of the corresponding OS, architecture and set of tools. Read more [here](./overview.md#structure-of-the-workflows) about these workflows. + +The latter are the _reusable workflows_ that are used as jobs in several other workflows. + +For example, the [`job_python_unit_tests.yml`](./../../../../.github/workflows/job_python_unit_tests.yml) reusable workflow is used in the [`linux.yml`](./../../../../.github/workflows/linux.yml), [`linux_arm64.yml`](./../../../../.github/workflows/linux_arm64.yml), +[`mac.yml`](./../../../../.github/workflows/mac.yml) and [`mac_arm64.yml`](./../../../../.github/workflows/mac_arm64.yml) workflows as a `Python_Unit_Tests` job: +```yaml + Python_Unit_Tests: + name: Python unit tests + needs: [ Build, Smart_CI ] + uses: ./.github/workflows/job_python_unit_tests.yml + with: + runner: 'aks-linux-4-cores-16gb' + container: '{"image": "openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04", "volumes": ["/mount:/mount"]}' + affected-components: ${{ needs.smart_ci.outputs.affected_components }} +``` + +Refer to the next section for the usage reference. + +## Using Reusable Workflows + +Refer to the [official GitHub Actions documentation](https://docs.github.com/en/actions/using-workflows/reusing-workflows#calling-a-reusable-workflow) for a complete reference. + +To use a reusable workflow, it should be referenced as a `job`. The [`job_python_unit_tests.yml`](./../../../../.github/workflows/job_python_unit_tests.yml) reusable workflow example +in the [`linux.yml`](./../../../../.github/workflows/linux.yml) workflow: +```yaml + Python_Unit_Tests: + name: Python unit tests + needs: [ Build, Smart_CI ] + uses: ./.github/workflows/job_python_unit_tests.yml + with: + runner: 'aks-linux-4-cores-16gb' + container: '{"image": "openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04", "volumes": ["/mount:/mount"]}' + affected-components: ${{ needs.smart_ci.outputs.affected_components }} +``` +where: +* `name` - the display name of the job +* `needs` - the job's needs, i.e., the jobs that should be completed before this one starts +* `uses` - the path to the reusable workflow +* `with` - the input keys that will be passed to the reusable workflow. Refer to the workflow file to learn more about its inputs, refer to the [official GitHub Actions documentation](https://docs.github.com/en/actions/using-workflows/reusing-workflows#using-inputs-and-secrets-in-a-reusable-workflow) for a syntax reference + +## Adding Reusable Workflows + +If you would like to add new similar stages to several workflows, consider creating a reusable workflow to reduce duplication. + +The reusable workflows in the OpenVINO GitHub Actions CI usually have: +* the filename starting with `job_`, e.g., [`job_cxx_unit_tests.yml`](./../../../../.github/workflows/job_cxx_unit_tests.yml) +* the `runner` input - the runner name that will be used to execute the steps in a job, learn more about the available runners and how to use them [here](./runners.md) +* the `container` input - JSON to be converted to the value of the "container" configuration for the job, learn more about using Docker in the workflows [here](./docker_images.md) +* *Optional* the `affected-components` input - components that are affected by changes in the commit defined by the Smart CI Action, learn more about the Smart CI system [here](./smart_ci.md) + +*Note*: Per the [GitHub documentation](https://docs.github.com/en/actions/using-workflows/about-workflows#about-workflows), all workflows should be placed under [`./.github/workflows`](./../../../../.github/workflows). + +As the reusable workflows are structured and behave like jobs, refer to [this document](./adding_tests.md) to learn more about creating a job and +use the information about the reusable workflows to make a job into a reusable workflow. diff --git a/docs/notebooks/108-gpu-device-with-output.rst b/docs/notebooks/108-gpu-device-with-output.rst index c116872ec3d462..8cbc04a5516bc4 100644 --- a/docs/notebooks/108-gpu-device-with-output.rst +++ b/docs/notebooks/108-gpu-device-with-output.rst @@ -218,7 +218,7 @@ for that property. indent = len(max(supported_properties, key=len)) for property_key in supported_properties: - if property_key not in ('SUPPORTED_METRICS', 'SUPPORTED_CONFIG_KEYS', 'SUPPORTED_PROPERTIES'): + if property_key not in ('SUPPORTED_PROPERTIES'): try: property_val = core.get_property(device, property_key) except TypeError: diff --git a/docs/snippets/gpu/custom_kernels_api.cpp b/docs/snippets/gpu/custom_kernels_api.cpp index e244c6d47a4cae..44c149de968570 100644 --- a/docs/snippets/gpu/custom_kernels_api.cpp +++ b/docs/snippets/gpu/custom_kernels_api.cpp @@ -5,21 +5,17 @@ # define WAS_OV_LIBRARY_DEFINED #endif -#include "ie_plugin_config.hpp" - #ifdef WAS_OV_LIBRARY_DEFINED # undef IN_OV_COMPONENT # undef WAS_OV_LIBRARY_DEFINED #endif int main() { - IE_SUPPRESS_DEPRECATED_START //! [part0] ov::Core core; // Load GPU Extensions - core.set_property("GPU", {{ CONFIG_KEY(CONFIG_FILE), "" }}); + core.set_property("GPU", {{ "CONFIG_FILE", "" }}); //! [part0] - IE_SUPPRESS_DEPRECATED_END return 0; } diff --git a/docs/snippets/ov_model_snippets.cpp b/docs/snippets/ov_model_snippets.cpp index f821007ebedf00..0a7cc8ad0f08cf 100644 --- a/docs/snippets/ov_model_snippets.cpp +++ b/docs/snippets/ov_model_snippets.cpp @@ -297,7 +297,7 @@ auto pow = std::make_shared(div->input(1).get_source_output() ov::op::v0::Constant::create(div->get_input_element_type(1), ov::Shape{1}, {-1})); auto mul = std::make_shared(div->input(0).get_source_output(), pow); mul->set_friendly_name(div->get_friendly_name()); -ngraph::replace_node(div, mul); +ov::replace_node(div, mul); // ! [ov:replace_friendly_name] } diff --git a/docs/snippets/ov_preprocessing.cpp b/docs/snippets/ov_preprocessing.cpp index 176953f46691f1..640e13b142c78d 100644 --- a/docs/snippets/ov_preprocessing.cpp +++ b/docs/snippets/ov_preprocessing.cpp @@ -1,9 +1,10 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include +#include "openvino/core/graph_util.hpp" +#include "openvino/core/preprocess/pre_post_process.hpp" +#include "openvino/opsets/opset8.hpp" +#include "openvino/runtime/core.hpp" void ppp_input_1(ov::preprocess::PrePostProcessor& ppp) { //! [ov:preprocess:input_1] diff --git a/docs/snippets/ov_preprocessing.py b/docs/snippets/ov_preprocessing.py index 8a8f4ce212b4f7..440b40c980aca4 100644 --- a/docs/snippets/ov_preprocessing.py +++ b/docs/snippets/ov_preprocessing.py @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 # -import openvino.runtime.properties as props +import openvino.properties as props from openvino.preprocess import ResizeAlgorithm, ColorFormat from openvino import Layout, Type, serialize import openvino as ov diff --git a/docs/snippets/template_pattern_transformation.cpp b/docs/snippets/template_pattern_transformation.cpp index 40aeec26c82aee..e1b82c441e3dd6 100644 --- a/docs/snippets/template_pattern_transformation.cpp +++ b/docs/snippets/template_pattern_transformation.cpp @@ -1,10 +1,11 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include "template_pattern_transformation.hpp" #include "openvino/cc/pass/itt.hpp" +#include "openvino/core/graph_util.hpp" #include "openvino/core/rt_info.hpp" #include "openvino/opsets/opset3.hpp" #include "openvino/pass/manager.hpp" diff --git a/docs/snippets/vpu/custom_op.cpp b/docs/snippets/vpu/custom_op.cpp deleted file mode 100644 index 1a94bffd01b28f..00000000000000 --- a/docs/snippets/vpu/custom_op.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "openvino/runtime/core.hpp" -#include "ie_plugin_config.hpp" - -int main() { -//! [part0] -ov::Core core; -// Load Myriad Extensions -core.set_property("MYRIAD", {{CONFIG_KEY(CONFIG_FILE), ""}}); -//! [part0] - -return 0; -} - diff --git a/docs/sphinx_setup/_static/css/custom.css b/docs/sphinx_setup/_static/css/custom.css index ac4a3e1f9386e0..7091e346e5a818 100644 --- a/docs/sphinx_setup/_static/css/custom.css +++ b/docs/sphinx_setup/_static/css/custom.css @@ -261,6 +261,11 @@ div.highlight { .bd-sidebar { top: calc(var(--pst-header-height)); } + +.bd-links { + margin-top: 10px; +} + body { padding-top: calc(var(--pst-header-height)); } diff --git a/docs/sphinx_setup/_static/html/banner_data.json b/docs/sphinx_setup/_static/html/banner_data.json index 77f7bb8e4569be..be5c8a950b291a 100644 --- a/docs/sphinx_setup/_static/html/banner_data.json +++ b/docs/sphinx_setup/_static/html/banner_data.json @@ -1,5 +1,5 @@ { - "p": "OpenVINO 2022.1 has introduced OpenVINO API 2.0. For more information on transition steps from the previous API, see the transition guide", + "p": "", "version": "1", - "style": "info" + "style": "warning" } \ No newline at end of file diff --git a/docs/sphinx_setup/_static/js/graphs.js b/docs/sphinx_setup/_static/js/graphs.js index c3b86fca1b157a..8f02f24207a87b 100644 --- a/docs/sphinx_setup/_static/js/graphs.js +++ b/docs/sphinx_setup/_static/js/graphs.js @@ -23,7 +23,7 @@ const OVdefaultSelections = { 'resnet-50', ] }, - parameters: {name: 'kpi', data: ['Throughput']}, + parameters: {name: 'kpi', data: ['Throughput','Latency']}, pracision: {name: 'precision', data: ['INT8', 'FP32']} } diff --git a/docs/sphinx_setup/_static/js/hide_banner.js b/docs/sphinx_setup/_static/js/hide_banner.js index 76fe65ba041087..54a96ca1a2616c 100644 --- a/docs/sphinx_setup/_static/js/hide_banner.js +++ b/docs/sphinx_setup/_static/js/hide_banner.js @@ -2,40 +2,42 @@ var cookieVersion = 0; window.onload = (e) => { fetch('/build/docs/_build/_static/html/banner_data.json').then((data) => { data.json().then((item) => { - cookieVersion = item.version; - var transitionBanner = document.getElementById("info-banner"); - if (document.cookie.split(';').filter(function (find_cookie_name) { - return find_cookie_name.trim().indexOf('TransitionBannerIsHiddenX' + cookieVersion + '=') === 0; - } - ).length) { - transitionBanner.classList.add("hidden-banner"); - } - transitionBanner.classList.add(item.style); - - const p = document.createElement("p"); - p.innerHTML = item.p; - transitionBanner.append(p); - - const button = document.createElement("button"); - button.className = "close-banner"; - button.type = "button"; - - const span = document.createElement("span"); - span.setAttribute('aria-hidden', 'true'); - span.innerHTML = '×'; - button.appendChild(span); - button.addEventListener("click", function () { - var cookieContent = 'TransitionBannerIsHiddenX' + cookieVersion + '=true;'; - var expiry = 'expires='; - var date = new Date(); - var expirationDate = date.getTime() + (365 * 24 * 60 * 60 * 1000); - date.setTime(expirationDate); - expiry += date.toUTCString(); - document.cookie = cookieContent + expiry; + if(item != null && item.p != "" && item.version != "" && item.style != "" ) { + cookieVersion = item.version; var transitionBanner = document.getElementById("info-banner"); - transitionBanner.classList.add("hidden-banner"); - }); - transitionBanner.append(button) + if (document.cookie.split(';').filter(function (find_cookie_name) { + return find_cookie_name.trim().indexOf('TransitionBannerIsHiddenX' + cookieVersion + '=') === 0; + } + ).length) { + transitionBanner.classList.add("hidden-banner"); + } + transitionBanner.classList.add(item.style); + + const p = document.createElement("p"); + p.innerHTML = item.p; + transitionBanner.append(p); + + const button = document.createElement("button"); + button.className = "close-banner"; + button.type = "button"; + + const span = document.createElement("span"); + span.setAttribute('aria-hidden', 'true'); + span.innerHTML = '×'; + button.appendChild(span); + button.addEventListener("click", function () { + var cookieContent = 'TransitionBannerIsHiddenX' + cookieVersion + '=true;'; + var expiry = 'expires='; + var date = new Date(); + var expirationDate = date.getTime() + (365 * 24 * 60 * 60 * 1000); + date.setTime(expirationDate); + expiry += date.toUTCString(); + document.cookie = cookieContent + expiry; + var transitionBanner = document.getElementById("info-banner"); + transitionBanner.classList.add("hidden-banner"); + }); + transitionBanner.append(button) + } }); }); }; diff --git a/docs/sphinx_setup/api/ie_python_api/api.rst b/docs/sphinx_setup/api/ie_python_api/api.rst index 01fcc7ca30656d..ff41d6ef3a4c9d 100644 --- a/docs/sphinx_setup/api/ie_python_api/api.rst +++ b/docs/sphinx_setup/api/ie_python_api/api.rst @@ -101,6 +101,12 @@ OpenVINO Python API openvino.runtime.opset13 +.. autosummary:: + :toctree: _autosummary + :template: custom-module-template.rst + + openvino.runtime.opset14 + .. autosummary:: :toctree: _autosummary :template: custom-module-template.rst diff --git a/install_build_dependencies.sh b/install_build_dependencies.sh index de2a53a25c9b77..61a8cf5974b202 100755 --- a/install_build_dependencies.sh +++ b/install_build_dependencies.sh @@ -69,9 +69,7 @@ if [ -f /etc/lsb-release ] || [ -f /etc/debian_version ] ; then libffi-dev \ `# spell checking for MO sources` \ python3-enchant \ - `# samples and tools` \ - libgflags-dev \ - zlib1g-dev \ + `# tools` \ wget # TF lite frontend if apt-cache search --names-only '^libflatbuffers-dev'| grep -q libflatbuffers-dev; then @@ -128,10 +126,7 @@ elif [ -f /etc/redhat-release ] || grep -q "rhel" /etc/os-release ; then opencl-headers \ `# python API` \ python3-pip \ - python3-devel \ - `# samples and tools` \ - zlib-devel \ - gflags-devel + python3-devel elif [ -f /etc/os-release ] && grep -q "SUSE" /etc/os-release ; then zypper refresh zypper install -y \ @@ -169,11 +164,7 @@ elif [ -f /etc/os-release ] && grep -q "SUSE" /etc/os-release ; then `# python API` \ python39-pip \ python39-setuptools \ - python39-devel \ - `# samples and tools` \ - zlib-devel \ - gflags-devel-static \ - nlohmann_json-devel + python39-devel elif [ -f /etc/os-release ] && grep -q "raspbian" /etc/os-release; then # Raspbian apt update @@ -200,11 +191,7 @@ elif [ -f /etc/os-release ] && grep -q "raspbian" /etc/os-release; then python3-pip \ python3-venv \ python3-setuptools \ - libpython3-dev \ - `# samples and tools` \ - libgflags-dev \ - zlib1g-dev \ - nlohmann-json-dev + libpython3-dev else echo "Unknown OS, please install build dependencies manually" fi diff --git a/samples/cpp/benchmark_app/main.cpp b/samples/cpp/benchmark_app/main.cpp index 6c3aafc2847eec..29a0b02b85722b 100644 --- a/samples/cpp/benchmark_app/main.cpp +++ b/samples/cpp/benchmark_app/main.cpp @@ -417,18 +417,14 @@ int main(int argc, char* argv[]) { OPENVINO_SUPPRESS_DEPRECATED_START // the rest are individual per-device settings (overriding the values set with perf modes) auto set_throughput_streams = [&]() { - std::string key = getDeviceTypeFromName(device) + "_THROUGHPUT_STREAMS"; + std::string key = ov::num_streams.name(); auto it_device_nstreams = device_nstreams.find(device); if (it_device_nstreams != device_nstreams.end()) { // set to user defined value - if (supported(key)) { - device_config[key] = it_device_nstreams->second; - } else if (supported(ov::num_streams.name())) { + if (supported(ov::num_streams.name())) { // Use API 2.0 key for streams - key = ov::num_streams.name(); device_config[key] = it_device_nstreams->second; } else if (is_virtual_device(device)) { - key = ov::num_streams.name(); update_device_config_for_virtual_device(it_device_nstreams->second, device_config, ov::num_streams); @@ -448,22 +444,18 @@ int main(int argc, char* argv[]) { "information look at README." << slog::endl; - if (supported(key)) { - device_config[key] = std::string(getDeviceTypeFromName(device) + "_THROUGHPUT_AUTO"); - } else if (supported(ov::num_streams.name())) { + if (supported(ov::num_streams.name())) { // Use API 2.0 key for streams - key = ov::num_streams.name(); device_config[key] = ov::streams::AUTO; } else if (is_virtual_device(device)) { // Set nstreams to default value auto if no nstreams specified from cmd line. for (auto& hwdevice : hardware_devices) { - std::string key = std::string(getDeviceTypeFromName(hwdevice) + "_THROUGHPUT_STREAMS"); - auto value = std::string(getDeviceTypeFromName(hwdevice) + "_THROUGHPUT_AUTO"); + ov::Any value = ov::streams::AUTO; setDeviceProperty(core, hwdevice, device_config, ov::num_streams(ov::streams::AUTO), - std::make_pair(key, value)); + std::make_pair(key, value.as())); } } } @@ -839,11 +831,6 @@ int main(int argc, char* argv[]) { for (auto& item : devices_properties) { slog::info << " " << item.first << ": " << slog::endl; for (auto& item2 : item.second.as()) { - OPENVINO_SUPPRESS_DEPRECATED_START - if (item2.first == ov::supported_properties || item2.first == "SUPPORTED_CONFIG_KEYS)" || - item2.first == "SUPPORTED_METRICS") - continue; - OPENVINO_SUPPRESS_DEPRECATED_END slog::info << " " << item2.first << ": " << item2.second.as() << slog::endl; } } diff --git a/samples/cpp/common/utils/include/samples/common.hpp b/samples/cpp/common/utils/include/samples/common.hpp index 6b3f7270c546c5..047e88b24cabff 100644 --- a/samples/cpp/common/utils/include/samples/common.hpp +++ b/samples/cpp/common/utils/include/samples/common.hpp @@ -44,7 +44,7 @@ static constexpr char pcSimpleSort[] = "simple_sort"; /** * @brief Unicode string wrappers */ -#if defined(ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32) +#if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32) # define tchar wchar_t # define tstring std::wstring # define tmain wmain @@ -56,7 +56,7 @@ static constexpr char pcSimpleSort[] = "simple_sort"; # define TSTRING2STRING(tstr) tstr #endif -#if defined(ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32) +#if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32) /** * @brief Convert wstring to string diff --git a/samples/python/hello_query_device/hello_query_device.py b/samples/python/hello_query_device/hello_query_device.py index 8efadc1466eff4..d7557d860c7316 100755 --- a/samples/python/hello_query_device/hello_query_device.py +++ b/samples/python/hello_query_device/hello_query_device.py @@ -28,7 +28,7 @@ def main(): log.info(f'{device} :') log.info('\tSUPPORTED_PROPERTIES:') for property_key in core.get_property(device, 'SUPPORTED_PROPERTIES'): - if property_key not in ('SUPPORTED_METRICS', 'SUPPORTED_CONFIG_KEYS', 'SUPPORTED_PROPERTIES'): + if property_key not in ('SUPPORTED_PROPERTIES'): try: property_val = core.get_property(device, property_key) except TypeError: diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3d7e164d1f9516..67ed291ff62913 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -23,6 +23,4 @@ add_subdirectory(bindings) if(ENABLE_TESTS) add_subdirectory(core/tests) add_subdirectory(tests) -else() - add_subdirectory(tests/ov_helpers/ov_models/ov_builders) endif() diff --git a/src/bindings/c/include/openvino/c/ov_core.h b/src/bindings/c/include/openvino/c/ov_core.h index 45bbeb35da662d..3c06481c6d8c03 100644 --- a/src/bindings/c/include/openvino/c/ov_core.h +++ b/src/bindings/c/include/openvino/c/ov_core.h @@ -171,27 +171,6 @@ ov_core_read_model_unicode(const ov_core_t* core, ov_model_t** model); #endif -/** - * @brief Reads models from IR / ONNX / PDPD / TF / TFLite formats. - * @ingroup ov_core_c_api - * @deprecated Use ov_core_read_model_from_memory_buffer instead. - * @param core A pointer to the ie_core_t instance. - * @param model_str String with a model in IR / ONNX / PDPD / TF / TFLite format, string is null-terminated. - * @param weights Shared pointer to a constant tensor with weights. - * @param model A pointer to the newly created model. - * Reading ONNX / PDPD / TF / TFLite models does not support loading weights from the @p weights tensors. - * @note Created model object shares the weights with the @p weights object. - * Thus, do not create @p weights on temporary data that can be freed later, since the model - * constant data will point to an invalid memory. - * @return Status code of the operation: OK(0) for success. - */ -OPENVINO_C_API(OPENVINO_DEPRECATED( - "This API is deprecated and will be replaced by ov_core_read_model_from_memory_buffer") ov_status_e) -ov_core_read_model_from_memory(const ov_core_t* core, - const char* model_str, - const ov_tensor_t* weights, - ov_model_t** model); - /** * @brief Reads models from IR / ONNX / PDPD / TF / TFLite formats with models string size. * @ingroup ov_core_c_api diff --git a/src/bindings/c/src/ov_core.cpp b/src/bindings/c/src/ov_core.cpp index 2624b93d8d0b28..a1a907403936c6 100644 --- a/src/bindings/c/src/ov_core.cpp +++ b/src/bindings/c/src/ov_core.cpp @@ -132,13 +132,6 @@ ov_status_e ov_core_read_model_from_memory_buffer(const ov_core_t* core, return ov_status_e::OK; } -ov_status_e ov_core_read_model_from_memory(const ov_core_t* core, - const char* model_str, - const ov_tensor_t* weights, - ov_model_t** model) { - return ov_core_read_model_from_memory_buffer(core, model_str, strlen(model_str), weights, model); -} - ov_status_e ov_core_compile_model(const ov_core_t* core, const ov_model_t* model, const char* device_name, diff --git a/src/bindings/c/src/ov_remote_context.cpp b/src/bindings/c/src/ov_remote_context.cpp index 68e802e256973e..f1b9d7cbd6aacf 100644 --- a/src/bindings/c/src/ov_remote_context.cpp +++ b/src/bindings/c/src/ov_remote_context.cpp @@ -20,12 +20,14 @@ const char* ov_property_key_intel_gpu_dev_object_handle = "DEV_OBJECT_HANDLE"; const char* ov_property_key_intel_gpu_va_plane = "VA_PLANE"; inline bool check_intel_gpu_property_value_is_ptr(std::string& key) { - if ((key == ov_property_key_intel_gpu_ocl_context) || (key == ov_property_key_intel_gpu_ocl_queue) || - (key == ov_property_key_intel_gpu_va_device) || (key == ov_property_key_intel_gpu_mem_handle) || - (key == ov_property_key_intel_gpu_dev_object_handle)) - return true; - else - return false; +#ifdef _WIN32 + return (key == ov_property_key_intel_gpu_ocl_context) || (key == ov_property_key_intel_gpu_ocl_queue) || + (key == ov_property_key_intel_gpu_va_device) || (key == ov_property_key_intel_gpu_mem_handle) || + (key == ov_property_key_intel_gpu_dev_object_handle); +#else + return (key == ov_property_key_intel_gpu_ocl_context) || (key == ov_property_key_intel_gpu_ocl_queue) || + (key == ov_property_key_intel_gpu_va_device) || (key == ov_property_key_intel_gpu_mem_handle); +#endif } //!< Properties of intel gpu cannot be compeletly handled by (char*) type, because it contains non-char pointer which diff --git a/src/bindings/c/tests/ov_auto_property_test.cpp b/src/bindings/c/tests/ov_auto_property_test.cpp index 6750092d845c93..74a47cca725d23 100644 --- a/src/bindings/c/tests/ov_auto_property_test.cpp +++ b/src/bindings/c/tests/ov_auto_property_test.cpp @@ -50,4 +50,4 @@ const std::vector test_property_config = { INSTANTIATE_TEST_SUITE_P(ov_auto_plugin_test_properties, ov_auto_plugin_test, - ::testing::ValuesIn(test_property_config)); \ No newline at end of file + ::testing::ValuesIn(test_property_config)); diff --git a/src/bindings/c/tests/ov_core_test.cpp b/src/bindings/c/tests/ov_core_test.cpp index 6d4dbcd28773d4..69762a901d8f69 100644 --- a/src/bindings/c/tests/ov_core_test.cpp +++ b/src/bindings/c/tests/ov_core_test.cpp @@ -78,34 +78,6 @@ TEST_P(ov_core_test, ov_core_read_model_no_bin) { ov_core_free(core); } -OPENVINO_SUPPRESS_DEPRECATED_START -TEST_P(ov_core_test, ov_core_read_model_from_memory) { - ov_core_t* core = nullptr; - OV_EXPECT_OK(ov_core_create(&core)); - EXPECT_NE(nullptr, core); - - std::vector weights_content(content_from_file(bin_file_name.c_str(), true)); - - ov_tensor_t* tensor = nullptr; - ov_shape_t shape; - int64_t dims[2] = {1, (int64_t)weights_content.size()}; - ov_shape_create(2, dims, &shape); - OV_EXPECT_OK(ov_tensor_create_from_host_ptr(ov_element_type_e::U8, shape, weights_content.data(), &tensor)); - EXPECT_NE(nullptr, tensor); - - std::vector xml_content(content_from_file(xml_file_name.c_str(), false)); - ov_model_t* model = nullptr; - OV_EXPECT_OK( - ov_core_read_model_from_memory(core, reinterpret_cast(xml_content.data()), tensor, &model)); - EXPECT_NE(nullptr, model); - - ov_shape_free(&shape); - ov_tensor_free(tensor); - ov_model_free(model); - ov_core_free(core); -} -OPENVINO_SUPPRESS_DEPRECATED_END - TEST_P(ov_core_test, ov_core_read_model_from_memory_buffer_with_size) { ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); diff --git a/src/bindings/js/node/.gitignore b/src/bindings/js/node/.gitignore index ad4dbf11d8e0b5..6bbca841fe2db9 100644 --- a/src/bindings/js/node/.gitignore +++ b/src/bindings/js/node/.gitignore @@ -3,3 +3,7 @@ dist build types ov_runtime + + +*.exp +*.lib diff --git a/src/bindings/js/node/CMakeLists.txt b/src/bindings/js/node/CMakeLists.txt index 1bf6eca9ee8501..cb713db9c753dc 100644 --- a/src/bindings/js/node/CMakeLists.txt +++ b/src/bindings/js/node/CMakeLists.txt @@ -12,6 +12,14 @@ if(CMAKE_COMPILER_IS_GNUCXX AND LINUX AND CMAKE_CXX_COMPILER_VERSION VERSION_LES return() endif() +if(WIN32) + set(CMAKE_JS_LIB ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/node.lib) + set(CMAKE_JS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/win_delay_load_hook.cc) + + set(CMAKE_JS_NODELIB_DEF ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/node-lib.def) + set(CMAKE_JS_NODELIB_TARGET ${CMAKE_JS_LIB}) +endif() + cmake_minimum_required(VERSION 3.14) project(ov_node_addon) @@ -57,15 +65,22 @@ add_library(${PROJECT_NAME} SHARED ${CMAKE_CURRENT_SOURCE_DIR}/src/addon.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/element_type.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/partial_shape_wrap.cpp + + ${CMAKE_JS_SRC} ) target_include_directories(${PROJECT_NAME} PRIVATE "${node-api-headers_SOURCE_DIR}/include" "${node-addon-api_SOURCE_DIR}" - "${CMAKE_CURRENT_SOURCE_DIR}/include" + "${CMAKE_CURRENT_SOURCE_DIR}/.." ) -target_link_libraries(${PROJECT_NAME} PRIVATE openvino::runtime) +target_link_libraries(${PROJECT_NAME} PRIVATE openvino::runtime ${CMAKE_JS_LIB}) + +if(MSVC AND CMAKE_JS_NODELIB_DEF AND CMAKE_JS_NODELIB_TARGET) + # Generate node.lib + execute_process(COMMAND ${CMAKE_AR} /def:${CMAKE_JS_NODELIB_DEF} /out:${CMAKE_JS_NODELIB_TARGET} ${CMAKE_STATIC_LINKER_FLAGS}) +endif() if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG) ov_add_compiler_flags(-Wno-missing-declarations) diff --git a/src/bindings/js/node/README.md b/src/bindings/js/node/README.md index f9ba10c4eff70f..544eb7e60f27f3 100644 --- a/src/bindings/js/node/README.md +++ b/src/bindings/js/node/README.md @@ -11,8 +11,25 @@ - Make sure that all submodules are updated `git submodule update --init --recursive` - Create build dir `mkdir build && cd build` -- To get binaries for openvinojs-node package run: - `cmake -DCPACK_GENERATOR=NPM -DENABLE_SYSTEM_TBB=OFF -UTBB* -DCMAKE_INSTALL_PREFIX=../src/bindings/js/node/bin ..` +- To configure binaries building run: + + ### Linux x86, Linux arm, Mac x86, Mac arm + ```bash + cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DENABLE_FASTER_BUILD=ON \ + -DCPACK_GENERATOR=NPM \ + -DENABLE_SYSTEM_TBB=OFF -UTBB* \ + -DENABLE_TESTS=OFF \ + -DENABLE_SAMPLES=OFF \ + -DENABLE_WHEEL=OFF \ + -DENABLE_PYTHON=OFF \ + -DENABLE_INTEL_GPU=OFF \ + -DCMAKE_INSTALL_PREFIX=../src/bindings/js/node/bin \ + .. + ``` + +- To get binaries for openvinojs-node package run compilation: `make --jobs=$(nproc --all) install` - Go to npm package folder `cd ../src/bindings/js/node` - Now you can install dependencies packages and transpile ts to js code. Run `npm install` diff --git a/src/bindings/js/node/include/async_reader.hpp b/src/bindings/js/node/include/async_reader.hpp index 55081889184232..b5872184328b52 100644 --- a/src/bindings/js/node/include/async_reader.hpp +++ b/src/bindings/js/node/include/async_reader.hpp @@ -5,7 +5,6 @@ #include -#include "model_wrap.hpp" #include "openvino/runtime/core.hpp" #include "read_model_args.hpp" diff --git a/src/bindings/js/node/include/core_wrap.hpp b/src/bindings/js/node/include/core_wrap.hpp index b746b6788dc7fd..13732e26d7a918 100644 --- a/src/bindings/js/node/include/core_wrap.hpp +++ b/src/bindings/js/node/include/core_wrap.hpp @@ -7,8 +7,6 @@ #include -#include "async_reader.hpp" -#include "errors.hpp" #include "openvino/runtime/core.hpp" class CoreWrap : public Napi::ObjectWrap { diff --git a/src/bindings/js/node/include/element_type.hpp b/src/bindings/js/node/include/element_type.hpp index 25ecac6f863c3b..7ff79a433a8214 100644 --- a/src/bindings/js/node/include/element_type.hpp +++ b/src/bindings/js/node/include/element_type.hpp @@ -4,8 +4,6 @@ #pragma once #include -#include "helper.hpp" - namespace element { /** @brief Exports JavaScript element enum. */ Napi::Object init(Napi::Env env, Napi::Object exports); diff --git a/src/bindings/js/node/include/helper.hpp b/src/bindings/js/node/include/helper.hpp index e94f5eae314cd6..796eaee4014046 100644 --- a/src/bindings/js/node/include/helper.hpp +++ b/src/bindings/js/node/include/helper.hpp @@ -7,7 +7,6 @@ #include #include -#include "element_type.hpp" #include "openvino/core/type/element_type.hpp" #include "openvino/openvino.hpp" diff --git a/src/bindings/js/node/include/infer_request.hpp b/src/bindings/js/node/include/infer_request.hpp index 1aaee2107af29e..483ac422e69426 100644 --- a/src/bindings/js/node/include/infer_request.hpp +++ b/src/bindings/js/node/include/infer_request.hpp @@ -3,6 +3,7 @@ #pragma once #include + #include #include "openvino/runtime/infer_request.hpp" @@ -101,8 +102,11 @@ class InferRequestWrap : public Napi::ObjectWrap { /** @brief Checks incoming Napi::Value and calls overloaded infer() method */ Napi::Value infer_dispatch(const Napi::CallbackInfo& info); +// 131123 +#ifndef _WIN32 /** @brief Checks incoming Napi::Value and asynchronously returns the result of inference. */ Napi::Value infer_async(const Napi::CallbackInfo& info); +#endif /** @brief Infers specified inputs in synchronous mode. * @param inputs An object with a collection of pairs key (input_name) and a value (tensor, tensor's data) diff --git a/src/bindings/js/node/include/model_wrap.hpp b/src/bindings/js/node/include/model_wrap.hpp index cedb965045b1f0..39c2a078b0d646 100644 --- a/src/bindings/js/node/include/model_wrap.hpp +++ b/src/bindings/js/node/include/model_wrap.hpp @@ -5,11 +5,8 @@ #include -#include "compiled_model.hpp" -#include "errors.hpp" #include "openvino/core/model.hpp" #include "openvino/runtime/core.hpp" -#include "tensor.hpp" class ModelWrap : public Napi::ObjectWrap { public: diff --git a/src/bindings/js/node/include/node_output.hpp b/src/bindings/js/node/include/node_output.hpp index e7038690fe05cf..0e1561d85f5edf 100644 --- a/src/bindings/js/node/include/node_output.hpp +++ b/src/bindings/js/node/include/node_output.hpp @@ -5,7 +5,6 @@ #include -#include "helper.hpp" #include "openvino/core/node_output.hpp" template diff --git a/src/bindings/js/node/include/partial_shape_wrap.hpp b/src/bindings/js/node/include/partial_shape_wrap.hpp index d52baf3ab01d67..236012bd291141 100644 --- a/src/bindings/js/node/include/partial_shape_wrap.hpp +++ b/src/bindings/js/node/include/partial_shape_wrap.hpp @@ -5,8 +5,6 @@ #include -#include "errors.hpp" -#include "helper.hpp" #include "openvino/core/partial_shape.hpp" class PartialShapeWrap : public Napi::ObjectWrap { diff --git a/src/bindings/js/node/include/preprocess/pre_post_process_wrap.hpp b/src/bindings/js/node/include/preprocess/pre_post_process_wrap.hpp index a751a3c7588472..8e525b22431fb6 100644 --- a/src/bindings/js/node/include/preprocess/pre_post_process_wrap.hpp +++ b/src/bindings/js/node/include/preprocess/pre_post_process_wrap.hpp @@ -5,14 +5,7 @@ #include -#include "element_type.hpp" -#include "errors.hpp" -#include "helper.hpp" -#include "model_wrap.hpp" #include "openvino/core/preprocess/pre_post_process.hpp" -#include "openvino/openvino.hpp" -#include "preprocess/input_info.hpp" -#include "preprocess/output_info.hpp" class PrePostProcessorWrap : public Napi::ObjectWrap { public: diff --git a/src/bindings/js/node/include/preprocess/preprocess.hpp b/src/bindings/js/node/include/preprocess/preprocess.hpp index eb0c172abd0d31..b88b0ac554f251 100644 --- a/src/bindings/js/node/include/preprocess/preprocess.hpp +++ b/src/bindings/js/node/include/preprocess/preprocess.hpp @@ -5,16 +5,11 @@ #include -#include "openvino/openvino.hpp" - -#include "preprocess/resize_algorithm.hpp" -#include "preprocess/pre_post_process_wrap.hpp" - namespace preprocess { - /** @brief This method is called during initialization of OpenVINO native add-on. - * It exports JavaScript preprocess property. - */ - Napi::Object init(Napi::Env env, Napi::Object exports); +/** @brief This method is called during initialization of OpenVINO native add-on. + * It exports JavaScript preprocess property. + */ +Napi::Object init(Napi::Env env, Napi::Object exports); - Napi::Value add_preprocess_namespace(const Napi::CallbackInfo& info); -}; +Napi::Value add_preprocess_namespace(const Napi::CallbackInfo& info); +}; // namespace preprocess diff --git a/src/bindings/js/node/include/preprocess/preprocess_steps.hpp b/src/bindings/js/node/include/preprocess/preprocess_steps.hpp index e44885962549a7..e0e4be559385c4 100644 --- a/src/bindings/js/node/include/preprocess/preprocess_steps.hpp +++ b/src/bindings/js/node/include/preprocess/preprocess_steps.hpp @@ -5,11 +5,10 @@ #include -#include "errors.hpp" -#include "helper.hpp" +#include "node/include/errors.hpp" +#include "node/include/helper.hpp" #include "openvino/core/preprocess/preprocess_steps.hpp" - class PreProcessSteps : public Napi::ObjectWrap { public: PreProcessSteps(const Napi::CallbackInfo& info); @@ -18,7 +17,7 @@ class PreProcessSteps : public Napi::ObjectWrap { Napi::Value resize(const Napi::CallbackInfo& info); - void set_preprocess_info(ov::preprocess::PreProcessSteps& info) ; + void set_preprocess_info(ov::preprocess::PreProcessSteps& info); private: ov::preprocess::PreProcessSteps* _preprocess_info; diff --git a/src/bindings/js/node/include/preprocess/resize_algorithm.hpp b/src/bindings/js/node/include/preprocess/resize_algorithm.hpp index 493ea634d616e1..781c05bafdd488 100644 --- a/src/bindings/js/node/include/preprocess/resize_algorithm.hpp +++ b/src/bindings/js/node/include/preprocess/resize_algorithm.hpp @@ -4,7 +4,5 @@ #pragma once #include -#include "helper.hpp" - /** \brief Creates JS object to represent C++ enum class ResizeAlgorithm */ Napi::Value enumResizeAlgorithm(const Napi::CallbackInfo& info); diff --git a/src/bindings/js/node/include/tensor.hpp b/src/bindings/js/node/include/tensor.hpp index e531be6671a9bf..91285a77097b61 100644 --- a/src/bindings/js/node/include/tensor.hpp +++ b/src/bindings/js/node/include/tensor.hpp @@ -5,12 +5,6 @@ #include -#include "element_type.hpp" -#include "errors.hpp" -#include "helper.hpp" -#include "openvino/core/shape.hpp" -#include "openvino/core/type/element_type.hpp" -#include "openvino/runtime/compiled_model.hpp" #include "openvino/runtime/tensor.hpp" class TensorWrap : public Napi::ObjectWrap { diff --git a/src/bindings/js/node/src/addon.cpp b/src/bindings/js/node/src/addon.cpp index 3b619104edb0a9..64d5273eebaef6 100644 --- a/src/bindings/js/node/src/addon.cpp +++ b/src/bindings/js/node/src/addon.cpp @@ -1,20 +1,20 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 -#include "addon.hpp" +#include "node/include/addon.hpp" #include -#include "compiled_model.hpp" -#include "core_wrap.hpp" -#include "element_type.hpp" -#include "infer_request.hpp" -#include "model_wrap.hpp" -#include "node_output.hpp" +#include "node/include/compiled_model.hpp" +#include "node/include/core_wrap.hpp" +#include "node/include/element_type.hpp" +#include "node/include/infer_request.hpp" +#include "node/include/model_wrap.hpp" +#include "node/include/node_output.hpp" +#include "node/include/partial_shape_wrap.hpp" +#include "node/include/preprocess/preprocess.hpp" +#include "node/include/tensor.hpp" #include "openvino/openvino.hpp" -#include "partial_shape_wrap.hpp" -#include "preprocess/preprocess.hpp" -#include "tensor.hpp" void init_class(Napi::Env env, Napi::Object exports, diff --git a/src/bindings/js/node/src/async_reader.cpp b/src/bindings/js/node/src/async_reader.cpp index f9e104d67053fa..bcdd6b84e94ec1 100644 --- a/src/bindings/js/node/src/async_reader.cpp +++ b/src/bindings/js/node/src/async_reader.cpp @@ -1,7 +1,9 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 -#include "async_reader.hpp" +#include "node/include/async_reader.hpp" + +#include "node/include/model_wrap.hpp" void ReaderWorker::Execute() { ov::Core core; diff --git a/src/bindings/js/node/src/compiled_model.cpp b/src/bindings/js/node/src/compiled_model.cpp index 82deba2a7d93ea..fa7c959fd01db8 100644 --- a/src/bindings/js/node/src/compiled_model.cpp +++ b/src/bindings/js/node/src/compiled_model.cpp @@ -1,12 +1,12 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 -#include "compiled_model.hpp" +#include "node/include/compiled_model.hpp" -#include "addon.hpp" -#include "errors.hpp" -#include "infer_request.hpp" -#include "node_output.hpp" +#include "node/include/addon.hpp" +#include "node/include/errors.hpp" +#include "node/include/infer_request.hpp" +#include "node/include/node_output.hpp" CompiledModelWrap::CompiledModelWrap(const Napi::CallbackInfo& info) : Napi::ObjectWrap(info), @@ -70,7 +70,7 @@ Napi::Value CompiledModelWrap::get_outputs(const Napi::CallbackInfo& info) { auto cm_outputs = _compiled_model.outputs(); // Output Napi::Array js_outputs = Napi::Array::New(info.Env(), cm_outputs.size()); - size_t i = 0; + uint32_t i = 0; for (auto& out : cm_outputs) js_outputs[i++] = Output::wrap(info.Env(), out); @@ -104,7 +104,7 @@ Napi::Value CompiledModelWrap::get_inputs(const Napi::CallbackInfo& info) { auto cm_inputs = _compiled_model.inputs(); // Output Napi::Array js_inputs = Napi::Array::New(info.Env(), cm_inputs.size()); - size_t i = 0; + uint32_t i = 0; for (auto& out : cm_inputs) js_inputs[i++] = Output::wrap(info.Env(), out); diff --git a/src/bindings/js/node/src/core_wrap.cpp b/src/bindings/js/node/src/core_wrap.cpp index 1378d2e59ca0ac..743fbb811f8a6d 100644 --- a/src/bindings/js/node/src/core_wrap.cpp +++ b/src/bindings/js/node/src/core_wrap.cpp @@ -1,12 +1,15 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 -#include "core_wrap.hpp" +#include "node/include/core_wrap.hpp" -#include "addon.hpp" -#include "compiled_model.hpp" -#include "model_wrap.hpp" -#include "read_model_args.hpp" +#include "node/include/addon.hpp" +#include "node/include/async_reader.hpp" +#include "node/include/compiled_model.hpp" +#include "node/include/errors.hpp" +#include "node/include/helper.hpp" +#include "node/include/model_wrap.hpp" +#include "node/include/read_model_args.hpp" CoreWrap::CoreWrap(const Napi::CallbackInfo& info) : Napi::ObjectWrap(info), _core{} {} @@ -221,7 +224,7 @@ Napi::Value CoreWrap::get_available_devices(const Napi::CallbackInfo& info) { const auto& devices = _core.get_available_devices(); Napi::Array js_devices = Napi::Array::New(info.Env(), devices.size()); - size_t i = 0; + uint32_t i = 0; for (const auto& dev : devices) js_devices[i++] = dev; diff --git a/src/bindings/js/node/src/element_type.cpp b/src/bindings/js/node/src/element_type.cpp index 54458dc028732f..6b8a7956168ca6 100644 --- a/src/bindings/js/node/src/element_type.cpp +++ b/src/bindings/js/node/src/element_type.cpp @@ -1,10 +1,9 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 -#include "element_type.hpp" +#include "node/include/element_type.hpp" -#include -#include +#include "node/include/helper.hpp" namespace element { Napi::Object init(Napi::Env env, Napi::Object exports) { diff --git a/src/bindings/js/node/src/errors.cpp b/src/bindings/js/node/src/errors.cpp index ce527bed1586fd..62b20d107781a4 100644 --- a/src/bindings/js/node/src/errors.cpp +++ b/src/bindings/js/node/src/errors.cpp @@ -1,7 +1,7 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 -#include "errors.hpp" +#include "node/include/errors.hpp" void reportError(const Napi::Env& env, std::string msg) { Napi::Error::New(env, msg).ThrowAsJavaScriptException(); diff --git a/src/bindings/js/node/src/helper.cpp b/src/bindings/js/node/src/helper.cpp index 3484c3b1b8b91b..c22398985ab54f 100644 --- a/src/bindings/js/node/src/helper.cpp +++ b/src/bindings/js/node/src/helper.cpp @@ -1,9 +1,9 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 -#include "helper.hpp" +#include "node/include/helper.hpp" -#include "tensor.hpp" +#include "node/include/tensor.hpp" const std::vector& get_supported_types() { static const std::vector supported_element_types = @@ -67,7 +67,7 @@ std::vector js_to_cpp>(const Napi::CallbackInfo& inf std::vector nativeArray; - for (size_t i = 0; i < arrayLength; ++i) { + for (uint32_t i = 0; i < arrayLength; ++i) { Napi::Value arrayItem = array[i]; if (!arrayItem.IsNumber()) { OPENVINO_THROW(std::string("Passed array must contain only numbers.")); @@ -107,7 +107,7 @@ std::unordered_set js_to_cpp>( std::unordered_set nativeArray; - for (size_t i = 0; i < arrayLength; ++i) { + for (uint32_t i = 0; i < arrayLength; ++i) { Napi::Value arrayItem = array[i]; if (!arrayItem.IsString()) { OPENVINO_THROW(std::string("Passed array must contain only strings.")); @@ -199,7 +199,7 @@ std::map js_to_cpp>( const auto& config = elem.ToObject(); const auto& keys = config.GetPropertyNames(); - for (size_t i = 0; i < keys.Length(); ++i) { + for (uint32_t i = 0; i < keys.Length(); ++i) { const std::string& option = static_cast(keys[i]).ToString(); properties_to_cpp[option] = js_to_cpp(config.Get(option), {napi_string}); } @@ -216,7 +216,7 @@ Napi::String cpp_to_js(const Napi::CallbackIn template <> Napi::Array cpp_to_js(const Napi::CallbackInfo& info, const ov::Shape shape) { auto arr = Napi::Array::New(info.Env(), shape.size()); - for (size_t i = 0; i < shape.size(); ++i) + for (uint32_t i = 0; i < shape.size(); ++i) arr[i] = shape[i]; return arr; } @@ -226,7 +226,7 @@ Napi::Array cpp_to_js(const Napi::CallbackInfo& i size_t size = shape.size(); Napi::Array dimensions = Napi::Array::New(info.Env(), size); - for (size_t i = 0; i < size; i++) { + for (uint32_t i = 0; i < size; i++) { ov::Dimension dim = shape[i]; if (dim.is_static()) { @@ -254,7 +254,7 @@ Napi::Array cpp_to_js(const Napi::CallbackInfo& info // Indexes looks wierd, but clear assignment, // like: interval[0] = value doesn't work here - size_t indexes[] = {0, 1}; + uint32_t indexes[] = {0, 1}; interval[indexes[0]] = dim.get_min_length(); interval[indexes[1]] = dim.get_max_length(); @@ -270,13 +270,13 @@ ov::TensorVector parse_input_data(const Napi::Value& input) { ov::TensorVector parsed_input; if (input.IsArray()) { auto inputs = input.As(); - for (size_t i = 0; i < inputs.Length(); ++i) { + for (uint32_t i = 0; i < inputs.Length(); ++i) { parsed_input.emplace_back(cast_to_tensor(static_cast(inputs[i]))); } } else if (input.IsObject()) { auto inputs = input.ToObject(); const auto& keys = inputs.GetPropertyNames(); - for (size_t i = 0; i < keys.Length(); ++i) { + for (uint32_t i = 0; i < keys.Length(); ++i) { auto value = inputs.Get(static_cast(keys[i]).ToString().Utf8Value()); parsed_input.emplace_back(cast_to_tensor(static_cast(value))); } diff --git a/src/bindings/js/node/src/infer_request.cpp b/src/bindings/js/node/src/infer_request.cpp index 2a61411fb8d420..b8e1f809af2e2a 100644 --- a/src/bindings/js/node/src/infer_request.cpp +++ b/src/bindings/js/node/src/infer_request.cpp @@ -1,15 +1,16 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 -#include "infer_request.hpp" +#include "node/include/infer_request.hpp" #include -#include -#include "addon.hpp" -#include "compiled_model.hpp" -#include "node_output.hpp" -#include "tensor.hpp" +#include "node/include/addon.hpp" +#include "node/include/compiled_model.hpp" +#include "node/include/errors.hpp" +#include "node/include/helper.hpp" +#include "node/include/node_output.hpp" +#include "node/include/tensor.hpp" namespace { std::mutex infer_mutex; @@ -30,7 +31,10 @@ Napi::Function InferRequestWrap::get_class(Napi::Env env) { InstanceMethod("getInputTensor", &InferRequestWrap::get_input_tensor), InstanceMethod("getOutputTensor", &InferRequestWrap::get_output_tensor), InstanceMethod("infer", &InferRequestWrap::infer_dispatch), + // 128760 +#ifndef _WIN32 InstanceMethod("inferAsync", &InferRequestWrap::infer_async), +#endif InstanceMethod("getCompiledModel", &InferRequestWrap::get_compiled_model), }); } @@ -171,7 +175,7 @@ Napi::Value InferRequestWrap::infer_dispatch(const Napi::CallbackInfo& info) { } void InferRequestWrap::infer(const Napi::Array& inputs) { - for (size_t i = 0; i < inputs.Length(); ++i) { + for (uint32_t i = 0; i < inputs.Length(); ++i) { auto tensor = value_to_tensor(inputs[i], _infer_request, i); _infer_request.set_input_tensor(i, tensor); } @@ -181,7 +185,7 @@ void InferRequestWrap::infer(const Napi::Array& inputs) { void InferRequestWrap::infer(const Napi::Object& inputs) { const auto& keys = inputs.GetPropertyNames(); - for (size_t i = 0; i < keys.Length(); ++i) { + for (uint32_t i = 0; i < keys.Length(); ++i) { auto input_name = static_cast(keys[i]).ToString().Utf8Value(); auto value = inputs.Get(input_name); auto tensor = value_to_tensor(value, _infer_request, input_name); @@ -194,7 +198,8 @@ void InferRequestWrap::infer(const Napi::Object& inputs) { Napi::Value InferRequestWrap::get_compiled_model(const Napi::CallbackInfo& info) { return CompiledModelWrap::wrap(info.Env(), _infer_request.get_compiled_model()); } - +// 131123 +#ifndef _WIN32 void FinalizerCallback(Napi::Env env, void* finalizeData, TsfnContext* context) { context->native_thread.join(); delete context; @@ -256,3 +261,4 @@ Napi::Value InferRequestWrap::infer_async(const Napi::CallbackInfo& info) { context->native_thread = std::thread(performInferenceThread, context); return context->deferred.Promise(); } +#endif diff --git a/src/bindings/js/node/src/model_wrap.cpp b/src/bindings/js/node/src/model_wrap.cpp index 9ba601cc728daa..f81c2b027db56f 100644 --- a/src/bindings/js/node/src/model_wrap.cpp +++ b/src/bindings/js/node/src/model_wrap.cpp @@ -1,10 +1,11 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 -#include "model_wrap.hpp" +#include "node/include/model_wrap.hpp" -#include "addon.hpp" -#include "node_output.hpp" +#include "node/include/addon.hpp" +#include "node/include/errors.hpp" +#include "node/include/node_output.hpp" ModelWrap::ModelWrap(const Napi::CallbackInfo& info) : Napi::ObjectWrap(info), @@ -99,7 +100,7 @@ Napi::Value ModelWrap::get_inputs(const Napi::CallbackInfo& info) { auto cm_inputs = _model->inputs(); // Output Napi::Array js_inputs = Napi::Array::New(info.Env(), cm_inputs.size()); - size_t i = 0; + uint32_t i = 0; for (auto& input : cm_inputs) js_inputs[i++] = Output::wrap(info.Env(), input); @@ -110,7 +111,7 @@ Napi::Value ModelWrap::get_outputs(const Napi::CallbackInfo& info) { auto cm_outputs = _model->outputs(); // Output Napi::Array js_outputs = Napi::Array::New(info.Env(), cm_outputs.size()); - size_t i = 0; + uint32_t i = 0; for (auto& out : cm_outputs) js_outputs[i++] = Output::wrap(info.Env(), out); diff --git a/src/bindings/js/node/src/node_output.cpp b/src/bindings/js/node/src/node_output.cpp index 4c2fba452c4cd4..444b35255ccc74 100644 --- a/src/bindings/js/node/src/node_output.cpp +++ b/src/bindings/js/node/src/node_output.cpp @@ -1,11 +1,11 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 -#include "node_output.hpp" +#include "node/include/node_output.hpp" -#include "addon.hpp" -#include "helper.hpp" -#include "partial_shape_wrap.hpp" +#include "node/include/addon.hpp" +#include "node/include/helper.hpp" +#include "node/include/partial_shape_wrap.hpp" Output::Output(const Napi::CallbackInfo& info) : Napi::ObjectWrap>(info), _output{} {} diff --git a/src/bindings/js/node/src/partial_shape_wrap.cpp b/src/bindings/js/node/src/partial_shape_wrap.cpp index 7f7ef05e53d3cd..f9632d2f2b20f7 100644 --- a/src/bindings/js/node/src/partial_shape_wrap.cpp +++ b/src/bindings/js/node/src/partial_shape_wrap.cpp @@ -1,9 +1,11 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 -#include "partial_shape_wrap.hpp" +#include "node/include/partial_shape_wrap.hpp" -#include "addon.hpp" +#include "node/include/addon.hpp" +#include "node/include/errors.hpp" +#include "node/include/helper.hpp" PartialShapeWrap::PartialShapeWrap(const Napi::CallbackInfo& info) : Napi::ObjectWrap(info) { const size_t attrs_length = info.Length(); diff --git a/src/bindings/js/node/src/preprocess/input_info.cpp b/src/bindings/js/node/src/preprocess/input_info.cpp index 09165c4c617083..d1504d83dd7233 100644 --- a/src/bindings/js/node/src/preprocess/input_info.cpp +++ b/src/bindings/js/node/src/preprocess/input_info.cpp @@ -1,12 +1,12 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 -#include "preprocess/input_info.hpp" +#include "node/include/preprocess/input_info.hpp" -#include "errors.hpp" -#include "preprocess/input_model_info.hpp" -#include "preprocess/input_tensor_info.hpp" -#include "preprocess/preprocess_steps.hpp" +#include "node/include/errors.hpp" +#include "node/include/preprocess/input_model_info.hpp" +#include "node/include/preprocess/input_tensor_info.hpp" +#include "node/include/preprocess/preprocess_steps.hpp" InputInfo::InputInfo(const Napi::CallbackInfo& info) : Napi::ObjectWrap(info){}; diff --git a/src/bindings/js/node/src/preprocess/input_model_info.cpp b/src/bindings/js/node/src/preprocess/input_model_info.cpp index 91dd706edd80c2..5756154fc8f368 100644 --- a/src/bindings/js/node/src/preprocess/input_model_info.cpp +++ b/src/bindings/js/node/src/preprocess/input_model_info.cpp @@ -1,12 +1,10 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 -#include "preprocess/input_model_info.hpp" +#include "node/include/preprocess/input_model_info.hpp" -#include - -#include "errors.hpp" -#include "helper.hpp" +#include "node/include/errors.hpp" +#include "node/include/helper.hpp" InputModelInfo::InputModelInfo(const Napi::CallbackInfo& info) : Napi::ObjectWrap(info){}; diff --git a/src/bindings/js/node/src/preprocess/input_tensor_info.cpp b/src/bindings/js/node/src/preprocess/input_tensor_info.cpp index 5416b56cacc13d..38ab2779ffc275 100644 --- a/src/bindings/js/node/src/preprocess/input_tensor_info.cpp +++ b/src/bindings/js/node/src/preprocess/input_tensor_info.cpp @@ -1,10 +1,10 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 -#include "preprocess/input_tensor_info.hpp" +#include "node/include/preprocess/input_tensor_info.hpp" -#include "errors.hpp" -#include "helper.hpp" +#include "node/include/errors.hpp" +#include "node/include/helper.hpp" InputTensorInfo::InputTensorInfo(const Napi::CallbackInfo& info) : Napi::ObjectWrap(info){}; diff --git a/src/bindings/js/node/src/preprocess/output_info.cpp b/src/bindings/js/node/src/preprocess/output_info.cpp index 9fa81e615119b1..3422228f70a979 100644 --- a/src/bindings/js/node/src/preprocess/output_info.cpp +++ b/src/bindings/js/node/src/preprocess/output_info.cpp @@ -1,10 +1,10 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 -#include "preprocess/output_info.hpp" +#include "node/include/preprocess/output_info.hpp" -#include "errors.hpp" -#include "preprocess/output_tensor_info.hpp" +#include "node/include/errors.hpp" +#include "node/include/preprocess/output_tensor_info.hpp" OutputInfo::OutputInfo(const Napi::CallbackInfo& info) : Napi::ObjectWrap(info){}; diff --git a/src/bindings/js/node/src/preprocess/output_tensor_info.cpp b/src/bindings/js/node/src/preprocess/output_tensor_info.cpp index f544f2477f3238..32886187d5f9e1 100644 --- a/src/bindings/js/node/src/preprocess/output_tensor_info.cpp +++ b/src/bindings/js/node/src/preprocess/output_tensor_info.cpp @@ -1,10 +1,10 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 -#include "preprocess/output_tensor_info.hpp" +#include "node/include/preprocess/output_tensor_info.hpp" -#include "errors.hpp" -#include "helper.hpp" +#include "node/include/errors.hpp" +#include "node/include/helper.hpp" OutputTensorInfo::OutputTensorInfo(const Napi::CallbackInfo& info) : Napi::ObjectWrap(info){}; diff --git a/src/bindings/js/node/src/preprocess/pre_post_process_wrap.cpp b/src/bindings/js/node/src/preprocess/pre_post_process_wrap.cpp index b715647c8f2b58..c8a4c801471d05 100644 --- a/src/bindings/js/node/src/preprocess/pre_post_process_wrap.cpp +++ b/src/bindings/js/node/src/preprocess/pre_post_process_wrap.cpp @@ -1,9 +1,12 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 -#include "preprocess/pre_post_process_wrap.hpp" +#include "node/include/preprocess/pre_post_process_wrap.hpp" -#include "addon.hpp" +#include "node/include/errors.hpp" +#include "node/include/model_wrap.hpp" +#include "node/include/preprocess/input_info.hpp" +#include "node/include/preprocess/output_info.hpp" PrePostProcessorWrap::PrePostProcessorWrap(const Napi::CallbackInfo& info) : Napi::ObjectWrap(info) { diff --git a/src/bindings/js/node/src/preprocess/preprocess.cpp b/src/bindings/js/node/src/preprocess/preprocess.cpp index 983f6e706f34f6..5ccd1c65d52f68 100644 --- a/src/bindings/js/node/src/preprocess/preprocess.cpp +++ b/src/bindings/js/node/src/preprocess/preprocess.cpp @@ -1,9 +1,11 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 -#include "preprocess/preprocess.hpp" +#include "node/include/preprocess/preprocess.hpp" -#include "addon.hpp" +#include "node/include/addon.hpp" +#include "node/include/preprocess/pre_post_process_wrap.hpp" +#include "node/include/preprocess/resize_algorithm.hpp" namespace preprocess { Napi::Object init(Napi::Env env, Napi::Object exports) { diff --git a/src/bindings/js/node/src/preprocess/preprocess_steps.cpp b/src/bindings/js/node/src/preprocess/preprocess_steps.cpp index 29ccd067d209f2..75b3c077799658 100644 --- a/src/bindings/js/node/src/preprocess/preprocess_steps.cpp +++ b/src/bindings/js/node/src/preprocess/preprocess_steps.cpp @@ -1,7 +1,7 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 -#include "preprocess/preprocess_steps.hpp" +#include "node/include/preprocess/preprocess_steps.hpp" PreProcessSteps::PreProcessSteps(const Napi::CallbackInfo& info) : Napi::ObjectWrap(info){}; diff --git a/src/bindings/js/node/src/preprocess/resize_algorithm.cpp b/src/bindings/js/node/src/preprocess/resize_algorithm.cpp index 1447d5ee972965..cfaa32c28c9153 100644 --- a/src/bindings/js/node/src/preprocess/resize_algorithm.cpp +++ b/src/bindings/js/node/src/preprocess/resize_algorithm.cpp @@ -1,11 +1,9 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 -#include "preprocess/resize_algorithm.hpp" +#include "node/include/preprocess/resize_algorithm.hpp" -#include - -#include "openvino/runtime/core.hpp" +#include Napi::Value enumResizeAlgorithm(const Napi::CallbackInfo& info) { auto enumObj = Napi::Object::New(info.Env()); diff --git a/src/bindings/js/node/src/tensor.cpp b/src/bindings/js/node/src/tensor.cpp index 1c9f67240c416d..a062db821cdbd5 100644 --- a/src/bindings/js/node/src/tensor.cpp +++ b/src/bindings/js/node/src/tensor.cpp @@ -1,9 +1,13 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 -#include "tensor.hpp" +#include "node/include/tensor.hpp" -#include "addon.hpp" +#include "node/include/addon.hpp" +#include "node/include/errors.hpp" +#include "node/include/helper.hpp" +#include "openvino/core/shape.hpp" +#include "openvino/core/type/element_type.hpp" TensorWrap::TensorWrap(const Napi::CallbackInfo& info) : Napi::ObjectWrap(info) { if (info.Length() == 0) { diff --git a/src/bindings/js/node/tests/infer_request.test.js b/src/bindings/js/node/tests/infer_request.test.js index 513a2a3324bcbf..bd05da9400c998 100644 --- a/src/bindings/js/node/tests/infer_request.test.js +++ b/src/bindings/js/node/tests/infer_request.test.js @@ -2,6 +2,7 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 +const os = require('node:os'); const { addon: ov } = require('..'); const assert = require('assert'); const { describe, it } = require('node:test'); @@ -78,35 +79,38 @@ describe('InferRequest', () => { }); }); - it('Test inferAsync(inputData: { [inputName: string]: Tensor })', () => { - inferRequestAsync.inferAsync({ data: tensor }).then(result => { - assert.ok(result['fc_out'] instanceof ov.Tensor); - assert.deepStrictEqual(Object.keys(result), ['fc_out']); - assert.deepStrictEqual(result['fc_out'].data.length, 10);} - ); - }); + // 131123 + if (os.platform() !== 'win32') { + it('Test inferAsync(inputData: { [inputName: string]: Tensor })', () => { + inferRequestAsync.inferAsync({ data: tensor }).then(result => { + assert.ok(result['fc_out'] instanceof ov.Tensor); + assert.deepStrictEqual(Object.keys(result), ['fc_out']); + assert.deepStrictEqual(result['fc_out'].data.length, 10);} + ); + }); - it('Test inferAsync(inputData: Tensor[])', () => { - inferRequestAsync.inferAsync([ tensor ]).then(result => { - assert.ok(result['fc_out'] instanceof ov.Tensor); - assert.deepStrictEqual(Object.keys(result), ['fc_out']); - assert.deepStrictEqual(result['fc_out'].data.length, 10); + it('Test inferAsync(inputData: Tensor[])', () => { + inferRequestAsync.inferAsync([ tensor ]).then(result => { + assert.ok(result['fc_out'] instanceof ov.Tensor); + assert.deepStrictEqual(Object.keys(result), ['fc_out']); + assert.deepStrictEqual(result['fc_out'].data.length, 10); + }); }); - }); - it('Test inferAsync([data]) throws: Cannot create a tensor from the passed Napi::Value.', () => { - assert.throws( - () => inferRequestAsync.inferAsync(['string']).then(), - /Cannot create a tensor from the passed Napi::Value./ - ); - }); + it('Test inferAsync([data]) throws: Cannot create a tensor from the passed Napi::Value.', () => { + assert.throws( + () => inferRequestAsync.inferAsync(['string']).then(), + /Cannot create a tensor from the passed Napi::Value./ + ); + }); - it('Test inferAsync({ data: "string"}) throws: Cannot create a tensor from the passed Napi::Value.', () => { - assert.throws( - () => inferRequestAsync.inferAsync({data: 'string'}).then(), - /Cannot create a tensor from the passed Napi::Value./ - ); - }); + it('Test inferAsync({ data: "string"}) throws: Cannot create a tensor from the passed Napi::Value.', () => { + assert.throws( + () => inferRequestAsync.inferAsync({data: 'string'}).then(), + /Cannot create a tensor from the passed Napi::Value./ + ); + }); + } it('Test setInputTensor(tensor)', () => { inferRequest.setInputTensor(tensor); diff --git a/src/bindings/js/node/thirdparty/node-lib.def b/src/bindings/js/node/thirdparty/node-lib.def new file mode 100644 index 00000000000000..8d46bbec841109 --- /dev/null +++ b/src/bindings/js/node/thirdparty/node-lib.def @@ -0,0 +1,147 @@ +NAME NODE.EXE +EXPORTS +napi_async_destroy +napi_async_init +napi_cancel_async_work +napi_create_async_work +napi_create_buffer +napi_create_buffer_copy +napi_create_external_buffer +napi_delete_async_work +napi_fatal_error +napi_get_buffer_info +napi_get_node_version +napi_is_buffer +napi_make_callback +napi_module_register +napi_queue_async_work +napi_adjust_external_memory +napi_call_function +napi_close_escapable_handle_scope +napi_close_handle_scope +napi_coerce_to_bool +napi_coerce_to_number +napi_coerce_to_object +napi_coerce_to_string +napi_create_array +napi_create_array_with_length +napi_create_arraybuffer +napi_create_dataview +napi_create_double +napi_create_error +napi_create_external +napi_create_external_arraybuffer +napi_create_function +napi_create_int32 +napi_create_int64 +napi_create_object +napi_create_promise +napi_create_range_error +napi_create_reference +napi_create_string_latin1 +napi_create_string_utf16 +napi_create_string_utf8 +napi_create_symbol +napi_create_type_error +napi_create_typedarray +napi_create_uint32 +napi_define_class +napi_define_properties +napi_delete_element +napi_delete_property +napi_delete_reference +napi_escape_handle +napi_get_and_clear_last_exception +napi_get_array_length +napi_get_arraybuffer_info +napi_get_boolean +napi_get_cb_info +napi_get_dataview_info +napi_get_element +napi_get_global +napi_get_last_error_info +napi_get_named_property +napi_get_new_target +napi_get_null +napi_get_property +napi_get_property_names +napi_get_prototype +napi_get_reference_value +napi_get_typedarray_info +napi_get_undefined +napi_get_value_bool +napi_get_value_double +napi_get_value_external +napi_get_value_int32 +napi_get_value_int64 +napi_get_value_string_latin1 +napi_get_value_string_utf16 +napi_get_value_string_utf8 +napi_get_value_uint32 +napi_get_version +napi_has_element +napi_has_named_property +napi_has_own_property +napi_has_property +napi_instanceof +napi_is_array +napi_is_arraybuffer +napi_is_dataview +napi_is_error +napi_is_exception_pending +napi_is_promise +napi_is_typedarray +napi_new_instance +napi_open_escapable_handle_scope +napi_open_handle_scope +napi_reference_ref +napi_reference_unref +napi_reject_deferred +napi_remove_wrap +napi_resolve_deferred +napi_run_script +napi_set_element +napi_set_named_property +napi_set_property +napi_strict_equals +napi_throw +napi_throw_error +napi_throw_range_error +napi_throw_type_error +napi_typeof +napi_unwrap +napi_wrap +napi_get_uv_event_loop +napi_add_env_cleanup_hook +napi_close_callback_scope +napi_fatal_exception +napi_open_callback_scope +napi_remove_env_cleanup_hook +napi_acquire_threadsafe_function +napi_call_threadsafe_function +napi_create_threadsafe_function +napi_get_threadsafe_function_context +napi_ref_threadsafe_function +napi_release_threadsafe_function +napi_unref_threadsafe_function +napi_add_finalizer +napi_create_date +napi_get_date_value +napi_is_date +napi_create_bigint_int64 +napi_create_bigint_uint64 +napi_create_bigint_words +napi_get_all_property_names +napi_get_instance_data +napi_get_value_bigint_int64 +napi_get_value_bigint_uint64 +napi_get_value_bigint_words +napi_set_instance_data +napi_detach_arraybuffer +napi_is_detached_arraybuffer +napi_add_async_cleanup_hook +napi_remove_async_cleanup_hook +napi_check_object_type_tag +napi_object_freeze +napi_object_seal +napi_type_tag_object diff --git a/src/bindings/js/node/thirdparty/win_delay_load_hook.cc b/src/bindings/js/node/thirdparty/win_delay_load_hook.cc new file mode 100644 index 00000000000000..9e652fa4df06b3 --- /dev/null +++ b/src/bindings/js/node/thirdparty/win_delay_load_hook.cc @@ -0,0 +1,52 @@ +/* + * When this file is linked to a DLL, it sets up a delay-load hook that + * intervenes when the DLL is trying to load 'node.exe' or 'iojs.exe' + * dynamically. Instead of trying to locate the .exe file it'll just return + * a handle to the process image. + * + * This allows compiled addons to work when node.exe or iojs.exe is renamed. + */ + +#ifdef _MSC_VER + +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif + +#include + +#include +#include + +static HMODULE node_dll = NULL; +static HMODULE nw_dll = NULL; + +static FARPROC WINAPI load_exe_hook(unsigned int event, DelayLoadInfo* info) { + if (event == dliNotePreGetProcAddress) { + FARPROC ret = NULL; + ret = GetProcAddress(node_dll, info->dlp.szProcName); + if (ret) + return ret; + ret = GetProcAddress(nw_dll, info->dlp.szProcName); + return ret; + } + if (event == dliStartProcessing) { + node_dll = GetModuleHandleA("node.dll"); + nw_dll = GetModuleHandleA("nw.dll"); + return NULL; + } + if (event != dliNotePreLoadLibrary) + return NULL; + + if (_stricmp(info->szDll, "node.exe") != 0) + return NULL; + + // Fall back to the current process + if(!node_dll) node_dll = GetModuleHandleA(NULL); + + return (FARPROC) node_dll; +} + +decltype(__pfnDliNotifyHook2) __pfnDliNotifyHook2 = load_exe_hook; + +#endif diff --git a/src/bindings/python/constraints.txt b/src/bindings/python/constraints.txt index 91af9a31b30429..94054315f9c0c6 100644 --- a/src/bindings/python/constraints.txt +++ b/src/bindings/python/constraints.txt @@ -2,7 +2,7 @@ numpy>=1.16.6,<1.27 # Python bindings, frontends # pytest -pytest>=5.0,<7.5 +pytest>=5.0,<8.1 pytest-dependency==0.6.0 pytest-html==4.1.1 pytest-timeout==2.2.0 diff --git a/src/bindings/python/requirements_test.txt b/src/bindings/python/requirements_test.txt index 7bc1157d4edceb..98ac20ece72cf4 100644 --- a/src/bindings/python/requirements_test.txt +++ b/src/bindings/python/requirements_test.txt @@ -23,7 +23,6 @@ flake8-string-format flake8-variables-names flake8_builtins<2.3.0 flake8_coding -flake8_commas flake8_pep3101 flake8_quotes mypy diff --git a/src/bindings/python/src/openvino/__init__.py b/src/bindings/python/src/openvino/__init__.py index 1d75589bd2eceb..9db717409cf327 100644 --- a/src/bindings/python/src/openvino/__init__.py +++ b/src/bindings/python/src/openvino/__init__.py @@ -23,7 +23,7 @@ from openvino import helpers as helpers from openvino import preprocess as preprocess from openvino import utils as utils -from openvino.runtime import properties as properties +from openvino import properties as properties # Import most important classes and functions from openvino.runtime from openvino.runtime import Model diff --git a/src/bindings/python/src/openvino/frontend/pytorch/fx_decoder.py b/src/bindings/python/src/openvino/frontend/pytorch/fx_decoder.py index 09375329cb7770..cb6b6beb0e2ede 100644 --- a/src/bindings/python/src/openvino/frontend/pytorch/fx_decoder.py +++ b/src/bindings/python/src/openvino/frontend/pytorch/fx_decoder.py @@ -11,6 +11,7 @@ import torch + class TorchFXPythonDecoder (Decoder): def __init__(self, pt_module, fx_gm, nodes=None, mark_node_callback=None, input_shapes=[], input_types=[]): @@ -23,56 +24,96 @@ def __init__(self, pt_module, fx_gm, nodes=None, mark_node_callback=None, input_ self.input_types = input_types self.input_shapes = input_shapes + self._input_signature = [] + self._output_names = [] + if issubclass(type(pt_module), torch.fx.graph_module.GraphModule): + self._input_is_list = None self._nodes = list(pt_module.graph.nodes) self._inputs = [] self._outputs = [] for i in range(len(self._nodes)): if self._nodes[i].op == 'placeholder': self._inputs.append(i) + self._input_signature.append(self._nodes[i].name) elif self._nodes[i].op == 'output': # Instead of putting output index, refer to its target args = self._nodes[i].args if isinstance(args[0], tuple): args = args[0] - for output in args: - self._outputs.append(self._nodes.index(output)) + if isinstance(args[0], dict): + for name, output in args[0].items(): + self._outputs.append(self._nodes.index(output)) + self._output_names.append(name) + else: + for output in args: + self._outputs.append(self._nodes.index(output)) elif issubclass(type(pt_module), torch.fx.Node): - - self._nodes = nodes # passed from outer context + self._nodes = nodes # passed from outer context # FIXME: Quadratic complexity nodes*nodes considering the outer loop over all nodes for i in range(len(self._nodes)): if self._nodes[i] == pt_module: self._outputs = [i] - # code constant or None input as a tuple to diffirentiate it from regular input - # negative index is used to mark inputs initialized by inline constants, there are no such inputs in the graph - self._inputs = [self._nodes.index(arg) if arg in self._nodes else (arg,) for arg in pt_module.args] + # None in inputs mean the input is inlined or None (also considered inlined) + self._inputs = [self._nodes.index( + arg) if arg in self._nodes else (arg,) for arg in pt_module.args] - # FIXME: Find a better way to pass nested tuples to OV frontend. This is a temprary solution to flatten arguments. + # FIXME: Find a better way to pass nested tuples to OV frontend. This is a temporary solution to flatten arguments. new_inputs = [] for i in range(len(pt_module.args)): - expand_list = False - if isinstance(pt_module.args[i], list): + if isinstance(pt_module.args[i], list) and any([isinstance(a, torch.fx.Node) for a in pt_module.args[i]]): for arg in pt_module.args[i]: if arg in self._nodes: - expand_list = True - break; - if expand_list: - for arg in pt_module.args[i]: - new_inputs.append(self._nodes.index(arg)) + new_inputs.append(self._nodes.index(arg)) + else: + new_inputs.append((arg,)) else: new_inputs.append(self._inputs[i]) self._inputs = new_inputs + def inputs(self): + # Consider 0 a special case which may mean the input is inlined, but not guaranteed + return [x if not isinstance(x, tuple) else 0 for x in self._inputs] + + def is_input_inlined(self, index): + return isinstance(self._inputs[index], tuple) + + @staticmethod + def arg_to_constant(arg): + if isinstance(arg, list): + if len(arg) > 0: + return make_constant(pt_to_ov_type_map[type( + arg[0]).__name__], Shape([len(arg)]), arg) + else: + # TODO: which type should we use if list is empty? Need a signaling value here + return make_constant(int, Shape([0]), []) + elif isinstance(arg, bool): + return make_constant(OVType.boolean, Shape([]), [arg]) + elif isinstance(arg, int): + arg = maybe_convert_max_int(arg) + return make_constant(OVType.i32, Shape( + []), [arg]) # TODO: i32? why not i64? + elif isinstance(arg, float): + return make_constant(OVType.f32, Shape( + []), [arg]) # TODO: f32? why not f64? + return None + + def inlined_input(self, index): + assert index < len(self._inputs), "Requested input doesn't exist" + assert isinstance(self._inputs[index], tuple), "Requested input which is not inlined" + assert self._inputs[index][0] is not None, "Requested None inlined input" + constant = None + arg = self._inputs[index][0] + constant = self.arg_to_constant(arg) - def inputs(self): - return [x if x is not None else 100000 for x in self._inputs] + assert constant is not None, "Constant wasn't created for inlined input" + return constant.outputs() def input(self, index): # TODO: remove return self.inputs()[index] # TODO: find specialized method @@ -81,6 +122,8 @@ def get_input_debug_name(self, index): return "input"+str(index) def get_input_signature_name(self, index: int) -> str: + if self._input_signature is not None and index < len(self._input_signature): + return self._input_signature[index] return self.get_input_debug_name(index) def get_input_shape(self, index): @@ -89,6 +132,16 @@ def get_input_shape(self, index): input = self._raw_input(index) return self.get_shape_for_value(input) + def get_input_strides(self, index: int) -> list: + raw_input = self._raw_input(index) + if isinstance(raw_input, torch.fx.node.Node) and hasattr(raw_input, "meta"): + meta = raw_input.meta + if "tensor_meta" in meta and hasattr(meta["tensor_meta"], "stride"): + strides = list(meta["tensor_meta"].stride) + if strides: + return strides + return [] + def get_input_type(self, index): if index < len(self.input_types): return OVAny(pt_to_ov_type_map[str(self.input_types[index])]) @@ -96,7 +149,10 @@ def get_input_type(self, index): return self.get_type_for_value(input) def get_output_debug_name(self, index): - return "output"+str(index) + if self._output_names is not None and index < len(self._output_names): + return self._output_names[index] + name = getattr(self.pt_module, "name", "output") + return name + ":" + str(index) def get_output_shape(self, index): output = self._raw_output(index) @@ -106,52 +162,58 @@ def get_output_type(self, index): output = self._raw_output(index) return self.get_type_for_value(output) - def _get_known_type_for_value(self, type): - ''' - Returns known/unknown types wrapped as OVAny - ''' - # Check for simple scalar types first - # TODO: Don't use str, use native types - if type is None: - return OVAny(OVType.dynamic) - if str(type) in pt_to_ov_type_map: - return OVAny(pt_to_ov_type_map[str(type)]) - elif type.__class__ is torch.TensorType: - # Tensor type, parse element type - # TODO: replace string by native type - # return OVAny(PartialShape([1,2,3])) - return OVAny(DecoderType.Tensor(self._get_known_type_for_value(type.dtype()))) - elif type.__class__ is torch.ListType: - element_type = type.getElementType() - return OVAny(DecoderType.List(self._get_known_type_for_value(element_type))) - else: - # Not yet recognized - return OVAny(OVType.dynamic) - #pt_type_class = value.type().__class__ - # if pt_type_class is torch.ListType: - def get_shape_for_value(self, value): - if value and ('tensor_meta' in value.meta.keys()): - return PartialShape(value.meta['tensor_meta'].shape) - return PartialShape([1]) + if value and hasattr(value, "meta") and ('tensor_meta' in value.meta.keys()): + if value.meta['tensor_meta']: + return PartialShape(len(value.meta['tensor_meta'].shape) * [-1]) + return PartialShape.dynamic() def get_type_for_value(self, value): if issubclass(type(value), torch.fx.Node): if ('tensor_meta' in value.meta.keys()): - pt_type = value.meta['tensor_meta'].dtype - if str(pt_type) in pt_to_ov_type_map: - ov_type = pt_to_ov_type_map[str(pt_type)] - return OVAny(ov_type) + if value.meta['tensor_meta'] and isinstance(value.meta['tensor_meta'], torch.Tensor): + pt_type = value.meta['tensor_meta'].dtype + if str(pt_type) in pt_to_ov_type_map: + ov_type = pt_to_ov_type_map[str(pt_type)] + return OVAny(ov_type) else: - return OVAny(OVType.f32) + return OVAny(OVType.dynamic) elif isinstance(value, int): return OVAny(OVType.i32) elif isinstance(value, float): return OVAny(OVType.f32) elif isinstance(value, bool): return OVAny(OVType.boolean) - else: - return OVAny(OVType.f32) + return OVAny(OVType.dynamic) + + def get_attribute(self, name): + if name in self.pt_module.kwargs: + attr = self.pt_module.kwargs[name] + if isinstance(attr, torch.dtype): + return OVAny(pt_to_ov_type_map[str(attr)]) + if isinstance(attr, torch.device): + return OVAny(attr.type) + if isinstance(attr, str): + return OVAny(attr) + # Numeric attrs convert to Constant + constant = self.arg_to_constant(attr) + if constant is not None: + return OVAny(constant.output(0)) + # so that has_attribute return True if attribute exist + return OVAny(DecoderType.PyNone()) + return OVAny(None) + + def get_named_input(self, name): + """ + Returns id of kwargs input. Such input can be Node or a constant value, + this function is only used for to return node index. If the input is + constant, get_attribute should be used. + """ + if name in self.pt_module.kwargs: + arg = self.pt_module.kwargs[name] + if isinstance(arg, torch.fx.Node): + return self._nodes.index(arg) + raise RuntimeError("This input is not a Node") def get_subgraph_size(self): if issubclass(type(self.pt_module), torch.fx.Node): @@ -165,8 +227,11 @@ def visit_subgraph(self, node_visitor): # make sure topological order is satisfied for node in self._nodes: if node.op == 'placeholder' or node.op == 'output': - continue # skipping non-operational nodes - decoder = TorchFXPythonDecoder(node, self.fx_gm, self._nodes, mark_node_callback=self.mark_node_callback) + continue # skipping non-operational nodes + if node.op == 'call_function' and str(node.target) in ["aten._assert_async.msg"]: + continue + decoder = TorchFXPythonDecoder( + node, self.fx_gm, self._nodes, mark_node_callback=self.mark_node_callback) self.m_decoders.append(decoder) node_visitor(decoder) @@ -176,7 +241,8 @@ def get_subgraphs(self): return list(self.pt_module.blocks()) def get_subgraph_decoder(self, index): - decoder = TorchFXPythonDecoder(self.get_subgraphs()[index], self.fx_gm, mark_node_callback=self.mark_node_callback) + decoder = TorchFXPythonDecoder(self.get_subgraphs( + )[index], self.fx_gm, mark_node_callback=self.mark_node_callback) self.m_decoders.append(decoder) return decoder @@ -202,7 +268,7 @@ def _raw_output(self, index): return self._raw_outputs()[index] def _raw_inputs(self): - return [self._nodes[x] if x is not None and x < len(self._nodes) else x for x in self._inputs] + return [self._nodes[x] if not isinstance(x, tuple) and x < len(self._nodes) else x[0] for x in self._inputs] def _raw_input(self, index): return self._raw_inputs()[index] @@ -214,6 +280,10 @@ def output(self, index): return self.outputs()[index] def mark_node(self, node): + name = self.get_op_type() + if "FrameworkNode" not in node.get_type_name(): + name += "/" + node.get_type_name() + node.set_friendly_name(name) if self.mark_node_callback is not None: self.mark_node_callback(self, node) return node @@ -223,10 +293,9 @@ def as_constant(self): if self.pt_module.op == 'get_attr': # Extract Constant from FX module field ret = fetch_attr(self.fx_gm, self.pt_module.target) - ov_const = op.Constant(ret.numpy(), shared_memory=True) + ov_const = op.Constant(ret.numpy(force=True), shared_memory=True) return ov_const.outputs() - if not self.get_op_type() == 'prim::Constant': return None pt_value = self._raw_output(0) @@ -258,7 +327,8 @@ def as_constant_tensor(self, pt_value): ivalue = pt_value.toIValue() if pt_value.isCompleteTensor(): try: - ivalue = ivalue.to(memory_format=torch.contiguous_format).detach().cpu() + ivalue = ivalue.to( + memory_format=torch.contiguous_format).detach().cpu() except: print("[ WARNING ] Tensor couldn't detach") if str(pt_value.type().dtype()) in pt_to_py_type_map: @@ -273,12 +343,15 @@ def as_constant_tensor(self, pt_value): # this is only possible with adding a new ctor for Constant Python binding # TODO Check strides and pass them somehow values = ivalue.data_ptr() - ov_const = make_constant(ovtype, ovshape.get_shape(), values) + ov_const = make_constant( + ovtype, ovshape.get_shape(), values) except: # old variant that makes a slow data copying - print(f"[ WARNING ] Constant wasn't able to convert from data_ptr.") + print( + f"[ WARNING ] Constant wasn't able to convert from data_ptr.") values = ivalue.flatten().tolist() - ov_const = make_constant(ovtype, ovshape.get_shape(), values) + ov_const = make_constant( + ovtype, ovshape.get_shape(), values) return ov_const.outputs() else: # Incomplete tensor can be scalar @@ -294,14 +367,17 @@ def as_constant_tensor(self, pt_value): try: ovshape = PartialShape(ivalue.size()) ovtype = pt_to_ov_type_map[str(ivalue.type())] - ov_const = make_constant(ovtype, ovshape.get_shape(), ivalue.data_ptr()) + ov_const = make_constant( + ovtype, ovshape.get_shape(), ivalue.data_ptr()) except: # old variant that makes a slow data copying - print(f"[ WARNING ] Constant wasn't able to convert from data_ptr.") - nvalues = ivalue.numpy() + print( + f"[ WARNING ] Constant wasn't able to convert from data_ptr.") + nvalues = ivalue.numpy(force=True) ovtype = np_to_ov_type_map[str(nvalues.dtype)] ovshape = PartialShape(nvalues.shape) - ov_const = make_constant(ovtype, ovshape.get_shape(), nvalues.flatten().tolist()) + ov_const = make_constant( + ovtype, ovshape.get_shape(), nvalues.flatten().tolist()) return ov_const.outputs() return None @@ -325,7 +401,7 @@ def as_constant_list(self, pt_value): return ov_const.outputs() def input_is_none(self, index): - if index >= len(self.inputs()) or self._raw_input(index) is None: + if index >= len(self._inputs) or (isinstance(self._inputs[index], tuple) and self._inputs[index][0] is None): return True else: r_input = self._raw_input(index) @@ -342,7 +418,8 @@ def inlined_inputs(self, index): arg = self._inputs[i][0] if isinstance(arg, list): if len(arg) > 0: - constant = make_constant(pt_to_ov_type_map[type(arg[0]).__name__], Shape([len(arg)]), arg) + constant = make_constant(pt_to_ov_type_map[type( + arg[0]).__name__], Shape([len(arg)]), arg) else: # TODO: which type should we use if list is empty? Need a signaling value here constant = make_constant(int, Shape([0]), []) @@ -350,9 +427,11 @@ def inlined_inputs(self, index): constant = make_constant(OVType.boolean, Shape([]), [arg]) elif isinstance(arg, int): arg = maybe_convert_max_int(arg) - constant = make_constant(OVType.i32, Shape([]), [arg]) # TODO: i32? why not i64? + constant = make_constant(OVType.i32, Shape( + []), [arg]) # TODO: i32? why not i64? elif isinstance(arg, float): - constant = make_constant(OVType.f32, Shape([]), [arg]) # TODO: f32? why not f64? + constant = make_constant(OVType.f32, Shape( + []), [arg]) # TODO: f32? why not f64? if constant is None: if arg is None: diff --git a/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py b/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py index 7c2c53e68b0065..4c8356b59228ba 100644 --- a/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py +++ b/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py @@ -16,13 +16,14 @@ class TorchScriptPythonDecoder (Decoder): - def __init__(self, pt_module, graph_element=None, example_input=None, alias_db=None, shared_memory=True, skip_freeze=False): + def __init__(self, pt_module, graph_element=None, example_input=None, alias_db=None, shared_memory=True, skip_freeze=False, constant_cache=None): Decoder.__init__(self) # We store every decoder created by this decoder so that all them are not deleted until the first decoder is deleted self.m_decoders = [] self._input_signature = None self._shared_memory = shared_memory self._input_is_list = False + self.constant_cache = constant_cache if constant_cache is not None else dict() if graph_element is None: try: pt_module = self._get_scripted_model( @@ -225,8 +226,11 @@ def get_subgraph_size(self) -> int: def visit_subgraph(self, node_visitor) -> None: # make sure topological order is satisfied for node in self.graph_element.nodes(): - decoder = TorchScriptPythonDecoder( - self.pt_module, node, alias_db=self.alias_db, shared_memory=self._shared_memory) + decoder = TorchScriptPythonDecoder(self.pt_module, + node, + alias_db=self.alias_db, + shared_memory=self._shared_memory, + constant_cache=self.constant_cache) self.m_decoders.append(decoder) node_visitor(decoder) @@ -246,8 +250,10 @@ def get_subgraphs(self) -> list: return list(self.graph_element.blocks()) def get_subgraph_decoder(self, index: int): - decoder = TorchScriptPythonDecoder(self.pt_module, self.get_subgraphs( - )[index], alias_db=self.alias_db, shared_memory=self._shared_memory) + decoder = TorchScriptPythonDecoder(self.pt_module, + self.get_subgraphs()[index], + alias_db=self.alias_db, + shared_memory=self._shared_memory) self.m_decoders.append(decoder) return decoder @@ -285,16 +291,36 @@ def mark_node(self, node): node.set_friendly_name(name) return node + def _add_name_to_const_and_cache(self, outputs, name): + if len(outputs) == 1: + # set name corresponding to state_dict name + outputs[0].get_node().set_friendly_name(name) + self.out_debug_name_overwrites[0] = name + self.constant_cache[name] = outputs + def try_decode_get_attr(self): - pt_value, name = get_value_from_getattr(self.graph_element, self.pt_module) + pt_value, name = get_value_from_getattr(self.graph_element, + self.pt_module) assert pt_value is not None, "Couldn't retrieve value from prim::GetAttr" if isinstance(pt_value, torch.ScriptObject): # We assume this is __torch__.torch.classes.quantized.Conv2dPackedParamsBase or __torch__.torch.classes.quantized.LinearPackedParamsBase # TODO: but can be anything. Figure a better way to distinguish weight, bias = pt_value.unpack() - res = convert_quantized_tensor(weight, self._shared_memory) + w_name = name + ".weight" + if w_name in self.constant_cache: + res = self.constant_cache[w_name] + else: + res = convert_quantized_tensor(weight, self._shared_memory) + self._add_name_to_const_and_cache(res, w_name) + if isinstance(bias, torch.Tensor): - res += ivalue_to_constant(bias) + b_name = name + ".bias" + if b_name in self.constant_cache: + res += self.constant_cache[b_name] + else: + b_res = ivalue_to_constant(bias) + self._add_name_to_const_and_cache(b_res, b_name) + res += b_res else: res += ops.convert_like(ivalue_to_constant(torch.zeros(1)) [0], res[0]).outputs() @@ -316,11 +342,13 @@ def try_decode_get_attr(self): pass return res elif not isinstance(pt_value, (torch.jit.ScriptModule, torch.jit.TracedModule)): - const = ivalue_to_constant(pt_value, shared_memory=self._shared_memory) - if len(const) > 0: - # set name corresponding to state_dict name - const[0].get_node().set_friendly_name(name) - self.out_debug_name_overwrites[0] = name + # this tensor can be used multiple times in the model, so we have to reuse constants + if name in self.constant_cache: + const = self.constant_cache[name] + else: + const = ivalue_to_constant(pt_value, + shared_memory=self._shared_memory) + self._add_name_to_const_and_cache(const, name) return const else: return [] @@ -333,13 +361,16 @@ def as_constant(self): pt_value = self._raw_output(0) pt_type = pt_value.type() if isinstance(pt_type, torch.TensorType): - return ivalue_to_constant(pt_value.toIValue(), shared_memory=self._shared_memory) + return ivalue_to_constant(pt_value.toIValue(), + shared_memory=self._shared_memory) if isinstance(pt_type, torch.ListType): return self._as_constant_list(pt_value) - const = ivalue_to_constant(pt_value.toIValue(), shared_memory=self._shared_memory) + const = ivalue_to_constant(pt_value.toIValue(), + shared_memory=self._shared_memory) if len(const) > 0: # set name corresponding to state_dict name - const[0].get_node().set_friendly_name(self.get_output_debug_name(0)) + const[0].get_node().set_friendly_name( + self.get_output_debug_name(0)) return const def as_string(self): @@ -389,7 +420,8 @@ def input_is_none(self, index: int) -> bool: else: in_node = r_input.node() if in_node.kind() == "prim::GetAttr": - pt_value, _ = get_value_from_getattr(in_node, self.pt_module) + pt_value, _ = get_value_from_getattr(in_node, + self.pt_module) return pt_value is None return False @@ -406,6 +438,18 @@ def may_produce_alias(self, in_index: int, out_index: int) -> bool: def inlined_inputs(self, index): return [] + def inlined_input(self, index): + return [] + + def is_input_inlined(self, index): + return False + + def get_attribute(self, name): + return OVAny(None) + + def get_named_input(self, name): + raise RuntimeError("There is no named inputs in TS graph") + @staticmethod def _transform_tensor_list_constants_to_listconstruct(graph: torch.Graph): # Function replaces prim::Constant containing List of Tensors with diff --git a/src/bindings/python/src/openvino/frontend/pytorch/utils.py b/src/bindings/python/src/openvino/frontend/pytorch/utils.py index 0225603e78ae54..157592f3aabee0 100644 --- a/src/bindings/python/src/openvino/frontend/pytorch/utils.py +++ b/src/bindings/python/src/openvino/frontend/pytorch/utils.py @@ -137,8 +137,13 @@ def graph_has_ops(graph, op_types:list) -> bool: "torch.bool": OVType.boolean, "torch.DoubleTensor": OVType.f64, "torch.FloatTensor": OVType.f32, + "torch.HalfTensor": OVType.f16, + "torch.BFloat16Tensor": OVType.bf16, "torch.IntTensor": OVType.i32, "torch.LongTensor": OVType.i64, + "torch.ShortTensor": OVType.i16, + "torch.CharTensor": OVType.i8, + "torch.ByteTensor": OVType.u8, "torch.BoolTensor": OVType.boolean, "torch.quint8": OVType.u8, "torch.qint8": OVType.i8, diff --git a/src/bindings/python/src/openvino/properties/__init__.py b/src/bindings/python/src/openvino/properties/__init__.py index 05c5a260d65882..e4685f5495f4a4 100644 --- a/src/bindings/python/src/openvino/properties/__init__.py +++ b/src/bindings/python/src/openvino/properties/__init__.py @@ -12,10 +12,10 @@ __make_properties(__properties, __name__) # Submodules -from openvino.runtime.properties import hint -from openvino.runtime.properties import intel_cpu -from openvino.runtime.properties import intel_gpu -from openvino.runtime.properties import intel_auto -from openvino.runtime.properties import device -from openvino.runtime.properties import log -from openvino.runtime.properties import streams +from openvino.properties import hint +from openvino.properties import intel_cpu +from openvino.properties import intel_gpu +from openvino.properties import intel_auto +from openvino.properties import device +from openvino.properties import log +from openvino.properties import streams diff --git a/src/bindings/python/src/openvino/runtime/opset14/__init__.py b/src/bindings/python/src/openvino/runtime/opset14/__init__.py new file mode 100644 index 00000000000000..7f330fbc87766d --- /dev/null +++ b/src/bindings/python/src/openvino/runtime/opset14/__init__.py @@ -0,0 +1,188 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2018-2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +from openvino.runtime.opset1.ops import absolute +from openvino.runtime.opset1.ops import absolute as abs +from openvino.runtime.opset1.ops import acos +from openvino.runtime.opset4.ops import acosh +from openvino.runtime.opset8.ops import adaptive_avg_pool +from openvino.runtime.opset8.ops import adaptive_max_pool +from openvino.runtime.opset1.ops import add +from openvino.runtime.opset1.ops import asin +from openvino.runtime.opset4.ops import asinh +from openvino.runtime.opset6.ops import assign +from openvino.runtime.opset1.ops import atan +from openvino.runtime.opset4.ops import atanh +from openvino.runtime.opset1.ops import avg_pool +from openvino.runtime.opset5.ops import batch_norm_inference +from openvino.runtime.opset2.ops import batch_to_space +from openvino.runtime.opset1.ops import binary_convolution +from openvino.runtime.opset13.ops import bitwise_and +from openvino.runtime.opset13.ops import bitwise_not +from openvino.runtime.opset13.ops import bitwise_or +from openvino.runtime.opset13.ops import bitwise_xor +from openvino.runtime.opset3.ops import broadcast +from openvino.runtime.opset3.ops import bucketize +from openvino.runtime.opset1.ops import ceiling +from openvino.runtime.opset1.ops import ceiling as ceil +from openvino.runtime.opset1.ops import clamp +from openvino.runtime.opset1.ops import concat +from openvino.runtime.opset13.ops import constant +from openvino.runtime.opset1.ops import convert +from openvino.runtime.opset1.ops import convert_like +from openvino.runtime.opset1.ops import convolution +from openvino.runtime.opset1.ops import convolution_backprop_data +from openvino.runtime.opset1.ops import cos +from openvino.runtime.opset1.ops import cosh +from openvino.runtime.opset1.ops import ctc_greedy_decoder +from openvino.runtime.opset6.ops import ctc_greedy_decoder_seq_len +from openvino.runtime.opset4.ops import ctc_loss +from openvino.runtime.opset3.ops import cum_sum +from openvino.runtime.opset3.ops import cum_sum as cumsum +from openvino.runtime.opset8.ops import deformable_convolution +from openvino.runtime.opset1.ops import deformable_psroi_pooling +from openvino.runtime.opset1.ops import depth_to_space +from openvino.runtime.opset8.ops import detection_output +from openvino.runtime.opset7.ops import dft +from openvino.runtime.opset1.ops import divide +from openvino.runtime.opset7.ops import einsum +from openvino.runtime.opset1.ops import elu +from openvino.runtime.opset3.ops import embedding_bag_offsets_sum +from openvino.runtime.opset3.ops import embedding_bag_packed_sum +from openvino.runtime.opset3.ops import embedding_segments_sum +from openvino.runtime.opset3.ops import extract_image_patches +from openvino.runtime.opset1.ops import equal +from openvino.runtime.opset1.ops import erf +from openvino.runtime.opset1.ops import exp +from openvino.runtime.opset9.ops import eye +from openvino.runtime.opset13.ops import fake_convert +from openvino.runtime.opset13.ops import fake_quantize +from openvino.runtime.opset1.ops import floor +from openvino.runtime.opset1.ops import floor_mod +from openvino.runtime.opset8.ops import gather +from openvino.runtime.opset6.ops import gather_elements +from openvino.runtime.opset8.ops import gather_nd +from openvino.runtime.opset1.ops import gather_tree +from openvino.runtime.opset7.ops import gelu +from openvino.runtime.opset9.ops import generate_proposals +from openvino.runtime.opset1.ops import greater +from openvino.runtime.opset1.ops import greater_equal +from openvino.runtime.opset9.ops import grid_sample +from openvino.runtime.opset1.ops import grn +from openvino.runtime.opset1.ops import group_convolution +from openvino.runtime.opset1.ops import group_convolution_backprop_data +from openvino.runtime.opset12.ops import group_normalization +from openvino.runtime.opset3.ops import gru_cell +from openvino.runtime.opset5.ops import gru_sequence +from openvino.runtime.opset1.ops import hard_sigmoid +from openvino.runtime.opset5.ops import hsigmoid +from openvino.runtime.opset4.ops import hswish +from openvino.runtime.opset7.ops import idft +from openvino.runtime.opset8.ops import if_op +from openvino.runtime.opset11.ops import interpolate +from openvino.runtime.opset9.ops import irdft +from openvino.runtime.opset10.ops import is_finite +from openvino.runtime.opset10.ops import is_inf +from openvino.runtime.opset10.ops import is_nan +from openvino.runtime.opset8.ops import i420_to_bgr +from openvino.runtime.opset8.ops import i420_to_rgb +from openvino.runtime.opset1.ops import less +from openvino.runtime.opset1.ops import less_equal +from openvino.runtime.opset1.ops import log +from openvino.runtime.opset1.ops import logical_and +from openvino.runtime.opset1.ops import logical_not +from openvino.runtime.opset1.ops import logical_or +from openvino.runtime.opset1.ops import logical_xor +from openvino.runtime.opset5.ops import log_softmax +from openvino.runtime.opset5.ops import loop +from openvino.runtime.opset1.ops import lrn +from openvino.runtime.opset4.ops import lstm_cell +from openvino.runtime.opset5.ops import lstm_sequence +from openvino.runtime.opset1.ops import matmul +from openvino.runtime.opset8.ops import matrix_nms +from openvino.runtime.opset8.ops import max_pool +from openvino.runtime.opset1.ops import maximum +from openvino.runtime.opset1.ops import minimum +from openvino.runtime.opset4.ops import mish +from openvino.runtime.opset1.ops import mod +from openvino.runtime.opset9.ops import multiclass_nms +from openvino.runtime.opset13.ops import multinomial +from openvino.runtime.opset1.ops import multiply +from openvino.runtime.opset6.ops import mvn +from openvino.runtime.opset1.ops import negative +from openvino.runtime.opset13.ops import nms_rotated +from openvino.runtime.opset9.ops import non_max_suppression +from openvino.runtime.opset3.ops import non_zero +from openvino.runtime.opset1.ops import normalize_l2 +from openvino.runtime.opset1.ops import not_equal +from openvino.runtime.opset8.ops import nv12_to_bgr +from openvino.runtime.opset8.ops import nv12_to_rgb +from openvino.runtime.opset1.ops import one_hot +from openvino.runtime.opset12.ops import pad +from openvino.runtime.opset1.ops import parameter +from openvino.runtime.opset1.ops import power +from openvino.runtime.opset1.ops import prelu +from openvino.runtime.opset8.ops import prior_box +from openvino.runtime.opset1.ops import prior_box_clustered +from openvino.runtime.opset1.ops import psroi_pooling +from openvino.runtime.opset4.ops import proposal +from openvino.runtime.opset4.ops import range +from openvino.runtime.opset8.ops import random_uniform +from openvino.runtime.opset9.ops import rdft +from openvino.runtime.opset6.ops import read_value +from openvino.runtime.opset4.ops import reduce_l1 +from openvino.runtime.opset4.ops import reduce_l2 +from openvino.runtime.opset1.ops import reduce_logical_and +from openvino.runtime.opset1.ops import reduce_logical_or +from openvino.runtime.opset1.ops import reduce_max +from openvino.runtime.opset1.ops import reduce_mean +from openvino.runtime.opset1.ops import reduce_min +from openvino.runtime.opset1.ops import reduce_prod +from openvino.runtime.opset1.ops import reduce_sum +from openvino.runtime.opset1.ops import region_yolo +from openvino.runtime.opset2.ops import reorg_yolo +from openvino.runtime.opset1.ops import relu +from openvino.runtime.opset1.ops import reshape +from openvino.runtime.opset13.ops import result +from openvino.runtime.opset1.ops import reverse_sequence +from openvino.runtime.opset3.ops import rnn_cell +from openvino.runtime.opset5.ops import rnn_sequence +from openvino.runtime.opset9.ops import roi_align +from openvino.runtime.opset2.ops import roi_pooling +from openvino.runtime.opset7.ops import roll +from openvino.runtime.opset5.ops import round +from openvino.runtime.opset13.ops import scaled_dot_product_attention +from openvino.runtime.opset12.ops import scatter_elements_update +from openvino.runtime.opset4.ops import scatter_nd_update +from openvino.runtime.opset3.ops import scatter_update +from openvino.runtime.opset1.ops import select +from openvino.runtime.opset1.ops import selu +from openvino.runtime.opset3.ops import shape_of +from openvino.runtime.opset3.ops import shuffle_channels +from openvino.runtime.opset1.ops import sigmoid +from openvino.runtime.opset1.ops import sign +from openvino.runtime.opset1.ops import sin +from openvino.runtime.opset1.ops import sinh +from openvino.runtime.opset8.ops import slice +from openvino.runtime.opset8.ops import softmax +from openvino.runtime.opset4.ops import softplus +from openvino.runtime.opset9.ops import softsign +from openvino.runtime.opset2.ops import space_to_batch +from openvino.runtime.opset1.ops import space_to_depth +from openvino.runtime.opset1.ops import split +from openvino.runtime.opset1.ops import sqrt +from openvino.runtime.opset1.ops import squared_difference +from openvino.runtime.opset1.ops import squeeze +from openvino.runtime.opset1.ops import strided_slice +from openvino.runtime.opset1.ops import subtract +from openvino.runtime.opset4.ops import swish +from openvino.runtime.opset1.ops import tan +from openvino.runtime.opset1.ops import tanh +from openvino.runtime.opset1.ops import tensor_iterator +from openvino.runtime.opset1.ops import tile +from openvino.runtime.opset11.ops import topk +from openvino.runtime.opset1.ops import transpose +from openvino.runtime.opset10.ops import unique +from openvino.runtime.opset1.ops import unsqueeze +from openvino.runtime.opset1.ops import variadic_split diff --git a/src/bindings/python/src/openvino/runtime/utils/decorators.py b/src/bindings/python/src/openvino/runtime/utils/decorators.py index d29a31938526b2..991edc519dbe9c 100644 --- a/src/bindings/python/src/openvino/runtime/utils/decorators.py +++ b/src/bindings/python/src/openvino/runtime/utils/decorators.py @@ -44,7 +44,7 @@ def wrapper(*args: Any, **kwargs: Any) -> Node: for node_name in node_names: # Apply only on auto-generated nodes. Create such node and apply affixes. # Any Node instance supplied by the user is keeping the name as-is. - if node_name in arg_mapping and not isinstance(arg_mapping[node_name], Node): + if node_name in arg_mapping and not isinstance(arg_mapping[node_name], (Node, Output)): arg_mapping[node_name] = _apply_affix(as_node(arg_mapping[node_name]), prefix=kwargs.get("prefix", ""), suffix=kwargs.get("suffix", ""), diff --git a/src/bindings/python/src/pyopenvino/core/properties/properties.cpp b/src/bindings/python/src/pyopenvino/core/properties/properties.cpp index 341d76313512aa..66dde3c3236514 100644 --- a/src/bindings/python/src/pyopenvino/core/properties/properties.cpp +++ b/src/bindings/python/src/pyopenvino/core/properties/properties.cpp @@ -12,7 +12,7 @@ namespace py = pybind11; void regmodule_properties(py::module m) { // Top submodule - py::module m_properties = m.def_submodule("properties", "openvino.runtime.properties submodule"); + py::module m_properties = m.def_submodule("properties", "openvino.properties submodule"); // Submodule properties - enums py::enum_(m_properties, "Affinity", py::arithmetic()) @@ -52,7 +52,7 @@ void regmodule_properties(py::module m) { // Submodule hint py::module m_hint = - m_properties.def_submodule("hint", "openvino.runtime.properties.hint submodule that simulates ov::hint"); + m_properties.def_submodule("hint", "openvino.properties.hint submodule that simulates ov::hint"); // Submodule hint - enums py::enum_(m_hint, "Priority", py::arithmetic()) @@ -89,8 +89,7 @@ void regmodule_properties(py::module m) { // Submodule intel_cpu py::module m_intel_cpu = - m_properties.def_submodule("intel_cpu", - "openvino.runtime.properties.intel_cpu submodule that simulates ov::intel_cpu"); + m_properties.def_submodule("intel_cpu", "openvino.properties.intel_cpu submodule that simulates ov::intel_cpu"); // Submodule intel_cpu property wrap_property_RW(m_intel_cpu, ov::intel_cpu::denormals_optimization, "denormals_optimization"); @@ -100,8 +99,7 @@ void regmodule_properties(py::module m) { // Submodule intel_gpu py::module m_intel_gpu = - m_properties.def_submodule("intel_gpu", - "openvino.runtime.properties.intel_gpu submodule that simulates ov::intel_gpu"); + m_properties.def_submodule("intel_gpu", "openvino.properties.intel_gpu submodule that simulates ov::intel_gpu"); wrap_property_RO(m_intel_gpu, ov::intel_gpu::device_total_mem_size, "device_total_mem_size"); wrap_property_RO(m_intel_gpu, ov::intel_gpu::uarch_version, "uarch_version"); @@ -112,9 +110,9 @@ void regmodule_properties(py::module m) { wrap_property_RW(m_intel_gpu, ov::intel_gpu::disable_winograd_convolution, "disable_winograd_convolution"); // Submodule hint (intel_gpu) - py::module m_intel_gpu_hint = m_intel_gpu.def_submodule( - "hint", - "openvino.runtime.properties.intel_gpu.hint submodule that simulates ov::intel_gpu::hint"); + py::module m_intel_gpu_hint = + m_intel_gpu.def_submodule("hint", + "openvino.properties.intel_gpu.hint submodule that simulates ov::intel_gpu::hint"); // `ThrottleLevel` enum is conflicting with `priorities.hint.Priority` in bindings. // `ov::intel_gpu::hint::ThrottleLevel` workaround proxy class: @@ -123,7 +121,7 @@ void regmodule_properties(py::module m) { py::class_> m_throttle_level( m_intel_gpu_hint, "ThrottleLevel", - "openvino.runtime.properties.intel_gpu.hint.ThrottleLevel that simulates ov::intel_gpu::hint::ThrottleLevel"); + "openvino.properties.intel_gpu.hint.ThrottleLevel that simulates ov::intel_gpu::hint::ThrottleLevel"); m_throttle_level.attr("LOW") = ov::intel_gpu::hint::ThrottleLevel::LOW; m_throttle_level.attr("MEDIUM") = ov::intel_gpu::hint::ThrottleLevel::MEDIUM; @@ -137,7 +135,7 @@ void regmodule_properties(py::module m) { // Submodule device py::module m_device = - m_properties.def_submodule("device", "openvino.runtime.properties.device submodule that simulates ov::device"); + m_properties.def_submodule("device", "openvino.properties.device submodule that simulates ov::device"); // Submodule device - enums py::enum_(m_device, "Type", py::arithmetic()) @@ -208,7 +206,7 @@ void regmodule_properties(py::module m) { py::class_> m_capability( m_device, "Capability", - "openvino.runtime.properties.device.Capability that simulates ov::device::capability"); + "openvino.properties.device.Capability that simulates ov::device::capability"); m_capability.attr("FP32") = ov::device::capability::FP32; m_capability.attr("BF16") = ov::device::capability::BF16; @@ -225,7 +223,7 @@ void regmodule_properties(py::module m) { py::class_> m_memory_type( m_intel_gpu, "MemoryType", - "openvino.runtime.properties.intel_gpu.MemoryType submodule that simulates ov::intel_gpu::memory_type"); + "openvino.properties.intel_gpu.MemoryType submodule that simulates ov::intel_gpu::memory_type"); m_memory_type.attr("surface") = ov::intel_gpu::memory_type::surface; m_memory_type.attr("buffer") = ov::intel_gpu::memory_type::buffer; @@ -236,13 +234,12 @@ void regmodule_properties(py::module m) { py::class_> m_capability_gpu( m_intel_gpu, "CapabilityGPU", - "openvino.runtime.properties.intel_gpu.CapabilityGPU submodule that simulates ov::intel_gpu::capability"); + "openvino.properties.intel_gpu.CapabilityGPU submodule that simulates ov::intel_gpu::capability"); m_capability_gpu.attr("HW_MATMUL") = ov::intel_gpu::capability::HW_MATMUL; // Submodule log - py::module m_log = - m_properties.def_submodule("log", "openvino.runtime.properties.log submodule that simulates ov::log"); + py::module m_log = m_properties.def_submodule("log", "openvino.properties.log submodule that simulates ov::log"); // Submodule log - enums py::enum_(m_log, "Level", py::arithmetic()) @@ -258,8 +255,7 @@ void regmodule_properties(py::module m) { // Submodule streams py::module m_streams = - m_properties.def_submodule("streams", - "openvino.runtime.properties.streams submodule that simulates ov::streams"); + m_properties.def_submodule("streams", "openvino.properties.streams submodule that simulates ov::streams"); py::class_> cls_num(m_streams, "Num"); @@ -285,7 +281,7 @@ void regmodule_properties(py::module m) { // Submodule auto py::module m_intel_auto = m_properties.def_submodule("intel_auto", - "openvino.runtime.properties.intel_auto submodule that simulates ov::intel_auto"); + "openvino.properties.intel_auto submodule that simulates ov::intel_auto"); // Submodule intel_auto - enums py::enum_(m_intel_auto, "SchedulePolicy", py::arithmetic()) .value("ROUND_ROBIN", ov::intel_auto::SchedulePolicy::ROUND_ROBIN) diff --git a/src/bindings/python/src/pyopenvino/frontend/pytorch/decoder.hpp b/src/bindings/python/src/pyopenvino/frontend/pytorch/decoder.hpp index 9e372203158ed8..91c3c979d79172 100644 --- a/src/bindings/python/src/pyopenvino/frontend/pytorch/decoder.hpp +++ b/src/bindings/python/src/pyopenvino/frontend/pytorch/decoder.hpp @@ -110,8 +110,21 @@ class PyDecoder : public ov::frontend::pytorch::TorchDecoder { PYBIND11_OVERRIDE_PURE(bool, TorchDecoder, may_produce_alias, in_index, out_index); } - ov::OutputVector inlined_inputs(size_t start_index) const override { - PYBIND11_OVERRIDE_PURE(ov::OutputVector, TorchDecoder, inlined_inputs, start_index); } + ov::OutputVector inlined_input(size_t index) const override { + PYBIND11_OVERRIDE_PURE(ov::OutputVector, TorchDecoder, inlined_input, index); + } + + bool is_input_inlined(size_t index) const override { + PYBIND11_OVERRIDE_PURE(bool, TorchDecoder, is_input_inlined, index); + } + + ov::Any get_attribute(const std::string &name) const override{ + PYBIND11_OVERRIDE_PURE(ov::Any, TorchDecoder, get_attribute, name); + } + + size_t get_named_input(const std::string &name) const override{ + PYBIND11_OVERRIDE_PURE(size_t, TorchDecoder, get_named_input, name); + } const std::string& decoder_type_name() const override { PYBIND11_OVERRIDE_PURE(const std::string&, TorchDecoder, decoder_type_name); diff --git a/src/bindings/python/src/pyopenvino/graph/util.cpp b/src/bindings/python/src/pyopenvino/graph/util.cpp index 96c9dc5500257c..24e6cfb624e353 100644 --- a/src/bindings/python/src/pyopenvino/graph/util.cpp +++ b/src/bindings/python/src/pyopenvino/graph/util.cpp @@ -9,7 +9,6 @@ #include #include "openvino/core/graph_util.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/pass/manager.hpp" #include "pyopenvino/graph/ops/constant.hpp" #include "pyopenvino/utils/utils.hpp" diff --git a/src/bindings/python/src/pyopenvino/utils/utils.cpp b/src/bindings/python/src/pyopenvino/utils/utils.cpp index 906c19ae820864..57a17ad6fb57a5 100644 --- a/src/bindings/python/src/pyopenvino/utils/utils.cpp +++ b/src/bindings/python/src/pyopenvino/utils/utils.cpp @@ -375,6 +375,8 @@ ov::Any py_object_to_any(const py::object& py_obj) { return py::cast(py_obj); } else if (py::isinstance(py_obj)) { return py::cast(py_obj); + } else if (py::isinstance>(py_obj)) { + return py::cast>(py_obj); // FrontEnd Decoder } else if (py::isinstance(py_obj)) { return py::cast>(py_obj); diff --git a/src/bindings/python/tests/test_graph/test_affix_ops.py b/src/bindings/python/tests/test_graph/test_affix_ops.py index 717ce1d11cc0f0..7e42b38172cc0c 100644 --- a/src/bindings/python/tests/test_graph/test_affix_ops.py +++ b/src/bindings/python/tests/test_graph/test_affix_ops.py @@ -18,7 +18,7 @@ "XYZ", "_custom_suffix", ]) -def test_fake_quantize_affix_fails(prefix_string, suffix_string): +def test_affix_not_applied_on_nodes(prefix_string, suffix_string): levels = np.int32(4) data_shape = [1, 2, 3, 4] bound_shape = [] @@ -61,6 +61,61 @@ def test_fake_quantize_affix_fails(prefix_string, suffix_string): assert output_high_name == parameter_output_high.friendly_name +@pytest.mark.parametrize("prefix_string", [ + "ABC", + "custom_prefix_", +]) +@pytest.mark.parametrize("suffix_string", [ + "XYZ", + "_custom_suffix", +]) +def test_affix_not_applied_on_output(prefix_string, suffix_string): + levels = np.int32(4) + data_shape = [1, 2, 3, 4] + bound_shape = [] + + p1 = ov.parameter(data_shape, name="A", dtype=np.float32) + p2 = ov.parameter(data_shape, name="B", dtype=np.float32) + + data_name = "AplusB" + data = ov.add(p1, p2, name=data_name) + data_output = data.output(0) + + input_low_name = "input_low" + parameter_input_low = ov.parameter(bound_shape, name=input_low_name, dtype=np.float32) + + input_high_name = "input_high" + parameter_input_high = ov.parameter(bound_shape, name=input_high_name, dtype=np.float32) + + output_low_name = "output_low" + parameter_output_low = ov.parameter(bound_shape, name=output_low_name, dtype=np.float32) + + output_high_name = "output_high" + parameter_output_high = ov.parameter(bound_shape, name=output_high_name, dtype=np.float32) + + model = ov.fake_quantize( + data_output, + parameter_input_low, + parameter_input_high, + parameter_output_low, + parameter_output_high, + levels, + prefix=prefix_string, + suffix=suffix_string, + ) + + # Check if node was created correctly + assert model.get_type_name() == "FakeQuantize" + assert model.get_output_size() == 1 + assert list(model.get_output_shape(0)) == [1, 2, 3, 4] + + assert data_name == data_output.get_node().friendly_name + assert input_low_name == parameter_input_low.friendly_name + assert input_high_name == parameter_input_high.friendly_name + assert output_low_name == parameter_output_low.friendly_name + assert output_high_name == parameter_output_high.friendly_name + + @pytest.mark.parametrize("prefix_string", [ "", "ABC", diff --git a/src/bindings/python/tests/test_graph/test_fake_convert.py b/src/bindings/python/tests/test_graph/test_fake_convert.py index d0375d8cbedf52..da5a23045fc97d 100644 --- a/src/bindings/python/tests/test_graph/test_fake_convert.py +++ b/src/bindings/python/tests/test_graph/test_fake_convert.py @@ -53,5 +53,6 @@ def test_fake_convert_const_inputs(data_array, scale_array, shift_array, input_t op = ops.fake_convert(**input_kwargs) assert op.get_output_size() == 1 assert op.get_type_name() == "FakeConvert" + assert op.get_destination_type() == (destination_type if destination_type else "f8e4m3") assert op.get_output_partial_shape(0) == PartialShape(data_array.shape) assert op.get_output_element_type(0) == Type(input_type) diff --git a/src/bindings/python/tests/test_runtime/test_core.py b/src/bindings/python/tests/test_runtime/test_core.py index 61cb3cdcc6755b..a01463edefa199 100644 --- a/src/bindings/python/tests/test_runtime/test_core.py +++ b/src/bindings/python/tests/test_runtime/test_core.py @@ -19,6 +19,7 @@ serialize, ) +import openvino.properties as props import openvino.properties.hint as hints from openvino.runtime import Extension from tests.utils.helpers import ( @@ -229,7 +230,7 @@ def test_available_devices(device): def test_get_property(device): core = Core() - conf = core.get_property(device, "SUPPORTED_CONFIG_KEYS") + conf = core.get_property(device, props.supported_properties()) assert "PERF_COUNT" in conf diff --git a/src/bindings/python/tests/test_runtime/test_properties.py b/src/bindings/python/tests/test_runtime/test_properties.py index 12fc10f51668bb..857dcdedd1bcf6 100644 --- a/src/bindings/python/tests/test_runtime/test_properties.py +++ b/src/bindings/python/tests/test_runtime/test_properties.py @@ -17,6 +17,7 @@ import openvino.properties.log as log import openvino.properties.streams as streams from openvino import Core, Type, OVAny +from openvino.runtime import properties ### @@ -31,6 +32,7 @@ def test_properties_ro_base(): def test_properties_rw_base(): assert ov.properties.cache_dir == "CACHE_DIR" assert props.cache_dir("./test_dir") == ("CACHE_DIR", OVAny("./test_dir")) + assert properties.cache_dir("./test_dir") == ("CACHE_DIR", OVAny("./test_dir")) with pytest.raises(TypeError) as e: props.cache_dir(6) @@ -475,6 +477,7 @@ def test_properties_hint_model(): model = generate_add_model() + assert properties.hint.model() == "MODEL_PTR" assert hints.model == "MODEL_PTR" property_tuple = hints.model(model) diff --git a/src/bindings/python/tests/test_transformations/test_pattern_ops.py b/src/bindings/python/tests/test_transformations/test_pattern_ops.py index ad8b9c0afc04c9..cba87643c36ad5 100644 --- a/src/bindings/python/tests/test_transformations/test_pattern_ops.py +++ b/src/bindings/python/tests/test_transformations/test_pattern_ops.py @@ -21,7 +21,7 @@ def test_wrap_type_pattern_type(): - last_opset_number = 13 + last_opset_number = 14 for i in range(1, last_opset_number + 1): WrapType(f"opset{i}.Parameter") WrapType(f"opset{i}::Parameter") diff --git a/src/cmake/openvino.cmake b/src/cmake/openvino.cmake index e093302dd55129..770615d9365010 100644 --- a/src/cmake/openvino.cmake +++ b/src/cmake/openvino.cmake @@ -23,7 +23,6 @@ add_library(${TARGET_NAME} $ $ $ - $ $ $ $<$:$>) diff --git a/src/common/low_precision_transformations/include/low_precision/layer_transformation.hpp b/src/common/low_precision_transformations/include/low_precision/layer_transformation.hpp index e68f395049ca8d..87ce9fec59b8f3 100644 --- a/src/common/low_precision_transformations/include/low_precision/layer_transformation.hpp +++ b/src/common/low_precision_transformations/include/low_precision/layer_transformation.hpp @@ -41,16 +41,7 @@ namespace precision_set { LP_TRANSFORMATIONS_API const std::vector& get_int8_support(); LP_TRANSFORMATIONS_API const std::vector& get_int8_int16_int32_support(); } // namespace precision_set -enum levels : size_t { - int4 = 16, - int4_narrow_range = 15, - int8 = 256, - int8_narrow_range = 255, - int16 = 65536, - int16_narrow_range = 65535, - int32 = size_t(4294967296), // for ARM and ia32 platforms where this number bigger than size_t but never used - int32_narrow_range = 4294967295 -}; + class LP_TRANSFORMATIONS_API DataPrecision { public: DataPrecision() : precision(element::undefined), min(0.f), max(0.f), hasZeroPoint(false) {} diff --git a/src/common/low_precision_transformations/include/low_precision/low_precision.hpp b/src/common/low_precision_transformations/include/low_precision/low_precision.hpp index f40c92605d6cf9..083ec628ca2c0a 100644 --- a/src/common/low_precision_transformations/include/low_precision/low_precision.hpp +++ b/src/common/low_precision_transformations/include/low_precision/low_precision.hpp @@ -6,6 +6,7 @@ #include #include +#include // one place to include all Low Precision Transformations from ov::pass::low_precision #include "low_precision/rt_info/intervals_alignment_attribute.hpp" @@ -59,7 +60,7 @@ class ov::pass::low_precision::TypeRelaxedReplacer : public ov::pass::GraphRewri TypeRelaxedReplacer(); }; -class ov::pass::low_precision::LowPrecision : public ov::pass::ModelPass { +class LP_TRANSFORMATIONS_API ov::pass::low_precision::LowPrecision : public ov::pass::ModelPass { public: OPENVINO_RTTI("LowPrecision", "0"); LowPrecision( @@ -68,7 +69,9 @@ class ov::pass::low_precision::LowPrecision : public ov::pass::ModelPass { const LayerTransformation::Params = LayerTransformation::Params()); bool run_on_model(const std::shared_ptr& m) override; - static bool isFunctionQuantized(const std::shared_ptr& model); + static bool isFunctionQuantized( + const std::shared_ptr& model, + const std::set& supported_levels = all_levels); static bool isFQLevelsPresent(const std::shared_ptr& model, const std::set& levels); template diff --git a/src/common/low_precision_transformations/include/low_precision/quantization_details.hpp b/src/common/low_precision_transformations/include/low_precision/quantization_details.hpp index a34260b4f1a1ee..6c65278e97ac7b 100644 --- a/src/common/low_precision_transformations/include/low_precision/quantization_details.hpp +++ b/src/common/low_precision_transformations/include/low_precision/quantization_details.hpp @@ -5,6 +5,7 @@ #pragma once #include +#include #include #include @@ -15,6 +16,24 @@ namespace ov { namespace pass { namespace low_precision { +enum levels : size_t { + int4 = 16, + int4_narrow_range = 15, + int8 = 256, + int8_narrow_range = 255, + int16 = 65536, + int16_narrow_range = 65535, + int32 = size_t(4294967296), // for ARM and ia32 platforms where this number bigger than size_t but never used + int32_narrow_range = 4294967295 +}; + +static std::set all_levels = { + levels::int4, levels::int4_narrow_range, + levels::int8, levels::int8_narrow_range, + levels::int16, levels::int16_narrow_range, + levels::int32, levels::int32_narrow_range +}; + class LP_TRANSFORMATIONS_API QuantizationDetails { public: QuantizationDetails(); @@ -50,7 +69,9 @@ class LP_TRANSFORMATIONS_API QuantizationDetails { bool empty() const noexcept; - static bool isSupportedLevel(const size_t level); + static bool isSupportedLevel( + const size_t level, + const std::set& supported_levels = all_levels); const size_t levels; const std::vector inputLowValues; diff --git a/src/common/low_precision_transformations/src/low_precision.cpp b/src/common/low_precision_transformations/src/low_precision.cpp index 0f46c41c81768e..988b38f49a9fbe 100644 --- a/src/common/low_precision_transformations/src/low_precision.cpp +++ b/src/common/low_precision_transformations/src/low_precision.cpp @@ -297,7 +297,9 @@ bool ov::pass::low_precision::LowPrecision::run_on_model(const std::shared_ptr& model) { +bool ov::pass::low_precision::LowPrecision::isFunctionQuantized( + const std::shared_ptr& model, + const std::set& supported_levels) { std::set> handledNodes; std::deque> nodes; for (const auto& result : model->get_results()) { @@ -316,7 +318,7 @@ bool ov::pass::low_precision::LowPrecision::isFunctionQuantized(const std::share if (const auto fakeQuantize = ov::as_type_ptr(parent)) { if (QuantizationDetails::outputLayoutIsSupported(fakeQuantize, true) && - QuantizationDetails::isSupportedLevel(fakeQuantize->get_levels())) { + QuantizationDetails::isSupportedLevel(fakeQuantize->get_levels(), supported_levels)) { return true; } } else if (const auto multiSubGraph = ov::as_type_ptr(parent)) { diff --git a/src/common/low_precision_transformations/src/quantization_details.cpp b/src/common/low_precision_transformations/src/quantization_details.cpp index 8219690dbbd19d..04d8381d4b7b4f 100644 --- a/src/common/low_precision_transformations/src/quantization_details.cpp +++ b/src/common/low_precision_transformations/src/quantization_details.cpp @@ -170,15 +170,10 @@ bool QuantizationDetails::empty() const noexcept { return (levels == 0ul) && inputLowValues.empty() && inputHighValues.empty() && outputLowValues.empty() && outputHighValues.empty(); } -bool QuantizationDetails::isSupportedLevel(const size_t level) { - using ov::pass::low_precision::levels; - static const std::unordered_set supported_levels = { - levels::int4, levels::int4_narrow_range, - levels::int8, levels::int8_narrow_range, - levels::int16, levels::int16_narrow_range, - levels::int32, levels::int32_narrow_range - }; - return supported_levels.find(level) != supported_levels.end(); +bool QuantizationDetails::isSupportedLevel( + const size_t quantization_level, + const std::set& supported_levels) { + return supported_levels.find(static_cast(quantization_level)) != supported_levels.end(); } } // namespace low_precision diff --git a/src/common/low_precision_transformations/tests/eltwise_transformation_is_broadcasted_test.cpp b/src/common/low_precision_transformations/tests/eltwise_transformation_is_broadcasted_test.cpp index b953ea7b14c9e5..0a3c75649376b0 100644 --- a/src/common/low_precision_transformations/tests/eltwise_transformation_is_broadcasted_test.cpp +++ b/src/common/low_precision_transformations/tests/eltwise_transformation_is_broadcasted_test.cpp @@ -5,8 +5,6 @@ #include #include "low_precision/eltwise_base_transformation.hpp" -#include - using namespace ::testing; using namespace std; diff --git a/src/common/low_precision_transformations/tests/precision_details_test.cpp b/src/common/low_precision_transformations/tests/precision_details_test.cpp index f0c158f4d00c64..e8a81f200cd1fa 100644 --- a/src/common/low_precision_transformations/tests/precision_details_test.cpp +++ b/src/common/low_precision_transformations/tests/precision_details_test.cpp @@ -7,8 +7,6 @@ #include "low_precision/layer_transformation.hpp" #include "low_precision/fake_quantize.hpp" -#include - using namespace ::testing; using namespace std; using namespace ov::pass::low_precision; diff --git a/src/common/low_precision_transformations/tests/unit/calclulate_levels_test.cpp b/src/common/low_precision_transformations/tests/unit/calclulate_levels_test.cpp index 6344f22f359796..35917c62491015 100644 --- a/src/common/low_precision_transformations/tests/unit/calclulate_levels_test.cpp +++ b/src/common/low_precision_transformations/tests/unit/calclulate_levels_test.cpp @@ -3,7 +3,6 @@ // #include -#include #include "low_precision/network_helper.hpp" diff --git a/src/common/low_precision_transformations/tests/unit/data_precision_check.cpp b/src/common/low_precision_transformations/tests/unit/data_precision_check.cpp index f9f447a6222e24..4d6b83c9908046 100644 --- a/src/common/low_precision_transformations/tests/unit/data_precision_check.cpp +++ b/src/common/low_precision_transformations/tests/unit/data_precision_check.cpp @@ -4,7 +4,6 @@ #include #include -#include #include "low_precision/layer_transformation.hpp" #include "low_precision/network_helper.hpp" diff --git a/src/common/low_precision_transformations/tests/unit/layer_transformation_get_data_precision.cpp b/src/common/low_precision_transformations/tests/unit/layer_transformation_get_data_precision.cpp index a9d353c7440610..2002a5fa5327f3 100644 --- a/src/common/low_precision_transformations/tests/unit/layer_transformation_get_data_precision.cpp +++ b/src/common/low_precision_transformations/tests/unit/layer_transformation_get_data_precision.cpp @@ -4,7 +4,6 @@ #include #include -#include #include "low_precision/layer_transformation.hpp" #include "low_precision/network_helper.hpp" diff --git a/src/common/low_precision_transformations/tests/unit/reshape_test.cpp b/src/common/low_precision_transformations/tests/unit/reshape_test.cpp index 74e0e8224d75b8..045e9714166226 100644 --- a/src/common/low_precision_transformations/tests/unit/reshape_test.cpp +++ b/src/common/low_precision_transformations/tests/unit/reshape_test.cpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // -#include #include #include "low_precision/reshape.hpp" diff --git a/src/common/low_precision_transformations/tests/unit/update_reshape_values.cpp b/src/common/low_precision_transformations/tests/unit/update_reshape_values.cpp index 1b29f8f18a8c6f..56c605fda53ed4 100644 --- a/src/common/low_precision_transformations/tests/unit/update_reshape_values.cpp +++ b/src/common/low_precision_transformations/tests/unit/update_reshape_values.cpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // -#include #include #include "low_precision/network_helper.hpp" diff --git a/src/common/offline_transformations/include/compress_quantize_weights.hpp b/src/common/offline_transformations/include/compress_quantize_weights.hpp index 356ff01195ae3f..597b50828494a5 100644 --- a/src/common/offline_transformations/include/compress_quantize_weights.hpp +++ b/src/common/offline_transformations/include/compress_quantize_weights.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -10,13 +10,16 @@ namespace ov { namespace pass { class CompressQuantizeWeights; +class CompressWeightsWithFakeQuantize; +class CompressWeightsWithFakeConvert; } // namespace pass } // namespace ov /* - CompressQuantizeWeights transformation goal is to pre-quantize data to minimize runtime calculations with constant - data. To achieve this goal we perform FakeQuantize decomposition to separate quantization from dequantization in it. + CompressWeightsWithFakeQuantize transformation goal is to pre-quantize data to minimize runtime calculations with + constant data. To achieve this goal we perform FakeQuantize decomposition to separate quantization from + dequantization in it. Initial graph (FakeQuantize where all inputs are Constants): @@ -58,7 +61,46 @@ class CompressQuantizeWeights; With that we can skip same calculations in the runtime and make loading of such sub-graphs to the plugin faster. Additionally zero point can be fused to weights if it doesn't affect accuracy. */ -class ov::pass::CompressQuantizeWeights : public ov::pass::MatcherPass { +class ov::pass::CompressWeightsWithFakeQuantize : public ov::pass::MatcherPass { +public: + OPENVINO_RTTI("CompressWeightsWithFakeQuantize", "0"); + + CompressWeightsWithFakeQuantize(); +}; + +/* + CompressWeightsWithFakeConvert replaces FakeConvert node with constant inputs to the following subgraph: + + +----------+ + | Constant | + | (float8) } + +----+-----+ + | + v + +----------+ + | Convert | + | (float32)| + +----+-----+ + | + v + +----------+ +--------+ + | Subtract |<----| -shift | + +----+-----+ +--------+ + | + v + +----------+ +---------+ + | Multiply |<----| 1/scale | + +----------+ +---------+ + +*/ +class ov::pass::CompressWeightsWithFakeConvert : public ov::pass::MatcherPass { +public: + OPENVINO_RTTI("CompressWeightsWithFakeConvert", "0"); + + CompressWeightsWithFakeConvert(); +}; + +class ov::pass::CompressQuantizeWeights : public ov::pass::GraphRewrite { public: OPENVINO_RTTI("CompressQuantizeWeights", "0"); CompressQuantizeWeights(); diff --git a/src/common/offline_transformations/src/compress_quantize_weigths.cpp b/src/common/offline_transformations/src/compress_quantize_weigths.cpp index c708517445add5..51d9c8ed47e731 100644 --- a/src/common/offline_transformations/src/compress_quantize_weigths.cpp +++ b/src/common/offline_transformations/src/compress_quantize_weigths.cpp @@ -1,13 +1,13 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include "compress_quantize_weights.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/convert.hpp" #include "openvino/op/divide.hpp" +#include "openvino/op/fake_convert.hpp" #include "openvino/op/fake_quantize.hpp" #include "openvino/op/multiply.hpp" #include "openvino/op/subtract.hpp" @@ -17,6 +17,7 @@ #include "openvino/reference/autobroadcast_binop.hpp" #include "openvino/reference/convert.hpp" #include "openvino/reference/fake_quantize.hpp" +#include "transformations/utils/utils.hpp" #include "validation_util.hpp" static bool has_dequantization_subgraph(const std::shared_ptr& fq, @@ -60,7 +61,7 @@ static void replace_with_dequantize_subgraph(const std::shared_ptr(); auto weights_convert_pattern = pattern::wrap_type({weights_const_pattern}); OutputVector weights_options{weights_const_pattern, weights_convert_pattern}; @@ -220,8 +221,93 @@ ov::pass::CompressQuantizeWeights::CompressQuantizeWeights() { return true; }; - auto m = std::make_shared(fq_pattern, "CompressQuantizeWeights"); - this->register_matcher(m, callback); + auto m = std::make_shared(fq_pattern, "CompressWeightsWithFakeQuantize"); + register_matcher(m, callback); +} + +static std::shared_ptr get_fake_convert_shift( + const std::shared_ptr& fake_convert) { + if (fake_convert->get_input_size() < 3) + return nullptr; + const auto shift = ov::as_type_ptr(fake_convert->get_input_node_shared_ptr(2)); + if (!shift) + return nullptr; + float value = -1.0f; + if (!ov::op::util::get_single_value(shift, value) || value != 0.0f) + return shift; + return nullptr; +} + +ov::pass::CompressWeightsWithFakeConvert::CompressWeightsWithFakeConvert() { + auto weights_const_pattern = pattern::wrap_type(); + auto weights_convert_pattern = pattern::wrap_type({weights_const_pattern}); + OutputVector weights_options{weights_const_pattern, weights_convert_pattern}; + auto weights_pattern = std::make_shared(weights_options); + auto fake_convert_pattern = pattern::wrap_type( + {weights_pattern, pattern::wrap_type(), pattern::wrap_type()}); + auto fake_convert_pattern2 = + pattern::wrap_type({weights_pattern, pattern::wrap_type()}); + auto root = std::make_shared(OutputVector{fake_convert_pattern, fake_convert_pattern2}); + + matcher_pass_callback callback = [=](pattern::Matcher& m) { + const auto& pattern_map = m.get_pattern_map(); + const auto fake_convert = ov::as_type_ptr(m.get_match_root()); + auto weights = pattern_map.at(weights_const_pattern); + + NodeVector from{weights, fake_convert, fake_convert->get_input_node_shared_ptr(1)}; + NodeRegistry node_registry; + + if (weights->get_output_element_type(0) != fake_convert->get_input_element_type(0)) { + weights = std::make_shared(weights, fake_convert->get_input_element_type(0)); + } + const auto scale = fake_convert->input_value(1); + weights = std::make_shared(weights, scale); + const auto shift = get_fake_convert_shift(fake_convert); + if (shift) { + from.push_back(shift); + weights = std::make_shared(weights, shift); + } + const auto destination_type = element::Type(fake_convert->get_destination_type()); + const auto weights_convert = std::make_shared(weights, destination_type); + auto compressed_weights = ov::util::constantfold_subgraph(weights_convert); + if (!compressed_weights) { + return false; + } + node_registry.add(compressed_weights); + + const auto convert = + node_registry.make(compressed_weights, fake_convert->get_input_element_type(0)); + const auto inv_scale = ov::util::constantfold_subgraph( + std::make_shared(scale, + op::v0::Constant::create(scale.get_element_type(), Shape{}, {-1.0f}))); + if (!inv_scale) + return false; + node_registry.add(inv_scale); + std::shared_ptr multiply; + if (shift) { + // TODO: check if shift can be fused to weights and eliminate it + const auto neg_shift = ov::util::constantfold_subgraph(std::make_shared(shift)); + if (!neg_shift) + return false; + node_registry.add(neg_shift); + const auto subtract = node_registry.make(convert, neg_shift); + multiply = node_registry.make(subtract, inv_scale); + } else { + multiply = node_registry.make(convert, inv_scale); + } + + compressed_weights->set_friendly_name(weights->get_friendly_name()); + multiply->set_friendly_name(fake_convert->get_friendly_name()); + + copy_runtime_info(from, node_registry.get()); + + replace_node(fake_convert, multiply); + + return true; + }; + + auto m = std::make_shared(root, "CompressWeightsWithFakeConvert"); + register_matcher(m, callback); } static ov::Tensor tensor_from_constant(const std::shared_ptr& constant) { @@ -686,7 +772,6 @@ std::shared_ptr compress_quantized_weights( const std::shared_ptr& convert, const std::shared_ptr& zero_point, bool& can_fuse_zero_point) { - std::shared_ptr new_weights; const auto& weights_shape = weights->get_shape(); const auto& type = weights->get_element_type(); const auto& low_precision_type = convert->get_output_element_type(0); @@ -715,7 +800,6 @@ std::shared_ptr compress_quantized_weights( zero_point_constant->get_shape(), fq->get_levels(), can_fuse_zero_point); - break; } case ov::element::f16: { return compress_quantized_weights_internal(low_precision_type, @@ -733,7 +817,6 @@ std::shared_ptr compress_quantized_weights( zero_point_constant->get_shape(), fq->get_levels(), can_fuse_zero_point); - break; } case ov::element::bf16: { return compress_quantized_weights_internal(low_precision_type, @@ -751,7 +834,6 @@ std::shared_ptr compress_quantized_weights( zero_point_constant->get_shape(), fq->get_levels(), can_fuse_zero_point); - break; } default: return nullptr; @@ -832,57 +914,58 @@ std::shared_ptr compress_quantized_weights( bool zero_point_is_zero, const ov::Tensor& zero_point_tensor, bool& can_fuse_zero_point) { - std::shared_ptr new_weights; const auto& weights_shape = weights->get_shape(); const auto& type = weights->get_element_type(); switch (type) { case ov::element::f32: { - new_weights = compress_quantized_weights_internal(low_precision_type, - weights->get_data_ptr(), - weights_shape, - input_low->get_data_ptr(), - input_low->get_shape(), - input_high->get_data_ptr(), - input_low->get_shape(), - zero_point_tensor.data(), - zero_point_tensor.get_shape(), - levels, - zero_point_is_zero, - can_fuse_zero_point); - break; + return compress_quantized_weights_internal(low_precision_type, + weights->get_data_ptr(), + weights_shape, + input_low->get_data_ptr(), + input_low->get_shape(), + input_high->get_data_ptr(), + input_low->get_shape(), + zero_point_tensor.data(), + zero_point_tensor.get_shape(), + levels, + zero_point_is_zero, + can_fuse_zero_point); } case ov::element::f16: { - new_weights = compress_quantized_weights_internal(low_precision_type, - weights->get_data_ptr(), - weights_shape, - input_low->get_data_ptr(), - input_low->get_shape(), - input_high->get_data_ptr(), - input_low->get_shape(), - zero_point_tensor.data(), - zero_point_tensor.get_shape(), - levels, - zero_point_is_zero, - can_fuse_zero_point); - break; + return compress_quantized_weights_internal(low_precision_type, + weights->get_data_ptr(), + weights_shape, + input_low->get_data_ptr(), + input_low->get_shape(), + input_high->get_data_ptr(), + input_low->get_shape(), + zero_point_tensor.data(), + zero_point_tensor.get_shape(), + levels, + zero_point_is_zero, + can_fuse_zero_point); } case ov::element::bf16: { - new_weights = compress_quantized_weights_internal(low_precision_type, - weights->get_data_ptr(), - weights_shape, - input_low->get_data_ptr(), - input_low->get_shape(), - input_high->get_data_ptr(), - input_low->get_shape(), - zero_point_tensor.data(), - zero_point_tensor.get_shape(), - levels, - zero_point_is_zero, - can_fuse_zero_point); - break; + return compress_quantized_weights_internal(low_precision_type, + weights->get_data_ptr(), + weights_shape, + input_low->get_data_ptr(), + input_low->get_shape(), + input_high->get_data_ptr(), + input_low->get_shape(), + zero_point_tensor.data(), + zero_point_tensor.get_shape(), + levels, + zero_point_is_zero, + can_fuse_zero_point); } default: return nullptr; } - return new_weights; + return nullptr; +} + +ov::pass::CompressQuantizeWeights::CompressQuantizeWeights() { + add_matcher(); + add_matcher(); } diff --git a/src/common/snippets/src/lowered/linear_ir.cpp b/src/common/snippets/src/lowered/linear_ir.cpp index a29d8d2045a6f1..65eb3f741cc628 100644 --- a/src/common/snippets/src/lowered/linear_ir.cpp +++ b/src/common/snippets/src/lowered/linear_ir.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2023 Intel Corporation +// Copyright (C) 2023-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -104,6 +104,61 @@ ov::NodeVector LinearIR::get_ordered_ops(const std::shared_ptr& m) { return ov::topological_sort(nodes); } +namespace { +using NodeMap = std::unordered_map>; + +std::vector> clone_nodes(const std::vector>& nodes, + NodeMap& node_map) { + // for each node in topological order + auto sorted_nodes = topological_sort(nodes); + for (const auto& node : sorted_nodes) { + if (node_map.count(node.get()) == 0) { + // get (already) cloned arguments and clone the node + OutputVector cloned_args; + for (auto input : node->inputs()) { + ov::Output output = input.get_source_output(); + cloned_args.push_back(output.for_node(node_map.at(output.get_node()))); + } + std::vector> cloned_dependencies; + for (auto& dependency : node->get_control_dependencies()) { + std::shared_ptr& dependent = node_map.at(dependency.get()); + if (find(cloned_dependencies.begin(), cloned_dependencies.end(), dependent) == + cloned_dependencies.end()) { + cloned_dependencies.push_back(dependent); + } + } + auto cloned_node = node->copy_with_new_inputs(cloned_args, cloned_dependencies); + // There is a friendly name for this node so copy it + cloned_node->set_friendly_name(node->get_friendly_name()); + auto rt_info = node->get_rt_info(); + cloned_node->get_rt_info() = rt_info; + + for (auto output : node->outputs()) { + const auto& output_rt_info = output.get_rt_info(); + auto new_output = output.for_node(cloned_node); + new_output.get_rt_info() = output_rt_info; + } + + for (auto input : node->inputs()) { + const auto& output_rt_info = input.get_rt_info(); + auto new_input = cloned_node->input(input.get_index()); + new_input.get_rt_info() = output_rt_info; + } + + node_map[node.get()] = cloned_node; + } + } + + // create and return vector of cloned nodes + // order matches input vector (not necessarily topological) + std::vector> cloned_nodes; + for (const auto& node : nodes) { + cloned_nodes.push_back(node_map.at(node.get())); + } + return cloned_nodes; +} +} // namespace + LinearIR::container LinearIR::deep_copy_range(LinearIR::container::const_iterator begin, LinearIR::container::const_iterator end, ExressionMap& expression_map) { @@ -115,10 +170,8 @@ LinearIR::container LinearIR::deep_copy_range(LinearIR::container::const_iterato } // node_map and expr_map map original node pointer (expression) to a new pointer (expression) - ngraph::NodeMap node_map; - OPENVINO_SUPPRESS_DEPRECATED_START - ngraph::clone_nodes(original_nodes, node_map); - OPENVINO_SUPPRESS_DEPRECATED_END + NodeMap node_map; + clone_nodes(original_nodes, node_map); for (auto it = begin; it != end; it++) { const auto& expr = *it; diff --git a/src/common/snippets/src/pass/collapse_subgraph.cpp b/src/common/snippets/src/pass/collapse_subgraph.cpp index 7ce3d658e56a58..be16726b97d43f 100644 --- a/src/common/snippets/src/pass/collapse_subgraph.cpp +++ b/src/common/snippets/src/pass/collapse_subgraph.cpp @@ -17,7 +17,7 @@ #include "openvino/core/rt_info.hpp" #include "transformations/utils/utils.hpp" #include "openvino/op/util/attr_types.hpp" -#include "openvino/core/validation_util.hpp" +#include "validation_util.hpp" #include #include @@ -146,9 +146,7 @@ auto is_supported_op(const std::shared_ptr &n) -> bool { int64_t axis = -1; const auto rank = n->get_input_partial_shape(0).rank(); if (const auto softmax_v8 = ov::as_type_ptr(n)) { - OPENVINO_SUPPRESS_DEPRECATED_START - axis = ov::normalize_axis(n->get_friendly_name(), softmax_v8->get_axis(), rank); - OPENVINO_SUPPRESS_DEPRECATED_END + axis = ov::util::normalize_axis(n->get_friendly_name(), softmax_v8->get_axis(), rank); } else if (const auto softmax_v1 = ov::as_type_ptr(n)) { axis = softmax_v1->get_axis(); } else { diff --git a/src/common/snippets/src/pass/mha_tokenization.cpp b/src/common/snippets/src/pass/mha_tokenization.cpp index 67957c286a9e66..fa6fa584a2a9c7 100644 --- a/src/common/snippets/src/pass/mha_tokenization.cpp +++ b/src/common/snippets/src/pass/mha_tokenization.cpp @@ -14,7 +14,7 @@ #include "openvino/core/rt_info.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" -#include "openvino/core/validation_util.hpp" +#include "validation_util.hpp" namespace { @@ -288,9 +288,7 @@ ov::snippets::pass::TokenizeMHASnippets::TokenizeMHASnippets(const SnippetsToken int64_t axis = 0; const auto rank = interm_op->get_input_partial_shape(0).rank(); if (const auto softmax_v8 = ov::as_type_ptr(interm_op)) { - OPENVINO_SUPPRESS_DEPRECATED_START - axis = ov::normalize_axis(interm_op->get_friendly_name(), softmax_v8->get_axis(), rank); - OPENVINO_SUPPRESS_DEPRECATED_END + axis = ov::util::normalize_axis(interm_op->get_friendly_name(), softmax_v8->get_axis(), rank); } else if (const auto softmax_v1 = ov::as_type_ptr(interm_op)) { axis = softmax_v1->get_axis(); } else { diff --git a/src/common/snippets/src/pass/set_softmax_ports.cpp b/src/common/snippets/src/pass/set_softmax_ports.cpp index f8d38d51ec59b5..dce45fc0881608 100644 --- a/src/common/snippets/src/pass/set_softmax_ports.cpp +++ b/src/common/snippets/src/pass/set_softmax_ports.cpp @@ -10,7 +10,7 @@ #include "openvino/op/softmax.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" #include "openvino/pass/pattern/op/or.hpp" -#include "openvino/core/validation_util.hpp" +#include "validation_util.hpp" ov::snippets::pass::SetSoftmaxPorts::SetSoftmaxPorts() { @@ -31,9 +31,7 @@ ov::snippets::pass::SetSoftmaxPorts::SetSoftmaxPorts() { int64_t axis; if (const auto softmax_v8 = ov::as_type_ptr(root)) { - OPENVINO_SUPPRESS_DEPRECATED_START - axis = ov::normalize_axis(root->get_friendly_name(), softmax_v8->get_axis(), rank); - OPENVINO_SUPPRESS_DEPRECATED_END + axis = ov::util::normalize_axis(root->get_friendly_name(), softmax_v8->get_axis(), rank); } else if (const auto softmax_v1 = ov::as_type_ptr(root)) { axis = softmax_v1->get_axis(); } else { diff --git a/src/common/snippets/src/pass/softmax_reshape_elimination.cpp b/src/common/snippets/src/pass/softmax_reshape_elimination.cpp index 36a0afb7c11325..4b590b7fa96549 100644 --- a/src/common/snippets/src/pass/softmax_reshape_elimination.cpp +++ b/src/common/snippets/src/pass/softmax_reshape_elimination.cpp @@ -10,7 +10,7 @@ #include "openvino/core/rt_info.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" -#include "openvino/core/validation_util.hpp" +#include "validation_util.hpp" ov::snippets::pass::SoftmaxReshapeElimination::SoftmaxReshapeElimination() { MATCHER_SCOPE(SoftmaxReshapeElimination); @@ -34,9 +34,7 @@ ov::snippets::pass::SoftmaxReshapeElimination::SoftmaxReshapeElimination() { const auto softmax_rank = softmax->get_input_partial_shape(0).rank(); int64_t axis = 0; if (const auto softmax_v8 = ov::as_type_ptr(softmax)) { - OPENVINO_SUPPRESS_DEPRECATED_START - axis = ov::normalize_axis(softmax->get_friendly_name(), softmax_v8->get_axis(), softmax_rank); - OPENVINO_SUPPRESS_DEPRECATED_END + axis = ov::util::normalize_axis(softmax->get_friendly_name(), softmax_v8->get_axis(), softmax_rank); } else if (const auto softmax_v1 = ov::as_type_ptr(softmax)) { axis = softmax_v1->get_axis(); } else { diff --git a/src/common/snippets/src/pass/validate.cpp b/src/common/snippets/src/pass/validate.cpp index d80549403d0361..1a1155d189a70c 100644 --- a/src/common/snippets/src/pass/validate.cpp +++ b/src/common/snippets/src/pass/validate.cpp @@ -17,7 +17,7 @@ #include "openvino/op/reshape.hpp" #include "openvino/op/transpose.hpp" #include "openvino/op/softmax.hpp" -#include "openvino/core/validation_util.hpp" +#include "validation_util.hpp" namespace ov { @@ -62,9 +62,7 @@ bool Validate::is_supported_softmax(const std::shared_ptr& op) { const auto softmax_rank = op->get_input_partial_shape(0).rank(); int64_t axis = 0; if (const auto softmax_v8 = ov::as_type_ptr(op)) { - OPENVINO_SUPPRESS_DEPRECATED_START - axis = ov::normalize_axis(softmax_v8->get_friendly_name(), softmax_v8->get_axis(), softmax_rank); - OPENVINO_SUPPRESS_DEPRECATED_END + axis = ov::util::normalize_axis(softmax_v8->get_friendly_name(), softmax_v8->get_axis(), softmax_rank); } else if (const auto softmax_v1 = ov::as_type_ptr(op)) { axis = softmax_v1->get_axis(); } else { diff --git a/src/common/transformations/src/transformations/common_optimizations/fuse_rotary_positional_embeddings.cpp b/src/common/transformations/src/transformations/common_optimizations/fuse_rotary_positional_embeddings.cpp index 689664922486b7..15125e2650ec1a 100644 --- a/src/common/transformations/src/transformations/common_optimizations/fuse_rotary_positional_embeddings.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/fuse_rotary_positional_embeddings.cpp @@ -5,7 +5,6 @@ #include "transformations/common_optimizations/fuse_rotary_positional_embeddings.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/add.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/multiply.hpp" diff --git a/src/common/transformations/src/transformations/common_optimizations/matmul_const_transposes_extraction.cpp b/src/common/transformations/src/transformations/common_optimizations/matmul_const_transposes_extraction.cpp index 825fb20a3b7393..03b49d5609044e 100644 --- a/src/common/transformations/src/transformations/common_optimizations/matmul_const_transposes_extraction.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/matmul_const_transposes_extraction.cpp @@ -5,7 +5,6 @@ #include "transformations/common_optimizations/matmul_const_transposes_extraction.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/fake_quantize.hpp" #include "openvino/op/matmul.hpp" diff --git a/src/common/transformations/src/transformations/common_optimizations/reduce_merge.cpp b/src/common/transformations/src/transformations/common_optimizations/reduce_merge.cpp index 7d41a54b98c30b..daff4afbc239b3 100644 --- a/src/common/transformations/src/transformations/common_optimizations/reduce_merge.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/reduce_merge.cpp @@ -9,6 +9,7 @@ #include "itt.hpp" #include "openvino/core/rt_info.hpp" #include "openvino/op/concat.hpp" +#include "openvino/op/convert.hpp" #include "openvino/op/reduce_l1.hpp" #include "openvino/op/reduce_l2.hpp" #include "openvino/op/reduce_logical_and.hpp" @@ -18,6 +19,7 @@ #include "openvino/op/reduce_min.hpp" #include "openvino/op/reduce_prod.hpp" #include "openvino/op/reduce_sum.hpp" +#include "openvino/op/unsqueeze.hpp" #include "openvino/pass/pattern/op/or.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" #include "validation_util.hpp" @@ -64,6 +66,26 @@ bool fuse_reduce_operations(const std::shared_ptr& node) { } } + // Align reduce axes constants by shape and type + const bool dtype_match = + top_reduce->input_value(1).get_element_type() == bottom_reduce->input_value(1).get_element_type(); + for (auto& reduce : {top_reduce, bottom_reduce}) { + const auto reduce_axes_output = reduce->input_value(1); + const auto reduce_axes_node = reduce_axes_output.get_node_shared_ptr(); + const auto reduce_axes_rank = reduce_axes_output.get_partial_shape().rank(); + if (reduce_axes_rank == Dimension(0)) { + const auto unsqueeze_const = ov::op::v0::Constant::create(reduce_axes_node->get_element_type(), {}, {0}); + const auto unsqueeze = std::make_shared(reduce_axes_output, unsqueeze_const); + reduce->inputs()[1].replace_source_output(unsqueeze); + copy_runtime_info(reduce_axes_node, {unsqueeze_const, unsqueeze}); + } + if (!dtype_match) { + const auto cast = std::make_shared(reduce->input_value(1), ov::element::i64); + reduce->inputs()[1].replace_source_output(cast); + copy_runtime_info(reduce_axes_node, cast); + } + } + std::shared_ptr axes = std::make_shared(OutputVector{top_reduce->input_value(1), bottom_reduce->input_value(1)}, int64_t(0)); diff --git a/src/common/transformations/src/transformations/common_optimizations/select_with_one_value_condition.cpp b/src/common/transformations/src/transformations/common_optimizations/select_with_one_value_condition.cpp index f8f3c53acc5ac0..329922bb0a0b40 100644 --- a/src/common/transformations/src/transformations/common_optimizations/select_with_one_value_condition.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/select_with_one_value_condition.cpp @@ -8,7 +8,6 @@ #include "itt.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/select.hpp" diff --git a/src/common/transformations/src/transformations/common_optimizations/shared_ops_optimization.cpp b/src/common/transformations/src/transformations/common_optimizations/shared_ops_optimization.cpp index d2ee2f7845fe8b..e45dc0b95346ba 100644 --- a/src/common/transformations/src/transformations/common_optimizations/shared_ops_optimization.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/shared_ops_optimization.cpp @@ -5,7 +5,6 @@ #include "transformations/common_optimizations/shared_ops_optimization.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/add.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/ceiling.hpp" diff --git a/src/common/transformations/src/transformations/common_optimizations/transpose_reshape_elimination_for_matmul.cpp b/src/common/transformations/src/transformations/common_optimizations/transpose_reshape_elimination_for_matmul.cpp index 013c91ef680f0b..f6309ecbc17dc6 100644 --- a/src/common/transformations/src/transformations/common_optimizations/transpose_reshape_elimination_for_matmul.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/transpose_reshape_elimination_for_matmul.cpp @@ -9,7 +9,6 @@ #include "itt.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/matmul.hpp" #include "openvino/op/reshape.hpp" diff --git a/src/common/transformations/src/transformations/smart_reshape/broadcast_const_range_replacement.cpp b/src/common/transformations/src/transformations/smart_reshape/broadcast_const_range_replacement.cpp index fdbd53e3c4ce67..985a147fd8ab43 100644 --- a/src/common/transformations/src/transformations/smart_reshape/broadcast_const_range_replacement.cpp +++ b/src/common/transformations/src/transformations/smart_reshape/broadcast_const_range_replacement.cpp @@ -9,7 +9,6 @@ #include "itt.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/convert.hpp" diff --git a/src/common/transformations/src/transformations/smart_reshape/matmul_sr.cpp b/src/common/transformations/src/transformations/smart_reshape/matmul_sr.cpp index ff7dc8c927d0ae..1a3bccc2cc25dd 100644 --- a/src/common/transformations/src/transformations/smart_reshape/matmul_sr.cpp +++ b/src/common/transformations/src/transformations/smart_reshape/matmul_sr.cpp @@ -9,7 +9,6 @@ #include "itt.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/gather.hpp" diff --git a/src/common/transformations/src/transformations/transpose_sinking/ts_fuse.cpp b/src/common/transformations/src/transformations/transpose_sinking/ts_fuse.cpp index 4ebc7dca880dc0..116a4acba43ccc 100644 --- a/src/common/transformations/src/transformations/transpose_sinking/ts_fuse.cpp +++ b/src/common/transformations/src/transformations/transpose_sinking/ts_fuse.cpp @@ -8,7 +8,6 @@ #include #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/transpose.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" diff --git a/src/common/transformations/tests/common_optimizations/reduce_merge.cpp b/src/common/transformations/tests/common_optimizations/reduce_merge.cpp index a9ae6506e14384..18793aaecca7b3 100644 --- a/src/common/transformations/tests/common_optimizations/reduce_merge.cpp +++ b/src/common/transformations/tests/common_optimizations/reduce_merge.cpp @@ -306,3 +306,23 @@ TEST_F(TransformationTestsF, ReduceMergeConcatAxes) { comparator.enable(FunctionsComparator::CmpValues::CONST_VALUES); comparator.enable(FunctionsComparator::CmpValues::ACCURACY); } + +TEST_F(TransformationTestsF, ReduceMergeDifferentShapesAndTypes) { + { + auto data = std::make_shared(element::i64, Shape{3, 2}); + auto reduce1_axes = op::v0::Constant::create(element::i64, Shape{}, {0}); + auto reduce1 = std::make_shared(data, reduce1_axes, true); + auto reduce2_axis = op::v0::Constant::create(element::i32, Shape{1}, {0}); + model = std::make_shared(OutputVector{std::make_shared(reduce1, reduce2_axis, true)}, + ParameterVector{data}); + manager.register_pass(); + } + { + auto data = std::make_shared(element::i64, Shape{3, 2}); + auto axes = op::v0::Constant::create(element::i64, Shape{2}, {0, 0}); + auto reduce = std::make_shared(data, axes, true); + model_ref = std::make_shared(OutputVector{reduce}, ParameterVector{data}); + } + comparator.enable(FunctionsComparator::CmpValues::CONST_VALUES); + comparator.enable(FunctionsComparator::CmpValues::ACCURACY); +} diff --git a/src/common/transformations/tests/const_folding_for_mvn.cpp b/src/common/transformations/tests/const_folding_for_mvn.cpp index da6c671a2f1d16..1cb833bafb741a 100644 --- a/src/common/transformations/tests/const_folding_for_mvn.cpp +++ b/src/common/transformations/tests/const_folding_for_mvn.cpp @@ -6,7 +6,6 @@ #include "common_test_utils/graph_comparator.hpp" #include "common_test_utils/test_common.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/opsets/opset10.hpp" #include "openvino/pass/constant_folding.hpp" #include "openvino/pass/manager.hpp" diff --git a/src/common/transformations/tests/offline_transformations/pruning_test.cpp b/src/common/transformations/tests/offline_transformations/pruning_test.cpp index 485bcc28d4c462..9dab20582be727 100644 --- a/src/common/transformations/tests/offline_transformations/pruning_test.cpp +++ b/src/common/transformations/tests/offline_transformations/pruning_test.cpp @@ -62,65 +62,6 @@ class DISABLED_TransformationTestsF : public TransformationTestsF {}; class TransformationTestsBoolParamF : public TransformationTestsF, public testing::WithParamInterface {}; -// Uncomment and specify PRUNING_TARGET_IR_PATH var to check pruning on given IR -// TEST(TransformationTests, PruneIRTest) { -// InferenceEngine::Core core; -// -// const std::string input_model = ov::util::getenv_string("PRUNING_TARGET_IR_PATH"); -// if (input_model == "") -// return; -// -// auto model = core.ReadNetwork(input_model).getFunction(); -// -// { -// pass::Manager m; -// m.register_pass(); -// m.register_pass(); -// } -// // VisualizeTree modifier helps to print Masks and mark nodes with masks -// auto modifier = [](const Node& node, std::vector& attributes) { -// std::stringstream ss; -// size_t index{0}; -// for (const auto & output : node.outputs()) { -// if (const auto & mask = getMask(output)) { -// if (!mask->all_dims_are_empty()) { -// attributes.emplace_back("color=green"); -// attributes.emplace_back("penwidth=2"); -// } -// ss << "Mask(" << index << ") : " << *mask << "\\n"; -// } -// index++; -// } -// if (!ss.str().empty()) { -// auto label = std::find_if(attributes.begin(), attributes.end(), -// [](const std::string & value) { return value.find("label=") != std::string::npos; -// }); -// if (label != attributes.end()) { -// label->pop_back(); -// *label += "\n" + ss.str() + "\""; -// } else { -// attributes.push_back("label=\"" + ss.str() + "\""); -// } -// } -// }; -// -// { -// pass::Manager m; -// m.register_pass(std::string(VISUALIZE_TREE_ROOT) + "PruneIRTest_with_masks.svg", -// modifier); m.register_pass(); -// m.register_pass(std::string(VISUALIZE_TREE_ROOT) + -// "PruneIRTest_with_masks_after_shrink.svg", modifier); -// } -// -// if (VISUALIZE_TESTS_TREE) -// pass::VisualizeTree(std::string(VISUALIZE_TREE_ROOT) + "PruneIRTest.svg").run_on_function(model); -// { -// pass::Manager m; -// m.register_pass(std::string(VISUALIZE_TREE_ROOT) + "ir_model_pruned.xml", -// std::string(VISUALIZE_TREE_ROOT) + "ir_model_pruned.bin"); -// } -//} - TEST(TransformationTests, InitMasksOI) { Shape weights_shape{6, 3, 3, 3}; auto weights = opset10::Constant::create(element::f32, weights_shape, {0}); diff --git a/src/common/transformations/tests/symbolic_transformations/dereshape_matmul.cpp b/src/common/transformations/tests/symbolic_transformations/dereshape_matmul.cpp index 7ab4d48cc81381..40d8aef121ab4d 100644 --- a/src/common/transformations/tests/symbolic_transformations/dereshape_matmul.cpp +++ b/src/common/transformations/tests/symbolic_transformations/dereshape_matmul.cpp @@ -9,11 +9,11 @@ #include "common_test_utils/ov_test_utils.hpp" #include "openvino/core/dimension_tracker.hpp" #include "openvino/core/model.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/matmul.hpp" #include "openvino/op/parameter.hpp" #include "openvino/op/reshape.hpp" #include "transformations/utils/utils.hpp" +#include "validation_util.hpp" using namespace ov; using namespace ov::op; @@ -93,9 +93,7 @@ void get_dims(const ov::Output& source, const size_t& from, const size std::vector non_constant_ids; for (size_t i = from; i < to; ++i) { auto node = ov::op::util::node_to_get_shape_value_of_indices_from_shape_source(source, {i}); - OPENVINO_SUPPRESS_DEPRECATED_START - if (auto constant = ov::get_constant_from_source(node)) { - OPENVINO_SUPPRESS_DEPRECATED_END + if (auto constant = ov::util::get_constant_from_source(node)) { node = constant; } else { non_constant_ids.push_back(i); diff --git a/src/common/transformations/tests/utils/compress_quantize_weights.cpp b/src/common/transformations/tests/utils/compress_quantize_weights.cpp index 4c1eef7cea5489..fe0918cc3425c3 100644 --- a/src/common/transformations/tests/utils/compress_quantize_weights.cpp +++ b/src/common/transformations/tests/utils/compress_quantize_weights.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -391,3 +391,145 @@ TEST_F(TransformationTestsF, NegativeCompressQuantizeWeightsNonConstantInput) { comparator.enable(FunctionsComparator::CmpValues::CONST_VALUES); comparator.enable(FunctionsComparator::CmpValues::ACCURACY); } + +using CompressWeightsWithFakeConvertParams = std::tuple; // float8 type + +class CompressWeightsNoZeroPoint : public TransformationTestsF, + public testing::WithParamInterface {}; + +TEST_P(CompressWeightsNoZeroPoint, FakeConvert) { + const auto& param = GetParam(); + bool zero_point_absent = std::get<0>(param); + std::string destination_type = std::get<1>(param); + + { + auto weights = op::v0::Constant::create(element::f32, + Shape{3, 1, 2, 2}, + {-0.01448f, + -0.02314f, + -0.02244f, + -0.00090f, + 0.024261f, + 0.031921f, + 0.034088f, + -0.0497f, + -0.0588f, + -0.04541f, + -0.01281f, + 0.009109f}); + auto scale = op::v0::Constant::create(element::f32, Shape{3, 1, 1, 1}, {54.50976f}); + std::shared_ptr fake_convert; + if (zero_point_absent) { + fake_convert = std::make_shared(weights, scale, destination_type); + } else { + auto shift = op::v0::Constant::create(element::f32, Shape{3, 1, 1, 1}, {0.0f}); + fake_convert = std::make_shared(weights, scale, shift, destination_type); + } + model = std::make_shared(fake_convert, ParameterVector{}); + + manager.register_pass(); + } + + { + std::vector weights_data = + destination_type == "f8e4m3" + ? std::vector{-0.8125f, + -1.25f, + -1.25f, + -0.0507812f, + 1.375f, + 1.75f, + 1.875f, + -2.75f, + -3.25f, + -2.5f, + -0.6875f, + 0.5f} + : + + std::vector< + float>{-0.75f, -1.25f, -1.25f, -0.046875f, 1.25f, 1.75f, 1.75f, -2.5f, -3.0f, -2.5f, -0.75f, 0.5f}; + auto weights = + std::make_shared(element::Type(destination_type), Shape{3, 1, 2, 2}, weights_data); + auto convert = std::make_shared(weights, element::f32); + auto scale = op::v0::Constant::create(element::f32, Shape{3, 1, 1, 1}, {0.01834533f}); + auto multiply = std::make_shared(convert, scale); + model_ref = std::make_shared(multiply, ParameterVector{}); + } + + m_abs_threshold = 1e-6f; + m_rel_threshold = 1e-6f; + + comparator.enable(FunctionsComparator::CmpValues::CONST_VALUES); + comparator.enable(FunctionsComparator::CmpValues::ACCURACY); +} + +INSTANTIATE_TEST_SUITE_P(CompressQuantizeWeights, + CompressWeightsNoZeroPoint, + testing::Combine(testing::Values(false, true), testing::Values("f8e4m3", "f8e5m2"))); + +class CompressWeightsWithZeroPoint : public TransformationTestsF, public testing::WithParamInterface {}; + +TEST_P(CompressWeightsWithZeroPoint, FakeConvert) { + const auto& destination_type = GetParam(); + + { + auto weights = op::v0::Constant::create(element::f32, + Shape{3, 1, 2, 2}, + {-0.01448f, + -0.02314f, + -0.02244f, + -0.00090f, + 0.024261f, + 0.031921f, + 0.034088f, + -0.0497f, + -0.0588f, + -0.04541f, + -0.01281f, + 0.009109f}); + auto scale = op::v0::Constant::create(element::f32, Shape{3, 1, 1, 1}, {54.50976f}); + auto shift = op::v0::Constant::create(element::f32, Shape{3, 1, 1, 1}, {0.7f, -0.0304f, -0.012f}); + auto fake_convert = std::make_shared(weights, scale, shift, destination_type); + model = std::make_shared(fake_convert, ParameterVector{}); + + manager.register_pass(); + } + + { + std::vector weights_data = + destination_type == "f8e4m3" + ? std::vector{-1.5f, + -2.0f, + -1.875f, + -0.75f, + 1.375f, + 1.75f, + 1.875f, + -2.75f, + -3.25f, + -2.5f, + -0.6875f, + 0.5f} + : std::vector< + float>{-1.5f, -2.0f, -2.0f, -0.75f, 1.25f, 1.75f, 2.0f, -2.5f, -3.0f, -2.5f, -0.625f, 0.5f}; + + auto weights = + std::make_shared(element::Type(destination_type), Shape{3, 1, 2, 2}, weights_data); + auto convert = std::make_shared(weights, element::f32); + auto shift = op::v0::Constant::create(element::f32, Shape{3, 1, 1, 1}, {-0.7f, 0.0304f, 0.012f}); + auto subtract = std::make_shared(convert, shift); + auto scale = op::v0::Constant::create(element::f32, Shape{3, 1, 1, 1}, {1.0f / 54.50976f}); + auto multiply = std::make_shared(subtract, scale); + model_ref = std::make_shared(multiply, ParameterVector{}); + } + + m_abs_threshold = 1e-6f; + m_rel_threshold = 1e-6f; + + comparator.enable(FunctionsComparator::CmpValues::CONST_VALUES); + comparator.enable(FunctionsComparator::CmpValues::ACCURACY); +} + +INSTANTIATE_TEST_SUITE_P(CompressQuantizeWeights, CompressWeightsWithZeroPoint, testing::Values("f8e4m3", "f8e5m2")); diff --git a/src/common/util/include/openvino/util/file_util.hpp b/src/common/util/include/openvino/util/file_util.hpp index 05538638c9d7fc..94678df085db05 100644 --- a/src/common/util/include/openvino/util/file_util.hpp +++ b/src/common/util/include/openvino/util/file_util.hpp @@ -355,5 +355,16 @@ void save_binary(const std::string& path, const char* binary, size_t bin_size); */ const char* trim_file_name(const char* const fname); +template +using enableIfSupportedChar = + typename std::enable_if<(std::is_same::value || std::is_same::value)>::type; + +template > +inline std::basic_string make_path(const std::basic_string& folder, const std::basic_string& file) { + if (folder.empty()) + return file; + return folder + ov::util::FileTraits::file_separator + file; +} + } // namespace util } // namespace ov diff --git a/src/core/dev_api/legacy_op_extension.hpp b/src/core/dev_api/legacy_op_extension.hpp deleted file mode 100644 index 514e31da604b4c..00000000000000 --- a/src/core/dev_api/legacy_op_extension.hpp +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "openvino/core/op_extension.hpp" - -namespace ov { - -/** @brief Class to distinguish legacy extension. */ -class OPENVINO_API LegacyOpExtension : public BaseOpExtension { -public: - ~LegacyOpExtension() override; -}; -} // namespace ov diff --git a/src/core/include/ngraph/axis_set.hpp b/src/core/include/ngraph/axis_set.hpp deleted file mode 100644 index 9bcf8a06b4eaca..00000000000000 --- a/src/core/include/ngraph/axis_set.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED) -# define NGRAPH_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include -#include -#include -#include - -#include "ngraph/ngraph_visibility.hpp" -#include "openvino/core/axis_set.hpp" - -namespace ngraph { -using ov::AxisSet; -} // namespace ngraph diff --git a/src/core/include/ngraph/axis_vector.hpp b/src/core/include/ngraph/axis_vector.hpp deleted file mode 100644 index bb02571c1d4529..00000000000000 --- a/src/core/include/ngraph/axis_vector.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED) -# define NGRAPH_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include -#include -#include - -#include "ngraph/ngraph_visibility.hpp" -#include "openvino/core/axis_vector.hpp" - -namespace ngraph { -/// \brief A vector of axes. -using ov::AxisVector; -} // namespace ngraph diff --git a/src/core/include/ngraph/check.hpp b/src/core/include/ngraph/check.hpp deleted file mode 100644 index aa1d0b72230b4f..00000000000000 --- a/src/core/include/ngraph/check.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED) -# define NGRAPH_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include -#include -#include - -#include "openvino/core/except.hpp" - -namespace ngraph { -using ov::write_all_to_stream; - -using CheckFailure = ov::AssertFailure; -} // namespace ngraph - -#define NGRAPH_CHECK_HELPER2(exc_class, ctx, check, ...) OPENVINO_ASSERT_HELPER2(exc_class, ctx, check, __VA_ARGS__) - -#define NGRAPH_CHECK_HELPER1(exc_class, ctx, check) OPENVINO_ASSERT_HELPER1(exc_class, ctx, check) - -#define NGRAPH_CHECK(...) OPENVINO_ASSERT(__VA_ARGS__) - -#define NGRAPH_UNREACHABLE(...) NGRAPH_CHECK(false, "Unreachable: ", __VA_ARGS__) -#define NGRAPH_CHECK_HELPER(exc_class, ctx, ...) OPENVINO_ASSERT_HELPER(exc_class, ctx, __VA_ARGS__) diff --git a/src/core/include/ngraph/coordinate_diff.hpp b/src/core/include/ngraph/coordinate_diff.hpp deleted file mode 100644 index 669f72affa7cd7..00000000000000 --- a/src/core/include/ngraph/coordinate_diff.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED) -# define NGRAPH_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include -#include -#include - -#include "ngraph/ngraph_visibility.hpp" -#include "openvino/core/coordinate_diff.hpp" - -namespace ngraph { -/// \brief A difference (signed) of tensor element coordinates. -using ov::CoordinateDiff; -} // namespace ngraph diff --git a/src/core/include/ngraph/deprecated.hpp b/src/core/include/ngraph/deprecated.hpp deleted file mode 100644 index e6ed8371daa978..00000000000000 --- a/src/core/include/ngraph/deprecated.hpp +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED) -# define NGRAPH_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include "openvino/core/deprecated.hpp" - -#define NGRAPH_DEPRECATED(msg) OPENVINO_DEPRECATED(msg) -#define NGRAPH_ENUM_DEPRECATED(msg) OPENVINO_ENUM_DEPRECATED(msg) -#define NGRAPH_SUPPRESS_DEPRECATED_START OPENVINO_SUPPRESS_DEPRECATED_START -#define NGRAPH_SUPPRESS_DEPRECATED_END OPENVINO_SUPPRESS_DEPRECATED_END -#define NGRAPH_API_DEPRECATED \ - OPENVINO_DEPRECATED("The nGraph API is deprecated and will be removed in the 2024.0 release. " \ - "For instructions on transitioning to the new API, please refer to " \ - "https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") diff --git a/src/core/include/ngraph/enum_names.hpp b/src/core/include/ngraph/enum_names.hpp deleted file mode 100644 index 637e7aa0e3e170..00000000000000 --- a/src/core/include/ngraph/enum_names.hpp +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED) -# define NGRAPH_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include "ngraph/check.hpp" -#include "openvino/core/enum_names.hpp" - -namespace ngraph { -using ov::as_enum; -using ov::as_string; -using ov::EnumNames; -} // namespace ngraph diff --git a/src/core/include/ngraph/env_util.hpp b/src/core/include/ngraph/env_util.hpp deleted file mode 100644 index b11947531dd39a..00000000000000 --- a/src/core/include/ngraph/env_util.hpp +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED) -# define NGRAPH_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include -#include -#include - -#include "ngraph/deprecated.hpp" - -namespace ngraph { -/// \brief Get the names environment variable as a string. -/// \param env_var The string name of the environment variable to get. -/// \return Returns string by value or an empty string if the environment -/// variable is not set. -NGRAPH_API_DEPRECATED NGRAPH_API std::string getenv_string(const char* env_var); - -/// \brief Get the names environment variable as an integer. If the value is not a -/// valid integer then an exception is thrown. -/// \param env_var The string name of the environment variable to get. -/// \param default_value The value to return if the environment variable is not set. -/// \return Returns value or default_value if the environment variable is not set. -NGRAPH_API_DEPRECATED NGRAPH_API int32_t getenv_int(const char* env_var, int32_t default_value = -1); - -/// \brief Get the names environment variable as a boolean. If the value is not a -/// valid boolean then an exception is thrown. Valid booleans are one of -/// 1, 0, on, off, true, false -/// All values are case insensitive. -/// If the environment variable is not set the default_value is returned. -/// \param env_var The string name of the environment variable to get. -/// \param default_value The value to return if the environment variable is not set. -/// \return Returns the boolean value of the environment variable. -NGRAPH_API_DEPRECATED NGRAPH_API bool getenv_bool(const char* env_var, bool default_value = false); -} // namespace ngraph diff --git a/src/core/include/ngraph/graph_util.hpp b/src/core/include/ngraph/graph_util.hpp deleted file mode 100644 index 488a8077591ebe..00000000000000 --- a/src/core/include/ngraph/graph_util.hpp +++ /dev/null @@ -1,235 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED) -# define NGRAPH_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ngraph/check.hpp" -#include "ngraph/deprecated.hpp" -#include "openvino/core/graph_util.hpp" - -namespace ov { -namespace op { -namespace v0 { -class Parameter; -class Result; -} // namespace v0 -} // namespace op -} // namespace ov -namespace ngraph { - -namespace op { -namespace v0 { -using ov::op::v0::Parameter; -using ov::op::v0::Result; -} // namespace v0 -} // namespace op - -using ov::compare_constants; -using ov::replace_node; -using ov::replace_node_update_name; -using ov::replace_nodes; -using ov::replace_output_update_name; -using ov::topological_sort; -using ov::traverse_nodes; - -using NodeMap = std::unordered_map>; - -NGRAPH_API_DEPRECATED -NGRAPH_API -ov::NodeVector find_common_args(std::shared_ptr target, std::shared_ptr replacement); - -/// Topological sort of just nodes -template -NGRAPH_API_DEPRECATED std::vector> subgraph_topological_sort(T nodes) { - std::stack> nodes_to_do; - std::unordered_set nodes_done; - std::unordered_set nodes_to_emit; - std::vector> result; - - for (auto& node : nodes) { - nodes_to_emit.insert(node.get()); - nodes_to_do.push(node.get()); - } - // NB: Some centos versions implement std::list::size() by counting elements - size_t nodes_remaining = nodes_to_emit.size(); - while (nodes_to_do.size() > 0 && nodes_remaining > 0) { - ov::Node* node = nodes_to_do.top(); - if (nodes_done.count(node) == 0) { - bool can_add = true; - size_t arg_count = node->get_input_size(); - for (size_t i = 0; i < arg_count; ++i) { - ov::Node* dep = node->get_input_node_ptr(arg_count - i - 1); - if (nodes_done.count(dep) == 0 && nodes_to_emit.count(node) != 0) { - can_add = false; - nodes_to_do.push(dep); - } - } - for (auto& depptr : node->get_control_dependencies()) { - ov::Node* dep = depptr.get(); - if (nodes_done.count(dep) == 0) { - can_add = false; - nodes_to_do.push(dep); - } - } - if (can_add) { - if (nodes_to_emit.count(node) != 0) { - result.push_back(node->shared_from_this()); - nodes_remaining--; - } - nodes_to_do.pop(); - nodes_done.insert(node); - } - } - - else { - nodes_to_do.pop(); - } - } - return result; -} - -template -NGRAPH_API_DEPRECATED void validate_nodes_and_infer_types(const T& nodes) { - OPENVINO_SUPPRESS_DEPRECATED_START - for (auto& node : subgraph_topological_sort(nodes)) { - node->revalidate_and_infer_types(); - } - OPENVINO_SUPPRESS_DEPRECATED_END -} - -// Check if all paths from X to a result go through Y -NGRAPH_API_DEPRECATED -NGRAPH_API -bool is_post_dominated(ov::Node* X, ov::Node* Y); - -NGRAPH_API_DEPRECATED -NGRAPH_API -bool is_equal_to_const_value(const std::string& const_value, const ov::Output& reduce_constant); - -// input nodes are cloned and returned -// NodeMap input may contain default node mapping i.e. pre-cloned nodes -// NodeMap output (by reference) fully maps input and cloned nodes -NGRAPH_API_DEPRECATED -NGRAPH_API -std::vector> clone_nodes(const std::vector>& nodes, - NodeMap& node_map); - -// input nodes are cloned and returned -// NodeMap input may contain default node mapping i.e. pre-cloned nodes -// NodeMap output (by reference) fully maps input and cloned nodes -NGRAPH_API_DEPRECATED -NGRAPH_API -std::list> clone_nodes(const std::vector>& nodes, - ov::RawNodeOutputMap& node_map); - -NGRAPH_API_DEPRECATED -NGRAPH_API -std::pair, std::shared_ptr> insert_result_parameter_split( - const std::shared_ptr& src_node, - const std::shared_ptr& dst_node); - -NGRAPH_API_DEPRECATED -NGRAPH_API -void insert_new_node_between(const std::shared_ptr& src_node, - const std::shared_ptr& dst_node, - const std::shared_ptr& new_node); - -NGRAPH_API_DEPRECATED -NGRAPH_API -std::shared_ptr make_zero(const ov::element::Type& element_type, const ov::Shape& shape); - -NGRAPH_API_DEPRECATED -NGRAPH_API -std::shared_ptr make_constant_from_string(std::string val, - const ov::element::Type& element_type, - const ov::Shape& shape); - -NGRAPH_API_DEPRECATED -NGRAPH_API -bool is_zero(const ov::Output& reduce_constant); - -NGRAPH_API_DEPRECATED -NGRAPH_API -ov::NodeVector get_subgraph_outputs(const ov::NodeVector& nodes, - const ov::NodeVector& exclusions, - bool ignore_unused = false, - bool ignore_output_duplicates = true); - -// Extract sub-graph computing the `results`. Stops backward traversal at either a Parameter -// node -// or a node that belongs to args -NGRAPH_API_DEPRECATED -NGRAPH_API -ov::NodeVector extract_subgraph(const ov::NodeVector& results, const ov::NodeVector& args); - -NGRAPH_API_DEPRECATED -NGRAPH_API -bool is_one(const ov::Output& reduce_constant); - -// Returns true if `node` is live in the graph i.e. a result op -// transitively uses this `node` -NGRAPH_API_DEPRECATED -NGRAPH_API -bool is_used(ov::Node* node); - -// Returns count of `node` users that are still live in the graph -NGRAPH_API_DEPRECATED -NGRAPH_API -size_t get_user_count(ov::Node* node); - -NGRAPH_API_DEPRECATED -NGRAPH_API -bool is_strided(const ov::Strides& strides); - -NGRAPH_API_DEPRECATED -NGRAPH_API -bool is_valid_rank(const std::shared_ptr& node, std::vector valid_ranks); - -NGRAPH_API_DEPRECATED -NGRAPH_API -void plot_graph(std::shared_ptr f, - const std::string& filename, - std::function& attributes)> = nullptr); - -/// \return A vector containing handles for each input of dst that is connected to an output -/// of `src`. -NGRAPH_API_DEPRECATED -NGRAPH_API -std::vector> get_inputs_from(ov::Node& src, ov::Node& dst); -/// \return A vector containing a handle for each output of src that is connected to an input -/// of `dst`. -NGRAPH_API_DEPRECATED -NGRAPH_API -std::vector> get_outputs_to(ov::Node& src, ov::Node& dst); - -/// Checks the func for graph cycles starting from results going backwards, then from parameters -/// going forward. -/// It returns true if a cycle is found and the first cycle encountered. -NGRAPH_API_DEPRECATED -NGRAPH_API -bool check_for_cycles(const ov::Model* func, ov::NodeVector& cycle_nodes, bool& is_bkwd_cycle); -} // namespace ngraph - -using ngraph::replace_node; -using ngraph::replace_output_update_name; diff --git a/src/core/include/ngraph/ngraph_visibility.hpp b/src/core/include/ngraph/ngraph_visibility.hpp deleted file mode 100644 index 2a2c26f79be901..00000000000000 --- a/src/core/include/ngraph/ngraph_visibility.hpp +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED) -# define NGRAPH_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include "openvino/core/core_visibility.hpp" - -#define NGRAPH_API OPENVINO_API -#define NGRAPH_API_C OPENVINO_API_C -#define NGRAPH_EXTERN_C OPENVINO_EXTERN_C - -#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT -# ifndef ENABLE_UNICODE_PATH_SUPPORT -# define ENABLE_UNICODE_PATH_SUPPORT -# endif -#endif diff --git a/src/core/include/ngraph/op/concat.hpp b/src/core/include/ngraph/op/concat.hpp deleted file mode 100644 index a7d67014756623..00000000000000 --- a/src/core/include/ngraph/op/concat.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED) -# define NGRAPH_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include - -#include "openvino/op/concat.hpp" - -namespace ngraph { -namespace op { -namespace v0 { -using ov::op::v0::Concat; -} // namespace v0 -using v0::Concat; -} // namespace op -} // namespace ngraph diff --git a/src/core/include/ngraph/op/divide.hpp b/src/core/include/ngraph/op/divide.hpp deleted file mode 100644 index 7e23179987e62c..00000000000000 --- a/src/core/include/ngraph/op/divide.hpp +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED) -# define NGRAPH_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include "openvino/op/divide.hpp" - -namespace ngraph { -namespace op { -namespace v1 { -using ov::op::v1::Divide; -} // namespace v1 -} // namespace op -} // namespace ngraph diff --git a/src/core/include/ngraph/op/parameter.hpp b/src/core/include/ngraph/op/parameter.hpp deleted file mode 100644 index 4442673f078e92..00000000000000 --- a/src/core/include/ngraph/op/parameter.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED) -# define NGRAPH_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include "openvino/op/parameter.hpp" - -namespace ngraph { -namespace op { -namespace v0 { -using ov::op::v0::Parameter; -} // namespace v0 -using v0::Parameter; -} // namespace op -using ParameterVector = std::vector>; -} // namespace ngraph diff --git a/src/core/include/ngraph/op/split.hpp b/src/core/include/ngraph/op/split.hpp deleted file mode 100644 index 0afd5979ef18f8..00000000000000 --- a/src/core/include/ngraph/op/split.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED) -# define NGRAPH_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include -#include - -#include "openvino/op/split.hpp" - -namespace ngraph { -namespace op { -namespace v1 { -using ov::op::v1::Split; -} // namespace v1 -} // namespace op -} // namespace ngraph diff --git a/src/core/include/ngraph/op/util/attr_types.hpp b/src/core/include/ngraph/op/util/attr_types.hpp deleted file mode 100644 index ea56388b492515..00000000000000 --- a/src/core/include/ngraph/op/util/attr_types.hpp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED) -# define NGRAPH_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include -#include - -#include "ngraph/ngraph_visibility.hpp" -#include "openvino/op/util/attr_types.hpp" - -namespace ngraph { -namespace op { -using ov::op::AutoBroadcastSpec; -using ov::op::AutoBroadcastType; -using ov::op::BroadcastModeSpec; -using ov::op::BroadcastType; -using ov::op::EpsMode; -using ov::op::PadMode; -using ov::op::PadType; -using ov::op::RecurrentSequenceDirection; -using ov::op::RoundingType; -using ov::op::TopKMode; -using ov::op::TopKSortType; -} // namespace op -} // namespace ngraph diff --git a/src/core/include/ngraph/op/util/op_types.hpp b/src/core/include/ngraph/op/util/op_types.hpp deleted file mode 100644 index bd882f0e4827bf..00000000000000 --- a/src/core/include/ngraph/op/util/op_types.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED) -# define NGRAPH_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include - -#include "ngraph/ngraph_visibility.hpp" -#include "openvino/op/util/op_types.hpp" - -namespace ngraph { -namespace op { -using ov::op::util::is_binary_elementwise_arithmetic; -using ov::op::util::is_binary_elementwise_comparison; -using ov::op::util::is_binary_elementwise_logical; -using ov::op::util::is_commutative; -using ov::op::util::is_constant; -using ov::op::util::is_op; -using ov::op::util::is_output; -using ov::op::util::is_parameter; -using ov::op::util::is_sink; -using ov::op::util::is_unary_elementwise_arithmetic; -using ov::op::util::supports_auto_broadcast; -} // namespace op -} // namespace ngraph diff --git a/src/core/include/ngraph/partial_shape.hpp b/src/core/include/ngraph/partial_shape.hpp deleted file mode 100644 index caa51dc1a685be..00000000000000 --- a/src/core/include/ngraph/partial_shape.hpp +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED) -# define NGRAPH_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include "ngraph/op/util/attr_types.hpp" -#include "ngraph/rank.hpp" -#include "ngraph/shape.hpp" -#include "openvino/core/partial_shape.hpp" - -namespace ngraph { -using ov::PartialShape; -} // namespace ngraph diff --git a/src/core/include/ngraph/rank.hpp b/src/core/include/ngraph/rank.hpp deleted file mode 100644 index f33600e8e3c074..00000000000000 --- a/src/core/include/ngraph/rank.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED) -# define NGRAPH_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include "openvino/core/rank.hpp" - -namespace ngraph { -using ov::Rank; -} // namespace ngraph diff --git a/src/core/include/ngraph/shape.hpp b/src/core/include/ngraph/shape.hpp deleted file mode 100644 index 09d5a3964c42fa..00000000000000 --- a/src/core/include/ngraph/shape.hpp +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED) -# define NGRAPH_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include -#include -#include - -#include "ngraph/axis_set.hpp" -#include "ngraph/ngraph_visibility.hpp" -#include "ngraph/strides.hpp" -#include "openvino/core/shape.hpp" - -namespace ngraph { -using ov::is_scalar; -using ov::is_vector; -using ov::row_major_stride; -using ov::row_major_strides; -using ov::Shape; -using ov::shape_size; -} // namespace ngraph diff --git a/src/core/include/ngraph/strides.hpp b/src/core/include/ngraph/strides.hpp deleted file mode 100644 index c961334402d7b9..00000000000000 --- a/src/core/include/ngraph/strides.hpp +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED) -# define NGRAPH_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include -#include -#include - -#include "ngraph/ngraph_visibility.hpp" -#include "openvino/core/strides.hpp" - -namespace ngraph { -using ov::Strides; -} // namespace ngraph diff --git a/src/core/include/ngraph/util.hpp b/src/core/include/ngraph/util.hpp deleted file mode 100644 index 01e5dab9dbc6dd..00000000000000 --- a/src/core/include/ngraph/util.hpp +++ /dev/null @@ -1,286 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED) -# define NGRAPH_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include -#include -#include -#include // llvm 8.1 gets confused about `malloc` otherwise -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ngraph/axis_vector.hpp" -#include "ngraph/graph_util.hpp" -#include "ngraph/shape.hpp" -#include "openvino/core/enum_mask.hpp" -#include "openvino/core/type/element_type.hpp" -#include "openvino/core/type/element_type_traits.hpp" -#include "openvino/runtime/tensor.hpp" - -namespace ov { -class Node; -} -namespace ngraph { -using ov::EnumMask; -using ov::Node; -class stopwatch; -class Tensor; - -NGRAPH_SUPPRESS_DEPRECATED_START -template -NGRAPH_API_DEPRECATED std::string join(const T& v, const std::string& sep = ", ") { - std::ostringstream ss; - size_t count = 0; - for (const auto& x : v) { - if (count++ > 0) { - ss << sep; - } - ss << x; - } - return ss.str(); -} - -template -NGRAPH_API_DEPRECATED std::string vector_to_string(const T& v) { - std::ostringstream os; - os << "[ " << ngraph::join(v) << " ]"; - return os.str(); -} - -NGRAPH_API -NGRAPH_API_DEPRECATED -size_t hash_combine(const std::vector& list); -NGRAPH_API -NGRAPH_API_DEPRECATED -void dump(std::ostream& out, const void*, size_t); -NGRAPH_API -NGRAPH_API_DEPRECATED -std::string to_lower(const std::string& s); -NGRAPH_API -NGRAPH_API_DEPRECATED -std::string to_upper(const std::string& s); -NGRAPH_API -NGRAPH_API_DEPRECATED -std::string trim(const std::string& s); -NGRAPH_API -NGRAPH_API_DEPRECATED -std::vector split(const std::string& s, char delimiter, bool trim = false); - -template -NGRAPH_API_DEPRECATED std::string locale_string(T x) { - std::stringstream ss; - ss.imbue(std::locale("")); - ss << x; - return ss.str(); -} - -class NGRAPH_API NGRAPH_DEPRECATED("It is obsolete structure and will be removed soon") stopwatch { -public: - void start() { - if (m_active == false) { - m_total_count++; - m_active = true; - m_start_time = m_clock.now(); - } - } - - void stop() { - if (m_active == true) { - auto end_time = m_clock.now(); - m_last_time = end_time - m_start_time; - m_total_time += m_last_time; - m_active = false; - } - } - - size_t get_call_count() const; - size_t get_seconds() const; - size_t get_milliseconds() const; - size_t get_microseconds() const; - std::chrono::nanoseconds get_timer_value() const; - size_t get_nanoseconds() const; - - size_t get_total_seconds() const; - size_t get_total_milliseconds() const; - size_t get_total_microseconds() const; - size_t get_total_nanoseconds() const; - -private: - std::chrono::high_resolution_clock m_clock; - std::chrono::time_point m_start_time; - bool m_active = false; - std::chrono::nanoseconds m_total_time = std::chrono::high_resolution_clock::duration::zero(); - std::chrono::nanoseconds m_last_time = std::chrono::high_resolution_clock::duration::zero(); - size_t m_total_count = 0; -}; - -/// Parses a string containing a literal of the underlying type. -template -NGRAPH_API_DEPRECATED T parse_string(const std::string& s) { - T result; - std::stringstream ss; - - ss << s; - ss >> result; - - // Check that (1) parsing succeeded and (2) the entire string was used. - if (ss.fail() || ss.rdbuf()->in_avail() != 0) { - OPENVINO_THROW("Could not parse literal '" + s + "'"); - } - - return result; -} - -/// template specializations for float and double to handle INFINITY, -INFINITY -/// and NaN values. -template <> -NGRAPH_API_DEPRECATED NGRAPH_API float parse_string(const std::string& s); -template <> -NGRAPH_API_DEPRECATED NGRAPH_API double parse_string(const std::string& s); - -/// template specializations for int8_t and uint8_t to handle the fact that default -/// implementation ends up treating values as characters so that the number "0" turns into -/// the parsed value 48, which is it's ASCII value -template <> -NGRAPH_API_DEPRECATED NGRAPH_API int8_t parse_string(const std::string& s); -template <> -NGRAPH_API_DEPRECATED NGRAPH_API uint8_t parse_string(const std::string& s); - -/// Parses a list of strings containing literals of the underlying type. -template -NGRAPH_API_DEPRECATED std::vector parse_string(const std::vector& ss) { - NGRAPH_SUPPRESS_DEPRECATED_START - std::vector result(ss.size()); - std::transform(ss.begin(), ss.end(), result.begin(), [](const std::string& s) { - return parse_string(s); - }); - return result; - NGRAPH_SUPPRESS_DEPRECATED_END -} - -template -NGRAPH_API_DEPRECATED T ceil_div(const T& x, const T& y) { - return (x == 0 ? 0 : (1 + (x - 1) / y)); -} - -template -NGRAPH_API_DEPRECATED T subtract_or_zero(T x, T y) { - return y > x ? 0 : x - y; -} - -NGRAPH_API -NGRAPH_API_DEPRECATED -void* ngraph_malloc(size_t size); -NGRAPH_API -NGRAPH_API_DEPRECATED -void ngraph_free(void*); - -NGRAPH_API -NGRAPH_API_DEPRECATED -size_t round_up(size_t size, size_t alignment); - -NGRAPH_API -NGRAPH_API_DEPRECATED -AxisVector get_default_order(size_t rank); - -NGRAPH_API -NGRAPH_API_DEPRECATED -AxisVector get_default_order(const ov::Rank& rank); - -NGRAPH_API -NGRAPH_API_DEPRECATED -AxisVector get_default_order(const ov::Shape& shape); - -NGRAPH_API -NGRAPH_API_DEPRECATED -AxisVector get_default_order(const ov::PartialShape& shape); - -/// \brief Function to query parsed version information of the version of ngraph which -/// contains this function. Version information strictly follows Semantic Versioning -/// http://semver.org -/// \param version The major part of the version -/// \param major Returns the major part of the version -/// \param minor Returns the minor part of the version -/// \param patch Returns the patch part of the version -/// \param extra Returns the extra part of the version. This includes everything following -/// the patch version number. -/// -/// \note Throws a runtime_error if there is an error during parsing -NGRAPH_API -NGRAPH_API_DEPRECATED -void parse_version_string(std::string version, size_t& major, size_t& minor, size_t& patch, std::string& extra); - -template -NGRAPH_API_DEPRECATED T double_to_int(double x, double float_to_int_converter(double)) { - if (!std::is_integral()) { - OPENVINO_THROW("Function double_to_int template parameter must be an integral type."); - } - - x = float_to_int_converter(x); - - double min_t = static_cast(std::numeric_limits::min()); - if (x < min_t) { - return std::numeric_limits::min(); - } - - double max_t = static_cast(std::numeric_limits::max()); - if (x > max_t) { - return std::numeric_limits::max(); - } - - return static_cast(x); -} -} // end namespace ngraph - -template -NGRAPH_API_DEPRECATED std::vector read_vector(std::shared_ptr tv) { - if (ov::element::from() != tv->get_element_type()) { - OPENVINO_THROW("read_vector type must match Tensor type"); - } - size_t element_count = ngraph::shape_size(tv->get_shape()); - size_t size = element_count * sizeof(T); - std::vector rc(element_count); - std::memcpy(rc.data(), tv->data(), size); - return rc; -} - -template -NGRAPH_API_DEPRECATED std::vector array_2_vector(typename ov::element_type_traits::value_type* data, - size_t size) { - std::vector result(size); - for (size_t i = 0; i < size; i++) { - result[i] = static_cast(data[i]); - } - return result; -} - -NGRAPH_API_DEPRECATED -std::vector NGRAPH_API read_float_vector(std::shared_ptr tv); - -NGRAPH_API_DEPRECATED -std::vector NGRAPH_API read_index_vector(std::shared_ptr tv); - -NGRAPH_API -NGRAPH_API_DEPRECATED -std::ostream& operator<<(std::ostream& os, const ov::NodeVector& nv); -NGRAPH_SUPPRESS_DEPRECATED_END diff --git a/src/core/include/ngraph/validation_util.hpp b/src/core/include/ngraph/validation_util.hpp deleted file mode 100644 index ac5a87acd3f6a4..00000000000000 --- a/src/core/include/ngraph/validation_util.hpp +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (C) 2018-2024 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED) -# define NGRAPH_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include - -#include "ngraph/coordinate_diff.hpp" -#include "ngraph/op/util/attr_types.hpp" -#include "openvino/core/validation_util.hpp" -#include "openvino/op/util/variable_context.hpp" - -namespace ngraph { -using ov::evaluate_as_partial_shape; -using ov::get_constant_from_source; -using ov::has_no_labels; -using ov::normalize_axes; -using ov::normalize_axis; -using ov::op::v0::Constant; - -namespace element { -using ov::element::Type; -using ov::element::Type_t; -} // namespace element - -NGRAPH_API_DEPRECATED -NGRAPH_API -Strides conv_default_strides(const Node* node, - const ov::PartialShape& data_batch_shape, - const ov::PartialShape& filters_shape); - -NGRAPH_API_DEPRECATED -NGRAPH_API -CoordinateDiff conv_default_padding(const Node* node, - const ov::PartialShape& data_batch_shape, - const ov::PartialShape& filters_shape); - -NGRAPH_API_DEPRECATED -NGRAPH_API -ov::PartialShape infer_windowed_reduction_output_shape(const Node* node, - const ov::PartialShape& data_shape, - const Strides& data_dilation, - const CoordinateDiff& data_padding_below, - const CoordinateDiff& data_padding_above, - const ov::PartialShape& window_shape, - const Strides& window_strides, - const Strides& window_dilation, - bool is_window_all_in_padding_allowed, - bool ceil_mode = false); - -NGRAPH_API_DEPRECATED -void validate_conv_params_spatial_dimensions(const Node* node, - const size_t num_spatial_dims, - const op::PadType auto_pad, - Strides& strides, - Strides& dilations, - CoordinateDiff& pads_begin, - CoordinateDiff& pads_end); - -NGRAPH_API_DEPRECATED -NGRAPH_API -ov::PartialShape infer_batched_pooling_forward(const Node* node, - const ov::PartialShape& data_batch_shape, - const CoordinateDiff& data_padding_below, - const CoordinateDiff& data_padding_above, - const ov::PartialShape& window_shape, - const Strides& window_strides, - bool is_window_all_in_padding_allowed, - bool ceil_mode = false, - const Strides& window_dilation = Strides{}); - -NGRAPH_API_DEPRECATED -NGRAPH_API -ov::PartialShape infer_slice_shape(const Node* node, - const ov::PartialShape& input_shape, - const std::vector& begin, - const std::vector& end, - const std::vector& strides, - const AxisSet& begin_mask, - const AxisSet& end_mask, - const AxisSet& new_axis_mask, - const AxisSet& shrink_axis_mask, - const AxisSet& ellipsis_mask); - -/// \brief Try to compute the maximum value of value -/// \return (true, max_value) if can be determined, or (false, numeric_limits::max()) -/// if not. -/// \deprecated Use evaluate_upper_bound instead -NGRAPH_API_DEPRECATED -NGRAPH_API std::pair maximum_value(const ov::Output& value); - -/// \brief Returns a Constant storing scalar value equal to std::numeric_limits::max() -NGRAPH_API_DEPRECATED -NGRAPH_API std::shared_ptr get_constant_max_of_type(element::Type_t t); - -/// \brief Returns a Constant storing scalar value equal to std::numeric_limits::min() -NGRAPH_API_DEPRECATED -NGRAPH_API std::shared_ptr get_constant_min_of_type(element::Type_t t); - -/// \brief Returns a Constant storing scalar value equal to std::numeric_limits::lowest() -NGRAPH_API_DEPRECATED -NGRAPH_API std::shared_ptr get_constant_lowest_of_type(element::Type_t t); - -namespace opset1 { -/// -/// \brief Calculates padding values for ConvolutionBackpropData operator. -/// -/// \param[in] input_data_shape The input data shape. -/// \param[in] filters_shape The filters shape. -/// \param[in] output_shape The output shape defined only for spatial dimentions. -/// \param[in] strides The strides values. -/// \param[in] dilations The dilations values. -/// \param[in] auto_pad_type The automatic padding mode. -/// \param[in] output_padding The output padding values. -/// \param pads_begin The placeholder for paddings at the beginning of axis. -/// \param pads_end The placeholder for paddings at the end of axis. -/// -NGRAPH_API_DEPRECATED -NGRAPH_API -void infer_conv_backprop_auto_padding(const Shape& input_data_shape, - const Shape& filters_shape, - const Shape& output_shape, - const Strides& strides, - const Strides& dilations, - const op::PadType auto_pad_type, - const CoordinateDiff& output_padding, - CoordinateDiff& pads_begin, - CoordinateDiff& pads_end); -} // namespace opset1 -} // namespace ngraph - -using ngraph::get_constant_from_source; diff --git a/src/core/include/openvino/core/core.hpp b/src/core/include/openvino/core/core.hpp index db587576e7d983..0239a7970de6ab 100644 --- a/src/core/include/openvino/core/core.hpp +++ b/src/core/include/openvino/core/core.hpp @@ -34,7 +34,6 @@ #include "openvino/core/shape.hpp" #include "openvino/core/strides.hpp" #include "openvino/core/type.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/core/version.hpp" #include "openvino/core/visibility.hpp" @@ -58,3 +57,4 @@ // type #include "openvino/core/type/element_type.hpp" +#include "openvino/core/type/element_type_traits.hpp" diff --git a/src/core/include/openvino/core/descriptor/tensor.hpp b/src/core/include/openvino/core/descriptor/tensor.hpp index d7be44f6e025b3..8a37af24710e79 100644 --- a/src/core/include/openvino/core/descriptor/tensor.hpp +++ b/src/core/include/openvino/core/descriptor/tensor.hpp @@ -46,8 +46,6 @@ class OPENVINO_API Tensor { Tensor(const element::Type& element_type, const PartialShape& pshape, const std::unordered_set& names = {}); - OPENVINO_DEPRECATED("This constructor is deprecated. Please use constructor with set of names") - Tensor(const element::Type& element_type, const PartialShape& pshape, const std::string& name); Tensor(const element::Type& element_type, const PartialShape& pshape, Node* node, size_t node_output_number); Tensor(const Tensor&) = delete; diff --git a/src/core/include/openvino/core/validation_util.hpp b/src/core/include/openvino/core/validation_util.hpp deleted file mode 100644 index 51ef5facdb4b21..00000000000000 --- a/src/core/include/openvino/core/validation_util.hpp +++ /dev/null @@ -1,154 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "openvino/core/coordinate_diff.hpp" -#include "openvino/core/node.hpp" -#include "openvino/op/constant.hpp" -#include "openvino/op/util/attr_types.hpp" - -namespace ov { - -/// \brief Handle out of range axis. -/// -/// \param[in] node The node with requested axis. -/// \param[in] axis The requested axis value. -/// \param[in] tensor_rank The corresponding tensor rank. -/// -/// \return Checking if axis is in range [-tensor_rank, tensor_rank-1], otherwise -/// returns error. If negative axis, it counts from the last to the first axis, -/// by adding tensor_rank to axis. -OPENVINO_DEPRECATED("This function is deprecated and will be moved to dev api in 2024.0 release.") -OPENVINO_API -int64_t normalize_axis(const Node* node, std::int64_t axis, const Rank& tensor_rank); - -/// \brief Handle out of range axes in vector. -/// -/// \param[in] node_description The name of node with requested axes. -/// \param[in] axes The requested vector of axes. -/// \param[in] tensor_rank The corresponding tensor rank. -/// -/// \return If any negative axis in vector, it counts from the last to the first -/// axis, by adding tensor_rank to axis. -/// -OPENVINO_DEPRECATED("This function is deprecated and will be moved to dev api in 2024.0 release.") -OPENVINO_API -std::vector normalize_axes(const std::string& node_description, - const std::vector& axes, - const Rank& tensor_rank); - -/// \brief Handle out of range axis. -/// -/// \param[in] node_description The node with requested axis. -/// \param[in] axis The requested axis value. -/// \param[in] tensor_rank The corresponding tensor rank. -/// -/// \return Checking if axis is in range [-tensor_rank, tensor_rank-1], otherwise -/// returns error. If negative axis, it counts from the last to the first axis, -/// by adding tensor_rank to axis. -OPENVINO_DEPRECATED("This function is deprecated and will be moved to dev api in 2024.0 release.") -OPENVINO_API -int64_t normalize_axis(const std::string& node_description, std::int64_t axis, const Rank& tensor_rank); - -/// \brief Handle out of range axis. -/// -/// \param[in] node The node with requested axis. -/// \param[in] axis The requested axis value. -/// \param[in] tensor_rank The corresponding tensor rank. -/// \param[in] axis_range_min The min value of accepted range for axis. -/// \param[in] axis_range_max The max value of accepted range for axis. -/// -/// \return Checking if axis is in range [axis_range_min, axis_range_max], otherwise -/// returns error. If negative axis, it counts from the last to the first axis, -/// by adding tensor_rank to axis. -OPENVINO_DEPRECATED("This function is deprecated and will be moved to dev api in 2024.0 release.") -OPENVINO_API -int64_t normalize_axis(const Node* node, - std::int64_t axis, - std::uint64_t tensor_rank, - std::int64_t axis_range_min, - std::int64_t axis_range_max); - -/// \brief Handle out of range axis. -/// -/// \param[in] node_description The name of node with requested axis. -/// \param[in] axis The requested axis value. -/// \param[in] tensor_rank The corresponding tensor rank. -/// \param[in] axis_range_min The min value of accepted range for axis. -/// \param[in] axis_range_max The max value of accepted range for axis. -/// -/// \return Checking if axis is in range [axis_range_min, axis_range_max], otherwise -/// returns error. If negative axis, it counts from the last to the first axis, -/// by adding tensor_rank to axis. -OPENVINO_DEPRECATED("This function is deprecated and will be moved to dev api in 2024.0 release.") -OPENVINO_API -int64_t normalize_axis(const std::string& node_description, - std::int64_t axis, - std::uint64_t tensor_rank, - std::int64_t axis_range_min, - std::int64_t axis_range_max); - -/// \brief Handle out of range axes in vector. -/// If any negative axis in vector, it counts from the last to the first axis, -/// by adding tensor_rank to axis. Changes axes vector inplace. -/// -/// \param[in] node The node with requested axes. -/// \param[in] tensor_rank The corresponding tensor rank. -/// \param[in,out] axes The requested vector of axes. -/// -OPENVINO_DEPRECATED("This function is deprecated and will be moved to dev api in 2024.0 release.") -OPENVINO_API -void normalize_axes(const Node* node, const int64_t& tensor_rank, std::vector& axes); - -/// \brief Evaluates lower and upper value estimations for the output tensor. Estimation would -/// be represented as partial shape object using Dimension(min, max) for each element. -/// \param output Node output pointing to the tensor for estimation. -/// \param pshape Resulting estimation would be stored in this PartialShape. -/// \return boolean status if value evaluation was successful. -OPENVINO_DEPRECATED("This function is deprecated and will be moved to dev api in 2024.0 release.") -OPENVINO_API bool evaluate_as_partial_shape(const Output& output, PartialShape& pshape); - -/// \brief Runs an estimation of source tensor. If it succeeded to calculate both bounds and -/// they are the same returns Constant operation from the resulting bound, otherwise nullptr. -OPENVINO_DEPRECATED("This function is deprecated and will be moved to dev api in 2024.0 release.") -OPENVINO_API std::shared_ptr get_constant_from_source(const Output& source); - -/// \brief Propagates value label from 0 input to the only output through an operation. -/// Not applicable for operations which require values interaction (example: mathematical -/// operations). Could be used for movement operations (example: gathering, shape change) -/// \param node Operation to be performed -/// \param output_labels Vector of TensorLabel objects representing resulting value labels -/// \return boolean status if label evaluation was successful. -OPENVINO_DEPRECATED("This function is deprecated and will be moved to dev api in 2024.0 release.") -OPENVINO_API bool default_label_evaluator(const Node* node, TensorLabelVector& output_labels); - -/// \brief Generates transpose default axes order at end of input vector. -/// -/// Default axes order is decreasing sequence numbers which start from `length - 1`. -/// -/// \param axes_order Vector where default order will be generated. -/// \param length Sequence length of axes order. -OPENVINO_DEPRECATED("This function is deprecated and will be moved to dev api in 2024.0 release.") -OPENVINO_API void generate_transpose_default_order(std::vector& axes_order, const size_t length); - -/// \brief Check if vector of axes order has got valid values. -/// -/// Axes order has to be unique numbers in range of [0, size). -/// -/// \param axes_order Vector with axes order to check. -/// \param size Input for transpose rank size. -/// -/// \return true if axes order is valid otherwise false. -OPENVINO_DEPRECATED("This function is deprecated and will be moved to dev api in 2024.0 release.") -OPENVINO_API bool is_valid_axes_order(const std::vector& axes_order, const size_t size); - -/// \brief Checks label tensor if there is no label -/// -/// \param labels Label tensor for check. -/// \return True if there is no labels, otherwise false. -OPENVINO_DEPRECATED("This function is deprecated and will be moved to dev api in 2024.0 release.") -OPENVINO_API bool has_no_labels(const TensorLabel& labels); - -} // namespace ov diff --git a/src/core/include/openvino/op/constant.hpp b/src/core/include/openvino/op/constant.hpp index 222b006c094ba8..ae539351058574 100644 --- a/src/core/include/openvino/op/constant.hpp +++ b/src/core/include/openvino/op/constant.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -7,21 +7,14 @@ #include #include -#ifndef IN_OV_COMPONENT -# define IN_OV_COMPONENT -# define WAS_OV_LIBRARY_DEFINED_CONSTANT -#endif - -#include "ngraph/util.hpp" -#include "openvino/core/rtti.hpp" - -#ifdef WAS_OV_LIBRARY_DEFINED_CONSTANT -# undef IN_OV_COMPONENT -# undef WAS_OV_LIBRARY_DEFINED_CONSTANT -#endif +#include "openvino/core/axis_set.hpp" +#include "openvino/core/axis_vector.hpp" #include "openvino/core/coordinate_diff.hpp" +#include "openvino/core/graph_util.hpp" +#include "openvino/core/rtti.hpp" #include "openvino/core/type/element_type.hpp" #include "openvino/core/type/element_type_traits.hpp" +#include "openvino/op/op.hpp" namespace ov { @@ -356,6 +349,12 @@ class OPENVINO_API Constant : public Op { case Type_t::u64: cast_vector(rc, num_elements_to_cast); break; + case Type_t::f8e4m3: + cast_vector(rc, num_elements_to_cast); + break; + case Type_t::f8e5m2: + cast_vector(rc, num_elements_to_cast); + break; case Type_t::string: cast_vector(rc, num_elements_to_cast); break; @@ -755,7 +754,8 @@ class OPENVINO_API Constant : public Op { typename StorageDataType = fundamental_type_for, typename std::enable_if::value || std::is_same::value || - std::is_same::value), + std::is_same::value || std::is_same::value || + std::is_same::value), bool>::type = true> void write_buffer(const std::vector& source) { auto p = get_data_ptr_nc(); diff --git a/src/core/include/openvino/op/convolution.hpp b/src/core/include/openvino/op/convolution.hpp index de40ae07605ea9..e184ab23e3b313 100644 --- a/src/core/include/openvino/op/convolution.hpp +++ b/src/core/include/openvino/op/convolution.hpp @@ -127,28 +127,6 @@ class OPENVINO_API ConvolutionBackpropData : public util::ConvolutionBackPropBas /// \return The output spatial dimensions shape. const PartialShape get_output_shape() const; void set_output_shape(const Shape& output_shape); - - /// \brief Calculates output spatial features size. - /// - /// \param[in] input_data_shape The input data partial shape - /// \param[in] filters_shape The filters partial shape - /// \param[in] strides The strides values. - /// \param[in] dilations The dilations values. - /// \param[in] pads_begin The paddings at the beginning of axis. - /// \param[in] pads_end The paddings at the end of axis. - /// \param[in] output_padding The output padding values. - /// \param output_spatial_shape The placeholder for computed output spatial partial - /// shape. - /// - OPENVINO_DEPRECATED("This member function is deprecated and will be removed soon.") - void infer_conv_backprop_output_spatial_shape(const std::vector& input_data_shape, - const std::vector& filters_shape, - const Strides& strides, - const Strides& dilations, - const CoordinateDiff& pads_begin, - const CoordinateDiff& pads_end, - const CoordinateDiff& output_padding, - std::vector& output_spatial_shape); }; } // namespace v1 } // namespace op diff --git a/src/core/include/openvino/op/fake_convert.hpp b/src/core/include/openvino/op/fake_convert.hpp index f091fd5cdb84c9..17441337c010dc 100644 --- a/src/core/include/openvino/op/fake_convert.hpp +++ b/src/core/include/openvino/op/fake_convert.hpp @@ -41,18 +41,39 @@ class OPENVINO_API FakeConvert : public Op { const ov::Output& shift, std::string destination_type = "f8e4m3"); + /// \brief Constructs FakeConvert operation (default shift). + /// + /// \param data The input data tensor. + /// \param scale Tensor with a scale factor for the data input. + /// \param destination_type The low precision type to be emulated. + FakeConvert(const ov::Output& data, + const ov::Output& scale, + const ov::element::Type& destination_type); + + /// \brief Constructs FakeConvert operation. + /// + /// \param data The input data tensor. + /// \param scale Tensor with a scale factor for the data input. + /// \param shift Tensor with a shift factor for the data input. + /// \param destination_type The low precision type to be emulated. + FakeConvert(const ov::Output& data, + const ov::Output& scale, + const ov::Output& shift, + const ov::element::Type& destination_type); + void validate_and_infer_types() override; std::shared_ptr clone_with_new_inputs(const ov::OutputVector& new_args) const override; bool visit_attributes(ov::AttributeVisitor& visitor) override; bool evaluate(TensorVector& outputs, const TensorVector& inputs) const override; bool has_evaluate() const override; - const std::string& get_destination_type() const; + std::string get_destination_type() const; + const ov::element::Type& get_destination_element_type() const; private: void validate_destination_type() const; - std::string m_destination_type = "f8e4m3"; + ov::element::Type m_destination_type = ov::element::f8e4m3; }; } // namespace v13 } // namespace op diff --git a/src/core/include/openvino/op/roi_pooling.hpp b/src/core/include/openvino/op/roi_pooling.hpp index 57799954a7641f..fef2546e3abff1 100644 --- a/src/core/include/openvino/op/roi_pooling.hpp +++ b/src/core/include/openvino/op/roi_pooling.hpp @@ -42,12 +42,6 @@ class OPENVINO_API ROIPooling : public Op { /// \return Shape with pooled_h and pooled_w attributes. const Shape& get_output_roi() const; - OPENVINO_DEPRECATED("Use 'get_output_roi' instead. Use of this member can be ambiguous with Node base " - "'get_output_size' which return number of outputs.") - const Shape& get_output_size() const { - return m_output_size; - } - /// \brief Set the spatial scale value. /// \param scale Scale value to set. void set_spatial_scale(float scale); diff --git a/src/core/include/openvino/op/util/convolution_base.hpp b/src/core/include/openvino/op/util/convolution_base.hpp index 0681d1a2e8e2b0..920fa17d74b13a 100644 --- a/src/core/include/openvino/op/util/convolution_base.hpp +++ b/src/core/include/openvino/op/util/convolution_base.hpp @@ -65,10 +65,6 @@ class OPENVINO_API ConvolutionBase : public Op { const CoordinateDiff& get_pads_end() const { return m_pads_end; } - OPENVINO_DEPRECATED("This method is deprecated and will be removed soon. Please use set_pads_end instead.") - void set_adding_above(const CoordinateDiff& pads_end) { - set_pads_end(pads_end); - } void set_pads_end(const CoordinateDiff& pads_end) { m_pads_end = pads_end; } diff --git a/src/core/include/openvino/op/util/max_pool_base.hpp b/src/core/include/openvino/op/util/max_pool_base.hpp index 4e8d9937ea57ac..e633c364a0bc3c 100644 --- a/src/core/include/openvino/op/util/max_pool_base.hpp +++ b/src/core/include/openvino/op/util/max_pool_base.hpp @@ -58,10 +58,6 @@ class OPENVINO_API MaxPoolBase : public Op { const Shape& get_pads_end() const { return m_pads_end; } - OPENVINO_DEPRECATED("This method is deprecated and will be removed soon. Please use set_pads_end instead.") - void set_adding_above(const Shape& pads_end) { - m_pads_end = pads_end; - } void set_pads_end(Shape pads_end); /// \return The pad type for pooling. diff --git a/src/core/include/openvino/opsets/opset.hpp b/src/core/include/openvino/opsets/opset.hpp index 629610450ee630..c393eeeb581d2d 100644 --- a/src/core/include/openvino/opsets/opset.hpp +++ b/src/core/include/openvino/opsets/opset.hpp @@ -163,6 +163,11 @@ const OPENVINO_API OpSet& get_opset12(); * @ingroup ov_opset_cpp_api */ const OPENVINO_API OpSet& get_opset13(); +/** + * @brief Returns opset14 + * @ingroup ov_opset_cpp_api + */ +const OPENVINO_API OpSet& get_opset14(); /** * @brief Returns map of available opsets * @ingroup ov_opset_cpp_api diff --git a/src/core/include/openvino/opsets/opset14.hpp b/src/core/include/openvino/opsets/opset14.hpp new file mode 100644 index 00000000000000..b4edf282425299 --- /dev/null +++ b/src/core/include/openvino/opsets/opset14.hpp @@ -0,0 +1,15 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "openvino/op/ops.hpp" + +namespace ov { +namespace opset14 { +#define _OPENVINO_OP_REG(a, b) using b::a; +#include "openvino/opsets/opset14_tbl.hpp" +#undef _OPENVINO_OP_REG +} // namespace opset14 +} // namespace ov diff --git a/src/core/include/openvino/opsets/opset14_tbl.hpp b/src/core/include/openvino/opsets/opset14_tbl.hpp new file mode 100644 index 00000000000000..774f7ec54076e7 --- /dev/null +++ b/src/core/include/openvino/opsets/opset14_tbl.hpp @@ -0,0 +1,221 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#ifndef _OPENVINO_OP_REG +# warning "_OPENVINO_OP_REG not defined" +# define _OPENVINO_OP_REG(x, y) +#endif + +_OPENVINO_OP_REG(Abs, ov::op::v0) +_OPENVINO_OP_REG(Acos, ov::op::v0) +_OPENVINO_OP_REG(Add, ov::op::v1) +_OPENVINO_OP_REG(Asin, ov::op::v0) +_OPENVINO_OP_REG(Atan, ov::op::v0) +_OPENVINO_OP_REG(AvgPool, ov::op::v1) +_OPENVINO_OP_REG(BatchNormInference, ov::op::v5) +_OPENVINO_OP_REG(BinaryConvolution, ov::op::v1) +_OPENVINO_OP_REG(Broadcast, ov::op::v3) +_OPENVINO_OP_REG(Bucketize, ov::op::v3) +_OPENVINO_OP_REG(CTCGreedyDecoder, ov::op::v0) +_OPENVINO_OP_REG(Ceiling, ov::op::v0) +_OPENVINO_OP_REG(Clamp, ov::op::v0) +_OPENVINO_OP_REG(Concat, ov::op::v0) +_OPENVINO_OP_REG(Constant, ov::op::v0) +_OPENVINO_OP_REG(Convert, ov::op::v0) +_OPENVINO_OP_REG(ConvertLike, ov::op::v1) +_OPENVINO_OP_REG(Convolution, ov::op::v1) +_OPENVINO_OP_REG(ConvolutionBackpropData, ov::op::v1) +_OPENVINO_OP_REG(Cos, ov::op::v0) +_OPENVINO_OP_REG(Cosh, ov::op::v0) +_OPENVINO_OP_REG(CumSum, ov::op::v0) +_OPENVINO_OP_REG(DeformablePSROIPooling, ov::op::v1) +_OPENVINO_OP_REG(DepthToSpace, ov::op::v0) +_OPENVINO_OP_REG(Divide, ov::op::v1) +_OPENVINO_OP_REG(Elu, ov::op::v0) +_OPENVINO_OP_REG(Erf, ov::op::v0) +_OPENVINO_OP_REG(Equal, ov::op::v1) +_OPENVINO_OP_REG(Exp, ov::op::v0) +_OPENVINO_OP_REG(ExtractImagePatches, ov::op::v3) +_OPENVINO_OP_REG(FakeQuantize, ov::op::v0) +_OPENVINO_OP_REG(Floor, ov::op::v0) +_OPENVINO_OP_REG(FloorMod, ov::op::v1) +_OPENVINO_OP_REG(GatherTree, ov::op::v1) +_OPENVINO_OP_REG(Greater, ov::op::v1) +_OPENVINO_OP_REG(GreaterEqual, ov::op::v1) +_OPENVINO_OP_REG(GridSample, ov::op::v9) +_OPENVINO_OP_REG(GroupConvolution, ov::op::v1) +_OPENVINO_OP_REG(GroupConvolutionBackpropData, ov::op::v1) +_OPENVINO_OP_REG(GRN, ov::op::v0) +_OPENVINO_OP_REG(HardSigmoid, ov::op::v0) +_OPENVINO_OP_REG(Less, ov::op::v1) +_OPENVINO_OP_REG(LessEqual, ov::op::v1) +_OPENVINO_OP_REG(Log, ov::op::v0) +_OPENVINO_OP_REG(LogicalAnd, ov::op::v1) +_OPENVINO_OP_REG(LogicalNot, ov::op::v1) +_OPENVINO_OP_REG(LogicalOr, ov::op::v1) +_OPENVINO_OP_REG(LogicalXor, ov::op::v1) +_OPENVINO_OP_REG(LRN, ov::op::v0) +_OPENVINO_OP_REG(LSTMCell, ov::op::v4) +_OPENVINO_OP_REG(MatMul, ov::op::v0) +_OPENVINO_OP_REG(Maximum, ov::op::v1) +_OPENVINO_OP_REG(Minimum, ov::op::v1) +_OPENVINO_OP_REG(Mod, ov::op::v1) +_OPENVINO_OP_REG(Multiply, ov::op::v1) +_OPENVINO_OP_REG(Negative, ov::op::v0) +_OPENVINO_OP_REG(NormalizeL2, ov::op::v0) +_OPENVINO_OP_REG(NotEqual, ov::op::v1) +_OPENVINO_OP_REG(OneHot, ov::op::v1) +_OPENVINO_OP_REG(PRelu, ov::op::v0) +_OPENVINO_OP_REG(PSROIPooling, ov::op::v0) +_OPENVINO_OP_REG(Parameter, ov::op::v0) +_OPENVINO_OP_REG(Power, ov::op::v1) +_OPENVINO_OP_REG(PriorBoxClustered, ov::op::v0) +_OPENVINO_OP_REG(Proposal, ov::op::v4) +_OPENVINO_OP_REG(Range, ov::op::v4) +_OPENVINO_OP_REG(Relu, ov::op::v0) +_OPENVINO_OP_REG(ReduceMax, ov::op::v1) +_OPENVINO_OP_REG(ReduceLogicalAnd, ov::op::v1) +_OPENVINO_OP_REG(ReduceLogicalOr, ov::op::v1) +_OPENVINO_OP_REG(ReduceMean, ov::op::v1) +_OPENVINO_OP_REG(ReduceMin, ov::op::v1) +_OPENVINO_OP_REG(ReduceProd, ov::op::v1) +_OPENVINO_OP_REG(ReduceSum, ov::op::v1) +_OPENVINO_OP_REG(RegionYolo, ov::op::v0) +_OPENVINO_OP_REG(ReorgYolo, ov::op::v0) +_OPENVINO_OP_REG(Reshape, ov::op::v1) +_OPENVINO_OP_REG(Result, ov::op::v0) +_OPENVINO_OP_REG(ReverseSequence, ov::op::v0) +_OPENVINO_OP_REG(ROIPooling, ov::op::v0) +_OPENVINO_OP_REG(ScatterNDUpdate, ov::op::v3) +_OPENVINO_OP_REG(Select, ov::op::v1) +_OPENVINO_OP_REG(Selu, ov::op::v0) +_OPENVINO_OP_REG(Sign, ov::op::v0) +_OPENVINO_OP_REG(Sigmoid, ov::op::v0) +_OPENVINO_OP_REG(Sin, ov::op::v0) +_OPENVINO_OP_REG(Sinh, ov::op::v0) +_OPENVINO_OP_REG(Sqrt, ov::op::v0) +_OPENVINO_OP_REG(SpaceToDepth, ov::op::v0) +_OPENVINO_OP_REG(Split, ov::op::v1) +_OPENVINO_OP_REG(SquaredDifference, ov::op::v0) +_OPENVINO_OP_REG(Squeeze, ov::op::v0) +_OPENVINO_OP_REG(StridedSlice, ov::op::v1) +_OPENVINO_OP_REG(Subtract, ov::op::v1) +_OPENVINO_OP_REG(Tan, ov::op::v0) +_OPENVINO_OP_REG(Tanh, ov::op::v0) +_OPENVINO_OP_REG(TensorIterator, ov::op::v0) +_OPENVINO_OP_REG(Tile, ov::op::v0) +_OPENVINO_OP_REG(Transpose, ov::op::v1) +_OPENVINO_OP_REG(Unsqueeze, ov::op::v0) +_OPENVINO_OP_REG(VariadicSplit, ov::op::v1) + +// New operations added in opset2 +_OPENVINO_OP_REG(BatchToSpace, ov::op::v1) +_OPENVINO_OP_REG(SpaceToBatch, ov::op::v1) + +// New operations added in opset3 +_OPENVINO_OP_REG(EmbeddingBagPackedSum, ov::op::v3) +_OPENVINO_OP_REG(EmbeddingSegmentsSum, ov::op::v3) +_OPENVINO_OP_REG(EmbeddingBagOffsetsSum, ov::op::v3) +_OPENVINO_OP_REG(GRUCell, ov::op::v3) +_OPENVINO_OP_REG(NonZero, ov::op::v3) +_OPENVINO_OP_REG(RNNCell, ov::op::v0) +_OPENVINO_OP_REG(ScatterUpdate, ov::op::v3) +_OPENVINO_OP_REG(ShuffleChannels, ov::op::v0) +_OPENVINO_OP_REG(ShapeOf, ov::op::v3) + +// New operations added in opset4 +_OPENVINO_OP_REG(Acosh, ov::op::v3) +_OPENVINO_OP_REG(Asinh, ov::op::v3) +_OPENVINO_OP_REG(Atanh, ov::op::v3) +_OPENVINO_OP_REG(CTCLoss, ov::op::v4) +_OPENVINO_OP_REG(HSwish, ov::op::v4) +_OPENVINO_OP_REG(Mish, ov::op::v4) +_OPENVINO_OP_REG(ReduceL1, ov::op::v4) +_OPENVINO_OP_REG(ReduceL2, ov::op::v4) +_OPENVINO_OP_REG(SoftPlus, ov::op::v4) +_OPENVINO_OP_REG(Swish, ov::op::v4) + +// New operations added in opset5 +_OPENVINO_OP_REG(GRUSequence, ov::op::v5) +_OPENVINO_OP_REG(HSigmoid, ov::op::v5) +_OPENVINO_OP_REG(LogSoftmax, ov::op::v5) +_OPENVINO_OP_REG(Loop, ov::op::v5) +_OPENVINO_OP_REG(LSTMSequence, ov::op::v5) +_OPENVINO_OP_REG(RNNSequence, ov::op::v5) +_OPENVINO_OP_REG(Round, ov::op::v5) + +// New operations added in opset6 +_OPENVINO_OP_REG(CTCGreedyDecoderSeqLen, ov::op::v6) +_OPENVINO_OP_REG(ExperimentalDetectronDetectionOutput, ov::op::v6) +_OPENVINO_OP_REG(ExperimentalDetectronGenerateProposalsSingleImage, ov::op::v6) +_OPENVINO_OP_REG(ExperimentalDetectronPriorGridGenerator, ov::op::v6) +_OPENVINO_OP_REG(ExperimentalDetectronROIFeatureExtractor, ov::op::v6) +_OPENVINO_OP_REG(ExperimentalDetectronTopKROIs, ov::op::v6) +_OPENVINO_OP_REG(GatherElements, ov::op::v6) +_OPENVINO_OP_REG(MVN, ov::op::v6) +_OPENVINO_OP_REG(Assign, ov::op::v6) // new version +_OPENVINO_OP_REG(ReadValue, ov::op::v6) // new version + +// New operations added in opset7 +_OPENVINO_OP_REG(DFT, ov::op::v7) +_OPENVINO_OP_REG(Einsum, ov::op::v7) +_OPENVINO_OP_REG(Gelu, ov::op::v7) +_OPENVINO_OP_REG(IDFT, ov::op::v7) +_OPENVINO_OP_REG(Roll, ov::op::v7) + +// New operations added in opset8 +_OPENVINO_OP_REG(Gather, ov::op::v8) +_OPENVINO_OP_REG(GatherND, ov::op::v8) +_OPENVINO_OP_REG(AdaptiveAvgPool, ov::op::v8) +_OPENVINO_OP_REG(AdaptiveMaxPool, ov::op::v8) +_OPENVINO_OP_REG(DeformableConvolution, ov::op::v8) +_OPENVINO_OP_REG(DetectionOutput, ov::op::v8) +_OPENVINO_OP_REG(I420toBGR, ov::op::v8) +_OPENVINO_OP_REG(I420toRGB, ov::op::v8) +_OPENVINO_OP_REG(MatrixNms, ov::op::v8) +_OPENVINO_OP_REG(MaxPool, ov::op::v8) +_OPENVINO_OP_REG(NV12toBGR, ov::op::v8) +_OPENVINO_OP_REG(NV12toRGB, ov::op::v8) +_OPENVINO_OP_REG(RandomUniform, ov::op::v8) +_OPENVINO_OP_REG(Slice, ov::op::v8) +_OPENVINO_OP_REG(Softmax, ov::op::v8) +_OPENVINO_OP_REG(If, ov::op::v8) +_OPENVINO_OP_REG(PriorBox, ov::op::v8) + +// New operations added in opset9 +_OPENVINO_OP_REG(IRDFT, ov::op::v9) +_OPENVINO_OP_REG(RDFT, ov::op::v9) +_OPENVINO_OP_REG(Eye, ov::op::v9) +_OPENVINO_OP_REG(NonMaxSuppression, ov::op::v9) +_OPENVINO_OP_REG(ROIAlign, ov::op::v9) +_OPENVINO_OP_REG(SoftSign, ov::op::v9) +_OPENVINO_OP_REG(GenerateProposals, ov::op::v9) +_OPENVINO_OP_REG(MulticlassNms, ov::op::v9) + +// New operations added in opset10 +_OPENVINO_OP_REG(IsFinite, ov::op::v10) +_OPENVINO_OP_REG(IsInf, ov::op::v10) +_OPENVINO_OP_REG(IsNaN, ov::op::v10) +_OPENVINO_OP_REG(Unique, ov::op::v10) + +// New operations added in opset11 +_OPENVINO_OP_REG(Interpolate, ov::op::v11) +_OPENVINO_OP_REG(TopK, ov::op::v11) + +// New operations added in opset12 +_OPENVINO_OP_REG(GroupNormalization, ov::op::v12) +_OPENVINO_OP_REG(Pad, ov::op::v12) +_OPENVINO_OP_REG(ScatterElementsUpdate, ov::op::v12) + +// New operations added in opset13 +_OPENVINO_OP_REG(BitwiseAnd, ov::op::v13) +_OPENVINO_OP_REG(BitwiseNot, ov::op::v13) +_OPENVINO_OP_REG(BitwiseOr, ov::op::v13) +_OPENVINO_OP_REG(BitwiseXor, ov::op::v13) +_OPENVINO_OP_REG(NMSRotated, ov::op::v13) +_OPENVINO_OP_REG(Multinomial, ov::op::v13) +_OPENVINO_OP_REG(ScaledDotProductAttention, ov::op::v13) +_OPENVINO_OP_REG(FakeConvert, ov::op::v13) + +// New operations added in opset14 diff --git a/src/core/include/openvino/pass/serialize.hpp b/src/core/include/openvino/pass/serialize.hpp index 1b24d705ca2664..759bc3e7973adb 100644 --- a/src/core/include/openvino/pass/serialize.hpp +++ b/src/core/include/openvino/pass/serialize.hpp @@ -32,18 +32,8 @@ class OPENVINO_API Serialize : public ov::pass::ModelPass { }; bool run_on_model(const std::shared_ptr& m) override; - OPENVINO_DEPRECATED("This constructor is deprecated. Please use new extension API") - Serialize(std::ostream& xmlFile, - std::ostream& binFile, - std::map custom_opsets, - Version version = Version::UNSPECIFIED); Serialize(std::ostream& xmlFile, std::ostream& binFile, Version version = Version::UNSPECIFIED); - OPENVINO_DEPRECATED("This constructor is deprecated. Please use new extension API") - Serialize(const std::string& xmlPath, - const std::string& binPath, - std::map custom_opsets, - Version version = Version::UNSPECIFIED); Serialize(const std::string& xmlPath, const std::string& binPath, Version version = Version::UNSPECIFIED); private: @@ -76,18 +66,12 @@ class OPENVINO_API StreamSerialize : public ov::pass::ModelPass { bool run_on_model(const std::shared_ptr& m) override; - OPENVINO_DEPRECATED("This constructor is deprecated. Please use new extension API") - StreamSerialize(std::ostream& stream, - std::map&& custom_opsets = {}, - const std::function& custom_data_serializer = {}, - Serialize::Version version = Serialize::Version::UNSPECIFIED); StreamSerialize(std::ostream& stream, const std::function& custom_data_serializer = {}, Serialize::Version version = Serialize::Version::UNSPECIFIED); private: std::ostream& m_stream; - std::map m_custom_opsets; std::function m_custom_data_serializer; const Serialize::Version m_version; }; diff --git a/src/core/include/openvino/runtime/allocator.hpp b/src/core/include/openvino/runtime/allocator.hpp index a8721b72554306..f92be30a434d40 100644 --- a/src/core/include/openvino/runtime/allocator.hpp +++ b/src/core/include/openvino/runtime/allocator.hpp @@ -14,9 +14,9 @@ #include "openvino/core/any.hpp" #include "openvino/core/core_visibility.hpp" -#include "openvino/core/deprecated.hpp" namespace ov { + class Tensor; /** @@ -158,10 +158,4 @@ class OPENVINO_API Allocator { explicit operator bool() const noexcept; }; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace runtime { -using ov::Allocator; -} // namespace runtime -OPENVINO_SUPPRESS_DEPRECATED_END - } // namespace ov diff --git a/src/core/include/openvino/runtime/tensor.hpp b/src/core/include/openvino/runtime/tensor.hpp index 43f63402e49da2..61b829fafb2ac1 100644 --- a/src/core/include/openvino/runtime/tensor.hpp +++ b/src/core/include/openvino/runtime/tensor.hpp @@ -259,9 +259,4 @@ class OPENVINO_API Tensor { */ using TensorVector = std::vector; -namespace runtime { -using ov::Tensor; -using ov::TensorVector; -} // namespace runtime - } // namespace ov diff --git a/src/core/reference/include/openvino/reference/fake_convert.hpp b/src/core/reference/include/openvino/reference/fake_convert.hpp index 47410c79902426..58fe81cd7fb511 100644 --- a/src/core/reference/include/openvino/reference/fake_convert.hpp +++ b/src/core/reference/include/openvino/reference/fake_convert.hpp @@ -113,7 +113,7 @@ void apply_scale_shift(T* out, * @param count Number of elements in the data input. * @param destination_type Name of the destination type. */ -void apply_conversion(const float16* data, float16* out, size_t element_count, const std::string& destination_type); +void apply_conversion(const float16* data, float16* out, size_t element_count, const element::Type& destination_type); } // namespace fake_convert_details /** @@ -140,7 +140,7 @@ void fake_convert(const T* data, const Shape& data_shape, const Shape& scale_shape, const Shape& shift_shape, - const std::string& destination_type) { + const element::Type& destination_type) { const size_t element_count = shape_size(data_shape); fake_convert_details::apply_scale_shift(out, data, @@ -185,7 +185,7 @@ void fake_convert(const T* data, const Shape& data_shape, const Shape& scale_shape, const Shape& shift_shape, - const std::string& destination_type) { + const element::Type& destination_type) { const size_t element_count = shape_size(data_shape); fake_convert_details::apply_scale_shift(out, data, scale, shift, data_shape, scale_shape, shift_shape, false); @@ -206,7 +206,7 @@ void fake_convert(const T* data, T* out, const Shape& data_shape, const Shape& scale_shape, - const std::string& destination_type) { + const element::Type& destination_type) { const auto shift = std::vector(shape_size(scale_shape), 0.f); fake_convert(data, scale, shift.data(), out, data_shape, scale_shape, scale_shape, destination_type); } diff --git a/src/core/reference/src/op/fake_convert.cpp b/src/core/reference/src/op/fake_convert.cpp index fa7499e6a12cd0..0aa498647eee27 100644 --- a/src/core/reference/src/op/fake_convert.cpp +++ b/src/core/reference/src/op/fake_convert.cpp @@ -149,10 +149,10 @@ namespace fake_convert_details { * @param count Number of elements in the data input. * @param destination_type Name of the destination type. */ -void apply_conversion(const float16* data, float16* out, size_t element_count, const std::string& destination_type) { - if (destination_type == "f8e5m2") { +void apply_conversion(const float16* data, float16* out, size_t element_count, const element::Type& destination_type) { + if (destination_type == element::f8e5m2) { reference::func::emulate_f8e5m2_on_fp16(data, out, element_count); - } else if (destination_type == "f8e4m3") { + } else if (destination_type == element::f8e4m3) { reference::func::emulate_f8e4m3_on_fp16(data, out, element_count); } else { OPENVINO_THROW("Unsupported destination type."); diff --git a/src/core/shape_inference/include/batch_to_space_shape_inference.hpp b/src/core/shape_inference/include/batch_to_space_shape_inference.hpp index 94010660716bb8..8372dafe81d7f9 100644 --- a/src/core/shape_inference/include/batch_to_space_shape_inference.hpp +++ b/src/core/shape_inference/include/batch_to_space_shape_inference.hpp @@ -7,7 +7,6 @@ #include #include "dimension_util.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/batch_to_space.hpp" #include "openvino/opsets/opset2.hpp" #include "utils.hpp" diff --git a/src/core/shape_inference/include/depth_to_space_shape_inference.hpp b/src/core/shape_inference/include/depth_to_space_shape_inference.hpp index 428af3ae42608a..c5aa99aafc7011 100644 --- a/src/core/shape_inference/include/depth_to_space_shape_inference.hpp +++ b/src/core/shape_inference/include/depth_to_space_shape_inference.hpp @@ -5,10 +5,9 @@ #pragma once #include -#include -#include -#include +#include "openvino/op/depth_to_space.hpp" +#include "openvino/opsets/opset1.hpp" #include "utils.hpp" namespace ov { namespace op { diff --git a/src/core/shape_inference/include/einsum_shape_inference.hpp b/src/core/shape_inference/include/einsum_shape_inference.hpp index 6cb265d9d6abb3..6e5c0049ea178b 100644 --- a/src/core/shape_inference/include/einsum_shape_inference.hpp +++ b/src/core/shape_inference/include/einsum_shape_inference.hpp @@ -4,9 +4,7 @@ #pragma once -#include -#include - +#include "openvino/op/einsum.hpp" #include "utils.hpp" namespace ov { namespace op { diff --git a/src/core/shape_inference/include/embedding_segments_sum_shape_inference.hpp b/src/core/shape_inference/include/embedding_segments_sum_shape_inference.hpp index 0acf534c7b4a78..edbed345e1f0f9 100644 --- a/src/core/shape_inference/include/embedding_segments_sum_shape_inference.hpp +++ b/src/core/shape_inference/include/embedding_segments_sum_shape_inference.hpp @@ -4,7 +4,6 @@ #pragma once -#include "openvino/core/validation_util.hpp" #include "openvino/op/embedding_segments_sum.hpp" #include "utils.hpp" diff --git a/src/core/shape_inference/include/embeddingbag_offsets_shape_inference.hpp b/src/core/shape_inference/include/embeddingbag_offsets_shape_inference.hpp index f69dc1bddecc14..4266661e66f4d1 100644 --- a/src/core/shape_inference/include/embeddingbag_offsets_shape_inference.hpp +++ b/src/core/shape_inference/include/embeddingbag_offsets_shape_inference.hpp @@ -5,7 +5,6 @@ #pragma once #include "embedding_shape_infer_utils.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/embeddingbag_offsets_sum.hpp" #include "utils.hpp" diff --git a/src/core/shape_inference/include/embeddingbag_packed_shape_inference.hpp b/src/core/shape_inference/include/embeddingbag_packed_shape_inference.hpp index 288583559cf6c3..1af486ea980c24 100644 --- a/src/core/shape_inference/include/embeddingbag_packed_shape_inference.hpp +++ b/src/core/shape_inference/include/embeddingbag_packed_shape_inference.hpp @@ -5,7 +5,6 @@ #pragma once #include "embedding_shape_infer_utils.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/util/embeddingbag_packed_base.hpp" #include "utils.hpp" diff --git a/src/core/shape_inference/include/eye_shape_inference.hpp b/src/core/shape_inference/include/eye_shape_inference.hpp index 2d6989b40a1ed3..c33ce3cc1fe088 100644 --- a/src/core/shape_inference/include/eye_shape_inference.hpp +++ b/src/core/shape_inference/include/eye_shape_inference.hpp @@ -4,7 +4,6 @@ #pragma once #include -#include "openvino/core/validation_util.hpp" #include "openvino/op/eye.hpp" #include "utils.hpp" diff --git a/src/core/shape_inference/include/fft_base_shape_inference.hpp b/src/core/shape_inference/include/fft_base_shape_inference.hpp index a3322fa084f31a..7ed8d9bd9ceae9 100644 --- a/src/core/shape_inference/include/fft_base_shape_inference.hpp +++ b/src/core/shape_inference/include/fft_base_shape_inference.hpp @@ -7,7 +7,6 @@ #include "fft_common_validation.hpp" #include "openvino/core/axis_vector.hpp" #include "openvino/core/dimension_tracker.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/util/fft_base.hpp" #include "utils.hpp" diff --git a/src/core/shape_inference/include/group_normalization_shape_inference.hpp b/src/core/shape_inference/include/group_normalization_shape_inference.hpp index a08d0762e702ca..c4c24796b392d8 100644 --- a/src/core/shape_inference/include/group_normalization_shape_inference.hpp +++ b/src/core/shape_inference/include/group_normalization_shape_inference.hpp @@ -3,8 +3,8 @@ // #pragma once #include -#include -#include + +#include "openvino/op/group_normalization.hpp" namespace ov { namespace op { diff --git a/src/core/shape_inference/include/gru_cell_shape_inference.hpp b/src/core/shape_inference/include/gru_cell_shape_inference.hpp index c8d64f2d710024..5066591d54f84a 100644 --- a/src/core/shape_inference/include/gru_cell_shape_inference.hpp +++ b/src/core/shape_inference/include/gru_cell_shape_inference.hpp @@ -2,11 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 // #pragma once -#include -#include - #include "gru_cell_shape_inference.hpp" #include "gru_sequence_shape_inference.hpp" +#include "openvino/op/gru_cell.hpp" #include "utils.hpp" namespace ov { diff --git a/src/core/shape_inference/include/gru_sequence_shape_inference.hpp b/src/core/shape_inference/include/gru_sequence_shape_inference.hpp index e439fbc211fdbe..cd179d041e48a9 100644 --- a/src/core/shape_inference/include/gru_sequence_shape_inference.hpp +++ b/src/core/shape_inference/include/gru_sequence_shape_inference.hpp @@ -2,9 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // #pragma once -#include -#include - +#include "openvino/op/gru_sequence.hpp" #include "rnn_base_shape_inference.hpp" #include "utils.hpp" diff --git a/src/core/shape_inference/include/matmul_shape_inference.hpp b/src/core/shape_inference/include/matmul_shape_inference.hpp index 54cc7b1e8f2866..bb588003fcc907 100644 --- a/src/core/shape_inference/include/matmul_shape_inference.hpp +++ b/src/core/shape_inference/include/matmul_shape_inference.hpp @@ -2,9 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // #pragma once -#include -#include - +#include "openvino/op/matmul.hpp" #include "utils.hpp" namespace ov { diff --git a/src/core/shape_inference/include/pad_shape_inference.hpp b/src/core/shape_inference/include/pad_shape_inference.hpp index 2304db7d210292..7a9e2c7b688e8e 100644 --- a/src/core/shape_inference/include/pad_shape_inference.hpp +++ b/src/core/shape_inference/include/pad_shape_inference.hpp @@ -5,7 +5,6 @@ #pragma once #include "dimension_util.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/pad.hpp" #include "openvino/op/util/pad_base.hpp" #include "utils.hpp" diff --git a/src/core/shape_inference/include/range_shape_inference.hpp b/src/core/shape_inference/include/range_shape_inference.hpp index 66f7eaa5d8f80e..4376076445a587 100644 --- a/src/core/shape_inference/include/range_shape_inference.hpp +++ b/src/core/shape_inference/include/range_shape_inference.hpp @@ -4,9 +4,7 @@ #pragma once -#include -#include - +#include "openvino/op/range.hpp" #include "utils.hpp" namespace ov { namespace op { diff --git a/src/core/shape_inference/include/reduce_shape_inference.hpp b/src/core/shape_inference/include/reduce_shape_inference.hpp index 7ba50b3b631e0e..676bb51e9f598a 100644 --- a/src/core/shape_inference/include/reduce_shape_inference.hpp +++ b/src/core/shape_inference/include/reduce_shape_inference.hpp @@ -4,7 +4,6 @@ #pragma once -#include "openvino/core/validation_util.hpp" #include "openvino/op/util/arithmetic_reductions_keep_dims.hpp" #include "openvino/op/util/logical_reduction_keep_dims.hpp" #include "utils.hpp" diff --git a/src/core/shape_inference/include/rnn_base_shape_inference.hpp b/src/core/shape_inference/include/rnn_base_shape_inference.hpp index 61f4067875d988..5a2e36ad35e0b0 100644 --- a/src/core/shape_inference/include/rnn_base_shape_inference.hpp +++ b/src/core/shape_inference/include/rnn_base_shape_inference.hpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // #pragma once -#include "openvino/core/validation_util.hpp" #include "openvino/op/util/rnn_cell_base.hpp" #include "utils.hpp" diff --git a/src/core/shape_inference/include/shape_nodes.hpp b/src/core/shape_inference/include/shape_nodes.hpp index f7cce159d27bd4..0656b28ee9e4fc 100644 --- a/src/core/shape_inference/include/shape_nodes.hpp +++ b/src/core/shape_inference/include/shape_nodes.hpp @@ -2,12 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // #pragma once -#include -#include -#include -#include -#include - +#include "openvino/op/util/arithmetic_reductions_keep_dims.hpp" +#include "openvino/op/util/logical_reduction_keep_dims.hpp" +#include "openvino/opsets/opset1.hpp" +#include "openvino/opsets/opset3.hpp" #include "utils.hpp" namespace ov { diff --git a/src/core/shape_inference/include/space_to_depth_shape_inference.hpp b/src/core/shape_inference/include/space_to_depth_shape_inference.hpp index 0f0bbfede0ca13..e7f3972488c6c4 100644 --- a/src/core/shape_inference/include/space_to_depth_shape_inference.hpp +++ b/src/core/shape_inference/include/space_to_depth_shape_inference.hpp @@ -5,10 +5,9 @@ #pragma once #include -#include -#include -#include +#include "openvino/op/space_to_depth.hpp" +#include "openvino/opsets/opset1.hpp" #include "utils.hpp" namespace ov { namespace op { diff --git a/src/core/shape_inference/include/utils.hpp b/src/core/shape_inference/include/utils.hpp index b34002d31fe678..b0a7c508619d83 100644 --- a/src/core/shape_inference/include/utils.hpp +++ b/src/core/shape_inference/include/utils.hpp @@ -9,7 +9,6 @@ #include "element_visitor.hpp" #include "openvino/core/bound_evaluation_util.hpp" #include "openvino/core/deprecated.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/opsets/opset1.hpp" #include "ov_optional.hpp" #include "shape_infer_type_utils.hpp" diff --git a/src/core/shape_inference/src/utils.cpp b/src/core/shape_inference/src/utils.cpp index 74351e6fc1cfc0..23d2c59230e34c 100644 --- a/src/core/shape_inference/src/utils.cpp +++ b/src/core/shape_inference/src/utils.cpp @@ -5,7 +5,6 @@ #include "utils.hpp" #include "eltwise_shape_inference.hpp" -#include "openvino/core/validation_util.hpp" namespace ov { namespace op { diff --git a/src/core/src/descriptor/tensor.cpp b/src/core/src/descriptor/tensor.cpp index 18c9fd3ff18f96..062a740bbd80b6 100644 --- a/src/core/src/descriptor/tensor.cpp +++ b/src/core/src/descriptor/tensor.cpp @@ -17,13 +17,6 @@ ov::descriptor::Tensor::Tensor(const element::Type& element_type, set_names(names); } -ov::descriptor::Tensor::Tensor(const element::Type& element_type, const PartialShape& pshape, const std::string& name) - : m_element_type(element_type), - m_partial_shape(pshape), - m_shape_changed(true) { - m_name_it = m_names.cend(); -} - ov::descriptor::Tensor::Tensor(const element::Type& element_type, const PartialShape& pshape, ov::Node* node, diff --git a/src/core/src/env_util.cpp b/src/core/src/env_util.cpp deleted file mode 100644 index 91eb1dc8291a24..00000000000000 --- a/src/core/src/env_util.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ngraph/env_util.hpp" - -#include "openvino/util/env_util.hpp" - -std::string ngraph::getenv_string(const char* env_var) { - return ov::util::getenv_string(env_var); -} - -int32_t ngraph::getenv_int(const char* env_var, int32_t default_value) { - return ov::util::getenv_int(env_var, default_value); -} - -bool ngraph::getenv_bool(const char* env_var, bool default_value) { - return ov::util::getenv_bool(env_var, default_value); -} diff --git a/src/core/include/ngraph/evaluator.hpp b/src/core/src/evaluator.hpp similarity index 75% rename from src/core/include/ngraph/evaluator.hpp rename to src/core/src/evaluator.hpp index 8a77cb3e8ae140..d784077a030222 100644 --- a/src/core/include/ngraph/evaluator.hpp +++ b/src/core/src/evaluator.hpp @@ -4,44 +4,32 @@ #pragma once -#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED) -# define NGRAPH_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - #include #include #include -#include "ngraph/deprecated.hpp" -#include "ngraph/shape.hpp" #include "openvino/core/node.hpp" +#include "openvino/core/shape.hpp" #include "openvino/core/type/element_type_traits.hpp" -namespace ngraph { +namespace ov { /// \brief Execute handlers on a subgraph to compute values /// /// template -class NGRAPH_API_DEPRECATED Evaluator { - NGRAPH_SUPPRESS_DEPRECATED_START +class Evaluator { public: /// \brief values we compute for outputs - using value_map = std::map; + using value_map = std::map; /// \brief Handler for a computation of a value about an op /// /// A handler is passed a Node* and a vector of computed input values. The handler should /// return a vector of computed output values. - using op_handler = std::function(ov::Node* op, std::vector& inputs)>; + using op_handler = std::function(Node* op, std::vector& inputs)>; /// \brief Table of ops with handlers - using op_handler_map = std::map; + using op_handler_map = std::map; /// \brief construct handler using the provided op handlers. /// @@ -78,7 +66,7 @@ class NGRAPH_API_DEPRECATED Evaluator { } protected: - op_handler get_handler(ov::Node* node) { + op_handler get_handler(Node* node) { op_handler handler = m_universal_handler; if (!handler) { auto it = m_handlers.find(node->get_type_info()); @@ -98,27 +86,27 @@ class NGRAPH_API_DEPRECATED Evaluator { /// \brief Intstructions for evaluations state machine class Inst { protected: - Inst(ov::Node* node) : m_node(node) {} + Inst(Node* node) : m_node(node) {} public: virtual ~Inst() {} - virtual void handle(Evaluator& evaluator, InstStack& inst_stack, ov::Node* node) = 0; - ov::Node* get_node() { + virtual void handle(Evaluator& evaluator, InstStack& inst_stack, Node* node) = 0; + Node* get_node() { return m_node; } protected: - ov::Node* m_node; + Node* m_node; }; /// \brief Ensure value has been analyzed class ValueInst : public Inst { public: - ValueInst(const ov::Output& value) : Inst(value.get_node()), m_index(value.get_index()) {} + ValueInst(const Output& value) : Inst(value.get_node()), m_index(value.get_index()) {} - ValueInst(const ov::RawNodeOutput& value) : Inst(value.node), m_index(value.index) {} + ValueInst(const RawNodeOutput& value) : Inst(value.node), m_index(value.index) {} - void handle(Evaluator& evaluator, InstStack& inst_stack, ov::Node* node) override { + void handle(Evaluator& evaluator, InstStack& inst_stack, Node* node) override { // Request to analyze this value if we can if (auto handler = evaluator.get_handler(node)) { // Ensure the inputs are processed and then execute the op handler @@ -141,9 +129,9 @@ class NGRAPH_API_DEPRECATED Evaluator { /// \brief All arguments have been handled; execute the node handler class ExecuteInst : public Inst { public: - ExecuteInst(ov::Node* node, op_handler& handler) : Inst(node), m_handler(handler) {} + ExecuteInst(Node* node, op_handler& handler) : Inst(node), m_handler(handler) {} - void handle(Evaluator& evaluator, InstStack& inst_stack, ov::Node* node) override { + void handle(Evaluator& evaluator, InstStack& inst_stack, Node* node) override { // Request to execute the handleer. Pass what we know about the inputs to the // handler and associate the results with the outputs std::vector inputs; @@ -162,7 +150,7 @@ class NGRAPH_API_DEPRECATED Evaluator { public: /// \brief Determine information about value - V evaluate(const ov::Output& value) { + V evaluate(const Output& value) { InstStack inst_stack; inst_stack.push(InstPtr(new ValueInst(value))); while (!inst_stack.empty()) { @@ -184,6 +172,5 @@ class NGRAPH_API_DEPRECATED Evaluator { op_handler_map m_handlers; op_handler m_default_handler; value_map& m_value_map; - NGRAPH_SUPPRESS_DEPRECATED_END }; -} // namespace ngraph +} // namespace ov diff --git a/src/core/src/graph_util.cpp b/src/core/src/graph_util.cpp index d66977c0d1c4e2..ec24a5cba81444 100644 --- a/src/core/src/graph_util.cpp +++ b/src/core/src/graph_util.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -340,346 +340,14 @@ void save_model(const std::shared_ptr& m, const std::string& ou manager.run_passes(cloned); } -} // namespace ov - -OPENVINO_SUPPRESS_DEPRECATED_START - -namespace ngraph { -ov::NodeVector find_common_args(std::shared_ptr node1, std::shared_ptr node2) { - std::unordered_set> node1_args; - - auto compute_node1_args = [&node1_args](const std::shared_ptr& node) { - node1_args.insert(node); - }; - - traverse_nodes({std::move(node1)}, compute_node1_args, ov::NodeVector{}); - - std::unordered_set> node2_args; - - auto compute_node2_args = [&node2_args](const std::shared_ptr& node) { - node2_args.insert(node); - }; - - traverse_nodes({std::move(node2)}, compute_node2_args, ov::NodeVector{}); - - ov::NodeVector common_args; - for (const auto& e : node1_args) { - if (node2_args.count(e) > 0) { - common_args.push_back(e); - } - } - - return common_args; -} - -// Check if all paths from X to a result go through Y -bool is_post_dominated(Node* X, Node* Y) { - std::unordered_set visited; - std::stack> stack; - stack.push(X); - - while (stack.size() > 0) { - ov::Node* curr = stack.top(); - visited.insert(curr); - if (ov::op::util::is_output(curr)) { - return false; - } - stack.pop(); - if (curr != Y) { - for (const auto& next : curr->get_users()) { - if (visited.count(next.get()) == 0) { - stack.push(next.get()); - } - } - } - } - return true; -} - -std::vector> clone_nodes(const std::vector>& nodes, - NodeMap& node_map) { - // for each node in topological order - auto sorted_nodes = topological_sort(nodes); - for (const auto& node : sorted_nodes) { - if (node_map.count(node.get()) == 0) { - // get (already) cloned arguments and clone the node - ov::OutputVector cloned_args; - for (auto input : node->inputs()) { - ov::Output output = input.get_source_output(); - cloned_args.push_back(output.for_node(node_map.at(output.get_node()))); - } - std::vector> cloned_dependencies; - for (auto& dependency : node->get_control_dependencies()) { - std::shared_ptr& dependent = node_map.at(dependency.get()); - if (find(cloned_dependencies.begin(), cloned_dependencies.end(), dependent) == - cloned_dependencies.end()) { - cloned_dependencies.push_back(dependent); - } - } - auto cloned_node = node->copy_with_new_inputs(cloned_args, cloned_dependencies); - // There is a friendly name for this node so copy it - cloned_node->set_friendly_name(node->get_friendly_name()); - auto rt_info = node->get_rt_info(); - cloned_node->get_rt_info() = rt_info; - - for (auto output : node->outputs()) { - const auto& output_rt_info = output.get_rt_info(); - auto new_output = output.for_node(cloned_node); - new_output.get_rt_info() = output_rt_info; - } - - for (auto input : node->inputs()) { - const auto& output_rt_info = input.get_rt_info(); - auto new_input = cloned_node->input(input.get_index()); - new_input.get_rt_info() = output_rt_info; - } - - node_map[node.get()] = cloned_node; - } - } - - // create and return vector of cloned nodes - // order matches input vector (not necessarily topological) - std::vector> cloned_nodes; - for (const auto& node : nodes) { - cloned_nodes.push_back(node_map.at(node.get())); - } - return cloned_nodes; -} - -std::list> clone_nodes(const std::vector>& nodes, - ov::RawNodeOutputMap& output_map) { - // for each node in topological order - auto sorted_nodes = topological_sort(nodes); - std::list> cloned_nodes; - for (const auto& node : sorted_nodes) { - auto node_outputs = node->outputs(); - for (const auto& value : node_outputs) { - if (output_map.count(value) == 0) { - // We need this node cloned - // get (already) cloned arguments and clone the node - ov::OutputVector cloned_args; - for (const auto& value : node->input_values()) { - cloned_args.push_back(output_map.at(value)); - } - ov::NodeVector cloned_dependencies; - for (auto& dependency : node->get_control_dependencies()) { - for (const auto& dependency_value : dependency->outputs()) { - std::shared_ptr dependent = output_map.at(dependency_value).get_node_shared_ptr(); - if (find(cloned_dependencies.begin(), cloned_dependencies.end(), dependent) == - cloned_dependencies.end()) { - cloned_dependencies.push_back(dependent); - } - } - } - auto cloned_node = node->copy_with_new_inputs(cloned_args, cloned_dependencies); - cloned_nodes.push_back(cloned_node); - // There is a friendly name for this node so copy it - cloned_node->set_friendly_name(node->get_friendly_name()); - auto rt_info = node->get_rt_info(); - cloned_node->get_rt_info() = rt_info; - for (const auto& cloned_value : cloned_node->outputs()) { - auto original_value = node_outputs.at(cloned_value.get_index()); - if (output_map.count(original_value) == 0) { - output_map[original_value] = cloned_value; - } - } - break; - } - } - } - return cloned_nodes; -} - -bool is_equal_to_const_value(const std::string& const_value, const ov::Output& reduce_constant) { - if (auto rc = ov::as_type_ptr(reduce_constant.get_node_shared_ptr())) { - return (rc->get_all_data_elements_bitwise_identical() && rc->convert_value_to_string(0) == const_value); - } else { - return false; - } -} - -// Insert result and parameter node between src_node and dst_node by splitting the graph -// -// Before: | After: -// (Device:0) (Device:1) | (Device:0) (Device:0) (Device:1) (Device:1) -// +-----+---+ +---+-----+ | +-----+---+ +---+-----+ +-----+---+ +---+-----+ -// | | | | | | | | | | | | | | | | | | | -// | | o +--[0]--> i | | | | | o +--[4]--> i | | | | o +--[8]--> i | | -// | | <--[1]--+ | | | | | <--[5]--+ | | | | <--[9]--+ | | -// | src +---+ +---+ dst | | | src +---+ +---+ res | | par +---+ +---+ dst | -// | | | | | | | | | | | | | -// | +------[2]------> | | | +------[6]------> | | +------[10]-----> | -// | <------[3]------+ | | | <------[7]------+ | | <------[11]-----+ | -// +-----+ +-----+ | +-----+ +-----+ +-----+ +-----+ -std::pair, std::shared_ptr> insert_result_parameter_split( - const std::shared_ptr& src_node, - const std::shared_ptr& dst_node) { - if (src_node->get_output_size() != 1) { - OPENVINO_THROW("Multiple output per op not supported in graph partition yet."); - } - - // Make parameter node - std::shared_ptr par_node = - std::make_shared(src_node->get_output_element_type(0), src_node->get_output_shape(0)); - - // Fix input / output among src, dst and par - std::vector> dst_inputs = get_inputs_from(*src_node, *dst_node); - OPENVINO_ASSERT(dst_inputs.size() == 1, - "insert_result_parameter_split encountered more than " - "one input between the source and destination nodes"); - auto& dst_input = dst_inputs[0]; - - std::vector> src_outputs = get_outputs_to(*src_node, *dst_node); - OPENVINO_ASSERT(src_outputs.size() == 1, - "insert_result_parameter_split encountered more than " - "one output between the source and destination nodes"); - auto& src_output = src_outputs[0]; - - // Remove [0] - src_output.remove_target_input(dst_input); - - // Remove [0] (again), add [8], remove [1], add [9] - dst_input.replace_source_output(par_node->output(0)); - - // Add res node - // Add [4], [5], [6], [7] - std::shared_ptr res_node = std::make_shared(src_node); - - return make_pair(res_node, par_node); -} - -// Insert unary node between two nodes like S->D => S->N->D -// Before: | After: -// +-----+---+ +---+-----+ | +-----+---+ +---+-----+---+ +---+-----+ -// | | | | | | | | | | | | | | | | | -// | | o +--[0]--> i | | | | | o +--[4]--> i | | o +--[8]--> i | | -// | | <--[1]--+ | | | | | <--[5]--+ | | <--[9]--+ | | -// | src +---+ +---+ dst | | | src +---+ +---+ new +---+ +---+ dst | -// | | | | | | | | | | | -// | +------[2]------> | | | +------[6]------> +------[10]-----> | -// | <------[3]------+ | | | <------[7]------+ <------[11]-----+ | -// +-----+ +-----+ | +-----+ +-----+ +-----+ -// | -// +-----+---+ +---+-----+ | -// | | | | | | | -// | | o +--[4]--> i | | | -// | | <--[5]--+ | | | -// | src +---+ +---+ new | | -// | | | | | -// | +------[6]------> | | -// | <------[7]------+ | | -// +-----+ +-----+ | -// -// This cannot be achieved by ngraph::replace_node(). -// With replace_node(), we could do: -// [ S S ] -// [ / \ | ] -// [ / \ => N ] -// [ / \ / \ ] -// [ D0 D1 D0 D1 ] -// -// But we want: -// [ S S ] -// [ / \ / \ ] -// [ / \ => N0 N1 ] -// [ / \ / \ ] -// [ D0 D1 D0 D1 ] -// -// Typically new_node is connected to src_node already. The reason we don't create `new_node` -// inside the function and return it (similar to ngraph::insert_result_parameter_split) is that -// we'll have to templatize its function to call new_node's constructor. -void insert_new_node_between(const std::shared_ptr& src_node, - const std::shared_ptr& dst_node, - const std::shared_ptr& new_node) { - // Fix input / output - std::vector> dst_inputs = get_inputs_from(*src_node, *dst_node); - OPENVINO_ASSERT(dst_inputs.size() == 1, - "insert_new_node_between encountered more than one " - "input between the source and destination nodes"); - auto& dst_input = dst_inputs[0]; - - std::vector> src_outputs = get_outputs_to(*src_node, *dst_node); - OPENVINO_ASSERT(src_outputs.size() == 1, - "insert_new_node_between encountered more than one " - "output between the source and destination nodes"); - auto& src_output = src_outputs[0]; - - src_output.remove_target_input(dst_input); // Remove [0] - dst_input.replace_source_output(new_node->output(0)); // Remove [0] (again), add [8], remove [1], add [9] -} - -std::shared_ptr make_zero(const ov::element::Type& element_type, const Shape& shape) { - auto zero = ov::op::v0::Constant::create(element_type, Shape{}, {0.0}); - if (shape.size() > 0) { - return std::make_shared( - zero, - ov::op::v0::Constant::create(ov::element::u64, Shape{shape.size()}, shape)); - } - return zero; -} - -std::shared_ptr make_constant_from_string(std::string val, - const ov::element::Type& element_type, - const Shape& shape) { - auto cvals = std::vector(shape_size(shape), val); - return std::make_shared(element_type, shape, cvals); -} - -bool is_zero(const ov::Output& reduce_constant) { - auto result_bool = is_equal_to_const_value("0", reduce_constant); - return result_bool; -} - -bool is_one(const ov::Output& reduce_constant) { - auto result_bool = is_equal_to_const_value("1", reduce_constant); - return result_bool; -} - -ov::NodeVector get_subgraph_outputs(const ov::NodeVector& nodes, - const ov::NodeVector& exclusions, - bool ignore_unused, - bool ignore_output_duplicates) { - std::set> exclusions_set(exclusions.begin(), exclusions.end()); - std::set> nodes_set(nodes.begin(), nodes.end()); - - ov::NodeVector outputs; - - for (const auto& n : nodes) { - if (exclusions_set.count(n) != 0) { - continue; - } - - for (const auto& u : n->get_users()) { - bool add_output = nodes_set.count(u) == 0 && (!ignore_unused || is_used(u.get())); - // check if output is already captured - add_output &= (ignore_output_duplicates || std::find(outputs.begin(), outputs.end(), n) == outputs.end()); - if (add_output) { - outputs.push_back(n); - } - } - } - return outputs; -} - -ov::NodeVector extract_subgraph(const ov::NodeVector& results, const ov::NodeVector& args) { - ov::NodeVector subgraph; - traverse_nodes( - results, - [&](const std::shared_ptr& n) { - subgraph.push_back(n); - }, - args); - return subgraph; -} - +bool is_used(Node* node); bool is_used(Node* node) { std::unordered_set instances_seen; std::stack> stack; stack.push(node); while (stack.size() > 0) { - ov::Node* n = stack.top(); + Node* n = stack.top(); if (instances_seen.count(n) == 0) { if (ov::op::util::is_output(n)) { return true; @@ -695,153 +363,4 @@ bool is_used(Node* node) { } return false; } - -size_t get_user_count(Node* node) { - size_t count = 0; - for (const auto& node_user : node->get_users()) { - count += is_used(node_user.get()); - } - return count; -} - -bool is_strided(const Strides& strides) { - return std::any_of(strides.begin(), strides.end(), [](size_t stride) { - return stride != 1; - }); -} - -bool is_valid_rank(const std::shared_ptr& node, std::vector valid_ranks) { - auto node_rank = node->get_shape().size(); - for (auto rank : valid_ranks) { - if (rank == node_rank) { - return true; - } - } - return false; -} - -void plot_graph(std::shared_ptr f, - const std::string& filename, - std::function& attributes)> attributes) { - ov::pass::Manager pass_manager; - pass_manager.register_pass(filename, attributes); - pass_manager.run_passes(std::move(f)); -} - -std::vector> get_inputs_from(Node& src, Node& dst) { - std::vector> result; - - for (auto& input : dst.inputs()) { - if (input.get_source_output().get_node() == &src) { - result.push_back(input); - } - } - - return result; -} - -std::vector> get_outputs_to(Node& src, Node& dst) { - std::vector> result; - - for (auto& output : src.outputs()) { - bool targets_dst = false; - - for (auto& input : output.get_target_inputs()) { - if (input.get_node() == &dst) { - targets_dst = true; - break; - } - } - - if (targets_dst) { - result.push_back(output); - } - } - - return result; -} - -static bool check_for_cycles_bkwd(const std::shared_ptr& node, - std::deque>& path, - std::unordered_set>& path_set, - ov::NodeVector& cycle_nodes) { - path.push_back(node); - path_set.insert(node); - for (size_t i = 0; i < node->inputs().size(); i++) { - auto arg = node->get_input_node_shared_ptr(i); - if (path_set.find(arg) != path_set.end()) { - for (const auto& it : path) { - cycle_nodes.push_back(it); - } - // last node - cycle_nodes.push_back(arg); - return true; - } - if (check_for_cycles_bkwd(arg, path, path_set, cycle_nodes)) { - return true; - } - } - path_set.erase(path.back()); - path.pop_back(); - return false; -} - -static bool check_for_cycles_fwd(const std::shared_ptr& node, - std::deque>& path, - std::unordered_set>& path_set, - ov::NodeVector& cycle_nodes) { - path.push_back(node); - path_set.insert(node); - for (auto& arg : node->get_users()) { - if (path_set.find(arg) != path_set.end()) { - for (const auto& it : path) { - cycle_nodes.push_back(it); - } - // last node - cycle_nodes.push_back(arg); - return true; - } - if (check_for_cycles_fwd(arg, path, path_set, cycle_nodes)) { - return true; - } - } - path_set.erase(path.back()); - path.pop_back(); - return false; -} - -bool check_for_cycles(const ov::Model* func, ov::NodeVector& cycle_nodes, bool& is_bkwd_cycle) { - for (const auto& res : func->get_results()) { - std::deque> path; - // mirror of path stack for faster cycle check - std::unordered_set> path_set; - if (check_for_cycles_bkwd(res, path, path_set, cycle_nodes)) { - is_bkwd_cycle = true; - return true; - } - } - - for (const auto& res : func->get_sinks()) { - std::deque> path; - // mirror of path stack for faster cycle check - std::unordered_set> path_set; - if (check_for_cycles_bkwd(res, path, path_set, cycle_nodes)) { - is_bkwd_cycle = true; - return true; - } - } - - for (const auto& param : func->get_parameters()) { - std::deque> path; - // mirror of path stack for faster cycle check - std::unordered_set> path_set; - if (check_for_cycles_fwd(param, path, path_set, cycle_nodes)) { - is_bkwd_cycle = false; - return true; - } - } - // no cycles - return false; -} - -} // namespace ngraph +} // namespace ov diff --git a/src/core/src/legacy_op_extension.cpp b/src/core/src/legacy_op_extension.cpp deleted file mode 100644 index c943d20ef9d88a..00000000000000 --- a/src/core/src/legacy_op_extension.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "legacy_op_extension.hpp" - -ov::LegacyOpExtension::~LegacyOpExtension() = default; diff --git a/src/core/src/model.cpp b/src/core/src/model.cpp index 16138ae3765931..334e9fe224146a 100644 --- a/src/core/src/model.cpp +++ b/src/core/src/model.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -8,11 +8,12 @@ #include #include +#include "evaluator.hpp" #include "itt.hpp" #include "layout_utils.hpp" -#include "ngraph/evaluator.hpp" #include "openvino/core/attribute_visitor.hpp" #include "openvino/core/except.hpp" +#include "openvino/core/graph_util.hpp" #include "openvino/core/meta_data.hpp" #include "openvino/core/partial_shape.hpp" #include "openvino/op/parameter.hpp" @@ -521,8 +522,7 @@ bool ov::Model::evaluate(ov::TensorVector& output_tensors, outputs.push_back(m_sink); } // evaluate nodes - OPENVINO_SUPPRESS_DEPRECATED_START - ngraph::Evaluator evaluator({}, value_map); + Evaluator evaluator({}, value_map); evaluator.set_universal_handler( [&output_tensor_map, &evaluation_context](Node* node, const ov::TensorVector& input_tensors) -> ov::TensorVector { @@ -551,7 +551,6 @@ bool ov::Model::evaluate(ov::TensorVector& output_tensors, for (const auto& value : outputs) { evaluator.evaluate(value); } - OPENVINO_SUPPRESS_DEPRECATED_END for (size_t i = 0; i < m_results.size(); ++i) { auto result = m_results.at(i)->output(0); output_tensors.at(i) = output_tensor_map[result]; diff --git a/src/core/src/node.cpp b/src/core/src/node.cpp index 80ac8cdeba84fd..84ad0004848c74 100644 --- a/src/core/src/node.cpp +++ b/src/core/src/node.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -15,6 +15,7 @@ #include "openvino/core/descriptor/input.hpp" #include "openvino/core/rt_info.hpp" #include "openvino/core/shape_util.hpp" +#include "openvino/op/util/op_types.hpp" #include "openvino/pass/constant_folding.hpp" #include "openvino/pass/pattern/matcher.hpp" #include "shape_validation.hpp" @@ -513,16 +514,18 @@ bool ov::Node::has_same_type(std::shared_ptr node) const { return true; } +namespace ov { +bool is_used(Node* node); +} + ov::NodeVector ov::Node::get_users(bool check_is_used) const { NodeVector result; for (const auto& output : outputs()) { for (auto input : output.get_target_inputs()) { Node* input_node = input.get_node(); - OPENVINO_SUPPRESS_DEPRECATED_START - if (!check_is_used || ngraph::is_used(input_node)) { + if (!check_is_used || is_used(input_node)) { result.push_back(input_node->shared_from_this()); } - OPENVINO_SUPPRESS_DEPRECATED_END } } return result; diff --git a/src/core/src/op/batch_norm.cpp b/src/core/src/op/batch_norm.cpp index b6d8f2b0ec0a8e..0ddb5cba090071 100644 --- a/src/core/src/op/batch_norm.cpp +++ b/src/core/src/op/batch_norm.cpp @@ -10,6 +10,7 @@ #include "itt.hpp" #include "openvino/core/attribute_visitor.hpp" #include "openvino/core/type.hpp" +#include "validation_util.hpp" namespace ov { namespace op { diff --git a/src/core/src/op/bucketize.cpp b/src/core/src/op/bucketize.cpp index 72f40bbabcd98c..d05b4edc7e15cc 100644 --- a/src/core/src/op/bucketize.cpp +++ b/src/core/src/op/bucketize.cpp @@ -7,7 +7,6 @@ #include "bucketize_shape_inference.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" namespace ov { op::v3::Bucketize::Bucketize(const Output& data, diff --git a/src/core/src/op/ceiling.cpp b/src/core/src/op/ceiling.cpp index 17139143523ed4..b3ea66ae2a6d50 100644 --- a/src/core/src/op/ceiling.cpp +++ b/src/core/src/op/ceiling.cpp @@ -6,7 +6,6 @@ #include "element_visitor.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/reference/ceiling.hpp" namespace ov { diff --git a/src/core/src/op/convolution.cpp b/src/core/src/op/convolution.cpp index 8883a4b87515c6..0bc9a6862cd69e 100644 --- a/src/core/src/op/convolution.cpp +++ b/src/core/src/op/convolution.cpp @@ -160,33 +160,6 @@ void op::v1::ConvolutionBackpropData::set_output_shape(const ov::Shape& shape) { set_argument(2, v0::Constant::create(et, Shape{shape.size()}, shape)); } -void op::v1::ConvolutionBackpropData::infer_conv_backprop_output_spatial_shape( - const vector& input_data_shape, - const vector& filters_shape, - const Strides& strides, - const Strides& dilations, - const CoordinateDiff& pads_begin, - const CoordinateDiff& pads_end, - const CoordinateDiff& output_padding, - vector& output_spatial_shape) { - size_t num_spatial_dims = input_data_shape.size(); - NODE_VALIDATION_CHECK(this, - filters_shape.size() == num_spatial_dims && strides.size() == num_spatial_dims && - dilations.size() == num_spatial_dims && pads_begin.size() == num_spatial_dims && - pads_end.size() == num_spatial_dims && output_padding.size() == num_spatial_dims); - - for (size_t i = 0; i < num_spatial_dims; ++i) { - if (input_data_shape[i].is_static() && filters_shape[i].is_static()) { - int64_t val = strides[i] * (input_data_shape[i].get_length() - 1) + - dilations[i] * (filters_shape[i].get_length() - 1) + 1 - pads_begin[i] - pads_end[i] + - output_padding[i]; - output_spatial_shape.emplace_back(val); - } else { - output_spatial_shape.push_back(Dimension::dynamic()); - } - } -} - void op::v1::ConvolutionBackpropData::validate_and_infer_types() { OV_OP_SCOPE(v1_ConvolutionBackpropData_validate_and_infer_types); const auto& delta_et = get_input_element_type(0); diff --git a/src/core/src/op/ctc_loss.cpp b/src/core/src/op/ctc_loss.cpp index 0df71597c8f7d1..fdd18224732e65 100644 --- a/src/core/src/op/ctc_loss.cpp +++ b/src/core/src/op/ctc_loss.cpp @@ -6,7 +6,6 @@ #include "ctc_loss_shape_inference.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" namespace ov { op::v4::CTCLoss::CTCLoss(const Output& logits, diff --git a/src/core/src/op/deformable_psroi_pooling.cpp b/src/core/src/op/deformable_psroi_pooling.cpp index 2d6a1e39b2f556..b5d956aed8b17d 100644 --- a/src/core/src/op/deformable_psroi_pooling.cpp +++ b/src/core/src/op/deformable_psroi_pooling.cpp @@ -6,7 +6,6 @@ #include "deformable_psroi_pooling_shape_inference.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" namespace ov { diff --git a/src/core/src/op/depth_to_space.cpp b/src/core/src/op/depth_to_space.cpp index 441312f6dd559b..47e7137ea6203a 100644 --- a/src/core/src/op/depth_to_space.cpp +++ b/src/core/src/op/depth_to_space.cpp @@ -11,7 +11,6 @@ #include "depth_to_space_shape_inference.hpp" #include "itt.hpp" #include "openvino/core/shape.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/reference/depth_to_space.hpp" namespace ov { diff --git a/src/core/src/op/detection_output.cpp b/src/core/src/op/detection_output.cpp index 69eef9f98e456c..dfdddd007d82e6 100644 --- a/src/core/src/op/detection_output.cpp +++ b/src/core/src/op/detection_output.cpp @@ -6,7 +6,6 @@ #include "detection_output_shape_inference.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" // ------------------------------ V0 ------------------------------ ov::op::v0::DetectionOutput::DetectionOutput(const Output& box_logits, diff --git a/src/core/src/op/einsum.cpp b/src/core/src/op/einsum.cpp index cf7ebeef6ef2cc..6b1a2fa2cf6a94 100644 --- a/src/core/src/op/einsum.cpp +++ b/src/core/src/op/einsum.cpp @@ -11,7 +11,6 @@ #include "einsum_shape_inference.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" namespace ov { namespace { diff --git a/src/core/src/op/experimental_detectron_topkrois.cpp b/src/core/src/op/experimental_detectron_topkrois.cpp index 7c9bf6b6cb1c6d..5aa1d1cf5b2cc2 100644 --- a/src/core/src/op/experimental_detectron_topkrois.cpp +++ b/src/core/src/op/experimental_detectron_topkrois.cpp @@ -7,7 +7,6 @@ #include "experimental_detectron_topkrois_shape_inference.hpp" #include "itt.hpp" #include "openvino/core/attribute_visitor.hpp" -#include "openvino/core/validation_util.hpp" namespace ov { op::v6::ExperimentalDetectronTopKROIs::ExperimentalDetectronTopKROIs(const Output& input_rois, diff --git a/src/core/src/op/eye.cpp b/src/core/src/op/eye.cpp index a3612c40e61c3f..a8b5accf41a1cf 100644 --- a/src/core/src/op/eye.cpp +++ b/src/core/src/op/eye.cpp @@ -7,7 +7,6 @@ #include "element_visitor.hpp" #include "eye_shape_inference.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/reference/eye.hpp" namespace ov { diff --git a/src/core/src/op/fake_convert.cpp b/src/core/src/op/fake_convert.cpp index 0aad25b58917d2..5b3c8f8d8e9938 100644 --- a/src/core/src/op/fake_convert.cpp +++ b/src/core/src/op/fake_convert.cpp @@ -14,8 +14,8 @@ namespace ov { namespace op { namespace v13 { namespace fake_convert_details { -static const std::vector& get_valid_types() { - static const std::vector valid_types{"f8e4m3", "f8e5m2"}; +static const std::vector& get_valid_types() { + static const std::vector valid_types{ov::element::f8e4m3, ov::element::f8e5m2}; return valid_types; } @@ -24,7 +24,7 @@ struct Evaluate : element::NoAction { template > static result_type visit(ov::TensorVector& outputs, const ov::TensorVector& inputs, - const std::string& destination_type) { + const ov::element::Type& destination_type) { if (inputs.size() == 2) { // Default shift reference::fake_convert(inputs[0].data(), inputs[1].data(), @@ -50,21 +50,36 @@ struct Evaluate : element::NoAction { FakeConvert::FakeConvert(const ov::Output& data, const ov::Output& scale, std::string destination_type) + : FakeConvert(data, scale, ov::element::Type(destination_type)) {} + +FakeConvert::FakeConvert(const ov::Output& data, + const ov::Output& scale, + const ov::Output& shift, + std::string destination_type) + : FakeConvert(data, scale, shift, ov::element::Type(destination_type)) {} + +FakeConvert::FakeConvert(const ov::Output& data, + const ov::Output& scale, + const ov::element::Type& destination_type) : Op({data, scale}), - m_destination_type(std::move(destination_type)) { + m_destination_type(destination_type) { constructor_validate_and_infer_types(); } FakeConvert::FakeConvert(const ov::Output& data, const ov::Output& scale, const ov::Output& shift, - std::string destination_type) + const ov::element::Type& destination_type) : Op({data, scale, shift}), - m_destination_type(std::move(destination_type)) { + m_destination_type(destination_type) { constructor_validate_and_infer_types(); } -const std::string& FakeConvert::get_destination_type() const { +std::string FakeConvert::get_destination_type() const { + return m_destination_type.get_type_name(); +} + +const ov::element::Type& FakeConvert::get_destination_element_type() const { return m_destination_type; } @@ -141,7 +156,7 @@ bool FakeConvert::evaluate(ov::TensorVector& outputs, const ov::TensorVector& in inputs[0].get_element_type(), outputs, inputs, - get_destination_type()); + get_destination_element_type()); return true; } diff --git a/src/core/src/op/gather_tree.cpp b/src/core/src/op/gather_tree.cpp index c9724059ed43cc..a98b7f5e941a5c 100644 --- a/src/core/src/op/gather_tree.cpp +++ b/src/core/src/op/gather_tree.cpp @@ -6,7 +6,6 @@ #include "gather_tree_shape_inference.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" namespace ov { op::v1::GatherTree::GatherTree(const Output& step_ids, diff --git a/src/core/src/op/mod.cpp b/src/core/src/op/mod.cpp index b321b58d4c54a9..79cc4158b90f65 100644 --- a/src/core/src/op/mod.cpp +++ b/src/core/src/op/mod.cpp @@ -7,7 +7,6 @@ #include "bound_evaluate.hpp" #include "element_visitor.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/equal.hpp" #include "openvino/op/logical_or.hpp" diff --git a/src/core/src/op/multiclass_nms.cpp b/src/core/src/op/multiclass_nms.cpp index fcbf314c8ac107..dde9e2725ddeca 100644 --- a/src/core/src/op/multiclass_nms.cpp +++ b/src/core/src/op/multiclass_nms.cpp @@ -6,7 +6,6 @@ #include "itt.hpp" #include "multiclass_nms_shape_inference.hpp" -#include "openvino/core/validation_util.hpp" namespace ov { namespace op { diff --git a/src/core/src/op/negative.cpp b/src/core/src/op/negative.cpp index 8f8f6a2cc513e2..23b941aece9928 100644 --- a/src/core/src/op/negative.cpp +++ b/src/core/src/op/negative.cpp @@ -6,7 +6,6 @@ #include "element_visitor.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/reference/negate.hpp" namespace ov { diff --git a/src/core/src/op/proposal.cpp b/src/core/src/op/proposal.cpp index 75430a95051e7a..1a6354680221f5 100644 --- a/src/core/src/op/proposal.cpp +++ b/src/core/src/op/proposal.cpp @@ -5,7 +5,6 @@ #include "openvino/op/proposal.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "proposal_shape_inference.hpp" namespace ov { diff --git a/src/core/src/op/psroi_pooling.cpp b/src/core/src/op/psroi_pooling.cpp index 9fb12a9b3d7780..39833a72e2f271 100644 --- a/src/core/src/op/psroi_pooling.cpp +++ b/src/core/src/op/psroi_pooling.cpp @@ -6,7 +6,6 @@ #include "itt.hpp" #include "openvino/core/attribute_visitor.hpp" -#include "openvino/core/validation_util.hpp" #include "psroi_pooling_shape_inference.hpp" namespace ov { diff --git a/src/core/src/op/reduce_l1.cpp b/src/core/src/op/reduce_l1.cpp index fb44d686764200..d7bb8fec86a638 100644 --- a/src/core/src/op/reduce_l1.cpp +++ b/src/core/src/op/reduce_l1.cpp @@ -6,7 +6,6 @@ #include "element_visitor.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/util/axes_util.hpp" #include "openvino/reference/reduce_l1.hpp" #include "reduce_shape_inference.hpp" diff --git a/src/core/src/op/roi_align.cpp b/src/core/src/op/roi_align.cpp index 90168c49a2a326..13c82c8d96acdb 100644 --- a/src/core/src/op/roi_align.cpp +++ b/src/core/src/op/roi_align.cpp @@ -5,7 +5,6 @@ #include "openvino/reference/roi_align.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/roi_align.hpp" #include "roi_align_shape_inference.hpp" diff --git a/src/core/src/op/roi_pooling.cpp b/src/core/src/op/roi_pooling.cpp index 7f7855c7f75882..813a667e6fb4fa 100644 --- a/src/core/src/op/roi_pooling.cpp +++ b/src/core/src/op/roi_pooling.cpp @@ -5,7 +5,6 @@ #include "openvino/op/roi_pooling.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "roi_pooling_shape_inference.hpp" namespace ov { diff --git a/src/core/src/op/roll.cpp b/src/core/src/op/roll.cpp index 32f6a0e5ecb68d..4eb3c86e8ed547 100644 --- a/src/core/src/op/roll.cpp +++ b/src/core/src/op/roll.cpp @@ -5,7 +5,6 @@ #include "openvino/op/roll.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "roll_shape_inference.hpp" namespace ov { diff --git a/src/core/src/op/scatter_elements_update.cpp b/src/core/src/op/scatter_elements_update.cpp index 2cec3ff0762c8a..5cc7885c3fa09e 100644 --- a/src/core/src/op/scatter_elements_update.cpp +++ b/src/core/src/op/scatter_elements_update.cpp @@ -6,7 +6,6 @@ #include "element_visitor.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/reference/scatter_elements_update.hpp" #include "scatter_elements_update_shape_inference.hpp" diff --git a/src/core/src/op/softsign.cpp b/src/core/src/op/softsign.cpp index 37183363c78090..6b128cce58b876 100644 --- a/src/core/src/op/softsign.cpp +++ b/src/core/src/op/softsign.cpp @@ -6,7 +6,6 @@ #include "element_visitor.hpp" #include "itt.hpp" #include "openvino/core/shape_util.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/reference/softsign.hpp" #include "openvino/runtime/tensor.hpp" diff --git a/src/core/src/op/space_to_batch.cpp b/src/core/src/op/space_to_batch.cpp index 0101de2491d5b8..b4e32b133a43a0 100644 --- a/src/core/src/op/space_to_batch.cpp +++ b/src/core/src/op/space_to_batch.cpp @@ -11,7 +11,6 @@ #include "itt.hpp" #include "openvino/core/shape.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/util/attr_types.hpp" #include "openvino/op/util/precision_sensitive_attribute.hpp" #include "openvino/reference/pad.hpp" diff --git a/src/core/src/op/strided_slice.cpp b/src/core/src/op/strided_slice.cpp index 771020688fdb9e..bb2da1e9d5d062 100644 --- a/src/core/src/op/strided_slice.cpp +++ b/src/core/src/op/strided_slice.cpp @@ -11,7 +11,6 @@ #include "itt.hpp" #include "openvino/core/attribute_visitor.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/shape_of.hpp" diff --git a/src/core/src/op/topk.cpp b/src/core/src/op/topk.cpp index 3d11e5967d240a..d717bdc1ce9fa6 100644 --- a/src/core/src/op/topk.cpp +++ b/src/core/src/op/topk.cpp @@ -6,7 +6,6 @@ #include "element_visitor.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/reference/topk.hpp" #include "topk_shape_inference.hpp" diff --git a/src/core/src/op/util/embeddingbag_packed_base.cpp b/src/core/src/op/util/embeddingbag_packed_base.cpp index fa60a2d477fd9f..9bcc7ddc1a0ead 100644 --- a/src/core/src/op/util/embeddingbag_packed_base.cpp +++ b/src/core/src/op/util/embeddingbag_packed_base.cpp @@ -6,7 +6,6 @@ #include "embeddingbag_packed_shape_inference.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" using namespace std; diff --git a/src/core/src/opsets/opset.cpp b/src/core/src/opsets/opset.cpp index 17390735fed656..1412b8067bb0f0 100644 --- a/src/core/src/opsets/opset.cpp +++ b/src/core/src/opsets/opset.cpp @@ -109,7 +109,8 @@ const std::map>& ov::get_availabl _OPENVINO_REG_OPSET(opset10), _OPENVINO_REG_OPSET(opset11), _OPENVINO_REG_OPSET(opset12), - _OPENVINO_REG_OPSET(opset13)}; + _OPENVINO_REG_OPSET(opset13), + _OPENVINO_REG_OPSET(opset14)}; #undef _OPENVINO_REG_OPSET return opset_map; } @@ -256,3 +257,14 @@ const ov::OpSet& ov::get_opset13() { }); return opset; } + +const ov::OpSet& ov::get_opset14() { + static OpSet opset; + static std::once_flag flag; + std::call_once(flag, [&]() { +#define _OPENVINO_OP_REG(NAME, NAMESPACE) opset.insert(); +#include "openvino/opsets/opset14_tbl.hpp" +#undef _OPENVINO_OP_REG + }); + return opset; +} diff --git a/src/core/src/pass/constant_folding.cpp b/src/core/src/pass/constant_folding.cpp index 1d1edfe2aa2b5d..94777c95251684 100644 --- a/src/core/src/pass/constant_folding.cpp +++ b/src/core/src/pass/constant_folding.cpp @@ -6,7 +6,6 @@ #include "openvino/cc/pass/itt.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/util/op_types.hpp" #include "openvino/op/util/read_value_base.hpp" diff --git a/src/core/src/pass/manager.cpp b/src/core/src/pass/manager.cpp index fd25ea1e803af0..69363fe72f7c18 100644 --- a/src/core/src/pass/manager.cpp +++ b/src/core/src/pass/manager.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -12,7 +12,6 @@ #include #include "itt.hpp" -#include "ngraph/util.hpp" #include "openvino/pass/graph_rewrite.hpp" #include "openvino/pass/visualize_tree.hpp" #include "openvino/util/env_util.hpp" @@ -55,6 +54,44 @@ void ov::pass::Manager::set_per_pass_validation(bool new_state) { m_per_pass_validation = new_state; } +namespace { +class stopwatch { +public: + void start() { + if (m_active == false) { + m_active = true; + m_start_time = m_clock.now(); + } + } + + void stop() { + if (m_active == true) { + auto end_time = m_clock.now(); + m_last_time = end_time - m_start_time; + m_active = false; + } + } + + std::chrono::nanoseconds get_timer_value() const { + if (m_active) { + return (m_clock.now() - m_start_time); + } else { + return m_last_time; + } + } + + size_t get_milliseconds() const { + return std::chrono::duration_cast(get_timer_value()).count(); + } + +private: + std::chrono::high_resolution_clock m_clock; + std::chrono::time_point m_start_time; + bool m_active = false; + std::chrono::nanoseconds m_last_time = std::chrono::high_resolution_clock::duration::zero(); +}; +} // namespace + bool ov::pass::Manager::run_passes(shared_ptr func) { OPENVINO_SUPPRESS_DEPRECATED_START OV_ITT_SCOPED_TASK(ov::itt::domains::core, "pass::Manager::run_passes"); @@ -63,8 +100,8 @@ bool ov::pass::Manager::run_passes(shared_ptr func) { ov::util::getenv_bool("NGRAPH_PROFILE_PASS_ENABLE") || ov::util::getenv_bool("OV_PROFILE_PASS_ENABLE"); size_t index = 0; - ngraph::stopwatch pass_timer; - ngraph::stopwatch overall_timer; + stopwatch pass_timer; + stopwatch overall_timer; overall_timer.start(); bool pass_applied = false; bool function_changed = false; diff --git a/src/core/src/pass/serialize.cpp b/src/core/src/pass/serialize.cpp index 0ed69cad73dfa6..0da8c27ea83db6 100644 --- a/src/core/src/pass/serialize.cpp +++ b/src/core/src/pass/serialize.cpp @@ -192,7 +192,6 @@ class ConstantWriter { void ngfunction_2_ir(pugi::xml_node& node, const ov::Model& model, - const std::map& custom_opsets, ConstantWriter& constant_write_handler, int64_t version, bool deterministic); @@ -303,7 +302,6 @@ class RTInfoSerializer : public ov::AttributeVisitor { class XmlSerializer : public ov::AttributeVisitor { pugi::xml_node& m_xml_node; const std::string& m_node_type_name; - const std::map& m_custom_opsets; ConstantWriter& m_constant_write_handler; int64_t m_version; bool m_deterministic; @@ -423,7 +421,6 @@ class XmlSerializer : public ov::AttributeVisitor { public: XmlSerializer(pugi::xml_node& data, const std::string& node_type_name, - const std::map& custom_opsets, ConstantWriter& constant_write_handler, int64_t version, bool deterministic = false, @@ -431,7 +428,6 @@ class XmlSerializer : public ov::AttributeVisitor { ov::element::Type output_element_type = ov::element::dynamic) : m_xml_node(data), m_node_type_name(node_type_name), - m_custom_opsets(custom_opsets), m_constant_write_handler(constant_write_handler), m_version(version), m_deterministic(deterministic), @@ -612,21 +608,11 @@ class XmlSerializer : public ov::AttributeVisitor { // to layer above (m_xml_node.parent()) as in ngfunction_2_ir() layer (m_xml_node) with empty attributes // is removed. pugi::xml_node xml_body = m_xml_node.parent().append_child(name.c_str()); - ngfunction_2_ir(xml_body, - *adapter.get(), - m_custom_opsets, - m_constant_write_handler, - m_version, - m_deterministic); + ngfunction_2_ir(xml_body, *adapter.get(), m_constant_write_handler, m_version, m_deterministic); xml_body.remove_attribute("name"); xml_body.remove_attribute("version"); } else if (name == "net") { - ngfunction_2_ir(m_xml_node, - *adapter.get(), - m_custom_opsets, - m_constant_write_handler, - m_version, - m_deterministic); + ngfunction_2_ir(m_xml_node, *adapter.get(), m_constant_write_handler, m_version, m_deterministic); } else { OPENVINO_THROW("Unsupported Model name."); } @@ -672,33 +658,9 @@ const std::vector create_edge_mapping(const std::unordered_map& custom_opsets) { +std::string get_opset_name(const ov::Node* n) { OPENVINO_ASSERT(n != nullptr); - - // Try to find opset name from RT info - auto opset_it = n->get_rt_info().find("opset"); - if (opset_it != n->get_rt_info().end()) { - if (opset_it->second.is()) { - const std::string& opset_name = opset_it->second.as(); - if (custom_opsets.find(opset_name) != custom_opsets.end()) { - return opset_name; - } - } - } - - if (n->get_type_info().version_id != nullptr) { - return n->get_type_info().version_id; - } - - for (const auto& custom_opset : custom_opsets) { - std::string name = custom_opset.first; - ov::OpSet opset = custom_opset.second; - if (opset.contains_op_type(n)) { - return name; - } - } - - return "experimental"; + return n->get_type_info().version_id == nullptr ? "experimental" : n->get_type_info().version_id; } std::string get_precision_name(const ov::element::Type& elem_type) { @@ -740,6 +702,10 @@ std::string get_precision_name(const ov::element::Type& elem_type) { return "BOOL"; case ::ov::element::Type_t::nf4: return "NF4"; + case ::ov::element::Type_t::f8e4m3: + return "F8E4M3"; + case ::ov::element::Type_t::f8e5m2: + return "F8E5M2"; case ::ov::element::Type_t::string: return "STRING"; default: @@ -903,7 +869,6 @@ void serialize_rt_info(pugi::xml_node& root, const std::string& name, const ov:: void ngfunction_2_ir(pugi::xml_node& netXml, const ov::Model& model, - const std::map& custom_opsets, ConstantWriter& constant_node_write_handler, int64_t version, bool deterministic) { @@ -959,7 +924,7 @@ void ngfunction_2_ir(pugi::xml_node& netXml, } layer.append_attribute("type").set_value(translate_type_name(node_type_name).c_str()); if (!exec_graph) { - layer.append_attribute("version").set_value(get_opset_name(node, custom_opsets).c_str()); + layer.append_attribute("version").set_value(get_opset_name(node).c_str()); } // general attributes @@ -1085,7 +1050,6 @@ void ngfunction_2_ir(pugi::xml_node& netXml, PaddingsFixer fixed_node(node); XmlSerializer visitor(data, node_type_name, - custom_opsets, constant_node_write_handler, version, deterministic, @@ -1159,7 +1123,6 @@ void serializeFunc(std::ostream& xml_file, std::ostream& bin_file, std::shared_ptr model, ov::pass::Serialize::Version ver, - const std::map& custom_opsets, bool deterministic = false) { auto version = static_cast(ver); @@ -1182,7 +1145,7 @@ void serializeFunc(std::ostream& xml_file, pugi::xml_document xml_doc; pugi::xml_node net_node = xml_doc.append_child(name.c_str()); ConstantWriter constant_write_handler(bin_file); - XmlSerializer visitor(net_node, name, custom_opsets, constant_write_handler, version, deterministic); + XmlSerializer visitor(net_node, name, constant_write_handler, version, deterministic); visitor.on_attribute(name, model); xml_doc.save(xml_file); @@ -1204,7 +1167,7 @@ bool pass::Serialize::run_on_model(const std::shared_ptr& model) { disable_fp16_compression(node); if (m_xmlFile && m_binFile) { - serializeFunc(*m_xmlFile, *m_binFile, model, m_version, m_custom_opsets); + serializeFunc(*m_xmlFile, *m_binFile, model, m_version); } else { auto xmlDir = ov::util::get_directory(m_xmlPath); if (xmlDir != m_xmlPath) @@ -1218,7 +1181,7 @@ bool pass::Serialize::run_on_model(const std::shared_ptr& model) { OPENVINO_ASSERT(xml_file, "Can't open xml file: \"" + m_xmlPath + "\""); try { - serializeFunc(xml_file, bin_file, model, m_version, m_custom_opsets); + serializeFunc(xml_file, bin_file, model, m_version); } catch (const ov::AssertFailure&) { // optimization decision was made to create .bin file upfront and // write to it directly instead of buffering its content in memory, @@ -1235,43 +1198,24 @@ bool pass::Serialize::run_on_model(const std::shared_ptr& model) { return false; } -OPENVINO_SUPPRESS_DEPRECATED_START -pass::Serialize::Serialize(std::ostream& xmlFile, - std::ostream& binFile, - std::map custom_opsets, - pass::Serialize::Version version) +pass::Serialize::Serialize(std::ostream& xmlFile, std::ostream& binFile, pass::Serialize::Version version) : m_xmlFile{&xmlFile}, m_binFile{&binFile}, m_xmlPath{}, m_binPath{}, - m_version{version}, - m_custom_opsets{custom_opsets} {} - -pass::Serialize::Serialize(std::ostream& xmlFile, std::ostream& binFile, pass::Serialize::Version version) - : pass::Serialize::Serialize(xmlFile, binFile, std::map{}, version) {} + m_version{version} {} -pass::Serialize::Serialize(const std::string& xmlPath, - const std::string& binPath, - std::map custom_opsets, - pass::Serialize::Version version) +pass::Serialize::Serialize(const std::string& xmlPath, const std::string& binPath, pass::Serialize::Version version) : m_xmlFile{nullptr}, m_binFile{nullptr}, m_xmlPath{valid_xml_path(xmlPath)}, m_binPath{provide_bin_path(xmlPath, binPath)}, - m_version{version}, - m_custom_opsets{custom_opsets} {} - -pass::Serialize::Serialize(const std::string& xmlPath, const std::string& binPath, pass::Serialize::Version version) - : pass::Serialize::Serialize(xmlPath, binPath, std::map{}, version) {} -OPENVINO_SUPPRESS_DEPRECATED_END + m_version{version} {} -OPENVINO_SUPPRESS_DEPRECATED_START pass::StreamSerialize::StreamSerialize(std::ostream& stream, - std::map&& custom_opsets, const std::function& custom_data_serializer, Serialize::Version version) : m_stream(stream), - m_custom_opsets(std::move(custom_opsets)), m_custom_data_serializer(custom_data_serializer), m_version(version) { if (version != Serialize::Version::UNSPECIFIED && version != Serialize::Version::IR_V10 && @@ -1280,12 +1224,6 @@ pass::StreamSerialize::StreamSerialize(std::ostream& stream, } } -pass::StreamSerialize::StreamSerialize(std::ostream& stream, - const std::function& custom_data_serializer, - Serialize::Version version) - : StreamSerialize(stream, {}, custom_data_serializer, version) {} -OPENVINO_SUPPRESS_DEPRECATED_END - bool pass::StreamSerialize::run_on_model(const std::shared_ptr& model) { RUN_ON_MODEL_SCOPE(StreamSerialize); /* @@ -1329,7 +1267,7 @@ bool pass::StreamSerialize::run_on_model(const std::shared_ptr& model pugi::xml_document xml_doc; pugi::xml_node net_node = xml_doc.append_child(name.c_str()); ConstantWriter constant_write_handler(m_stream); - XmlSerializer visitor(net_node, name, m_custom_opsets, constant_write_handler, version); + XmlSerializer visitor(net_node, name, constant_write_handler, version); std::shared_ptr fun = model; visitor.on_attribute(name, fun); @@ -1396,7 +1334,7 @@ bool pass::Hash::run_on_model(const std::shared_ptr& model) { std::ostream bin(&binHash); // Determinism is important for hash calculation - serializeFunc(xml, bin, model, Serialize::Version::UNSPECIFIED, {}, true); + serializeFunc(xml, bin, model, Serialize::Version::UNSPECIFIED, true); uint64_t seed = 0; seed = hash_combine(seed, xmlHash.getResult()); diff --git a/src/core/src/pattern/matcher.cpp b/src/core/src/pattern/matcher.cpp index b38cb7acdbbe12..ab14a875a37168 100644 --- a/src/core/src/pattern/matcher.cpp +++ b/src/core/src/pattern/matcher.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -12,6 +12,8 @@ #include "openvino/util/log.hpp" namespace ov { +bool is_used(Node* node); + namespace pass { namespace pattern { MatcherState::MatcherState(Matcher* matcher) @@ -83,8 +85,30 @@ void Matcher::capture(const std::set& static_nodes) { } } } + +namespace { +ov::NodeVector get_subgraph_outputs(const NodeVector& nodes, const NodeVector& exclusions, bool ignore_unused) { + const std::set> exclusions_set(exclusions.begin(), exclusions.end()); + const std::set> nodes_set(nodes.begin(), nodes.end()); + + NodeVector outputs; + + for (const auto& n : nodes) { + if (exclusions_set.count(n) != 0) + continue; + + for (const auto& u : n->get_users()) { + bool add_output = nodes_set.count(u) == 0 && (!ignore_unused || is_used(u.get())); + if (add_output) { + outputs.push_back(n); + } + } + } + return outputs; +} +} // namespace + bool Matcher::is_contained_match(const NodeVector& exclusions, bool ignore_unused) { - OPENVINO_SUPPRESS_DEPRECATED_START if (exclusions.empty()) { NodeVector label_exclusions; for (const auto& entry : m_pattern_map) { @@ -93,11 +117,10 @@ bool Matcher::is_contained_match(const NodeVector& exclusions, bool ignore_unuse label_exclusions.push_back(entry.second.get_node_shared_ptr()); } } - return ngraph::get_subgraph_outputs(get_matched_nodes(), label_exclusions, ignore_unused).size() < 2; + return get_subgraph_outputs(get_matched_nodes(), label_exclusions, ignore_unused).size() < 2; } - return ngraph::get_subgraph_outputs(get_matched_nodes(), exclusions).size() < 2; - OPENVINO_SUPPRESS_DEPRECATED_END + return get_subgraph_outputs(get_matched_nodes(), exclusions, false).size() < 2; } bool Matcher::match_value(const ov::Output& pattern_value, const ov::Output& graph_value) { diff --git a/src/core/src/preprocess/preprocess_impls.hpp b/src/core/src/preprocess/preprocess_impls.hpp index 4d72a826a286e3..0bf89fe0918441 100644 --- a/src/core/src/preprocess/preprocess_impls.hpp +++ b/src/core/src/preprocess/preprocess_impls.hpp @@ -218,7 +218,7 @@ class InputTensorInfo::InputTensorInfoImpl : public TensorInfoImplBase { m_shape_set = true; } - void set_from(const ov::runtime::Tensor& runtime_tensor) { + void set_from(const ov::Tensor& runtime_tensor) { set_shape(runtime_tensor.get_shape()); set_element_type(runtime_tensor.get_element_type()); } diff --git a/src/core/src/specialize_function.cpp b/src/core/src/specialize_function.cpp deleted file mode 100644 index 5ecc9742772830..00000000000000 --- a/src/core/src/specialize_function.cpp +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ngraph/specialize_function.hpp" - -#include "itt.hpp" -#include "ngraph/op/util/op_types.hpp" -#include "openvino/op/constant.hpp" -#include "openvino/op/parameter.hpp" - -using namespace ngraph; -NGRAPH_SUPPRESS_DEPRECATED_START; - -using ov::op::v0::Constant; - -std::shared_ptr ngraph::specialize_function(std::shared_ptr f, - const std::vector& parameter_element_types, - const std::vector& parameter_shapes, - const std::vector& parameter_values) - -{ - OV_ITT_SCOPED_TASK(ov::itt::domains::core, "specialize_function"); - - OPENVINO_ASSERT(f->get_parameters().size() == parameter_shapes.size()); - OPENVINO_ASSERT(f->get_parameters().size() == parameter_element_types.size()); - OPENVINO_ASSERT(f->get_parameters().size() == parameter_values.size()); - - NodeMap m; - - for (size_t i = 0; i < parameter_shapes.size(); i++) { - OPENVINO_ASSERT(f->get_parameters()[i]->get_element_type().is_dynamic() || - parameter_element_types[i] == f->get_parameters()[i]->get_element_type()); - - if (parameter_values[i] != nullptr && parameter_shapes[i].is_static() && - parameter_element_types[i].is_static()) { - m[f->get_parameters()[i].get()] = std::make_shared(parameter_element_types[i], - parameter_shapes[i].to_shape(), - parameter_values[i]); - } else { - m[f->get_parameters()[i].get()] = - std::make_shared(parameter_element_types[i], parameter_shapes[i]); - } - auto rt_info = f->get_parameters()[i]->get_rt_info(); - m[f->get_parameters()[i].get()]->get_rt_info() = rt_info; - } - - for (auto old_node : f->get_ordered_ops()) { - if (op::is_parameter(old_node)) { - continue; - } - - ov::OutputVector new_args; - for (auto input : old_node->inputs()) { - auto output = input.get_source_output(); - new_args.push_back(output.for_node(m[output.get_node()])); - } - - ov::NodeVector cloned_dependencies; - for (auto& dependency : old_node->get_control_dependencies()) { - std::shared_ptr dependent = m.at(dependency.get()); - if (find(cloned_dependencies.begin(), cloned_dependencies.end(), dependent) == cloned_dependencies.end()) { - cloned_dependencies.push_back(dependent); - } - } - m[old_node.get()] = old_node->copy_with_new_inputs(new_args, cloned_dependencies); - - auto rt_info = old_node->get_rt_info(); - m[old_node.get()]->get_rt_info() = rt_info; - - m[old_node.get()]->set_friendly_name(old_node->get_friendly_name()); - } - - ov::ParameterVector new_parameters = f->get_parameters(); - for (size_t i = 0; i < new_parameters.size(); i++) { - auto name = new_parameters[i]->get_friendly_name(); - new_parameters[i] = ov::as_type_ptr(m[new_parameters[i].get()]); - - // If the replacement for a Parameter is not itself a Parameter, we must have replaced it - // with a constant. We will insert a dead Parameter into the clone's parameters, in order - // to maintain the arity of the original function. - if (new_parameters[i] == nullptr) { - new_parameters[i] = - std::make_shared(parameter_element_types[i], parameter_shapes[i]); - } - new_parameters[i]->set_friendly_name(name); - } - - ov::ResultVector new_results = f->get_results(); - for (size_t i = 0; i < new_results.size(); i++) { - auto name = new_results[i]->get_friendly_name(); - new_results[i] = std::static_pointer_cast(m[new_results[i].get()]); - new_results[i]->set_friendly_name(name); - } - auto new_sinks = f->get_sinks(); - for (size_t i = 0; i < new_sinks.size(); i++) { - new_sinks[i] = std::static_pointer_cast(m[new_sinks[i].get()]); - } - - return std::make_shared(new_results, new_sinks, new_parameters); -} diff --git a/src/core/src/util.cpp b/src/core/src/util.cpp deleted file mode 100644 index 7e14a09cf67a2d..00000000000000 --- a/src/core/src/util.cpp +++ /dev/null @@ -1,415 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ngraph/util.hpp" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "openvino/util/common_util.hpp" -#include "openvino/util/log.hpp" - -OPENVINO_SUPPRESS_DEPRECATED_START - -namespace ngraph { -void dump(std::ostream& out, const void* _data, size_t _size) { - auto flags = out.flags(); - const uint8_t* data = reinterpret_cast(_data); - size_t len = _size; - size_t index = 0; - while (index < len) { - out << std::hex << std::setw(8) << std::setfill('0') << index; - for (int i = 0; i < 8; i++) { - if (index + i < len) { - out << " " << std::hex << std::setw(2) << std::setfill('0') << static_cast(data[i]); - } else { - out << " "; - } - } - out << " "; - for (int i = 8; i < 16; i++) { - if (index + i < len) { - out << " " << std::hex << std::setw(2) << std::setfill('0') << static_cast(data[i]); - } else { - out << " "; - } - } - out << " "; - for (int i = 0; i < 16; i++) { - char ch = (index + i < len ? data[i] : ' '); - out << ((ch < 32) ? '.' : ch); - } - out << "\n"; - data += 16; - index += 16; - } - out.flags(flags); -} - -std::string to_lower(const std::string& s) { - return ov::util::to_lower(s); -} - -std::string to_upper(const std::string& s) { - return ov::util::to_upper(s); -} - -std::string trim(const std::string& s) { - return ov::util::trim(s); -} - -std::vector split(const std::string& src, char delimiter, bool do_trim) { - return ov::util::split(src, delimiter, do_trim); -} - -size_t hash_combine(const std::vector& list) { - return ov::util::hash_combine(list); -} - -void* ngraph_malloc(size_t size) { - auto ptr = malloc(size); - if (size != 0 && !ptr) { - OPENVINO_ERR << "malloc failed to allocate memory of size " << size; - throw std::bad_alloc(); - } - return ptr; -} - -void ngraph_free(void* ptr) { - if (ptr) { - free(ptr); - } -} - -size_t round_up(size_t size, size_t alignment) { - if (alignment == 0) { - return size; - } - - size_t remainder = size % alignment; - if (remainder == 0) { - return size; - } - - return size + alignment - remainder; -} - -size_t stopwatch::get_call_count() const { - return m_total_count; -} - -size_t stopwatch::get_seconds() const { - return std::chrono::duration_cast(get_timer_value()).count(); -} - -size_t stopwatch::get_milliseconds() const { - return std::chrono::duration_cast(get_timer_value()).count(); -} - -size_t stopwatch::get_microseconds() const { - return std::chrono::duration_cast(get_timer_value()).count(); -} - -size_t stopwatch::get_nanoseconds() const { - return get_timer_value().count(); -} - -std::chrono::nanoseconds stopwatch::get_timer_value() const { - if (m_active) { - return (m_clock.now() - m_start_time); - } else { - return m_last_time; - } -} - -size_t stopwatch::get_total_seconds() const { - return std::chrono::duration_cast(m_total_time).count(); -} - -size_t stopwatch::get_total_milliseconds() const { - return std::chrono::duration_cast(m_total_time).count(); -} - -size_t stopwatch::get_total_microseconds() const { - return std::chrono::duration_cast(m_total_time).count(); -} - -size_t stopwatch::get_total_nanoseconds() const { - return m_total_time.count(); -} - -template <> -float parse_string(const std::string& s) { - const char* tmp = s.c_str(); - char* end; - float result = strtof(tmp, &end); - if (*end != 0) { - throw std::runtime_error("Could not parse literal '" + s + "'"); - } - return result; -} - -template <> -double parse_string(const std::string& s) { - const char* tmp = s.c_str(); - char* end; - double result = strtod(tmp, &end); - if (*end != 0) { - throw std::runtime_error("Could not parse literal '" + s + "'"); - } - return result; -} - -template <> -int8_t parse_string(const std::string& s) { - char* err; - int8_t result = static_cast(strtol(s.c_str(), &err, 10)); - - // Check that (1) parsing succeeded and (2) the entire string was used. - if (*err != 0) { - throw std::runtime_error("Could not parse literal '" + s + "'"); - } - - return result; -} - -template <> -uint8_t parse_string(const std::string& s) { - char* err; - int8_t result = static_cast(strtol(s.c_str(), &err, 10)); - - // Check that (1) parsing succeeded and (2) the entire string was used. - if (*err != 0) { - throw std::runtime_error("Could not parse literal '" + s + "'"); - } - - return result; -} - -AxisVector get_default_order(const Shape& shape) { - return get_default_order(shape.size()); -} - -AxisVector get_default_order(const ov::PartialShape& shape) { - return get_default_order(shape.rank()); -} - -AxisVector get_default_order(size_t rank) { - AxisVector default_order(rank); - std::iota(begin(default_order), end(default_order), 0); - return default_order; -} - -AxisVector get_default_order(const ov::Rank& rank) { - OPENVINO_ASSERT(rank.is_static(), "Can not calculate default order for dynamic rank"); - - AxisVector default_order(rank.get_length()); - std::iota(begin(default_order), end(default_order), 0); - return default_order; -} - -void parse_version_string(std::string version, size_t& major, size_t& minor, size_t& patch, std::string& extra) { - // Since regex is broken in gcc 4.8 I will just manually parse the version string - // Version strings look like `0.25.0-rc.0+7c32240` or `v0.25.0-rc.0+7c32240` - size_t start; - size_t end; - extra = ""; - start = (version[0] == 'v' ? 1 : 0); - end = version.find_first_of('.', start); - std::string major_str = version.substr(start, end - start); - start = end + 1; - - end = version.find_first_of('.', start); - std::string minor_str = version.substr(start, end - start); - start = end + 1; - - end = version.find_first_of("-+", start); - std::string patch_str = version.substr(start, end - start); - start = end; - - if (start != std::string::npos) { - extra = version.substr(start); - } - - size_t err; - bool error = false; - try { - major = stoi(major_str, &err); - if (err != major_str.size()) { - error = true; - } - minor = stoi(minor_str, &err); - if (err != minor_str.size()) { - error = true; - } - patch = stoi(patch_str, &err); - if (err != patch_str.size()) { - error = true; - } - } catch (...) { - error = true; - } - if (error) { - OPENVINO_THROW("Error parsing version string '", version, "'"); - } -} -} // namespace ngraph - -std::vector read_float_vector(std::shared_ptr tv) { - std::vector float_vec; - ov::element::Type element_type = tv->get_element_type(); - - if (element_type == ov::element::boolean) { - std::vector vec = read_vector(tv); - // Changed from vector ctor to explicit for loop to add static_cast - // This silences MSVC warnings - for (char value : vec) { - float_vec.push_back(static_cast(value)); - } - } else if (element_type == ov::element::bf16) { - std::vector vec = read_vector(tv); - float_vec = ov::bfloat16::to_float_vector(vec); - } else if (element_type == ov::element::f16) { - std::vector vec = read_vector(tv); - for (ov::float16 value : vec) { - float_vec.push_back(static_cast(value)); - } - } else if (element_type == ov::element::f32) { - std::vector vec = read_vector(tv); - for (float value : vec) { - float_vec.push_back(static_cast(value)); - } - } else if (element_type == ov::element::f64) { - std::vector vec = read_vector(tv); - for (double value : vec) { - float_vec.push_back(static_cast(value)); - } - } else if (element_type == ov::element::i8) { - std::vector vec = read_vector(tv); - for (int8_t value : vec) { - float_vec.push_back(static_cast(value)); - } - } else if (element_type == ov::element::i16) { - std::vector vec = read_vector(tv); - for (int16_t value : vec) { - float_vec.push_back(static_cast(value)); - } - } else if (element_type == ov::element::i32) { - std::vector vec = read_vector(tv); - for (int32_t value : vec) { - float_vec.push_back(static_cast(value)); - } - } else if (element_type == ov::element::i64) { - std::vector vec = read_vector(tv); - for (int64_t value : vec) { - float_vec.push_back(static_cast(value)); - } - } else if (element_type == ov::element::u8) { - std::vector vec = read_vector(tv); - for (uint8_t value : vec) { - float_vec.push_back(static_cast(value)); - } - } else if (element_type == ov::element::u16) { - std::vector vec = read_vector(tv); - for (uint16_t value : vec) { - float_vec.push_back(static_cast(value)); - } - } else if (element_type == ov::element::u32) { - std::vector vec = read_vector(tv); - for (uint32_t value : vec) { - float_vec.push_back(static_cast(value)); - } - } else if (element_type == ov::element::u64) { - std::vector vec = read_vector(tv); - for (uint64_t value : vec) { - float_vec.push_back(static_cast(value)); - } - } else { - OPENVINO_THROW("Unsupported OpenVINO element type."); - } - - return float_vec; -} - -std::vector read_index_vector(std::shared_ptr tv) { - std::vector index_vec; - ov::element::Type element_type = tv->get_element_type(); - - if (element_type == ov::element::boolean) { - std::vector vec = read_vector(tv); - // Changed from vector ctor to explicit for loop to add static_cast - // This silences MSVC warnings - for (char value : vec) { - index_vec.push_back(static_cast(value)); - } - } else if (element_type == ov::element::bf16) { - std::vector vec = read_vector(tv); - std::vector float_vec = ov::bfloat16::to_float_vector(vec); - for (float value : float_vec) { - index_vec.push_back(static_cast(value)); - } - } else if (element_type == ov::element::f16) { - std::vector vec = read_vector(tv); - for (ov::float16 value : vec) { - index_vec.push_back(static_cast(static_cast(value))); - } - } else if (element_type == ov::element::f32) { - std::vector vec = read_vector(tv); - for (float value : vec) { - index_vec.push_back(static_cast(value)); - } - } else if (element_type == ov::element::f64) { - std::vector vec = read_vector(tv); - for (double value : vec) { - index_vec.push_back(static_cast(value)); - } - } else if (element_type == ov::element::i8) { - std::vector vec = read_vector(tv); - for (int8_t value : vec) { - index_vec.push_back(static_cast(value)); - } - } else if (element_type == ov::element::i16) { - std::vector vec = read_vector(tv); - for (int16_t value : vec) { - index_vec.push_back(static_cast(value)); - } - } else if (element_type == ov::element::i32) { - std::vector vec = read_vector(tv); - for (int32_t value : vec) { - index_vec.push_back(static_cast(value)); - } - } else if (element_type == ov::element::i64) { - index_vec = read_vector(tv); - } else if (element_type == ov::element::u8) { - std::vector vec = read_vector(tv); - for (uint8_t value : vec) { - index_vec.push_back(static_cast(value)); - } - } else if (element_type == ov::element::u16) { - std::vector vec = read_vector(tv); - for (uint16_t value : vec) { - index_vec.push_back(static_cast(value)); - } - } else if (element_type == ov::element::u32) { - std::vector vec = read_vector(tv); - for (uint32_t value : vec) { - index_vec.push_back(static_cast(value)); - } - } else if (element_type == ov::element::u64) { - std::vector vec = read_vector(tv); - for (uint64_t value : vec) { - index_vec.push_back(static_cast(value)); - } - } else { - OPENVINO_THROW("Unsupported OpenVINO element type."); - } - - return index_vec; -} diff --git a/src/core/src/validation_util.cpp b/src/core/src/validation_util.cpp index ba2799a8a39134..963a229799106b 100644 --- a/src/core/src/validation_util.cpp +++ b/src/core/src/validation_util.cpp @@ -2,721 +2,20 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "ngraph/validation_util.hpp" +#include "validation_util.hpp" #include #include #include "bound_evaluate.hpp" #include "compare.hpp" -#include "ngraph/evaluator.hpp" #include "openvino/core/dimension_tracker.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/gather.hpp" #include "openvino/op/negative.hpp" #include "openvino/op/ops.hpp" +#include "openvino/util/common_util.hpp" #include "sequnce_generator.hpp" -#include "validation_util.hpp" - -OPENVINO_SUPPRESS_DEPRECATED_START - -namespace ngraph { -using ov::Dimension; -namespace op { -namespace v0 { -using ov::op::v0::Constant; -using ov::op::v0::Negative; -} // namespace v0 -} // namespace op - -Strides conv_default_strides(const Node* /* node */, - const ov::PartialShape& data_batch_shape, - const ov::PartialShape& filters_shape) { - size_t rank; - - if (data_batch_shape.rank().is_static() && data_batch_shape.rank().get_length() >= 2) { - rank = data_batch_shape.rank().get_length() - 2; - } else if (filters_shape.rank().is_static() && filters_shape.rank().get_length() >= 2) { - rank = filters_shape.rank().get_length() - 2; - } else { - rank = 0; - } - - return Strides(rank, 1); -} - -CoordinateDiff conv_default_padding(const Node* /* node */, - const ov::PartialShape& data_batch_shape, - const ov::PartialShape& filters_shape) { - size_t rank; - - if (data_batch_shape.rank().is_static() && data_batch_shape.rank().get_length() >= 2) { - rank = data_batch_shape.rank().get_length() - 2; - } else if (filters_shape.rank().is_static() && filters_shape.rank().get_length() >= 2) { - rank = filters_shape.rank().get_length() - 2; - } else { - rank = 0; - } - - return CoordinateDiff(rank, 0); -} - -// -// Infers the output shape of a windowed reduction operation, where the data may be dilated and/or -// padded, and the reduction window may be strided and/or dilated. -// -// TODO(amprocte): The messages here would be a bit friendlier if we didn't say "after -// padding/after dilation" for cases where there is actually no padding/dilation. -// -ov::PartialShape infer_windowed_reduction_output_shape(const Node* node, - const ov::PartialShape& data_shape, - const Strides& data_dilation, - const CoordinateDiff& data_padding_below, - const CoordinateDiff& data_padding_above, - const ov::PartialShape& window_shape, - const Strides& window_strides, - const Strides& window_dilation, - bool is_window_all_in_padding_allowed, - bool ceil_mode) { - ov::PartialShape data_shape_merged{ov::PartialShape::dynamic()}; - - NODE_VALIDATION_CHECK( - node, - data_shape_merged.merge_rank(data_shape.rank()) && data_shape_merged.merge_rank(data_dilation.size()) && - data_shape_merged.merge_rank(data_padding_below.size()) && - data_shape_merged.merge_rank(data_padding_above.size()) && - data_shape_merged.merge_rank(window_shape.rank()) && data_shape_merged.merge_rank(window_strides.size()) && - data_shape_merged.merge_rank(window_dilation.size()), - "Ranks for data shape (", - data_shape, - "), data dilation (", - data_dilation, - "), padding below (", - data_padding_below, - "), padding above (", - data_padding_above, - "), window shape (", - window_shape, - "), window strides (", - window_strides, - "), and window dilation (", - window_dilation, - ") do not match."); - - ov::PartialShape output_shape = ov::PartialShape::dynamic(data_shape_merged.rank()); - if (output_shape.rank().is_static()) { - for (int64_t i = 0; i < output_shape.rank().get_length(); i++) { - NODE_VALIDATION_CHECK(node, - data_dilation[i] > 0, - "Data dilation (", - data_dilation, - ") has zero dimension at axis ", - i, - "."); - NODE_VALIDATION_CHECK(node, - window_strides[i] > 0, - "Window strides (", - window_strides, - ") has zero dimension at axis ", - i, - "."); - NODE_VALIDATION_CHECK(node, - window_dilation[i] > 0, - "Window dilation (", - window_dilation, - ") has zero dimension at axis ", - i, - "."); - - bool data_dim_static = data_shape.rank().is_static() && data_shape[i].is_static(); - bool window_dim_static = window_shape.rank().is_static() && window_shape[i].is_static(); - - ptrdiff_t data_padded_dilated_dim = -1; - if (data_dim_static) { - data_padded_dilated_dim = (static_cast(data_dilation[i]) * (data_shape[i].get_length() - 1)) + - 1 + data_padding_below[i] + data_padding_above[i]; - NODE_VALIDATION_CHECK(node, - data_padded_dilated_dim > 0, - "Data shape after padding and dilation has dimension less than 1 (dim: ", - data_padded_dilated_dim, - ") at axis ", - i, - "."); - } - - ptrdiff_t window_dilated_dim = -1; - if (window_dim_static) { - window_dilated_dim = static_cast(window_dilation[i]) * (window_shape[i].get_length() - 1) + 1; - - NODE_VALIDATION_CHECK(node, - window_dilated_dim > 0, - "Window after dilation has dimension less than 1 (dim: ", - window_dilated_dim, - ") at axis ", - i, - "."); - - NODE_VALIDATION_CHECK(node, - is_window_all_in_padding_allowed || (window_dilated_dim > data_padding_below[i] && - window_dilated_dim > data_padding_above[i]), - "Window after dilation is sometimes entirely in the padding area for axis ", - i, - " (dilated window dimension: ", - window_dilated_dim, - ", padding below dimension: ", - data_padding_below[i], - ", padding above dimension: ", - data_padding_above[i], - ") and this is not ", - "allowed."); - } - - if (data_dim_static && window_dim_static) { - NODE_VALIDATION_CHECK(node, - window_dilated_dim <= data_padded_dilated_dim, - "Window after dilation has dimension (dim: ", - window_dilated_dim, - ") larger than the data shape after padding (dim: ", - data_padded_dilated_dim, - ") at axis ", - i, - "."); - - if (ceil_mode) { - output_shape[i] = - ceil_div(static_cast(data_padded_dilated_dim) - static_cast(window_dilated_dim), - window_strides[i]) + - 1; - } else { - output_shape[i] = - ((static_cast(data_padded_dilated_dim) - static_cast(window_dilated_dim)) / - window_strides[i]) + - 1; - } - } - } - } - - return output_shape; -} - -void validate_conv_params_spatial_dimensions(const Node* node, - const size_t num_spatial_dims, - const op::PadType auto_pad, - Strides& strides, - Strides& dilations, - CoordinateDiff& pads_begin, - CoordinateDiff& pads_end) { - if (strides.size() == 0) { - strides = Strides(num_spatial_dims, 1); - } - if (dilations.size() == 0) { - dilations = Strides(num_spatial_dims, 1); - } - if (pads_begin.size() == 0 || auto_pad == op::PadType::VALID) { - pads_begin = CoordinateDiff(num_spatial_dims, 0); - } - if (pads_end.size() == 0 || auto_pad == op::PadType::VALID) { - pads_end = CoordinateDiff(num_spatial_dims, 0); - } - NODE_VALIDATION_CHECK(node, - strides.size() == num_spatial_dims, - "Strides should be defined for all and only spatial features."); - NODE_VALIDATION_CHECK(node, - dilations.size() == num_spatial_dims, - "Dilations should be defined for all and only spatial features."); - NODE_VALIDATION_CHECK(node, - pads_begin.size() == num_spatial_dims && pads_end.size() == num_spatial_dims, - "Pads should be defined for all and only spatial features."); -} - -// -// Infers the output batch shape and element type for batched pooling fprop. -// -ov::PartialShape infer_batched_pooling_forward(const Node* node, - const ov::PartialShape& data_batch_shape, - const CoordinateDiff& data_padding_below, - const CoordinateDiff& data_padding_above, - const ov::PartialShape& window_shape, - const Strides& window_strides, - bool is_window_all_in_padding_allowed, - bool ceil_mode, - const Strides& window_dilation) { - NODE_VALIDATION_CHECK(node, - data_batch_shape.rank().is_dynamic() || - (data_batch_shape.rank().get_length() >= 3 && data_batch_shape.rank().get_length() <= 5), - "Data batch must have rank of at least 4 or 5 (one batch axis, ", - "one input-channel axis, and two or three spatial dimension) ", - "(data batch shape: ", - data_batch_shape, - ")."); - - ov::PartialShape data_spatial_shape{ov::PartialShape::dynamic()}; - - NODE_VALIDATION_CHECK(node, - data_spatial_shape.merge_rank(data_batch_shape.rank() - 2) && - data_spatial_shape.merge_rank(data_padding_below.size()) && - data_spatial_shape.merge_rank(data_padding_above.size()) && - data_spatial_shape.merge_rank(window_shape.rank()) && - data_spatial_shape.merge_rank(window_strides.size()), - "Ranks for data item shape (data batch has shape ", - data_batch_shape, - ", so data item rank is ", - (data_batch_shape.rank() - 2), - "), padding below (", - data_padding_below, - "), padding above (", - data_padding_above, - "), window shape (", - window_shape, - "), and window strides (", - window_strides, - ") do not match."); - - Dimension batch_size{Dimension::dynamic()}; - Dimension channel_count{Dimension::dynamic()}; - ov::PartialShape data_output_spatial_shape{ov::PartialShape::dynamic(data_spatial_shape.rank())}; - - if (data_batch_shape.rank().is_static()) { - batch_size = data_batch_shape[0]; - channel_count = data_batch_shape[1]; - - for (int64_t i = 0; i < data_spatial_shape.rank().get_length(); i++) { - data_spatial_shape[i] = data_batch_shape[i + 2]; - } - - NODE_VALIDATION_CHECK(node, batch_size.is_dynamic() || batch_size.get_length() > 0, "Batch size is zero."); - - NODE_VALIDATION_CHECK(node, - channel_count.is_dynamic() || channel_count.get_length() > 0, - "Channel count is zero."); - - // For pooling ops we don't need dilation, so we fill in the identity value (all 1). - Strides data_dilation(data_spatial_shape.rank().get_length(), 1); - Strides dilations = window_dilation; - // if the window_dilation was not specified, generate the default value (no dilations) - if (window_dilation.empty()) { - // dilations equal to 1 for each spatial axis mean that the window is not dilated - dilations = Strides(data_spatial_shape.rank().get_length(), 1); - } - - data_output_spatial_shape = infer_windowed_reduction_output_shape(node, - data_spatial_shape, - data_dilation, - data_padding_below, - data_padding_above, - window_shape, - window_strides, - dilations, - is_window_all_in_padding_allowed, - ceil_mode); - } - - ov::PartialShape data_batch_output_shape{ov::PartialShape::dynamic(data_output_spatial_shape.rank() + 2)}; - data_batch_output_shape[0] = batch_size; - data_batch_output_shape[1] = channel_count; - - for (int64_t i = 0; i < data_spatial_shape.rank().get_length(); i++) { - data_batch_output_shape[i + 2] = data_output_spatial_shape[i]; - } - - return data_batch_output_shape; -} - -ov::PartialShape infer_slice_shape(const Node* node, - const ov::PartialShape& input_shape, - const std::vector& begin, - const std::vector& end, - const std::vector& strides, - const AxisSet& begin_mask, - const AxisSet& end_mask, - const AxisSet& new_axis_mask, - const AxisSet& shrink_axis_mask, - const AxisSet& ellipsis_mask) { - if (begin.size() && end.size()) { - NODE_VALIDATION_CHECK(node, - begin.size() == end.size(), - "Lower bounds and Upper bounds needs to have same number of values"); - } - if (begin.size() && strides.size()) { - NODE_VALIDATION_CHECK(node, - begin.size() == strides.size(), - "Lower bounds and strides needs to have same number of values"); - } - if (end.size() && strides.size()) { - NODE_VALIDATION_CHECK(node, - end.size() == strides.size(), - "Upper bounds and strides needs to have same number of values"); - } - - NODE_VALIDATION_CHECK(node, ellipsis_mask.size() <= 1, "At most one ellipsis is allowed."); - - if (input_shape.rank().is_dynamic()) { - return ov::PartialShape::dynamic(); - } - - NODE_VALIDATION_CHECK(node, - input_shape.rank().get_length() + new_axis_mask.size() >= begin.size(), - "Input rank plus number of new axis has to be at least the size of Lower " - "and Upper bounds vector."); - - std::vector dim; - - int64_t input_shape_idx = 0; - for (size_t axis = 0; axis < begin.size(); ++axis) { - // add all dimensions hidden under the ellipsis mask if ellipsis mask is set - if (ellipsis_mask.count(axis)) { - // only one bit in ellipsis mask is allowed - int num_new_axis_after_ellipses = 0; - int num_input_axis_before_ellipses = 0; - for (size_t i = 0; i < axis; ++i) { - if (!new_axis_mask.count(i)) { - num_input_axis_before_ellipses++; - } - } - for (size_t i = axis + 1; i < begin.size(); ++i) { - if (new_axis_mask.count(i)) { - num_new_axis_after_ellipses++; - } - } - - int64_t num_input_axis_after_ellipses = - (begin.size() - axis - num_new_axis_after_ellipses - 1); // -1 because it's a position of ellipses - int64_t num_of_hidden_dims = - input_shape.rank().get_length() - num_input_axis_after_ellipses - num_input_axis_before_ellipses; - for (int64_t i = 0; i < num_of_hidden_dims; ++i) { - dim.emplace_back(input_shape[input_shape_idx]); - input_shape_idx++; - } - } else { - // add new single dimension if new_axis_mask is set - if (new_axis_mask.count(axis)) { - dim.emplace_back(1); - } - // skip this dimension if shrink_axis_mask is set - else if (shrink_axis_mask.count(axis)) { - input_shape_idx++; - } - // calculating dimension (begin, end, begin_mask, end_mask, stride) - else { - // check dynamic dimension - if (input_shape[input_shape_idx].is_dynamic()) { - input_shape_idx++; - dim.emplace_back(Dimension::dynamic()); - continue; - } - - int64_t lb = begin[axis]; - int64_t ub = end[axis]; - - // set default value for stride or use given value - int64_t stride = 1; - if (strides.size() > axis) { - stride = strides[axis]; - } - NODE_VALIDATION_CHECK(node, stride != 0, "Stride must be non-zero"); - - // convert negative indexes to positive - // take max for this case: if abs(lb) > input_shape[input_shape_idx],then after - // conversion lb < 0 - // so according to tensorflow and numpy we just get 0 - if (lb < 0) { - lb = std::max(input_shape[input_shape_idx].get_length() + lb, int64_t(0)); - } - - if (ub < 0) { - ub = - std::max(input_shape[input_shape_idx].get_length() + ub, stride > 0 ? int64_t(0) : int64_t(-1)); - } - - // apply restrictions when begin or end values more than max possible values. - lb = std::min(input_shape[input_shape_idx].get_length(), lb); - ub = std::min(input_shape[input_shape_idx].get_length(), ub); - - int64_t dimension = 0; - if (stride < 0) { - // apply masks - if (begin_mask.count(axis)) { - lb = input_shape[input_shape_idx].get_length() - 1; - } - if (end_mask.count(axis)) { - ub = -1; - } - - lb = std::min(lb, input_shape[input_shape_idx].get_length() - 1); - lb -= 1; // we always get 1st element, so we need decrease range - if (ub <= lb) { - dimension = (ub - lb) / stride + 1; - } - } else { - // apply masks - if (begin_mask.count(axis)) { - lb = 0; - } - if (end_mask.count(axis)) { - ub = input_shape[input_shape_idx].get_length(); - } - - lb += 1; // we always get 1st element, so we need decrease range - if (ub >= lb) { - dimension = (ub - lb) / stride + 1; - } - } - - dim.emplace_back(dimension); - input_shape_idx++; - } - } - } - // get remaining values - for (; input_shape_idx < input_shape.rank().get_length(); ++input_shape_idx) { - dim.emplace_back(input_shape[input_shape_idx]); - } - - return dim; -} - -void opset1::infer_conv_backprop_auto_padding(const Shape& input_data_shape, - const Shape& filters_shape, - const Shape& output_shape, - const Strides& strides, - const Strides& dilations, - const op::PadType auto_pad_type, - const CoordinateDiff& output_padding, - CoordinateDiff& pads_begin, - CoordinateDiff& pads_end) { - OPENVINO_ASSERT(auto_pad_type == op::PadType::SAME_UPPER || auto_pad_type == op::PadType::SAME_LOWER); - - size_t num_spatial_dims = input_data_shape.size(); - OPENVINO_ASSERT(filters_shape.size() == num_spatial_dims && strides.size() == num_spatial_dims && - dilations.size() == num_spatial_dims && pads_begin.size() == num_spatial_dims && - pads_end.size() == num_spatial_dims && output_padding.size() == num_spatial_dims); - - pads_begin = CoordinateDiff(num_spatial_dims); - pads_end = CoordinateDiff(num_spatial_dims); - - for (uint64_t i = 0; i < num_spatial_dims; ++i) { - int total_padding = std::max( - static_cast(strides[i] * (input_data_shape[i] - 1) + dilations[i] * (filters_shape[i] - 1) + 1 - - output_shape[i] + output_padding[i]), - 0); - if (auto_pad_type != op::PadType::SAME_UPPER) { - pads_begin[i] = total_padding / 2; - pads_end[i] = total_padding - pads_begin[i]; - } else { - pads_end[i] = total_padding / 2; - pads_begin[i] = total_padding - pads_end[i]; - } - } -} - -namespace { -/// \brief Scalar variant describes value of an Output, for use in max shape determination -/// -/// For tensor values, we use the maximum value in the tensor -struct MaxValue { - /// \brief No information known about the output - MaxValue() = default; - /// \brief uint64_t assoiated with the output - MaxValue(uint64_t value) : m_value(value) {} - MaxValue(const std::vector& slices, int64_t slice_axis) : m_slices(slices), m_slice_axis(slice_axis) { - m_value = *max_element(m_slices.begin(), m_slices.end()); - } - uint64_t m_value{std::numeric_limits::max()}; - std::vector m_slices; - int64_t m_slice_axis{-1}; -}; - -std::vector exec_constant(Node* node, std::vector& inputs) { - auto result = MaxValue(); - auto op = ov::as_type(node); - auto element_type = op->get_output_element_type(0); - if (element_type.is_integral()) { - uint64_t max_val = 0; - if (element_type.is_signed()) { - for (auto elt : op->cast_vector()) { - if (max_val < static_cast(elt)) { - max_val = elt; - } - } - } else { - for (auto elt : op->cast_vector()) { - if (max_val < elt) { - max_val = elt; - } - } - } - result = MaxValue(max_val); - } - return {result}; -} - -std::vector exec_minimum(Node* node, std::vector& inputs) { - uint64_t min_value = std::numeric_limits::max(); - switch (node->get_output_element_type(0)) { - case element::Type_t::i8: - min_value = std::numeric_limits::max(); - break; - case element::Type_t::i16: - min_value = std::numeric_limits::max(); - break; - case element::Type_t::i32: - min_value = std::numeric_limits::max(); - break; - case element::Type_t::i64: - min_value = std::numeric_limits::max(); - break; - case element::Type_t::u8: - min_value = std::numeric_limits::max(); - break; - case element::Type_t::u16: - min_value = std::numeric_limits::max(); - break; - case element::Type_t::u32: - min_value = std::numeric_limits::max(); - break; - case element::Type_t::u64: - min_value = std::numeric_limits::max(); - break; - default: - break; - } - min_value = std::min(min_value, inputs.at(0).m_value); - min_value = std::min(min_value, inputs.at(1).m_value); - return {MaxValue(min_value)}; -} - -std::vector exec_concat(Node* node, std::vector& inputs) { - auto op = ov::as_type(node); - std::vector slice_maxen; - for (const auto& input : inputs) { - slice_maxen.push_back(input.m_value); - } - auto axis = op->get_concatenation_axis(); - return {MaxValue(slice_maxen, axis)}; -} - -std::vector exec_reduce_min(Node* node, std::vector& inputs) { - auto data = inputs.at(0); - if (data.m_slice_axis >= 0 && data.m_slices.size() > 1) { - if (auto indices_const = ov::as_type(node->get_input_node_ptr(1))) { - if (indices_const->get_output_element_type(0).is_integral()) { - const auto& indices_shape = indices_const->get_output_shape(0); - if (indices_shape == Shape{1}) { - auto indices = indices_const->cast_vector(); - auto axis = indices.at(0); - if (axis == data.m_slice_axis) { - return {MaxValue(*min_element(data.m_slices.begin(), data.m_slices.end()))}; - } - } - } - } - } - // Noting we can do - return {MaxValue(data.m_value)}; -} - -std::vector exec_shape_of(Node* node, std::vector& inputs) { - const auto& inputPS = node->get_input_partial_shape(0); - std::vector shapeDims; - for (int64_t i = 0; i < inputPS.rank().get_length(); i++) { - if (inputPS[i].is_static()) { - shapeDims.push_back(inputPS[i].get_length()); - } else { - shapeDims.push_back(std::numeric_limits::max()); - } - } - - return {MaxValue(shapeDims, 0)}; -} - -std::vector exec_gather(Node* node, std::vector& inputs) { - auto gather = ov::as_type(node); - - const auto& indices = ov::as_type_ptr(node->input_value(1).get_node_shared_ptr()); - const auto& axis = ov::as_type_ptr(node->input_value(2).get_node_shared_ptr()); - - if (!indices || !axis) { - return {MaxValue()}; - } - - if (gather->get_axis() != 0) { - return {MaxValue()}; - } - - const auto& indicesVec = indices->cast_vector(); - if (indicesVec.size() != 1 || indicesVec[0] >= static_cast(inputs[0].m_slices.size())) { - return {MaxValue()}; - } - - return {MaxValue(inputs[0].m_slices[indicesVec[0]])}; -} - -std::vector exec_nop(Node* node, std::vector& inputs) { - return {inputs.at(0)}; -} -} // namespace - -std::pair maximum_value(const ov::Output& value) { - static ngraph::Evaluator::op_handler_map handlers = { - {ov::op::v0::Concat::get_type_info_static(), exec_concat}, - {ov::op::v0::Constant::get_type_info_static(), exec_constant}, - {ov::op::v0::Convert::get_type_info_static(), exec_nop}, - {ov::op::v1::Gather::get_type_info_static(), exec_gather}, - {ov::op::v1::Minimum::get_type_info_static(), exec_minimum}, - {ov::op::v1::ReduceMin::get_type_info_static(), exec_reduce_min}, - {ov::op::v1::Reshape::get_type_info_static(), exec_nop}, - {ov::op::v3::ShapeOf::get_type_info_static(), exec_shape_of}, - {ov::op::v0::Squeeze::get_type_info_static(), exec_nop}, - {ov::op::v0::Unsqueeze::get_type_info_static(), exec_nop}}; - Evaluator::value_map value_map; - Evaluator evaluator(handlers, value_map); - auto val = evaluator.evaluate(value); - return std::pair(val.m_value < std::numeric_limits::max(), val.m_value); -} - -std::shared_ptr get_constant_max_of_type(element::Type_t t) { - auto tensor = ov::util::make_tensor_of_max_value(t); - return tensor ? std::make_shared(tensor) : nullptr; -} - -std::shared_ptr get_constant_min_of_type(element::Type_t t) { - auto tensor = ov::util::make_tensor_of_min_value(t); - return tensor ? std::make_shared(tensor) : nullptr; -} - -std::shared_ptr get_constant_lowest_of_type(element::Type_t t) { -#define OPENVINO_TYPE_TO_LOWEST_CONST(t) \ - case t: \ - return op::v0::Constant::create( \ - t, \ - {}, \ - {std::numeric_limits::value_type>::lowest()}); \ - break - - switch (t) { - OPENVINO_TYPE_TO_LOWEST_CONST(ov::element::boolean); - OPENVINO_TYPE_TO_LOWEST_CONST(ov::element::bf16); - OPENVINO_TYPE_TO_LOWEST_CONST(ov::element::f16); - OPENVINO_TYPE_TO_LOWEST_CONST(ov::element::f32); - OPENVINO_TYPE_TO_LOWEST_CONST(ov::element::f64); - OPENVINO_TYPE_TO_LOWEST_CONST(ov::element::i8); - OPENVINO_TYPE_TO_LOWEST_CONST(ov::element::i16); - OPENVINO_TYPE_TO_LOWEST_CONST(ov::element::i32); - OPENVINO_TYPE_TO_LOWEST_CONST(ov::element::i64); - OPENVINO_TYPE_TO_LOWEST_CONST(ov::element::u1); - OPENVINO_TYPE_TO_LOWEST_CONST(ov::element::u8); - OPENVINO_TYPE_TO_LOWEST_CONST(ov::element::u16); - OPENVINO_TYPE_TO_LOWEST_CONST(ov::element::u32); - OPENVINO_TYPE_TO_LOWEST_CONST(ov::element::u64); - - case ov::element::undefined: - case ov::element::dynamic: - default: - return nullptr; - } -} -} // namespace ngraph namespace { const auto normalize_axis_to = [](const int64_t& tensor_rank) { @@ -742,64 +41,6 @@ int64_t ov::util::normalize(const int64_t& value, const int64_t& max) { return (value < 0) ? value + max : value; }; -void ov::normalize_axes(const Node* node, const int64_t& tensor_rank, std::vector& axes) { - ov::util::normalize_axes(node, tensor_rank, axes); -} - -std::vector ov::normalize_axes(const std::string& node_description, - const std::vector& axes, - const Rank& tensor_rank) { - return ov::util::normalize_axes(node_description, axes, tensor_rank); -} - -int64_t ov::normalize_axis(const Node* node, std::int64_t axis, const Rank& tensor_rank) { - return ov::util::normalize_axis(node, axis, tensor_rank); -} - -int64_t ov::normalize_axis(const std::string& node_description, std::int64_t axis, const Rank& tensor_rank) { - return ov::util::normalize_axis(node_description, axis, tensor_rank); -} - -int64_t ov::normalize_axis(const Node* node, - std::int64_t axis, - std::uint64_t tensor_rank, - std::int64_t axis_range_min, - std::int64_t axis_range_max) { - return ov::util::normalize_axis(node, axis, tensor_rank, axis_range_min, axis_range_max); -} - -int64_t ov::normalize_axis(const std::string& node_description, - std::int64_t axis, - std::uint64_t tensor_rank, - std::int64_t axis_range_min, - std::int64_t axis_range_max) { - return ov::util::normalize_axis(node_description, axis, tensor_rank, axis_range_min, axis_range_max); -} - -bool ov::evaluate_as_partial_shape(const ov::Output& output, ov::PartialShape& pshape) { - return ov::util::evaluate_as_partial_shape(output, pshape); -} - -bool ov::default_label_evaluator(const Node* node, TensorLabelVector& output_labels) { - return ov::util::default_label_evaluator(node, output_labels); -} - -std::shared_ptr ov::get_constant_from_source(const ov::Output& source) { - return ov::util::get_constant_from_source(source); -} - -bool ov::has_no_labels(const ov::TensorLabel& labels) { - return ov::util::has_no_labels(labels); -} - -void ov::generate_transpose_default_order(std::vector& axes_order, const size_t length) { - ov::util::generate_transpose_default_order(axes_order, length); -} - -bool ov::is_valid_axes_order(const std::vector& axes_order, const size_t size) { - return ov::util::is_valid_axes_order(axes_order, size); -} - bool ov::util::are_unique(const std::vector& data) { return std::unordered_set(data.begin(), data.cend()).size() == data.size(); } @@ -809,7 +50,7 @@ int64_t ov::util::clip(const int64_t& value, const int64_t& min, const int64_t& return std::min(std::max(value, min), max); }; -std::shared_ptr ov::util::constantfold_subgraph(const ov::Output& subgraph_sink) { +std::shared_ptr ov::util::constantfold_subgraph(const ov::Output& subgraph_sink) { if (const auto& c = ov::as_type_ptr(subgraph_sink.get_node_shared_ptr())) return c; @@ -846,7 +87,7 @@ namespace ov { namespace util { using ov::op::v0::Constant; -std::shared_ptr get_constant_from_source(const ov::Output& source) { +std::shared_ptr get_constant_from_source(const ov::Output& source) { if (const auto& c = ov::as_type_ptr(source.get_node_shared_ptr())) { return c; } else if (has_and_set_equal_bounds(source)) { @@ -949,7 +190,7 @@ std::vector get_tensors_partial_shapes(const TensorVector& ten return shapes; } -std::vector get_node_input_partial_shapes(const Node& node) { +std::vector get_node_input_partial_shapes(const ov::Node& node) { std::vector shapes; shapes.reserve(node.get_input_size()); for (size_t i = 0; i < node.get_input_size(); ++i) { @@ -964,7 +205,7 @@ bool is_rank_compatible_any_of(const Rank& r, std::initializer_list others }); } -bool evaluate_as_partial_shape(const ov::Output& output, ov::PartialShape& pshape) { +bool evaluate_as_partial_shape(const ov::Output& output, ov::PartialShape& pshape) { Tensor lb, ub; std::tie(lb, ub) = evaluate_both_bounds(output); bool shape_defined = false; @@ -997,7 +238,7 @@ bool evaluate_as_partial_shape(const ov::Output& output, ov::PartialShape& return shape_defined; } -bool default_label_evaluator(const Node* node, TensorLabelVector& output_labels) { +bool default_label_evaluator(const ov::Node* node, TensorLabelVector& output_labels) { return default_label_evaluator(node, {0}, output_labels); } @@ -1026,7 +267,7 @@ std::vector normalize_axes(const std::string& node_description, return new_axes; } -void normalize_axes(const Node* node, const int64_t& tensor_rank, std::vector& axes) { +void normalize_axes(const ov::Node* node, const int64_t& tensor_rank, std::vector& axes) { const auto axis_checker = cmp::Between(-tensor_rank, tensor_rank ? (tensor_rank - 1) : 0); const auto invalid_axis = std::find_if_not(axes.cbegin(), axes.cend(), axis_checker); NODE_VALIDATION_CHECK(node, @@ -1035,7 +276,7 @@ void normalize_axes(const Node* node, const int64_t& tensor_rank, std::vectordescription(), axis, tensor_rank); } @@ -1059,7 +300,7 @@ int64_t normalize_axis(const std::string& node_description, std::int64_t axis, c tensor_rank_value ? (tensor_rank_value - 1) : 0); } -int64_t normalize_axis(const Node* node, +int64_t normalize_axis(const ov::Node* node, std::int64_t axis, std::uint64_t tensor_rank, std::int64_t axis_range_min, diff --git a/src/core/tests/CMakeLists.txt b/src/core/tests/CMakeLists.txt index c3f2120e98e2f8..73a0fe75c591b9 100644 --- a/src/core/tests/CMakeLists.txt +++ b/src/core/tests/CMakeLists.txt @@ -37,7 +37,6 @@ ov_add_test_target( LINK_LIBRARIES common_test_utils openvino::reference - openvino::builders openvino::util openvino::shape_inference ${CMAKE_DL_LIBS} diff --git a/src/core/tests/build_graph.cpp b/src/core/tests/build_graph.cpp index c6714fcb715358..a56fa20bf2fb90 100644 --- a/src/core/tests/build_graph.cpp +++ b/src/core/tests/build_graph.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -7,9 +7,9 @@ #include #include "common_test_utils/graph_comparator.hpp" +#include "common_test_utils/node_builders/broadcast.hpp" #include "common_test_utils/test_tools.hpp" #include "common_test_utils/type_prop.hpp" -#include "ngraph/graph_util.hpp" #include "openvino/core/except.hpp" #include "openvino/op/abs.hpp" #include "openvino/op/acos.hpp" @@ -25,7 +25,6 @@ #include "openvino/op/split.hpp" #include "openvino/op/squeeze.hpp" #include "openvino/op/util/variable.hpp" -#include "ov_models/ov_builders/broadcast.hpp" using namespace std; using namespace ov; @@ -36,8 +35,8 @@ TEST(build_graph, build_simple) { auto arg1 = make_shared(element::f32, Shape{3}); auto arg2 = make_shared(element::f32, Shape{32, 7}); auto arg3 = make_shared(element::f32, Shape{32, 7}); - auto broadcast_1 = ov::op::util::make_broadcast(arg3, Shape{10, 32, 7}, AxisSet{0}); - auto b1 = ov::op::util::make_broadcast(arg3, Shape{10, 32, 7}, AxisSet{0}); + auto broadcast_1 = ov::test::utils::make_broadcast(arg3, Shape{10, 32, 7}, AxisSet{0}); + auto b1 = ov::test::utils::make_broadcast(arg3, Shape{10, 32, 7}, AxisSet{0}); auto dot = make_shared(arg2, arg0); ASSERT_EQ(dot->input_value(0).get_node_shared_ptr(), arg2); ASSERT_EQ(dot->input_value(1).get_node_shared_ptr(), arg0); @@ -92,8 +91,8 @@ TEST(build_graph, function_undeclared_parameters) { auto arg1 = make_shared(element::f32, Shape{3}); auto arg2 = make_shared(element::f32, Shape{32, 7}); auto arg3 = make_shared(element::f32, Shape{32, 7}); - auto broadcast_1 = ov::op::util::make_broadcast(arg3, Shape{10, 32, 7}, AxisSet{0}); - auto b1 = ov::op::util::make_broadcast(arg3, Shape{10, 32, 7}, AxisSet{0}); + auto broadcast_1 = ov::test::utils::make_broadcast(arg3, Shape{10, 32, 7}, AxisSet{0}); + auto b1 = ov::test::utils::make_broadcast(arg3, Shape{10, 32, 7}, AxisSet{0}); auto dot = make_shared(arg2, arg0); ASSERT_EQ(dot->input_values()[0].get_node_shared_ptr(), arg2); ASSERT_EQ(dot->input_values()[1].get_node_shared_ptr(), arg0); @@ -128,9 +127,8 @@ TEST(build_graph, no_arg_construction) { add1->set_argument(0, acos0); add1->set_argument(1, abs0); NodeVector ops{arg0, arg1, add0, abs0, acos0, add1}; - OPENVINO_SUPPRESS_DEPRECATED_START - ngraph::validate_nodes_and_infer_types(ops); - OPENVINO_SUPPRESS_DEPRECATED_END + for (const auto& op : ov::topological_sort(ops)) + op->revalidate_and_infer_types(); ASSERT_EQ(add1->get_output_shape(0), Shape{7}); } @@ -438,8 +436,8 @@ TEST(build_graph, build_graph_parameters_autodetection) { auto arg1 = make_shared(element::f32, Shape{3}); auto arg2 = make_shared(element::f32, Shape{32, 7}); auto arg3 = make_shared(element::f32, Shape{32, 7}); - auto broadcast_1 = ov::op::util::make_broadcast(arg3, Shape{10, 32, 7}, AxisSet{0}); - auto b1 = ov::op::util::make_broadcast(arg3, Shape{10, 32, 7}, AxisSet{0}); + auto broadcast_1 = ov::test::utils::make_broadcast(arg3, Shape{10, 32, 7}, AxisSet{0}); + auto b1 = ov::test::utils::make_broadcast(arg3, Shape{10, 32, 7}, AxisSet{0}); auto dot = make_shared(arg2, arg0); auto f = make_shared(OutputVector{dot}); diff --git a/src/core/tests/constant.cpp b/src/core/tests/constant.cpp index 1481f94f0e8053..b91035eafcc525 100644 --- a/src/core/tests/constant.cpp +++ b/src/core/tests/constant.cpp @@ -1373,6 +1373,52 @@ TEST(constant, float16_vector) { EXPECT_EQ(p[3], float16(0)); } +TEST(constant, float8_e4m3_vector) { + const auto data_vec = std::vector{std::numeric_limits::lowest(), + -std::numeric_limits::min(), + std::numeric_limits::min(), + std::numeric_limits::max(), + std::numeric_limits::denorm_min(), + -1.5f, + -1.f, + -0.5f, + 0.f, + 0.5f, + 1.f, + 1.5f}; + Shape data_shape{data_vec.size()}; + EXPECT_EQ(data_vec.size(), shape_size(data_shape)); + + ov::op::v0::Constant const_op_from_vec(ov::element::f8e4m3, data_shape, data_vec); + EXPECT_EQ(data_vec, const_op_from_vec.get_vector()); + + ov::op::v0::Constant const_op_from_ptr(ov::element::f8e4m3, data_shape, data_vec.data()); + EXPECT_EQ(data_vec, const_op_from_ptr.get_vector()); +} + +TEST(constant, float8_e5m3_vector) { + const auto data_vec = std::vector{std::numeric_limits::lowest(), + -std::numeric_limits::min(), + std::numeric_limits::min(), + std::numeric_limits::max(), + std::numeric_limits::denorm_min(), + -1.5f, + -1.f, + -0.5f, + 0.f, + 0.5f, + 1.f, + 1.5f}; + Shape data_shape{data_vec.size()}; + EXPECT_EQ(data_vec.size(), shape_size(data_shape)); + + ov::op::v0::Constant const_op_from_vec(ov::element::f8e5m2, data_shape, data_vec); + EXPECT_EQ(data_vec, const_op_from_vec.get_vector()); + + ov::op::v0::Constant const_op_from_ptr(ov::element::f8e5m2, data_shape, data_vec.data()); + EXPECT_EQ(data_vec, const_op_from_ptr.get_vector()); +} + TEST(constant, float16_vector_broadcast) { Shape shape{4}; ov::op::v0::Constant c(element::f16, shape, vector{1}); diff --git a/src/core/tests/eval.cpp b/src/core/tests/eval.cpp index 8704a6a9251acf..4962e5db4ef7c7 100644 --- a/src/core/tests/eval.cpp +++ b/src/core/tests/eval.cpp @@ -2688,7 +2688,7 @@ TEST(eval, evaluate_fake_convert_f32_to_f8e4m3_scale_small) { auto scale = op::v0::Constant::create(et, Shape{1}, {fp8::MAX_F8E4M3 / max_input_val}); auto shift = op::v0::Constant::create(et, Shape{1}, {0.f}); - auto op = make_shared(data, scale, shift, "f8e4m3"); + auto op = make_shared(data, scale, shift, ov::element::f8e4m3); auto model = make_shared(OutputVector{op}, ParameterVector{data}); @@ -3189,6 +3189,68 @@ TEST(eval, evaluate_fake_convert_bf16_matching_f8_to_f8e4m3_scale_1) { EXPECT_THAT(read_vector(result), Pointwise(FloatEq(), input_data)); } +TEST(eval, evaluate_fake_convert_f32_to_f8e4m3_no_scale_no_shift_str_ctor) { + using namespace testing; + constexpr auto et = element::f32; + + std::vector input_data{0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.f, + -0.0f, -0.1f, -0.2f, -0.3f, -0.4f, -0.5f, -0.6f, -0.7f, -0.8f, -0.9f, -1.f}; + const auto data_shape = Shape{input_data.size()}; + + auto data = make_shared(et, data_shape); + auto scale = op::v0::Constant::create(et, Shape{1}, {1.0f}); + auto shift = op::v0::Constant::create(et, Shape{1}, {0.f}); + + auto op = make_shared(data, scale, shift, "f8e4m3"); + auto model = make_shared(OutputVector{op}, ParameterVector{data}); + + auto result = ov::Tensor(); + auto out_vector = ov::TensorVector{result}; + auto in_vector = ov::TensorVector{make_tensor(data_shape, input_data)}; + ASSERT_TRUE(model->evaluate(out_vector, in_vector)); + result = out_vector.at(0); + + EXPECT_EQ(result.get_element_type(), et); + EXPECT_EQ(result.get_shape(), data_shape); + EXPECT_THAT( + read_vector(result), + Pointwise(FloatEq(), std::vector{0.f, 0.1015625f, 0.203125f, 0.3125f, 0.40625f, 0.5f, + 0.625f, 0.6875f, 0.8125f, 0.875f, 1.f, -0.f, + -0.1015625f, -0.203125f, -0.3125f, -0.40625f, -0.5f, -0.625f, + -0.6875f, -0.8125f, -0.875f, -1.f})); +} + +TEST(eval, evaluate_fake_convert_f32_to_f8e4m3_no_scale_no_shift_default_type_ctor) { + using namespace testing; + constexpr auto et = element::f32; + + std::vector input_data{0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.f, + -0.0f, -0.1f, -0.2f, -0.3f, -0.4f, -0.5f, -0.6f, -0.7f, -0.8f, -0.9f, -1.f}; + const auto data_shape = Shape{input_data.size()}; + + auto data = make_shared(et, data_shape); + auto scale = op::v0::Constant::create(et, Shape{1}, {1.0f}); + auto shift = op::v0::Constant::create(et, Shape{1}, {0.f}); + + auto op = make_shared(data, scale, shift); + auto model = make_shared(OutputVector{op}, ParameterVector{data}); + + auto result = ov::Tensor(); + auto out_vector = ov::TensorVector{result}; + auto in_vector = ov::TensorVector{make_tensor(data_shape, input_data)}; + ASSERT_TRUE(model->evaluate(out_vector, in_vector)); + result = out_vector.at(0); + + EXPECT_EQ(result.get_element_type(), et); + EXPECT_EQ(result.get_shape(), data_shape); + EXPECT_THAT( + read_vector(result), + Pointwise(FloatEq(), std::vector{0.f, 0.1015625f, 0.203125f, 0.3125f, 0.40625f, 0.5f, + 0.625f, 0.6875f, 0.8125f, 0.875f, 1.f, -0.f, + -0.1015625f, -0.203125f, -0.3125f, -0.40625f, -0.5f, -0.625f, + -0.6875f, -0.8125f, -0.875f, -1.f})); +} + ///////////////////////////////////// FakeConvert f8e5m2 TEST(eval, evaluate_fake_convert_f32_to_f8e5m2_scale_1) { using namespace testing; @@ -3204,7 +3266,7 @@ TEST(eval, evaluate_fake_convert_f32_to_f8e5m2_scale_1) { auto scale = op::v0::Constant::create(et, Shape{1}, {1.f}); auto shift = op::v0::Constant::create(et, Shape{1}, {0.f}); - auto op = make_shared(data, scale, shift, "f8e5m2"); + auto op = make_shared(data, scale, shift, ov::element::f8e5m2); auto model = make_shared(OutputVector{op}, ParameterVector{data}); @@ -3235,7 +3297,7 @@ TEST(eval, evaluate_fake_convert_f16_to_f8e5m2_scale_1) { auto scale = op::v0::Constant::create(et, Shape{1}, {1.f}); auto shift = op::v0::Constant::create(et, Shape{1}, {0.f}); - auto op = make_shared(data, scale, shift, "f8e5m2"); + auto op = make_shared(data, scale, shift, ov::element::f8e5m2); auto model = make_shared(OutputVector{op}, ParameterVector{data}); auto result = ov::Tensor(); @@ -3265,7 +3327,7 @@ TEST(eval, evaluate_fake_convert_bf16_to_f8e5m2_scale_1) { auto scale = op::v0::Constant::create(et, Shape{1}, {1.f}); auto shift = op::v0::Constant::create(et, Shape{1}, {0.f}); - auto op = make_shared(data, scale, shift, "f8e5m2"); + auto op = make_shared(data, scale, shift, ov::element::f8e5m2); auto model = make_shared(OutputVector{op}, ParameterVector{data}); auto result = ov::Tensor(); @@ -3295,7 +3357,7 @@ TEST(eval, evaluate_fake_convert_f32_to_f8e5m2_scale_small) { auto scale = op::v0::Constant::create(et, Shape{1}, {fp8::MAX_F8E5M2 / max_input_val}); auto shift = op::v0::Constant::create(et, Shape{1}, {0.f}); - auto op = make_shared(data, scale, shift, "f8e5m2"); + auto op = make_shared(data, scale, shift, ov::element::f8e5m2); auto model = make_shared(OutputVector{op}, ParameterVector{data}); auto result = ov::Tensor(); @@ -3322,7 +3384,7 @@ TEST(eval, evaluate_fake_convert_f32_to_f8e5m2_scale_1_small) { auto scale = op::v0::Constant::create(et, Shape{1}, {1.0f}); auto shift = op::v0::Constant::create(et, Shape{1}, {0.f}); - auto op = make_shared(data, scale, shift, "f8e5m2"); + auto op = make_shared(data, scale, shift, ov::element::f8e5m2); auto model = make_shared(OutputVector{op}, ParameterVector{data}); auto result = ov::Tensor(); @@ -3349,7 +3411,7 @@ TEST(eval, evaluate_fake_convert_f32_to_f8e5m2_small_scale_1) { auto scale = op::v0::Constant::create(et, Shape{1}, {1.f}); auto shift = op::v0::Constant::create(et, Shape{1}, {0.f}); - auto op = make_shared(data, scale, shift, "f8e5m2"); + auto op = make_shared(data, scale, shift, ov::element::f8e5m2); auto model = make_shared(OutputVector{op}, ParameterVector{data}); auto result = ov::Tensor(); @@ -3376,7 +3438,7 @@ TEST(eval, evaluate_fake_convert_f32_to_f8e5m2_scale_big) { auto scale = op::v0::Constant::create(et, Shape{1}, {fp8::MAX_F8E5M2 / max_input_val}); auto shift = op::v0::Constant::create(et, Shape{1}, {0.f}); - auto op = make_shared(data, scale, shift, "f8e5m2"); + auto op = make_shared(data, scale, shift, ov::element::f8e5m2); auto model = make_shared(OutputVector{op}, ParameterVector{data}); auto result = ov::Tensor(); @@ -3404,7 +3466,7 @@ TEST(eval, evaluate_fake_convert_f32_to_f8e5m2_scale_shift_big) { auto scale = op::v0::Constant::create(et, Shape{1}, {scale_val}); auto shift = op::v0::Constant::create(et, Shape{1}, {fp8::MAX_F8E5M2 * scale_val}); - auto op = make_shared(data, scale, shift, "f8e5m2"); + auto op = make_shared(data, scale, shift, ov::element::f8e5m2); auto model = make_shared(OutputVector{op}, ParameterVector{data}); auto result = ov::Tensor(); @@ -3435,7 +3497,7 @@ TEST(eval, evaluate_fake_convert_f16_to_f8e5m2_scale_shift_big) { auto scale = op::v0::Constant::create(et, Shape{1}, {scale_val}); auto shift = op::v0::Constant::create(et, Shape{1}, {fp8::MAX_F8E5M2 * scale_val}); - auto op = make_shared(data, scale, shift, "f8e5m2"); + auto op = make_shared(data, scale, shift, ov::element::f8e5m2); auto model = make_shared(OutputVector{op}, ParameterVector{data}); auto result = ov::Tensor(); @@ -3466,7 +3528,7 @@ TEST(eval, evaluate_fake_convert_bf16_to_f8e5m2_scale_shift_big) { auto scale = op::v0::Constant::create(et, Shape{1}, {scale_val}); auto shift = op::v0::Constant::create(et, Shape{1}, {fp8::MAX_F8E5M2 * scale_val}); - auto op = make_shared(data, scale, shift, "f8e5m2"); + auto op = make_shared(data, scale, shift, ov::element::f8e5m2); auto model = make_shared(OutputVector{op}, ParameterVector{data}); auto result = ov::Tensor(); @@ -3495,7 +3557,7 @@ TEST(eval, evaluate_fake_convert_f32_to_f8e5m2_big_scale_1) { auto scale = op::v0::Constant::create(et, Shape{1}, {1.f}); auto shift = op::v0::Constant::create(et, Shape{1}, {0.f}); - auto op = make_shared(data, scale, shift, "f8e5m2"); + auto op = make_shared(data, scale, shift, ov::element::f8e5m2); auto model = make_shared(OutputVector{op}, ParameterVector{data}); auto result = ov::Tensor(); @@ -3562,7 +3624,7 @@ TEST(eval, evaluate_fake_convert_f32_matching_f8_to_f8e5m2_scale_1) { auto scale = op::v0::Constant::create(et, Shape{1}, {1.f}); auto shift = op::v0::Constant::create(et, Shape{1}, {0.f}); - auto op = make_shared(data, scale, shift, "f8e5m2"); + auto op = make_shared(data, scale, shift, ov::element::f8e5m2); auto model = make_shared(OutputVector{op}, ParameterVector{data}); @@ -3626,7 +3688,7 @@ TEST(eval, evaluate_fake_convert_f16_matching_f8_to_f8e5m2_scale_1) { auto scale = op::v0::Constant::create(et, Shape{1}, {1.f}); auto shift = op::v0::Constant::create(et, Shape{1}, {0.f}); - auto op = make_shared(data, scale, shift, "f8e5m2"); + auto op = make_shared(data, scale, shift, ov::element::f8e5m2); auto model = make_shared(OutputVector{op}, ParameterVector{data}); @@ -3690,7 +3752,7 @@ TEST(eval, evaluate_fake_convert_bf16_matching_f8_to_f8e5m2_scale_1) { auto scale = op::v0::Constant::create(et, Shape{1}, {1.f}); auto shift = op::v0::Constant::create(et, Shape{1}, {0.f}); - auto op = make_shared(data, scale, shift, "f8e5m2"); + auto op = make_shared(data, scale, shift, ov::element::f8e5m2); auto model = make_shared(OutputVector{op}, ParameterVector{data}); @@ -3724,7 +3786,7 @@ TEST(eval, evaluate_fake_convert_f32_matching_f8e4m3_to_f8e5m2_scale_1) { auto scale = op::v0::Constant::create(et, Shape{1}, {1.f}); auto shift = op::v0::Constant::create(et, Shape{1}, {0.f}); - auto op = make_shared(data, scale, shift, "f8e5m2"); + auto op = make_shared(data, scale, shift, ov::element::f8e5m2); auto model = make_shared(OutputVector{op}, ParameterVector{data}); auto result = ov::Tensor(); @@ -3738,6 +3800,39 @@ TEST(eval, evaluate_fake_convert_f32_matching_f8e4m3_to_f8e5m2_scale_1) { EXPECT_THAT(read_vector(result), Pointwise(FloatEq(), output_data)); } +TEST(eval, evaluate_fake_convert_f32_to_f8e5m2_scale_1_str_ctor) { + using namespace testing; + constexpr auto et = element::f32; + + std::vector input_data{0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.f, + -0.0f, -0.1f, -0.2f, -0.3f, -0.4f, -0.5f, -0.6f, -0.7f, -0.8f, -0.9f, -1.f}; + + const auto data_shape = Shape{input_data.size()}; + + auto data = make_shared(et, data_shape); + + auto scale = op::v0::Constant::create(et, Shape{1}, {1.f}); + auto shift = op::v0::Constant::create(et, Shape{1}, {0.f}); + + auto op = make_shared(data, scale, shift, "f8e5m2"); + + auto model = make_shared(OutputVector{op}, ParameterVector{data}); + + auto result = ov::Tensor(); + auto out_vector = ov::TensorVector{result}; + auto in_vector = ov::TensorVector{make_tensor(data_shape, input_data)}; + ASSERT_TRUE(model->evaluate(out_vector, in_vector)); + result = out_vector.at(0); + + EXPECT_EQ(result.get_element_type(), et); + EXPECT_EQ(result.get_shape(), data_shape); + EXPECT_THAT(read_vector(result), + Pointwise(FloatEq(), + std::vector{0.f, 0.09375f, 0.1875f, 0.3125f, 0.375f, 0.5f, 0.625f, 0.75f, + 0.75f, 0.875f, 1.f, -0.f, -0.09375f, -0.1875f, -0.3125f, -0.375f, + -0.5f, -0.625f, -0.75f, -0.75f, -0.875f, -1.f})); +} + TEST(eval, evaluate_f8e5m2_const_from_f32) { using namespace testing; constexpr auto et = element::f8e5m2; @@ -3837,7 +3932,7 @@ TEST(eval, evaluate_fake_convert_f32_seq_to_f8e5m2_scale_shift) { auto scale = op::v0::Constant::create(et, Shape{1}, {fp8::MAX_F8E5M2 / max_input_val}); auto shift = op::v0::Constant::create(et, Shape{1}, {5.f}); - auto op = make_shared(data, scale, shift, "f8e5m2"); + auto op = make_shared(data, scale, shift, ov::element::f8e5m2); auto model = make_shared(OutputVector{op}, ParameterVector{data}); auto result = ov::Tensor(); @@ -3900,7 +3995,7 @@ TEST(eval, evaluate_fake_convert_f32_to_f8e5m2_4x3_scale_big) { fp8::MAX_F8E5M2 / (fp8::MAX_F8E5M2 * 4.f)}); auto shift = op::v0::Constant::create(et, Shape{4, 1}, {0.f, 0.f, 0.f, 0.f}); - auto op = make_shared(data, scale, shift, "f8e5m2"); + auto op = make_shared(data, scale, shift, ov::element::f8e5m2); auto model = make_shared(OutputVector{op}, ParameterVector{data}); auto result = ov::Tensor(); @@ -3959,7 +4054,7 @@ TEST(eval, evaluate_fake_convert_f32_to_f8e5m2_3x4_scale_big) { fp8::MAX_F8E5M2 / (fp8::MAX_F8E5M2 * 4.f)}); auto shift = op::v0::Constant::create(et, Shape{1, 4}, {0.f, 0.f, 0.f, 0.f}); - auto op = make_shared(transposed_data, scale, shift, "f8e5m2"); + auto op = make_shared(transposed_data, scale, shift, ov::element::f8e5m2); auto model = make_shared(OutputVector{op}, ParameterVector{data}); auto result = ov::Tensor(); diff --git a/src/core/tests/op.cpp b/src/core/tests/op.cpp index b249c0698bf1db..29059999689fef 100644 --- a/src/core/tests/op.cpp +++ b/src/core/tests/op.cpp @@ -65,4 +65,5 @@ TEST(op, opset_multi_thread) { doTest(ov::get_opset11); doTest(ov::get_opset12); doTest(ov::get_opset13); + doTest(ov::get_opset14); } diff --git a/src/core/tests/opset.cpp b/src/core/tests/opset.cpp index 37eb02e38429cf..e1ed2d41c30445 100644 --- a/src/core/tests/opset.cpp +++ b/src/core/tests/opset.cpp @@ -12,6 +12,7 @@ #include "openvino/opsets/opset11.hpp" #include "openvino/opsets/opset12.hpp" #include "openvino/opsets/opset13.hpp" +#include "openvino/opsets/opset14.hpp" #include "openvino/opsets/opset2.hpp" #include "openvino/opsets/opset3.hpp" #include "openvino/opsets/opset4.hpp" @@ -71,7 +72,8 @@ INSTANTIATE_TEST_SUITE_P(opset, OpsetTestParams{ov::get_opset10, 177}, OpsetTestParams{ov::get_opset11, 177}, OpsetTestParams{ov::get_opset12, 178}, - OpsetTestParams{ov::get_opset13, 186}), + OpsetTestParams{ov::get_opset13, 186}, + OpsetTestParams{ov::get_opset14, 186}), OpsetTestNameGenerator{}); class MyOpOld : public ov::op::Op { diff --git a/src/core/tests/pattern.cpp b/src/core/tests/pattern.cpp index df1c81fcce1906..fdd9a783f91741 100644 --- a/src/core/tests/pattern.cpp +++ b/src/core/tests/pattern.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -588,14 +588,21 @@ TEST(pattern, test_sort) { } TEST(pattern, label_on_skip) { + const auto zero = std::string{"0"}; + const auto is_zero = [&zero](const Output& node) { + if (const auto c = as_type_ptr(node.get_node_shared_ptr())) { + return (c->get_all_data_elements_bitwise_identical() && c->convert_value_to_string(0) == zero); + } else { + return false; + } + }; + Shape shape{2, 2}; auto a = make_shared(element::i32, shape); auto b = make_shared(element::i32, Shape{}); - OPENVINO_SUPPRESS_DEPRECATED_START - auto iconst = ngraph::make_zero(element::i32, Shape{}); + auto iconst = op::v0::Constant::create(element::i32, Shape{}, {0.0f}); auto label = std::make_shared(iconst); - auto const_label = std::make_shared(iconst, ngraph::is_zero, NodeVector{iconst}); - OPENVINO_SUPPRESS_DEPRECATED_END + auto const_label = std::make_shared(iconst, is_zero, NodeVector{iconst}); auto bcst_pred = [](std::shared_ptr n) { return ov::as_type_ptr(n) != nullptr; diff --git a/src/core/tests/type_prop/batch_to_space.cpp b/src/core/tests/type_prop/batch_to_space.cpp index df529d1853ffdb..443831579968c0 100644 --- a/src/core/tests/type_prop/batch_to_space.cpp +++ b/src/core/tests/type_prop/batch_to_space.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -9,9 +9,9 @@ #include #include "common_test_utils/type_prop.hpp" -#include "ngraph/util.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/space_to_batch.hpp" +#include "openvino/util/common_util.hpp" using namespace std; using namespace testing; @@ -377,7 +377,7 @@ TEST(type_prop, batch_to_space_output_dynamic_shape_5D_when_batch_is_dynamic) { auto batch_to_space = make_shared(data, block_shape, crops_begin, crops_end); EXPECT_EQ(batch_to_space->get_output_partial_shape(0), - (ov::PartialShape{{ngraph::ceil_div(959, (6 * 5 * 16)), 962 / (6 * 5 * 16)}, + (ov::PartialShape{{ov::util::ceil_div(959, (6 * 5 * 16)), 962 / (6 * 5 * 16)}, {2 * 6 - 2 - 2, 34 * 6 - 2 - 2}, {9 * 5 - 1, 21 * 5 - 1}, {100, 162}, diff --git a/src/core/tests/type_prop/depth_to_space.cpp b/src/core/tests/type_prop/depth_to_space.cpp index 5562094caba906..e656bbe0a9be89 100644 --- a/src/core/tests/type_prop/depth_to_space.cpp +++ b/src/core/tests/type_prop/depth_to_space.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -7,7 +7,7 @@ #include #include "common_test_utils/type_prop.hpp" -#include "ngraph/util.hpp" +#include "openvino/util/common_util.hpp" using namespace std; using namespace ov; @@ -49,7 +49,7 @@ TEST(type_prop, depth_to_space_output_dynamicshape_block_first_5D_when_depth_is_ ASSERT_EQ(depth_to_space->get_output_partial_shape(0), (PartialShape{{2, 10}, - {ngraph::ceil_div(81, 27), 82 / 27}, + {ov::util::ceil_div(81, 27), 82 / 27}, {3 * 3, 7 * 3}, {423 * 3, 3000 * 3}, {235 * 3, 1345 * 3}})); diff --git a/src/core/tests/type_prop/mod.cpp b/src/core/tests/type_prop/mod.cpp index 0e5af52401b412..63c42576cc50a8 100644 --- a/src/core/tests/type_prop/mod.cpp +++ b/src/core/tests/type_prop/mod.cpp @@ -5,7 +5,6 @@ #include "openvino/op/mod.hpp" #include "arithmetic_ops.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/shape_of.hpp" diff --git a/src/core/tests/type_prop/tensor_iterator.cpp b/src/core/tests/type_prop/tensor_iterator.cpp index 64bd9df242860f..9c78450716d4b0 100644 --- a/src/core/tests/type_prop/tensor_iterator.cpp +++ b/src/core/tests/type_prop/tensor_iterator.cpp @@ -6,10 +6,10 @@ #include +#include "common_test_utils/node_builders/reshape.hpp" #include "common_test_utils/type_prop.hpp" #include "openvino/core/model.hpp" #include "openvino/opsets/opset5.hpp" -#include "ov_models/ov_builders/reshape.hpp" using namespace std; using namespace ov; @@ -34,14 +34,14 @@ TEST(type_prop, tensor_iterator_lstm) { auto X = make_shared(element::f32, Shape{N, 1, I}); auto W_body = make_shared(element::f32, Shape{4 * H, I}); auto R_body = make_shared(element::f32, Shape{4 * H, H}); - auto LSTM_cell = make_shared(ov::op::util::reshape(X, Shape{N, I}), - ov::op::util::reshape(H_t, Shape{N, H}), - ov::op::util::reshape(C_t, Shape{N, H}), + auto LSTM_cell = make_shared(ov::test::utils::reshape(X, Shape{N, I}), + ov::test::utils::reshape(H_t, Shape{N, H}), + ov::test::utils::reshape(C_t, Shape{N, H}), W_body, R_body, H); - auto H_o = ov::op::util::reshape(LSTM_cell->output(0), Shape{N, 1, H}); - auto C_o = ov::op::util::reshape(LSTM_cell->output(1), Shape{N, 1, H}); + auto H_o = ov::test::utils::reshape(LSTM_cell->output(0), Shape{N, 1, H}); + auto C_o = ov::test::utils::reshape(LSTM_cell->output(1), Shape{N, 1, H}); auto body = make_shared(OutputVector{H_o, C_o}, ParameterVector{X, H_t, C_t, W_body, R_body}); auto tensor_iterator = make_shared(); @@ -197,14 +197,14 @@ TEST(type_prop, tensor_iterator_with_dynamic_reshape) { auto X = make_shared(element::f32, Shape{N, 1, I}); auto W_body = make_shared(element::f32, Shape{4 * H, I}); auto R_body = make_shared(element::f32, Shape{4 * H, H}); - auto LSTM_cell = make_shared(ov::op::util::reshape(X, Shape{N, I}), - ov::op::util::reshape(H_t, Shape{N, H}), - ov::op::util::reshape(C_t, Shape{N, H}), + auto LSTM_cell = make_shared(ov::test::utils::reshape(X, Shape{N, I}), + ov::test::utils::reshape(H_t, Shape{N, H}), + ov::test::utils::reshape(C_t, Shape{N, H}), W_body, R_body, H); - auto H_o = ov::op::util::reshape(LSTM_cell->output(0), Shape{N, 1, H}); - auto C_o = ov::op::util::reshape(LSTM_cell->output(1), Shape{N, 1, H}); + auto H_o = ov::test::utils::reshape(LSTM_cell->output(0), Shape{N, 1, H}); + auto C_o = ov::test::utils::reshape(LSTM_cell->output(1), Shape{N, 1, H}); auto body = make_shared(OutputVector{H_o, C_o}, ParameterVector{X, H_t, C_t, W_body, R_body}); auto tensor_iterator = make_shared(); diff --git a/src/core/tests/type_prop/variadic_split.cpp b/src/core/tests/type_prop/variadic_split.cpp index 6a3ebd8e5ec73e..c053d272fc0c68 100644 --- a/src/core/tests/type_prop/variadic_split.cpp +++ b/src/core/tests/type_prop/variadic_split.cpp @@ -8,10 +8,10 @@ #include "common_test_utils/type_prop.hpp" #include "openvino/core/deprecated.hpp" #include "openvino/core/dimension_tracker.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/shape_of.hpp" #include "sequnce_generator.hpp" +#include "validation_util.hpp" using namespace std; using namespace ov; @@ -43,9 +43,7 @@ class VariadicSplitTest : public TestWithParam { std::generate_n(std::back_inserter(in_labels), p_shape.size(), ov::SeqGen(10)); auto exp_labels = in_labels; - OPENVINO_SUPPRESS_DEPRECATED_START - const auto n_axis = ov::normalize_axis("", axis, p_shape.rank()); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto n_axis = ov::util::normalize_axis("", axis, p_shape.rank()); exp_labels[n_axis] = ov::no_label; return {in_labels, exp_labels}; diff --git a/src/core/tests/type_relaxed_copy.cpp b/src/core/tests/type_relaxed_copy.cpp index bbda062e23271c..a6796ff5a466c2 100644 --- a/src/core/tests/type_relaxed_copy.cpp +++ b/src/core/tests/type_relaxed_copy.cpp @@ -7,7 +7,6 @@ #include #include -#include "ie_common.h" #include "openvino/op/matmul.hpp" #include "ov_ops/type_relaxed.hpp" diff --git a/src/core/tests/validation_utils.cpp b/src/core/tests/validation_utils.cpp index 2d22affa74be0e..21001e48480256 100644 --- a/src/core/tests/validation_utils.cpp +++ b/src/core/tests/validation_utils.cpp @@ -5,7 +5,6 @@ #include #include "openvino/core/type.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/opsets/opset8.hpp" #include "openvino/util/common_util.hpp" #include "validation_util.hpp" @@ -18,9 +17,7 @@ TEST(get_constant_from_source, invalidation_check) { auto r = std::make_shared(div, s, true); auto tmp_consumer = std::make_shared(s); - OPENVINO_SUPPRESS_DEPRECATED_START - ASSERT_TRUE(ov::get_constant_from_source(r)); - OPENVINO_SUPPRESS_DEPRECATED_END + ASSERT_TRUE(ov::util::get_constant_from_source(r)); ASSERT_TRUE(r->get_output_tensor(0).get_lower_value()); ASSERT_TRUE(r->get_output_tensor(0).get_upper_value()); @@ -45,9 +42,7 @@ TEST(get_constant_from_source, extract_static_dim_from_dynamic_shape_check) { auto zero = ov::opset8::Constant::create(ov::element::i64, {1}, {0}); const auto extract_static_dimension = std::make_shared(shape, one, zero); - OPENVINO_SUPPRESS_DEPRECATED_START - ASSERT_TRUE(ov::get_constant_from_source(extract_static_dimension)); - OPENVINO_SUPPRESS_DEPRECATED_END + ASSERT_TRUE(ov::util::get_constant_from_source(extract_static_dimension)); ASSERT_TRUE(extract_static_dimension->get_output_tensor(0).get_lower_value()); ASSERT_TRUE(extract_static_dimension->get_output_tensor(0).get_upper_value()); diff --git a/src/core/tests/visitors/op/tensor_iterator.cpp b/src/core/tests/visitors/op/tensor_iterator.cpp index d4253d7969e6fd..a3f5e5efa53672 100644 --- a/src/core/tests/visitors/op/tensor_iterator.cpp +++ b/src/core/tests/visitors/op/tensor_iterator.cpp @@ -6,10 +6,10 @@ #include +#include "common_test_utils/node_builders/reshape.hpp" #include "openvino/op/add.hpp" #include "openvino/op/lstm_cell.hpp" #include "openvino/op/multiply.hpp" -#include "ov_models/ov_builders/reshape.hpp" #include "visitors/visitors.hpp" using namespace std; @@ -39,14 +39,14 @@ TEST(attributes, tensor_iterator_lstm) { auto X = make_shared(element::f32, Shape{N, 1, I}); auto W_body = make_shared(element::f32, Shape{4 * H, I}); auto R_body = make_shared(element::f32, Shape{4 * H, H}); - auto LSTM_cell = make_shared(ov::op::util::reshape(X, Shape{N, I}), - ov::op::util::reshape(H_t, Shape{N, H}), - ov::op::util::reshape(C_t, Shape{N, H}), + auto LSTM_cell = make_shared(ov::test::utils::reshape(X, Shape{N, I}), + ov::test::utils::reshape(H_t, Shape{N, H}), + ov::test::utils::reshape(C_t, Shape{N, H}), W_body, R_body, H); - auto H_o = ov::op::util::reshape(LSTM_cell->output(0), Shape{N, 1, H}); - auto C_o = ov::op::util::reshape(LSTM_cell->output(1), Shape{N, 1, H}); + auto H_o = ov::test::utils::reshape(LSTM_cell->output(0), Shape{N, 1, H}); + auto C_o = ov::test::utils::reshape(LSTM_cell->output(1), Shape{N, 1, H}); auto body = make_shared(OutputVector{H_o, C_o}, ParameterVector{X, H_t, C_t, W_body, R_body}); auto tensor_iterator = make_shared(); diff --git a/src/frontends/common/include/openvino/frontend/extension/op.hpp b/src/frontends/common/include/openvino/frontend/extension/op.hpp index 0bb7b76fe54817..668fd56ccc5aa6 100644 --- a/src/frontends/common/include/openvino/frontend/extension/op.hpp +++ b/src/frontends/common/include/openvino/frontend/extension/op.hpp @@ -25,7 +25,7 @@ inline const ov::OpSet& get_opset_by_name(const std::string& opset_name) { if (opsets.find(opset_name) != opsets.end()) return opsets.at(opset_name)(); if (opset_name.empty() || opset_name == "latest") { - return ov::get_opset13(); + return ov::get_opset14(); } else { FRONT_END_GENERAL_CHECK(false, "Unsupported opset name: ", opset_name); } diff --git a/src/frontends/common/shutdown_protobuf/shutdown_protobuf.cpp b/src/frontends/common/shutdown_protobuf/shutdown_protobuf.cpp index 4cb7140a4fe81a..5bbd5a028b3ac3 100644 --- a/src/frontends/common/shutdown_protobuf/shutdown_protobuf.cpp +++ b/src/frontends/common/shutdown_protobuf/shutdown_protobuf.cpp @@ -4,7 +4,7 @@ #include -#if defined(_WIN32) +#if defined(_WIN32) && !defined(__MINGW32__) && !defined(__MINGW64__) # include BOOL WINAPI DllMain(HINSTANCE hinstDLL, // handle to DLL module DWORD fdwReason, // reason for calling function diff --git a/src/frontends/ir/src/input_model.cpp b/src/frontends/ir/src/input_model.cpp index 756d5708ace6c3..750d6739e3a903 100644 --- a/src/frontends/ir/src/input_model.cpp +++ b/src/frontends/ir/src/input_model.cpp @@ -8,7 +8,6 @@ #include "ir_deserializer.hpp" #include "openvino/core/except.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/subtract.hpp" @@ -18,6 +17,7 @@ #include "openvino/util/common_util.hpp" #include "openvino/util/xml_parse_utils.hpp" #include "utils.hpp" +#include "validation_util.hpp" namespace { void parse_pre_process(pugi::xml_node& root, @@ -183,9 +183,8 @@ void parse_pre_process(pugi::xml_node& root, const char* data = weights->get_ptr() + offset; per_channel_values[item.first] = ov::op::v0::Constant::create(input_type, mean_shape, data); } - OPENVINO_SUPPRESS_DEPRECATED_START - auto const_node = get_constant_from_source(std::make_shared(per_channel_values, 0)); - OPENVINO_SUPPRESS_DEPRECATED_END + auto const_node = + ov::util::get_constant_from_source(std::make_shared(per_channel_values, 0)); OPENVINO_ASSERT(const_node); const auto& consumers = input_node->output(0).get_target_inputs(); auto add = std::make_shared(input_node, const_node); diff --git a/src/frontends/ir/tests/meta_data_tests.cpp b/src/frontends/ir/tests/meta_data_tests.cpp index 8dd75fd65e33e7..eba4f38af67913 100644 --- a/src/frontends/ir/tests/meta_data_tests.cpp +++ b/src/frontends/ir/tests/meta_data_tests.cpp @@ -7,7 +7,6 @@ #include #include "common_test_utils/common_utils.hpp" -#include "file_utils.h" #include "openvino/core/any.hpp" #include "openvino/openvino.hpp" #include "openvino/util/file_util.hpp" diff --git a/src/frontends/onnx/frontend/CMakeLists.txt b/src/frontends/onnx/frontend/CMakeLists.txt index 50782959202168..19e65e3603ac38 100644 --- a/src/frontends/onnx/frontend/CMakeLists.txt +++ b/src/frontends/onnx/frontend/CMakeLists.txt @@ -8,7 +8,7 @@ ov_add_frontend(NAME onnx PROTOBUF_LITE SKIP_NCC_STYLE FILEDESCRIPTION "FrontEnd to load and convert ONNX file format" - LINK_LIBRARIES openvino::builders openvino_onnx_common openvino::core::dev) + LINK_LIBRARIES openvino_onnx_common openvino::core::dev) set(ONNX_OPSET_VERSION 18 CACHE INTERNAL "Supported version of ONNX operator set") target_compile_definitions(${TARGET_NAME} PRIVATE ONNX_OPSET_VERSION=${ONNX_OPSET_VERSION}) @@ -17,8 +17,3 @@ ov_ncc_naming_style(FOR_TARGET ${TARGET_NAME} SOURCE_DIRECTORIES "${${TARGET_NAME}_INCLUDE_DIR}" DEFINITIONS $) - -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/onnx_import - DESTINATION ${FRONTEND_INSTALL_INCLUDE}/ngraph/frontend - COMPONENT ${OV_CPACK_COMP_CORE_DEV} - ${OV_CPACK_COMP_CORE_DEV_EXCLUDE_ALL}) diff --git a/src/frontends/onnx/frontend/include/onnx_import/core/node.hpp b/src/frontends/onnx/frontend/include/onnx_import/core/node.hpp deleted file mode 100644 index 125016cecedda8..00000000000000 --- a/src/frontends/onnx/frontend/include/onnx_import/core/node.hpp +++ /dev/null @@ -1,310 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED) -# define NGRAPH_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include -#include - -#include "onnx_import/onnx_importer_visibility.hpp" -#include "openvino/core/deprecated.hpp" -#include "openvino/core/except.hpp" -#include "openvino/core/node.hpp" -#include "openvino/op/constant.hpp" - -namespace ONNX_NAMESPACE { -// forward declaration -class NodeProto; -} // namespace ONNX_NAMESPACE - -namespace ngraph { -namespace element { -using ov::element::Type; -} -namespace onnx_import { -namespace error { -namespace node { -struct UnknownAttribute : ov::Exception { - OPENVINO_SUPPRESS_DEPRECATED_START - explicit UnknownAttribute(const std::string& node, const std::string& name) - : ov::Exception{"Node (" + node + "): unknown attribute \'" + name + "\'"} {} - OPENVINO_SUPPRESS_DEPRECATED_END -}; - -} // namespace node - -} // namespace error - -// forward declaration -class Graph; -class Subgraph; -class Tensor; -class SparseTensor; -class Attribute; - -class NGRAPH_API_DEPRECATED ONNX_IMPORTER_API Node { -public: - Node() = delete; - // TODO: hide this ctor since it uses protobufs generated structures - Node(const ONNX_NAMESPACE::NodeProto& node_proto, Graph* graph); - - Node(Node&&) noexcept; - Node(const Node&); - - Node& operator=(Node&&) noexcept = delete; - Node& operator=(const Node&) = delete; - - ov::OutputVector get_ng_inputs() const; - const std::string& domain() const; - const std::string& op_type() const; - const std::string& get_name() const; - std::vector get_attribute_names() const; - const Attribute& get_attribute(const std::string& name) const; - - /// \brief Describe the ONNX Node to make debugging graphs easier - /// Function will return the Node's name if it has one, or the names of its outputs. - /// \return Description of Node - const std::string& get_description() const; - - const std::string& input(int index) const; - std::size_t get_inputs_size() const; - - const std::vector>& get_output_names() const; - const std::string& output(int index) const; - std::size_t get_outputs_size() const; - - bool has_attribute(const std::string& name) const; - - bool has_subgraphs() const; - const std::unordered_map>& get_subgraphs() const; - - template - T get_attribute_value(const std::string& name, T default_value) const; - - template - T get_attribute_value(const std::string& name) const; - - template - std::shared_ptr get_attribute_as_constant(const std::string& name) const; - - template - std::shared_ptr get_attribute_as_constant(const std::string& name, - ov::element::Type type) const; - - template - std::shared_ptr get_attribute_as_constant(const std::string& name, T default_value) const; - - template - std::shared_ptr get_attribute_as_constant(const std::string& name, - T default_value, - ov::element::Type type) const; - -private: - class Impl; - // In this case we need custom deleter, because Impl is an incomplete - // type. Node's are elements of std::vector. Without custom deleter - // compilation fails; the compiler is unable to parameterize an allocator's - // default deleter due to incomple type. - std::unique_ptr m_pimpl; -}; - -template <> -ONNX_IMPORTER_API float Node::get_attribute_value(const std::string& name, float default_value) const; - -template <> -ONNX_IMPORTER_API double Node::get_attribute_value(const std::string& name, double default_value) const; - -template <> -ONNX_IMPORTER_API std::int64_t Node::get_attribute_value(const std::string& name, std::int64_t default_value) const; - -template <> -ONNX_IMPORTER_API std::string Node::get_attribute_value(const std::string& name, std::string default_value) const; - -template <> -ONNX_IMPORTER_API Tensor Node::get_attribute_value(const std::string& name, Tensor default_value) const; - -template <> -ONNX_IMPORTER_API SparseTensor Node::get_attribute_value(const std::string& name, SparseTensor default_value) const; - -template <> -ONNX_IMPORTER_API Graph Node::get_attribute_value(const std::string& name, Graph default_value) const; - -template <> -ONNX_IMPORTER_API std::vector Node::get_attribute_value(const std::string& name, - std::vector default_value) const; - -template <> -ONNX_IMPORTER_API std::vector Node::get_attribute_value(const std::string& name, - std::vector default_value) const; - -template <> -ONNX_IMPORTER_API std::vector Node::get_attribute_value(const std::string& name, - std::vector default_value) const; - -template <> -ONNX_IMPORTER_API std::vector Node::get_attribute_value(const std::string& name, - std::vector default_value) const; - -template <> -ONNX_IMPORTER_API std::vector Node::get_attribute_value(const std::string& name, - std::vector default_value) const; - -template <> -ONNX_IMPORTER_API std::vector Node::get_attribute_value(const std::string& name, - std::vector default_value) const; - -template <> -ONNX_IMPORTER_API std::vector Node::get_attribute_value(const std::string& name, - std::vector default_value) const; - -template <> -ONNX_IMPORTER_API std::vector Node::get_attribute_value(const std::string& name, - std::vector default_value) const; - -template <> -ONNX_IMPORTER_API float Node::get_attribute_value(const std::string& name) const; - -template <> -ONNX_IMPORTER_API double Node::get_attribute_value(const std::string& name) const; - -template <> -ONNX_IMPORTER_API std::int64_t Node::get_attribute_value(const std::string& name) const; - -template <> -ONNX_IMPORTER_API std::size_t Node::get_attribute_value(const std::string& name) const; - -template <> -ONNX_IMPORTER_API std::string Node::get_attribute_value(const std::string& name) const; - -template <> -ONNX_IMPORTER_API Tensor Node::get_attribute_value(const std::string& name) const; - -template <> -ONNX_IMPORTER_API SparseTensor Node::get_attribute_value(const std::string& name) const; - -template <> -ONNX_IMPORTER_API Subgraph Node::get_attribute_value(const std::string& name) const; - -template <> -ONNX_IMPORTER_API std::vector Node::get_attribute_value(const std::string& name) const; - -template <> -ONNX_IMPORTER_API std::vector Node::get_attribute_value(const std::string& name) const; - -template <> -ONNX_IMPORTER_API std::vector Node::get_attribute_value(const std::string& name) const; - -template <> -ONNX_IMPORTER_API std::vector Node::get_attribute_value(const std::string& name) const; - -template <> -ONNX_IMPORTER_API std::vector Node::get_attribute_value(const std::string& name) const; - -template <> -ONNX_IMPORTER_API std::vector Node::get_attribute_value(const std::string& name) const; - -template <> -ONNX_IMPORTER_API std::vector Node::get_attribute_value(const std::string& name) const; - -template <> -ONNX_IMPORTER_API std::vector Node::get_attribute_value(const std::string& name) const; - -template <> -ONNX_IMPORTER_API std::shared_ptr Node::get_attribute_as_constant>( - const std::string& name) const; - -template <> -ONNX_IMPORTER_API std::shared_ptr Node::get_attribute_as_constant>( - const std::string& name, - ov::element::Type type) const; - -template <> -ONNX_IMPORTER_API std::shared_ptr Node::get_attribute_as_constant( - const std::string& name, - std::vector default_value) const; - -template <> -ONNX_IMPORTER_API std::shared_ptr Node::get_attribute_as_constant( - const std::string& name, - std::vector default_value, - ov::element::Type type) const; - -template <> -ONNX_IMPORTER_API std::shared_ptr Node::get_attribute_as_constant( - const std::string& name) const; - -template <> -ONNX_IMPORTER_API std::shared_ptr Node::get_attribute_as_constant(const std::string& name, - float default_value) const; - -template <> -ONNX_IMPORTER_API std::shared_ptr Node::get_attribute_as_constant(const std::string& name, - float default_value, - ov::element::Type type) const; - -template <> -ONNX_IMPORTER_API std::shared_ptr Node::get_attribute_as_constant( - const std::string& name, - ov::element::Type type) const; - -template <> -ONNX_IMPORTER_API std::shared_ptr Node::get_attribute_as_constant( - const std::string& name) const; - -template <> -ONNX_IMPORTER_API std::shared_ptr Node::get_attribute_as_constant(const std::string& name, - double default_value) const; - -template <> -ONNX_IMPORTER_API std::shared_ptr Node::get_attribute_as_constant( - const std::string& name, - ov::element::Type type) const; - -template <> -ONNX_IMPORTER_API std::shared_ptr Node::get_attribute_as_constant(const std::string& name, - double default_value, - ov::element::Type type) const; - -template <> -ONNX_IMPORTER_API std::shared_ptr Node::get_attribute_as_constant( - const std::string& name) const; - -template <> -ONNX_IMPORTER_API std::shared_ptr Node::get_attribute_as_constant( - const std::string& name, - ov::element::Type type) const; - -template <> -ONNX_IMPORTER_API std::shared_ptr Node::get_attribute_as_constant(const std::string& name, - int64_t default_value) const; - -template <> -ONNX_IMPORTER_API std::shared_ptr Node::get_attribute_as_constant( - const std::string& name, - ov::element::Type type) const; - -template <> -ONNX_IMPORTER_API std::shared_ptr Node::get_attribute_as_constant(const std::string& name, - int64_t default_value, - ov::element::Type type) const; - -OPENVINO_SUPPRESS_DEPRECATED_START -inline std::ostream& operator<<(std::ostream& outs, const Node& node) { - return (outs << ""); -} -OPENVINO_SUPPRESS_DEPRECATED_END - -} // namespace onnx_import - -} // namespace ngraph diff --git a/src/frontends/onnx/frontend/include/onnx_import/onnx.hpp b/src/frontends/onnx/frontend/include/onnx_import/onnx.hpp deleted file mode 100644 index 4dbe99de0c00f1..00000000000000 --- a/src/frontends/onnx/frontend/include/onnx_import/onnx.hpp +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED) -# define NGRAPH_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include -#include -#include -#include -#include - -#include "ngraph/deprecated.hpp" -#include "onnx_importer_visibility.hpp" -#include "openvino/core/model.hpp" - -/// \brief Top level nGraph namespace. -namespace ngraph { -/// \brief ONNX importer features namespace. -/// Functions in this namespace make it possible to use ONNX models. -namespace onnx_import { -/// \brief Returns a set of names of supported operators -/// for the given opset version and domain. -/// -/// \param[in] version An opset version to get the supported operators for. -/// \param[in] domain A domain to get the supported operators for. -/// -/// \return The set containing names of supported operators. -NGRAPH_API_DEPRECATED ONNX_IMPORTER_API std::set get_supported_operators(std::int64_t version, - const std::string& domain); - -/// \brief Determines whether ONNX operator is supported. -/// -/// \param[in] op_name The ONNX operator name. -/// \param[in] version The ONNX operator set version. -/// \param[in] domain The domain the ONNX operator is registered to. -/// If not set, the default domain "ai.onnx" is used. -/// -/// \return true if operator is supported, false otherwise. -NGRAPH_API_DEPRECATED ONNX_IMPORTER_API bool is_operator_supported(const std::string& op_name, - std::int64_t version, - const std::string& domain = "ai.onnx"); - -/// \brief Imports and converts an serialized ONNX model from the input stream -/// to an nGraph Function representation. -/// -/// \note If stream parsing fails or the ONNX model contains unsupported ops, -/// the function throws an ngraph_error exception. -/// -/// \param[in] stream The input stream (e.g. file stream, memory stream, etc). -/// \param[in] model_path The path to the imported onnx model. -/// It is required if the imported model uses data saved in external -/// files. -/// \param[in] enable_mmap Enable mapping files with external weights instead of reading. -/// -/// \return An nGraph function that represents a single output from the created graph. -NGRAPH_API_DEPRECATED ONNX_IMPORTER_API std::shared_ptr import_onnx_model(std::istream& stream, - const std::string& model_path = "", - bool enable_mmap = false); - -/// \brief Imports and converts an ONNX model from the input file -/// to an nGraph Function representation. -/// -/// \note If file parsing fails or the ONNX model contains unsupported ops, -/// the function throws an ngraph_error exception. -/// -/// \param[in] file_path The path to a file containing the ONNX model -/// (relative or absolute). -/// \param[in] enable_mmap Enable mapping files with external weights instead of reading. -/// -/// \return An nGraph function that represents a single output from the created graph. -NGRAPH_API_DEPRECATED ONNX_IMPORTER_API std::shared_ptr import_onnx_model(const std::string& file_path, - bool enable_mmap = false); -} // namespace onnx_import - -} // namespace ngraph diff --git a/src/frontends/onnx/frontend/include/onnx_import/onnx_importer_visibility.hpp b/src/frontends/onnx/frontend/include/onnx_import/onnx_importer_visibility.hpp deleted file mode 100644 index 3d3ae61319696b..00000000000000 --- a/src/frontends/onnx/frontend/include/onnx_import/onnx_importer_visibility.hpp +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED) -# define NGRAPH_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#ifdef OPENVINO_STATIC_LIBRARY -# define ONNX_IMPORTER_API -#else -# ifdef openvino_onnx_frontend_EXPORTS -# define ONNX_IMPORTER_API OPENVINO_CORE_EXPORTS -# else -# define ONNX_IMPORTER_API OPENVINO_CORE_IMPORTS -# endif // openvino_onnx_frontend_EXPORTS -#endif // OPENVINO_STATIC_LIBRARY diff --git a/src/frontends/onnx/frontend/include/onnx_import/onnx_utils.hpp b/src/frontends/onnx/frontend/include/onnx_import/onnx_utils.hpp deleted file mode 100644 index 8e4de8a6605635..00000000000000 --- a/src/frontends/onnx/frontend/include/onnx_import/onnx_utils.hpp +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED) -# define NGRAPH_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include -#include - -#include "onnx_import/core/operator_set.hpp" -#include "onnx_importer_visibility.hpp" -#include "openvino/core/deprecated.hpp" - -namespace ngraph { -namespace onnx_import { -/// \brief Registers ONNX custom operator. -/// The function performs the registration of external ONNX operator -/// which is not part of ONNX importer. -/// -/// \note The operator must be registered before calling -/// "import_onnx_model" functions. -/// -/// \param name The ONNX operator name. -/// \param version The ONNX operator set version. -/// \param domain The domain the ONNX operator is registered to. -/// \param fn The function providing the implementation of the operator -/// which transforms the single ONNX operator to an nGraph sub-graph. -NGRAPH_API_DEPRECATED ONNX_IMPORTER_API void register_operator(const std::string& name, - std::int64_t version, - const std::string& domain, - Operator fn); - -/// \brief Unregisters ONNX custom operator. -/// The function unregisters previously registered operator. -/// -/// \param name The ONNX operator name. -/// \param version The ONNX operator set version. -/// \param domain The domain the ONNX operator is registered to. -NGRAPH_API_DEPRECATED ONNX_IMPORTER_API void unregister_operator(const std::string& name, - std::int64_t version, - const std::string& domain); - -} // namespace onnx_import - -} // namespace ngraph diff --git a/src/frontends/onnx/frontend/include/openvino/frontend/onnx/node_context.hpp b/src/frontends/onnx/frontend/include/openvino/frontend/onnx/node_context.hpp index 0aa11b50d4a237..b6dac7caf9a10b 100644 --- a/src/frontends/onnx/frontend/include/openvino/frontend/onnx/node_context.hpp +++ b/src/frontends/onnx/frontend/include/openvino/frontend/onnx/node_context.hpp @@ -4,26 +4,19 @@ #pragma once -#include "openvino/core/deprecated.hpp" #include "openvino/frontend/extension/conversion.hpp" #include "openvino/frontend/node_context.hpp" #include "openvino/frontend/onnx/visibility.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { -class Node; -} -} // namespace ngraph - namespace ov { namespace frontend { namespace onnx { +class Node; class ONNX_FRONTEND_API NodeContext : public ov::frontend::NodeContext { public: using Ptr = std::shared_ptr; - explicit NodeContext(const ngraph::onnx_import::Node& context); + explicit NodeContext(const ov::frontend::onnx::Node& context); size_t get_input_size() const override; Output get_input(int port_idx) const override; @@ -31,14 +24,13 @@ class ONNX_FRONTEND_API NodeContext : public ov::frontend::NodeContext { ov::Any get_attribute_as_any(const std::string& name) const override; protected: - const ngraph::onnx_import::Node& m_context; + const ov::frontend::onnx::Node& m_context; ov::OutputVector m_inputs; private: ov::Any apply_additional_conversion_rules(const ov::Any& data, const std::type_info& type_info) const override; }; -using CreatorFunction = std::function; +using CreatorFunction = std::function; } // namespace onnx } // namespace frontend } // namespace ov -OPENVINO_SUPPRESS_DEPRECATED_END diff --git a/src/frontends/onnx/frontend/src/core/attribute.cpp b/src/frontends/onnx/frontend/src/core/attribute.cpp index 0f3ff1736e9a0e..5f4667acdba4b7 100644 --- a/src/frontends/onnx/frontend/src/core/attribute.cpp +++ b/src/frontends/onnx/frontend/src/core/attribute.cpp @@ -7,14 +7,15 @@ #include "core/graph.hpp" #include "core/model.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { Subgraph Attribute::get_subgraph(Graph* parent_graph) const { - if (m_attribute_proto->type() != ONNX_NAMESPACE::AttributeProto_AttributeType_GRAPH) { + if (m_attribute_proto->type() != AttributeProto_AttributeType::AttributeProto_AttributeType_GRAPH) { ONNX_INVALID_ATTR(m_attribute_proto->type(), "GRAPH"); } - auto model_proto = std::make_shared(); + auto model_proto = std::make_shared(); const auto& graph = m_attribute_proto->g(); model_proto->mutable_graph()->CopyFrom(graph); @@ -69,6 +70,6 @@ ov::Any Attribute::get_any() const { } } -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/core/attribute.hpp b/src/frontends/onnx/frontend/src/core/attribute.hpp index ea8bedb5a28d0f..92708e27a8863e 100644 --- a/src/frontends/onnx/frontend/src/core/attribute.hpp +++ b/src/frontends/onnx/frontend/src/core/attribute.hpp @@ -10,39 +10,34 @@ #include "core/tensor.hpp" #include "openvino/core/except.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { // forward declarations class Graph; class Subgraph; class Model; -// Detecting automatically the underlying type used to store the information -// for data type of values an attribute is holding. A bug was discovered in -// protobuf which forced ONNX team to switch from `enum AttributeProto_AttributeType` -// to `int32` in order to workaround the bug. This line allows using both versions -// of ONNX generated wrappers. -using AttributeProto_AttributeType = decltype(ONNX_NAMESPACE::AttributeProto{}.type()); +using ::ONNX_NAMESPACE::AttributeProto; +using ::ONNX_NAMESPACE::AttributeProto_AttributeType; +using ::ONNX_NAMESPACE::AttributeProto_AttributeType_Name; namespace detail { namespace attribute { template -inline T get_value(const ONNX_NAMESPACE::AttributeProto& attribute) { +inline T get_value(const AttributeProto& attribute) { OPENVINO_THROW("Unsupported attribute type"); } -#define ONNX_INVALID_ATTR(attr, expected) \ - OPENVINO_THROW("Invalid attribute type ", \ - ONNX_NAMESPACE::AttributeProto_AttributeType_Name(attr), \ - " expected: ", \ - expected) +#define ONNX_INVALID_ATTR(attr, expected) \ + OPENVINO_THROW("Invalid attribute type ", AttributeProto_AttributeType_Name(attr), " expected: ", expected) template <> -inline float get_value(const ONNX_NAMESPACE::AttributeProto& attribute) { +inline float get_value(const AttributeProto& attribute) { switch (attribute.type()) { - case ONNX_NAMESPACE::AttributeProto_AttributeType_INT: + case AttributeProto_AttributeType::AttributeProto_AttributeType_INT: return static_cast(attribute.i()); - case ONNX_NAMESPACE::AttributeProto_AttributeType_FLOAT: + case AttributeProto_AttributeType::AttributeProto_AttributeType_FLOAT: return attribute.f(); default: ONNX_INVALID_ATTR(attribute.type(), "INT, FLOAT"); @@ -50,15 +45,15 @@ inline float get_value(const ONNX_NAMESPACE::AttributeProto& attribute) { } template <> -inline std::vector get_value(const ONNX_NAMESPACE::AttributeProto& attribute) { +inline std::vector get_value(const AttributeProto& attribute) { switch (attribute.type()) { - case ONNX_NAMESPACE::AttributeProto_AttributeType_INT: + case AttributeProto_AttributeType::AttributeProto_AttributeType_INT: return {static_cast(attribute.i())}; - case ONNX_NAMESPACE::AttributeProto_AttributeType_INTS: + case AttributeProto_AttributeType::AttributeProto_AttributeType_INTS: return {std::begin(attribute.floats()), std::end(attribute.floats())}; - case ONNX_NAMESPACE::AttributeProto_AttributeType_FLOAT: + case AttributeProto_AttributeType::AttributeProto_AttributeType_FLOAT: return {attribute.f()}; - case ONNX_NAMESPACE::AttributeProto_AttributeType_FLOATS: + case AttributeProto_AttributeType::AttributeProto_AttributeType_FLOATS: return {std::begin(attribute.floats()), std::end(attribute.floats())}; default: ONNX_INVALID_ATTR(attribute.type(), "INT, INTS, FLOAT, FLOATS"); @@ -66,11 +61,11 @@ inline std::vector get_value(const ONNX_NAMESPACE::AttributeProto& attrib } template <> -inline double get_value(const ONNX_NAMESPACE::AttributeProto& attribute) { +inline double get_value(const AttributeProto& attribute) { switch (attribute.type()) { - case ONNX_NAMESPACE::AttributeProto_AttributeType_FLOAT: + case AttributeProto_AttributeType::AttributeProto_AttributeType_FLOAT: return static_cast(attribute.f()); - case ONNX_NAMESPACE::AttributeProto_AttributeType_INT: + case AttributeProto_AttributeType::AttributeProto_AttributeType_INT: return static_cast(attribute.i()); default: ONNX_INVALID_ATTR(attribute.type(), "INT, FLOAT"); @@ -78,19 +73,19 @@ inline double get_value(const ONNX_NAMESPACE::AttributeProto& attribute) { } template <> -inline std::vector get_value(const ONNX_NAMESPACE::AttributeProto& attribute) { +inline std::vector get_value(const AttributeProto& attribute) { #if defined(_MSC_VER) # pragma warning(push) # pragma warning(disable : 4244) #endif switch (attribute.type()) { - case ONNX_NAMESPACE::AttributeProto_AttributeType_INT: + case AttributeProto_AttributeType::AttributeProto_AttributeType_INT: return {static_cast(attribute.i())}; - case ONNX_NAMESPACE::AttributeProto_AttributeType_INTS: + case AttributeProto_AttributeType::AttributeProto_AttributeType_INTS: return {std::begin(attribute.ints()), std::end(attribute.ints())}; - case ONNX_NAMESPACE::AttributeProto_AttributeType_FLOAT: + case AttributeProto_AttributeType::AttributeProto_AttributeType_FLOAT: return {static_cast(attribute.f())}; - case ONNX_NAMESPACE::AttributeProto_AttributeType_FLOATS: + case AttributeProto_AttributeType::AttributeProto_AttributeType_FLOATS: return {std::begin(attribute.floats()), std::end(attribute.floats())}; default: ONNX_INVALID_ATTR(attribute.type(), "INT, INTS, FLOAT, FLOATS"); @@ -101,19 +96,19 @@ inline std::vector get_value(const ONNX_NAMESPACE::AttributeProto& attri } template <> -inline std::size_t get_value(const ONNX_NAMESPACE::AttributeProto& attribute) { - if (attribute.type() != ONNX_NAMESPACE::AttributeProto_AttributeType_INT) { +inline std::size_t get_value(const AttributeProto& attribute) { + if (attribute.type() != AttributeProto_AttributeType::AttributeProto_AttributeType_INT) { ONNX_INVALID_ATTR(attribute.type(), "INT"); } return static_cast(attribute.i()); } template <> -inline std::vector get_value(const ONNX_NAMESPACE::AttributeProto& attribute) { +inline std::vector get_value(const AttributeProto& attribute) { switch (attribute.type()) { - case ONNX_NAMESPACE::AttributeProto_AttributeType_INT: + case AttributeProto_AttributeType::AttributeProto_AttributeType_INT: return {static_cast(attribute.i())}; - case ONNX_NAMESPACE::AttributeProto_AttributeType_INTS: + case AttributeProto_AttributeType::AttributeProto_AttributeType_INTS: return {std::begin(attribute.ints()), std::end(attribute.ints())}; default: ONNX_INVALID_ATTR(attribute.type(), "INT, INTS"); @@ -121,19 +116,19 @@ inline std::vector get_value(const ONNX_NAMESPACE::AttributeProto& } template <> -inline int64_t get_value(const ONNX_NAMESPACE::AttributeProto& attribute) { - if (attribute.type() != ONNX_NAMESPACE::AttributeProto_AttributeType_INT) { +inline int64_t get_value(const AttributeProto& attribute) { + if (attribute.type() != AttributeProto_AttributeType::AttributeProto_AttributeType_INT) { ONNX_INVALID_ATTR(attribute.type(), "INT"); } return attribute.i(); } template <> -inline std::vector get_value(const ONNX_NAMESPACE::AttributeProto& attribute) { +inline std::vector get_value(const AttributeProto& attribute) { switch (attribute.type()) { - case ONNX_NAMESPACE::AttributeProto_AttributeType_INT: + case AttributeProto_AttributeType::AttributeProto_AttributeType_INT: return {attribute.i()}; - case ONNX_NAMESPACE::AttributeProto_AttributeType_INTS: + case AttributeProto_AttributeType::AttributeProto_AttributeType_INTS: return {std::begin(attribute.ints()), std::end(attribute.ints())}; default: ONNX_INVALID_ATTR(attribute.type(), "INT, INTS"); @@ -141,19 +136,19 @@ inline std::vector get_value(const ONNX_NAMESPACE::AttributeProto& attr } template <> -inline std::string get_value(const ONNX_NAMESPACE::AttributeProto& attribute) { - if (attribute.type() != ONNX_NAMESPACE::AttributeProto_AttributeType_STRING) { +inline std::string get_value(const AttributeProto& attribute) { + if (attribute.type() != AttributeProto_AttributeType::AttributeProto_AttributeType_STRING) { ONNX_INVALID_ATTR(attribute.type(), "STRING"); } return attribute.s(); } template <> -inline std::vector get_value(const ONNX_NAMESPACE::AttributeProto& attribute) { +inline std::vector get_value(const AttributeProto& attribute) { switch (attribute.type()) { - case ONNX_NAMESPACE::AttributeProto_AttributeType_STRING: + case AttributeProto_AttributeType::AttributeProto_AttributeType_STRING: return {attribute.s()}; - case ONNX_NAMESPACE::AttributeProto_AttributeType_STRINGS: + case AttributeProto_AttributeType::AttributeProto_AttributeType_STRINGS: return {std::begin(attribute.strings()), std::end(attribute.strings())}; default: ONNX_INVALID_ATTR(attribute.type(), "STRING, STRINGS"); @@ -161,29 +156,28 @@ inline std::vector get_value(const ONNX_NAMESPACE::AttributeProto& } } // namespace attribute - } // namespace detail class Attribute { public: enum class Type { - undefined = ONNX_NAMESPACE::AttributeProto_AttributeType_UNDEFINED, - float_point = ONNX_NAMESPACE::AttributeProto_AttributeType_FLOAT, - integer = ONNX_NAMESPACE::AttributeProto_AttributeType_INT, - string = ONNX_NAMESPACE::AttributeProto_AttributeType_STRING, - tensor = ONNX_NAMESPACE::AttributeProto_AttributeType_TENSOR, - graph = ONNX_NAMESPACE::AttributeProto_AttributeType_GRAPH, - sparse_tensor = ONNX_NAMESPACE::AttributeProto_AttributeType_SPARSE_TENSOR, - float_point_array = ONNX_NAMESPACE::AttributeProto_AttributeType_FLOATS, - integer_array = ONNX_NAMESPACE::AttributeProto_AttributeType_INTS, - string_array = ONNX_NAMESPACE::AttributeProto_AttributeType_STRINGS, - tensor_array = ONNX_NAMESPACE::AttributeProto_AttributeType_TENSORS, - sparse_tensor_array = ONNX_NAMESPACE::AttributeProto_AttributeType_SPARSE_TENSORS, - graph_array = ONNX_NAMESPACE::AttributeProto_AttributeType_GRAPHS + undefined = AttributeProto_AttributeType::AttributeProto_AttributeType_UNDEFINED, + float_point = AttributeProto_AttributeType::AttributeProto_AttributeType_FLOAT, + integer = AttributeProto_AttributeType::AttributeProto_AttributeType_INT, + string = AttributeProto_AttributeType::AttributeProto_AttributeType_STRING, + tensor = AttributeProto_AttributeType::AttributeProto_AttributeType_TENSOR, + graph = AttributeProto_AttributeType::AttributeProto_AttributeType_GRAPH, + sparse_tensor = AttributeProto_AttributeType::AttributeProto_AttributeType_SPARSE_TENSOR, + float_point_array = AttributeProto_AttributeType::AttributeProto_AttributeType_FLOATS, + integer_array = AttributeProto_AttributeType::AttributeProto_AttributeType_INTS, + string_array = AttributeProto_AttributeType::AttributeProto_AttributeType_STRINGS, + tensor_array = AttributeProto_AttributeType::AttributeProto_AttributeType_TENSORS, + sparse_tensor_array = AttributeProto_AttributeType::AttributeProto_AttributeType_SPARSE_TENSORS, + graph_array = AttributeProto_AttributeType::AttributeProto_AttributeType_GRAPHS }; Attribute() = delete; - Attribute(const ONNX_NAMESPACE::AttributeProto& attribute_proto, + Attribute(const AttributeProto& attribute_proto, const std::string& model_dir, detail::MappedMemoryHandles mmap_cache) : m_attribute_proto{&attribute_proto}, @@ -285,7 +279,7 @@ class Attribute { return {std::begin(m_attribute_proto->strings()), std::end(m_attribute_proto->strings())}; } - /* explicit */ operator ONNX_NAMESPACE::AttributeProto_AttributeType() const { + /* explicit */ operator AttributeProto_AttributeType() const { return m_attribute_proto->type(); } @@ -337,11 +331,11 @@ class Attribute { ov::Any get_any() const; private: - const ONNX_NAMESPACE::AttributeProto* m_attribute_proto; + const AttributeProto* m_attribute_proto; std::string m_model_dir; detail::MappedMemoryHandles m_mmap_cache; }; -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/core/graph.cpp b/src/frontends/onnx/frontend/src/core/graph.cpp index 9ac431b1c1b46e..4807ca248b34bc 100644 --- a/src/frontends/onnx/frontend/src/core/graph.cpp +++ b/src/frontends/onnx/frontend/src/core/graph.cpp @@ -9,24 +9,25 @@ #include #include +#include "core/node.hpp" +#include "core/null_node.hpp" #include "core/transform.hpp" #include "core/value_info.hpp" #include "exceptions.hpp" #include "onnx_framework_node.hpp" -#include "onnx_import/core/node.hpp" -#include "onnx_import/core/null_node.hpp" #include "openvino/core/node.hpp" #include "openvino/frontend/exception.hpp" #include "openvino/frontend/onnx/extension/conversion.hpp" #include "openvino/frontend/onnx/node_context.hpp" #include "openvino/op/util/op_types.hpp" #include "utils/common.hpp" -#include "utils/legacy_conversion_extension.hpp" using namespace ov; +using namespace ::ONNX_NAMESPACE; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace detail { bool common_node_for_all_outputs(const ov::OutputVector& outputs) { const auto first_out_node = outputs.at(0).get_node(); @@ -38,7 +39,6 @@ bool common_node_for_all_outputs(const ov::OutputVector& outputs) { return ret; }; -OPENVINO_SUPPRESS_DEPRECATED_START OperatorsBridge register_extensions(OperatorsBridge& bridge, const std::vector& conversions) { for (const auto& extension : conversions) { @@ -46,45 +46,33 @@ OperatorsBridge register_extensions(OperatorsBridge& bridge, bridge.overwrite_operator( common_conv_ext->get_op_type(), "", - [common_conv_ext](const ngraph::onnx_import::Node& node) -> ov::OutputVector { + [common_conv_ext](const ov::frontend::onnx::Node& node) -> ov::OutputVector { return common_conv_ext->get_converter()(ov::frontend::onnx::NodeContext(node)); }); } else if (const auto onnx_conv_ext = std::dynamic_pointer_cast(extension)) { bridge.overwrite_operator(onnx_conv_ext->get_op_type(), onnx_conv_ext->get_domain(), - [onnx_conv_ext](const ngraph::onnx_import::Node& node) -> ov::OutputVector { + [onnx_conv_ext](const ov::frontend::onnx::Node& node) -> ov::OutputVector { return onnx_conv_ext->get_converter()(ov::frontend::onnx::NodeContext(node)); }); } } return bridge; } -OPENVINO_SUPPRESS_DEPRECATED_END OperatorsBridge init_ops_bridge(const std::vector& conversions) { - const auto legacy_conv_ext = std::find_if(std::begin(conversions), - std::end(conversions), - [](const ov::frontend::ConversionExtensionBase::Ptr& conv) { - return std::dynamic_pointer_cast(conv); - }); - if (legacy_conv_ext == std::end(conversions)) { // no legacy extensions used - OperatorsBridge bridge; - return register_extensions(bridge, conversions); - } else { // legacy extensions can be mixed with the new one - return register_extensions(std::dynamic_pointer_cast(*legacy_conv_ext)->ops_bridge(), - conversions); - } + OperatorsBridge bridge; + return register_extensions(bridge, conversions); } -Model::ModelOpSet build_model_opset(const ONNX_NAMESPACE::ModelProto& model_proto, const OperatorsBridge& ops_bridge) { +Model::ModelOpSet build_model_opset(const ModelProto& model_proto, const OperatorsBridge& ops_bridge) { // copy the opset imports from the ONNX model and sort them by their version in ascending order // this will make sure that multiple opset imports for the same domain will cause the largest // version to be used for this model, for example: // [{domain:"", version:11}, {domain:"", version:1} {domain:"", version:13}] ==> {domain:"", version:13} auto opset_imports = model_proto.opset_import(); - const auto sort_by_version_ascending = [](const ONNX_NAMESPACE::OperatorSetIdProto& lhs, - const ONNX_NAMESPACE::OperatorSetIdProto& rhs) { + const auto sort_by_version_ascending = [](const OperatorSetIdProto& lhs, const OperatorSetIdProto& rhs) { return lhs.version() < rhs.version(); }; std::sort(std::begin(opset_imports), std::end(opset_imports), sort_by_version_ascending); @@ -92,7 +80,7 @@ Model::ModelOpSet build_model_opset(const ONNX_NAMESPACE::ModelProto& model_prot Model::ModelOpSet opset; std::for_each(opset_imports.rbegin(), opset_imports.rend(), - [&opset, &ops_bridge](const ONNX_NAMESPACE::OperatorSetIdProto& onnx_opset) { + [&opset, &ops_bridge](const OperatorSetIdProto& onnx_opset) { const auto domain = onnx_opset.has_domain() ? onnx_opset.domain() == "ai.onnx" ? "" : onnx_opset.domain() : ""; if (opset.find(domain) == std::end(opset)) { @@ -122,13 +110,13 @@ ov::frontend::ExtensionHolder subgraph_required_extensions( } // namespace detail Graph::Graph(const std::string& model_dir, - const std::shared_ptr& model_proto, + const std::shared_ptr& model_proto, detail::MappedMemoryHandles mmap_cache, ov::frontend::ExtensionHolder extensions) : Graph(model_dir, model_proto, common::make_unique(), mmap_cache, std::move(extensions)) {} Graph::Graph(const std::string& model_dir, - const std::shared_ptr& model_proto, + const std::shared_ptr& model_proto, std::unique_ptr&& cache, detail::MappedMemoryHandles mmap_cache, ov::frontend::ExtensionHolder extensions) @@ -155,7 +143,7 @@ Graph::Graph(const std::string& model_dir, // invalid external data makes initializers creation impossible throw; } catch (const ov::Exception&) { - ov_constant = ngraph::onnx_import::common::make_failsafe_constant(tensor.get_ov_type()); + ov_constant = ov::frontend::onnx::common::make_failsafe_constant(tensor.get_ov_type()); } initializers.emplace(initializer_tensor.name(), tensor); @@ -177,7 +165,6 @@ Graph::Graph(const std::string& model_dir, } } -OPENVINO_SUPPRESS_DEPRECATED_START void Graph::convert_to_ov_nodes() { const float total = static_cast(m_model->get_graph().node().size()); unsigned int completed = 0u; @@ -209,16 +196,14 @@ void Graph::convert_to_ov_nodes() { } } } -OPENVINO_SUPPRESS_DEPRECATED_END void Graph::remove_dangling_parameters() { - const auto any_tensor_name_matches_onnx_output = [](const Output& param_output, - const ONNX_NAMESPACE::GraphProto& graph) { + const auto any_tensor_name_matches_onnx_output = [](const Output& param_output, const GraphProto& graph) { const auto found_in_outputs = [&graph](const std::string& tensor_name) { const auto& graph_outputs = graph.output(); return std::any_of(std::begin(graph_outputs), std::end(graph_outputs), - [&tensor_name](const ONNX_NAMESPACE::ValueInfoProto& output) { + [&tensor_name](const ValueInfoProto& output) { return tensor_name == output.name(); }); }; @@ -256,12 +241,11 @@ std::shared_ptr Graph::convert() { return function; } -OPENVINO_SUPPRESS_DEPRECATED_START ov::OutputVector Graph::make_framework_nodes(const Node& onnx_node) { - std::shared_ptr framework_node; + std::shared_ptr framework_node; if (onnx_node.has_subgraphs()) { const auto& subgraphs = onnx_node.get_subgraphs(); - auto inputs = onnx_node.get_ng_inputs(); + auto inputs = onnx_node.get_ov_inputs(); std::vector> models; for (const auto& kv : subgraphs) { auto& subgraph = kv.second; @@ -275,9 +259,9 @@ ov::OutputVector Graph::make_framework_nodes(const Node& onnx_node) { } } } - framework_node = std::make_shared(onnx_node, models, inputs); + framework_node = std::make_shared(onnx_node, models, inputs); } else { - framework_node = std::make_shared(onnx_node); + framework_node = std::make_shared(onnx_node); } return framework_node->outputs(); } @@ -309,7 +293,6 @@ void Graph::decode_to_framework_nodes() { } } } -OPENVINO_SUPPRESS_DEPRECATED_END std::shared_ptr Graph::create_model() { auto model = std::make_shared(get_ov_outputs(), m_parameters, get_name()); @@ -340,7 +323,6 @@ Output Graph::get_ov_node_from_cache(const std::string& name) { return m_cache->get_node(name); } -OPENVINO_SUPPRESS_DEPRECATED_START ov::OutputVector Graph::get_ov_outputs() { ov::OutputVector results; for (const auto& output : m_model->get_graph().output()) { @@ -360,7 +342,7 @@ ov::OutputVector Graph::make_ov_nodes(const Node& onnx_node) { const auto ng_node_factory = m_model->get_operator(onnx_node.op_type(), onnx_node.domain()); try { ov_subgraph_outputs = ng_node_factory(onnx_node); - } catch (const ::ngraph::onnx_import::error::OnnxNodeValidationFailure& e) { + } catch (const ::ov::frontend::onnx::error::OnnxNodeValidationFailure& e) { error_message = e.what(); } catch (const std::exception& exc) { error_message = error::detail::get_error_msg_prefix(onnx_node); @@ -373,11 +355,12 @@ ov::OutputVector Graph::make_ov_nodes(const Node& onnx_node) { } } if (ov_subgraph_outputs.empty()) { // translation not possible (not supported op or exception during processing) - const auto not_supported_node = std::make_shared(onnx_node.get_ng_inputs(), - onnx_node.get_outputs_size(), - onnx_node.domain(), - onnx_node.op_type(), - error_message); + const auto not_supported_node = + std::make_shared(onnx_node.get_ov_inputs(), + onnx_node.get_outputs_size(), + onnx_node.domain(), + onnx_node.op_type(), + error_message); ov_subgraph_outputs = not_supported_node->outputs(); } @@ -443,18 +426,19 @@ void Graph::set_friendly_names(const Node& onnx_node, const ov::OutputVector& ov // null node does not have tensor if (!ov::op::util::is_null(ov_subgraph_outputs[i])) { ov_subgraph_outputs[i].get_tensor().set_names({onnx_node.output(static_cast(i))}); + OPENVINO_SUPPRESS_DEPRECATED_START ov::descriptor::set_ov_tensor_legacy_name(ov_subgraph_outputs[i].get_tensor(), onnx_node.output(static_cast(i))); + OPENVINO_SUPPRESS_DEPRECATED_END } } } -OPENVINO_SUPPRESS_DEPRECATED_END const OpsetImports& Graph::get_opset_imports() const { return m_model->get_opset_imports(); } -Subgraph::Subgraph(const std::shared_ptr& model_proto, Graph* parent_graph) +Subgraph::Subgraph(const std::shared_ptr& model_proto, Graph* parent_graph) : Graph(parent_graph->model_dir(), model_proto, common::make_unique(), @@ -507,6 +491,6 @@ void Subgraph::infer_inputs_from_parent() { } } -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/core/graph.hpp b/src/frontends/onnx/frontend/src/core/graph.hpp index f848a98e3bab3f..4ee94f564c7e8d 100644 --- a/src/frontends/onnx/frontend/src/core/graph.hpp +++ b/src/frontends/onnx/frontend/src/core/graph.hpp @@ -12,19 +12,19 @@ #include "core/graph_cache.hpp" #include "core/model.hpp" -#include "onnx_import/core/operator_set.hpp" -#include "openvino/core/deprecated.hpp" +#include "core/operator_set.hpp" #include "openvino/frontend/extension/holder.hpp" #include "openvino/op/parameter.hpp" #include "ops_bridge.hpp" #include "utils/tensor_external_data.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { class Graph : public std::enable_shared_from_this { public: Graph(const std::string& model_dir, - const std::shared_ptr& model_proto, + const std::shared_ptr& model_proto, detail::MappedMemoryHandles mmap_cache, ov::frontend::ExtensionHolder extensions = {}); Graph() = delete; @@ -51,9 +51,9 @@ class Graph : public std::enable_shared_from_this { } virtual bool is_ov_node_in_cache(const std::string& name) const; virtual ov::Output get_ov_node_from_cache(const std::string& name); - OPENVINO_SUPPRESS_DEPRECATED_START - ov::OutputVector make_ov_nodes(const Node& onnx_node); - OPENVINO_SUPPRESS_DEPRECATED_END + + ov::OutputVector make_ov_nodes(const ov::frontend::onnx::Node& onnx_node); + const OpsetImports& get_opset_imports() const; virtual ~Graph() = default; @@ -63,19 +63,16 @@ class Graph : public std::enable_shared_from_this { protected: Graph(const std::string& model_dir, - const std::shared_ptr& model, + const std::shared_ptr& model, std::unique_ptr&& cache, detail::MappedMemoryHandles mmap_cache, ov::frontend::ExtensionHolder extensions = {}); - OPENVINO_SUPPRESS_DEPRECATED_START void set_friendly_names(const Node& onnx_node, const ov::OutputVector& ng_subgraph_outputs) const; - OPENVINO_SUPPRESS_DEPRECATED_END protected: - OPENVINO_SUPPRESS_DEPRECATED_START - ov::OutputVector make_framework_nodes(const Node& onnx_node); - OPENVINO_SUPPRESS_DEPRECATED_END + ov::OutputVector make_framework_nodes(const ov::frontend::onnx::Node& onnx_node); + void decode_to_framework_nodes(); void convert_to_ov_nodes(); void remove_dangling_parameters(); @@ -88,9 +85,8 @@ class Graph : public std::enable_shared_from_this { ov::frontend::ExtensionHolder m_extensions = {}; private: - OPENVINO_SUPPRESS_DEPRECATED_START std::vector m_nodes; - OPENVINO_SUPPRESS_DEPRECATED_END + std::string m_model_dir; detail::MappedMemoryHandles m_mmap_cache; OperatorsBridge m_ops_bridge; @@ -105,7 +101,7 @@ class Subgraph : public Graph { /// /// \param[in] model The ONNX model object. /// \param[in] parent_graph The reference to the parent graph. - Subgraph(const std::shared_ptr& model, Graph* parent_graph); + Subgraph(const std::shared_ptr& model, Graph* parent_graph); /// \brief Return nodes which are on the edge the subgraph and the parent graph. /// \return Vector of edge nodes from parent scope. @@ -137,6 +133,6 @@ inline std::ostream& operator<<(std::ostream& outs, const Graph& graph) { static const char* const ONNX_GRAPH_RT_ATTRIBUTE = "onnx_graph"; -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/core/graph_cache.cpp b/src/frontends/onnx/frontend/src/core/graph_cache.cpp index 8ef624c76da4fa..ec686da8ae07d5 100644 --- a/src/frontends/onnx/frontend/src/core/graph_cache.cpp +++ b/src/frontends/onnx/frontend/src/core/graph_cache.cpp @@ -6,8 +6,9 @@ #include "openvino/core/except.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { void GraphCache::emplace_node(const std::string& name, ov::Output&& node) { m_graph_cache_map[name] = std::move(node); } @@ -30,5 +31,6 @@ ov::Output GraphCache::get_node(const std::string& name) const { bool GraphCache::contains(const std::string& name) const { return (m_graph_cache_map.count(name) > 0); } -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/core/graph_cache.hpp b/src/frontends/onnx/frontend/src/core/graph_cache.hpp index fe021e64289dfc..c706fed7a3674a 100644 --- a/src/frontends/onnx/frontend/src/core/graph_cache.hpp +++ b/src/frontends/onnx/frontend/src/core/graph_cache.hpp @@ -10,8 +10,9 @@ #include "openvino/core/node.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { /// \brief GraphCache stores and provides access to ONNX graph initializers. class GraphCache { public: @@ -49,5 +50,6 @@ class GraphCache { private: std::map> m_graph_cache_map; }; -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/core/model.cpp b/src/frontends/onnx/frontend/src/core/model.cpp index 3e59a7edaf599f..32f5d21991259e 100644 --- a/src/frontends/onnx/frontend/src/core/model.cpp +++ b/src/frontends/onnx/frontend/src/core/model.cpp @@ -10,19 +10,22 @@ #include "openvino/util/log.hpp" #include "ops_bridge.hpp" -namespace ngraph { -namespace onnx_import { -std::string get_node_domain(const ONNX_NAMESPACE::NodeProto& node_proto) { +using namespace ::ONNX_NAMESPACE; + +namespace ov { +namespace frontend { +namespace onnx { +std::string get_node_domain(const NodeProto& node_proto) { return node_proto.has_domain() ? node_proto.domain() : ""; } -std::int64_t get_opset_version(const ONNX_NAMESPACE::ModelProto& model_proto, const std::string& domain) { +std::int64_t get_opset_version(const ModelProto& model_proto, const std::string& domain) { // copy the opsets and sort them (descending order) // then return the version from the first occurrence of a given domain auto opset_imports = model_proto.opset_import(); std::sort(std::begin(opset_imports), std::end(opset_imports), - [](const ONNX_NAMESPACE::OperatorSetIdProto& lhs, const ONNX_NAMESPACE::OperatorSetIdProto& rhs) { + [](const OperatorSetIdProto& lhs, const OperatorSetIdProto& rhs) { return lhs.version() > rhs.version(); }); @@ -35,7 +38,7 @@ std::int64_t get_opset_version(const ONNX_NAMESPACE::ModelProto& model_proto, co OPENVINO_THROW("Couldn't find operator set's version for domain: ", domain, "."); } -Model::Model(std::shared_ptr model_proto, ModelOpSet&& model_opset) +Model::Model(std::shared_ptr model_proto, ModelOpSet&& model_opset) : m_model_proto{std::move(model_proto)}, m_opset{std::move(model_opset)} {} @@ -76,6 +79,6 @@ void Model::enable_opset_domain(const std::string& domain, const OperatorsBridge } } -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/core/model.hpp b/src/frontends/onnx/frontend/src/core/model.hpp index 148c9f867b8c64..189fc3fbc2b15b 100644 --- a/src/frontends/onnx/frontend/src/core/model.hpp +++ b/src/frontends/onnx/frontend/src/core/model.hpp @@ -10,16 +10,22 @@ #include #include -#include "onnx_import/core/operator_set.hpp" +#include "core/operator_set.hpp" + +namespace ov { +namespace frontend { +namespace onnx { +using ::ONNX_NAMESPACE::GraphProto; +using ::ONNX_NAMESPACE::ModelProto; +using ::ONNX_NAMESPACE::NodeProto; +using ::ONNX_NAMESPACE::OperatorSetIdProto; -namespace ngraph { -namespace onnx_import { /// \brief Type of container which stores opset version and domain in ONNX format -using OpsetImports = ::google::protobuf::RepeatedPtrField; +using OpsetImports = ::google::protobuf::RepeatedPtrField; -std::string get_node_domain(const ONNX_NAMESPACE::NodeProto& node_proto); +std::string get_node_domain(const NodeProto& node_proto); -std::int64_t get_opset_version(const ONNX_NAMESPACE::ModelProto& model_proto, const std::string& domain); +std::int64_t get_opset_version(const ModelProto& model_proto, const std::string& domain); class OperatorsBridge; @@ -29,7 +35,7 @@ class Model { // built based on the opset imports in the ModelProto object using ModelOpSet = std::unordered_map; - explicit Model(std::shared_ptr model_proto, ModelOpSet&& model_opset); + explicit Model(std::shared_ptr model_proto, ModelOpSet&& model_opset); Model(const Model&) = delete; Model(Model&&) = delete; @@ -40,7 +46,7 @@ class Model { const std::string& get_producer_name() const { return m_model_proto->producer_name(); } - const ONNX_NAMESPACE::GraphProto& get_graph() const { + const GraphProto& get_graph() const { return m_model_proto->graph(); } std::int64_t get_model_version() const { @@ -92,7 +98,7 @@ class Model { void enable_opset_domain(const std::string& domain, const OperatorsBridge& ops_bridge); private: - const std::shared_ptr m_model_proto; + const std::shared_ptr m_model_proto; ModelOpSet m_opset; }; @@ -100,6 +106,6 @@ inline std::ostream& operator<<(std::ostream& outs, const Model& model) { return (outs << ""); } -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/core/node.cpp b/src/frontends/onnx/frontend/src/core/node.cpp index ff87ff9cc36899..ed2195e64d9415 100644 --- a/src/frontends/onnx/frontend/src/core/node.cpp +++ b/src/frontends/onnx/frontend/src/core/node.cpp @@ -1,23 +1,24 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include #include "core/attribute.hpp" #include "core/graph.hpp" +#include "core/null_node.hpp" #include "core/tensor.hpp" -#include "onnx_import/core/null_node.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { class Node::Impl { public: Impl() = delete; - Impl(const ONNX_NAMESPACE::NodeProto& node_proto, Graph* graph) + Impl(const NodeProto& node_proto, Graph* graph) : m_node_proto{&node_proto}, m_name{node_proto.has_name() ? node_proto.name() : ""}, m_domain{get_node_domain(node_proto)}, @@ -33,7 +34,7 @@ class Node::Impl { } } - Impl(const ONNX_NAMESPACE::NodeProto& node_proto, + Impl(const NodeProto& node_proto, Graph* graph, const std::unordered_map>& subgraphs) : m_node_proto{&node_proto}, @@ -48,7 +49,7 @@ class Node::Impl { } const std::vector& attributes() const; - ov::OutputVector get_ng_inputs() const; + ov::OutputVector get_ov_inputs() const; const std::string& domain() const; const std::string& op_type() const; @@ -87,13 +88,13 @@ class Node::Impl { T default_value, ov::element::Type type) const; - const ONNX_NAMESPACE::NodeProto& node_proto() const; + const NodeProto& node_proto() const; Graph* graph() const; private: Subgraph get_subgraph_from_attribute(const std::string& name) const; - const ONNX_NAMESPACE::NodeProto* m_node_proto; + const NodeProto* m_node_proto; std::string m_name; std::string m_domain; Graph* m_graph; @@ -104,8 +105,7 @@ class Node::Impl { std::unordered_map> m_subgraphs; }; -OPENVINO_SUPPRESS_DEPRECATED_START -const ONNX_NAMESPACE::NodeProto& Node::Impl::node_proto() const { +const NodeProto& Node::Impl::node_proto() const { return *m_node_proto; } Graph* Node::Impl::graph() const { @@ -200,15 +200,13 @@ ov::Any Node::get_attribute_value(const std::string& name) const { return get_attribute(name).get_any(); } -ov::OutputVector Node::Impl::get_ng_inputs() const { +ov::OutputVector Node::Impl::get_ov_inputs() const { ov::OutputVector result; for (const auto& name : m_node_proto->input()) { if (!name.empty()) { result.push_back(m_graph->get_ov_node_from_cache(name)); } else { - OPENVINO_SUPPRESS_DEPRECATED_START result.push_back(std::make_shared()->output(0)); - OPENVINO_SUPPRESS_DEPRECATED_END } } return result; @@ -231,7 +229,7 @@ template std::shared_ptr Node::Impl::get_attribute_as_constant(const std::string& name) const { const auto value = get_attribute_value(name); const ov::element::Type type = ov::element::from(); - return std::make_shared(type, Shape{}, value); + return std::make_shared(type, ov::Shape{}, value); } template @@ -239,7 +237,7 @@ std::shared_ptr Node::Impl::get_attribute_as_constant(cons T default_value) const { const auto value = get_attribute_value(name, default_value); const ov::element::Type type = ov::element::from(); - return std::make_shared(type, Shape{}, value); + return std::make_shared(type, ov::Shape{}, value); } template @@ -248,7 +246,7 @@ std::shared_ptr Node::Impl::get_attribute_as_constant(cons ov::element::Type type) const { const auto value = get_attribute_value(name, default_value); return std::make_shared(type == ov::element::undefined ? ov::element::from() : type, - Shape{}, + ov::Shape{}, value); } @@ -257,7 +255,7 @@ std::shared_ptr Node::Impl::get_attribute_as_constant(cons ov::element::Type type) const { const auto value = get_attribute_value(name); return std::make_shared(type == ov::element::undefined ? ov::element::from() : type, - Shape{}, + ov::Shape{}, value); } @@ -295,7 +293,7 @@ std::shared_ptr Node::Impl::get_attribute_as_constant(cons value); } -Node::Node(const ONNX_NAMESPACE::NodeProto& node_proto, Graph* graph) +Node::Node(const NodeProto& node_proto, Graph* graph) : m_pimpl{new Impl{node_proto, graph}, [](Impl* impl) { delete impl; }} {} @@ -307,8 +305,8 @@ Node::Node(const Node& other) delete impl; }} {} -ov::OutputVector Node::get_ng_inputs() const { - return m_pimpl->get_ng_inputs(); +ov::OutputVector Node::get_ov_inputs() const { + return m_pimpl->get_ov_inputs(); } const std::string& Node::domain() const { return m_pimpl->domain(); @@ -377,7 +375,6 @@ const Attribute& Node::get_attribute(const std::string& name) const { } return *found_attr; } -OPENVINO_SUPPRESS_DEPRECATED_END template <> float Node::get_attribute_value(const std::string& name, float default_value) const { @@ -638,6 +635,6 @@ std::shared_ptr Node::get_attribute_as_constant(const std: std::move(type)); } -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/core/node.hpp b/src/frontends/onnx/frontend/src/core/node.hpp new file mode 100644 index 00000000000000..c6083900337f23 --- /dev/null +++ b/src/frontends/onnx/frontend/src/core/node.hpp @@ -0,0 +1,285 @@ +// Copyright (C) 2018-2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include + +#include "openvino/core/deprecated.hpp" +#include "openvino/core/except.hpp" +#include "openvino/core/node.hpp" +#include "openvino/op/constant.hpp" + +namespace ONNX_NAMESPACE { +// forward declaration +class NodeProto; +} // namespace ONNX_NAMESPACE + +namespace ov { +namespace frontend { +namespace onnx { +namespace error { +namespace node { +struct UnknownAttribute : ov::Exception { + OPENVINO_SUPPRESS_DEPRECATED_START + explicit UnknownAttribute(const std::string& node, const std::string& name) + : ov::Exception{"Node (" + node + "): unknown attribute \'" + name + "\'"} {} + OPENVINO_SUPPRESS_DEPRECATED_END +}; + +} // namespace node +} // namespace error + +// forward declaration +class Graph; +class Subgraph; +class Tensor; +class SparseTensor; +class Attribute; + +using ::ONNX_NAMESPACE::NodeProto; + +class Node { +public: + Node() = delete; + // TODO: hide this ctor since it uses protobufs generated structures + Node(const NodeProto& node_proto, Graph* graph); + + Node(Node&&) noexcept; + Node(const Node&); + + Node& operator=(Node&&) noexcept = delete; + Node& operator=(const Node&) = delete; + + ov::OutputVector get_ov_inputs() const; + const std::string& domain() const; + const std::string& op_type() const; + const std::string& get_name() const; + std::vector get_attribute_names() const; + const Attribute& get_attribute(const std::string& name) const; + + /// \brief Describe the ONNX Node to make debugging graphs easier + /// Function will return the Node's name if it has one, or the names of its outputs. + /// \return Description of Node + const std::string& get_description() const; + + const std::string& input(int index) const; + std::size_t get_inputs_size() const; + + const std::vector>& get_output_names() const; + const std::string& output(int index) const; + std::size_t get_outputs_size() const; + + bool has_attribute(const std::string& name) const; + + bool has_subgraphs() const; + const std::unordered_map>& get_subgraphs() const; + + template + T get_attribute_value(const std::string& name, T default_value) const; + + template + T get_attribute_value(const std::string& name) const; + + template + std::shared_ptr get_attribute_as_constant(const std::string& name) const; + + template + std::shared_ptr get_attribute_as_constant(const std::string& name, + ov::element::Type type) const; + + template + std::shared_ptr get_attribute_as_constant(const std::string& name, T default_value) const; + + template + std::shared_ptr get_attribute_as_constant(const std::string& name, + T default_value, + ov::element::Type type) const; + +private: + class Impl; + // In this case we need custom deleter, because Impl is an incomplete + // type. Node's are elements of std::vector. Without custom deleter + // compilation fails; the compiler is unable to parameterize an allocator's + // default deleter due to incomple type. + std::unique_ptr m_pimpl; +}; + +template <> +float Node::get_attribute_value(const std::string& name, float default_value) const; + +template <> +double Node::get_attribute_value(const std::string& name, double default_value) const; + +template <> +std::int64_t Node::get_attribute_value(const std::string& name, std::int64_t default_value) const; + +template <> +std::string Node::get_attribute_value(const std::string& name, std::string default_value) const; + +template <> +Tensor Node::get_attribute_value(const std::string& name, Tensor default_value) const; + +template <> +SparseTensor Node::get_attribute_value(const std::string& name, SparseTensor default_value) const; + +template <> +Graph Node::get_attribute_value(const std::string& name, Graph default_value) const; + +template <> +std::vector Node::get_attribute_value(const std::string& name, std::vector default_value) const; + +template <> +std::vector Node::get_attribute_value(const std::string& name, std::vector default_value) const; + +template <> +std::vector Node::get_attribute_value(const std::string& name, + std::vector default_value) const; + +template <> +std::vector Node::get_attribute_value(const std::string& name, + std::vector default_value) const; + +template <> +std::vector Node::get_attribute_value(const std::string& name, + std::vector default_value) const; + +template <> +std::vector Node::get_attribute_value(const std::string& name, std::vector default_value) const; + +template <> +std::vector Node::get_attribute_value(const std::string& name, + std::vector default_value) const; + +template <> +std::vector Node::get_attribute_value(const std::string& name, std::vector default_value) const; + +template <> +float Node::get_attribute_value(const std::string& name) const; + +template <> +double Node::get_attribute_value(const std::string& name) const; + +template <> +std::int64_t Node::get_attribute_value(const std::string& name) const; + +template <> +std::size_t Node::get_attribute_value(const std::string& name) const; + +template <> +std::string Node::get_attribute_value(const std::string& name) const; + +template <> +Tensor Node::get_attribute_value(const std::string& name) const; + +template <> +SparseTensor Node::get_attribute_value(const std::string& name) const; + +template <> +Subgraph Node::get_attribute_value(const std::string& name) const; + +template <> +std::vector Node::get_attribute_value(const std::string& name) const; + +template <> +std::vector Node::get_attribute_value(const std::string& name) const; + +template <> +std::vector Node::get_attribute_value(const std::string& name) const; + +template <> +std::vector Node::get_attribute_value(const std::string& name) const; + +template <> +std::vector Node::get_attribute_value(const std::string& name) const; + +template <> +std::vector Node::get_attribute_value(const std::string& name) const; + +template <> +std::vector Node::get_attribute_value(const std::string& name) const; + +template <> +std::vector Node::get_attribute_value(const std::string& name) const; + +template <> +std::shared_ptr Node::get_attribute_as_constant>( + const std::string& name) const; + +template <> +std::shared_ptr Node::get_attribute_as_constant>( + const std::string& name, + ov::element::Type type) const; + +template <> +std::shared_ptr Node::get_attribute_as_constant(const std::string& name, + std::vector default_value) const; + +template <> +std::shared_ptr Node::get_attribute_as_constant(const std::string& name, + std::vector default_value, + ov::element::Type type) const; + +template <> +std::shared_ptr Node::get_attribute_as_constant(const std::string& name) const; + +template <> +std::shared_ptr Node::get_attribute_as_constant(const std::string& name, + float default_value) const; + +template <> +std::shared_ptr Node::get_attribute_as_constant(const std::string& name, + float default_value, + ov::element::Type type) const; + +template <> +std::shared_ptr Node::get_attribute_as_constant(const std::string& name, + ov::element::Type type) const; + +template <> +std::shared_ptr Node::get_attribute_as_constant(const std::string& name) const; + +template <> +std::shared_ptr Node::get_attribute_as_constant(const std::string& name, + double default_value) const; + +template <> +std::shared_ptr Node::get_attribute_as_constant(const std::string& name, + ov::element::Type type) const; + +template <> +std::shared_ptr Node::get_attribute_as_constant(const std::string& name, + double default_value, + ov::element::Type type) const; + +template <> +std::shared_ptr Node::get_attribute_as_constant(const std::string& name) const; + +template <> +std::shared_ptr Node::get_attribute_as_constant(const std::string& name, + ov::element::Type type) const; + +template <> +std::shared_ptr Node::get_attribute_as_constant(const std::string& name, + int64_t default_value) const; + +template <> +std::shared_ptr Node::get_attribute_as_constant(const std::string& name, + ov::element::Type type) const; + +template <> +std::shared_ptr Node::get_attribute_as_constant(const std::string& name, + int64_t default_value, + ov::element::Type type) const; + +OPENVINO_SUPPRESS_DEPRECATED_START +inline std::ostream& operator<<(std::ostream& outs, const Node& node) { + return (outs << ""); +} +OPENVINO_SUPPRESS_DEPRECATED_END + +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/core/null_node.cpp b/src/frontends/onnx/frontend/src/core/null_node.cpp index 78131c4f85e8b5..e95a2255c782bf 100644 --- a/src/frontends/onnx/frontend/src/core/null_node.cpp +++ b/src/frontends/onnx/frontend/src/core/null_node.cpp @@ -2,24 +2,24 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "onnx_import/core/null_node.hpp" +#include "core/null_node.hpp" #include -#include "openvino/core/deprecated.hpp" #include "openvino/core/node.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { std::shared_ptr NullNode::clone_with_new_inputs(const ov::OutputVector& /* new_args */) const { return std::make_shared(); } -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov bool ov::op::util::is_null(const ov::Node* node) { - return dynamic_cast(node) != nullptr; + return dynamic_cast(node) != nullptr; } bool ov::op::util::is_null(const std::shared_ptr& node) { @@ -29,4 +29,3 @@ bool ov::op::util::is_null(const std::shared_ptr& node) { bool ov::op::util::is_null(const Output& output) { return is_null(output.get_node()); } -OPENVINO_SUPPRESS_DEPRECATED_END diff --git a/src/frontends/onnx/frontend/include/onnx_import/core/null_node.hpp b/src/frontends/onnx/frontend/src/core/null_node.hpp similarity index 89% rename from src/frontends/onnx/frontend/include/onnx_import/core/null_node.hpp rename to src/frontends/onnx/frontend/src/core/null_node.hpp index 484540b3d67360..c1e59b476cecba 100644 --- a/src/frontends/onnx/frontend/include/onnx_import/core/null_node.hpp +++ b/src/frontends/onnx/frontend/src/core/null_node.hpp @@ -4,6 +4,7 @@ #pragma once +#include "openvino/core/node.hpp" #include "openvino/op/op.hpp" namespace ov { @@ -14,9 +15,9 @@ bool is_null(const std::shared_ptr& node); bool is_null(const Output& output); } // namespace util } // namespace op -} // namespace ov -namespace ngraph { -namespace onnx_import { + +namespace frontend { +namespace onnx { /// \brief Represents a missing optional input or output of an ONNX node /// /// Some ONNX operators have inputs or outputs that are marked as optional, @@ -35,5 +36,6 @@ class NullNode : public ov::op::Op { virtual std::shared_ptr clone_with_new_inputs(const ov::OutputVector& new_args) const override; }; -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/include/onnx_import/core/operator_set.hpp b/src/frontends/onnx/frontend/src/core/operator_set.hpp similarity index 61% rename from src/frontends/onnx/frontend/include/onnx_import/core/operator_set.hpp rename to src/frontends/onnx/frontend/src/core/operator_set.hpp index 9fd2bb842045e6..60032edd133833 100644 --- a/src/frontends/onnx/frontend/include/onnx_import/core/operator_set.hpp +++ b/src/frontends/onnx/frontend/src/core/operator_set.hpp @@ -8,18 +8,18 @@ #include #include -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { /// \brief Function which transforms single ONNX operator to nGraph sub-graph. -OPENVINO_SUPPRESS_DEPRECATED_START -using Operator = std::function; -OPENVINO_SUPPRESS_DEPRECATED_END + +using Operator = std::function; /// \brief Map which contains ONNX operators accessible by std::string value as a key. using OperatorSet = std::unordered_map; -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/core/sparse_tensor.hpp b/src/frontends/onnx/frontend/src/core/sparse_tensor.hpp index 55c3c792cf50df..dc6845249a847f 100644 --- a/src/frontends/onnx/frontend/src/core/sparse_tensor.hpp +++ b/src/frontends/onnx/frontend/src/core/sparse_tensor.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -12,22 +12,25 @@ #include "openvino/core/type/element_type.hpp" #include "tensor.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { +using ::ONNX_NAMESPACE::SparseTensorProto; + class SparseTensor { public: SparseTensor() = delete; - SparseTensor(const ONNX_NAMESPACE::SparseTensorProto& sparse_tensor, + SparseTensor(const SparseTensorProto& sparse_tensor, const std::string& model_dir, detail::MappedMemoryHandles mmap_cache) : m_values{sparse_tensor.values(), model_dir, mmap_cache}, m_indices{sparse_tensor.indices(), model_dir, mmap_cache}, m_shape{std::begin(sparse_tensor.dims()), std::end(sparse_tensor.dims())} { - if (m_shape == Shape{0}) { + if (m_shape == ov::Shape{0}) { // It's possible to construct a sparse tensor in ONNX with "dims: 0" property - // Such tensor contains a scalar. This results in a Shape{0} stored in m_shape. - // In OpenVINO a scalar is represented with Shape{} and thus this replacement. - m_shape = Shape{}; + // Such tensor contains a scalar. This results in a ov::Shape{0} stored in m_shape. + // In OpenVINO a scalar is represented with ov::Shape{} and thus this replacement. + m_shape = ov::Shape{}; } } @@ -37,7 +40,7 @@ class SparseTensor { SparseTensor& operator=(const SparseTensor&) = delete; SparseTensor& operator=(SparseTensor&&) = delete; - const Shape& get_shape() const { + const ov::Shape& get_shape() const { return m_shape; } @@ -60,11 +63,12 @@ class SparseTensor { private: Tensor m_values; Tensor m_indices; - Shape m_shape; + ov::Shape m_shape; }; inline std::ostream& operator<<(std::ostream& outs, const SparseTensor& tensor) { return (outs << ""); } -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/core/tensor.cpp b/src/frontends/onnx/frontend/src/core/tensor.cpp index e5caa078716963..75d95f0dd56db6 100644 --- a/src/frontends/onnx/frontend/src/core/tensor.cpp +++ b/src/frontends/onnx/frontend/src/core/tensor.cpp @@ -4,8 +4,9 @@ #include "core/tensor.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { template <> std::vector Tensor::get_data() const { @@ -15,7 +16,7 @@ std::vector Tensor::get_data() const { if (m_tensor_proto->has_raw_data()) { return detail::__get_raw_data(m_tensor_proto->raw_data(), m_tensor_proto->data_type()); } - if (m_tensor_proto->data_type() == ONNX_NAMESPACE::TensorProto_DataType_DOUBLE) { + if (m_tensor_proto->data_type() == TensorProto_DataType::TensorProto_DataType_DOUBLE) { return detail::__get_data(m_tensor_proto->double_data()); } ONNX_INVALID_DATA_TYPE(m_tensor_proto->data_type(), "DOUBLE, raw data"); @@ -29,7 +30,7 @@ std::vector Tensor::get_data() const { if (m_tensor_proto->has_raw_data()) { return detail::__get_raw_data(m_tensor_proto->raw_data(), m_tensor_proto->data_type()); } - if (m_tensor_proto->data_type() == ONNX_NAMESPACE::TensorProto_DataType_FLOAT) { + if (m_tensor_proto->data_type() == TensorProto_DataType::TensorProto_DataType_FLOAT) { return detail::__get_data(m_tensor_proto->float_data()); } ONNX_INVALID_DATA_TYPE(m_tensor_proto->data_type(), "FLOAT, raw data"); @@ -43,7 +44,7 @@ std::vector Tensor::get_data() const { if (m_tensor_proto->has_raw_data()) { return detail::__get_raw_data(m_tensor_proto->raw_data(), m_tensor_proto->data_type()); } - if (m_tensor_proto->data_type() == ONNX_NAMESPACE::TensorProto_DataType_FLOAT16) { + if (m_tensor_proto->data_type() == TensorProto_DataType::TensorProto_DataType_FLOAT16) { using std::begin; using std::end; @@ -67,7 +68,7 @@ std::vector Tensor::get_data() const { if (m_tensor_proto->has_raw_data()) { return detail::__get_raw_data(m_tensor_proto->raw_data(), m_tensor_proto->data_type()); } - if (m_tensor_proto->data_type() == ONNX_NAMESPACE::TensorProto_DataType_BFLOAT16) { + if (m_tensor_proto->data_type() == TensorProto_DataType::TensorProto_DataType_BFLOAT16) { return detail::__get_data(m_tensor_proto->int32_data()); } ONNX_INVALID_DATA_TYPE(m_tensor_proto->data_type(), "INT32, raw data"); @@ -81,7 +82,7 @@ std::vector Tensor::get_data() const { if (m_tensor_proto->has_raw_data()) { return detail::__get_raw_data(m_tensor_proto->raw_data(), m_tensor_proto->data_type()); } - if (m_tensor_proto->data_type() == ONNX_NAMESPACE::TensorProto_DataType_INT8) { + if (m_tensor_proto->data_type() == TensorProto_DataType::TensorProto_DataType_INT8) { return detail::__get_data(m_tensor_proto->int32_data()); } ONNX_INVALID_DATA_TYPE(m_tensor_proto->data_type(), "INT8, raw data"); @@ -95,7 +96,7 @@ std::vector Tensor::get_data() const { if (m_tensor_proto->has_raw_data()) { return detail::__get_raw_data(m_tensor_proto->raw_data(), m_tensor_proto->data_type()); } - if (m_tensor_proto->data_type() == ONNX_NAMESPACE::TensorProto_DataType_INT16) { + if (m_tensor_proto->data_type() == TensorProto_DataType::TensorProto_DataType_INT16) { return detail::__get_data(m_tensor_proto->int32_data()); } ONNX_INVALID_DATA_TYPE(m_tensor_proto->data_type(), "INT16, raw data"); @@ -109,7 +110,7 @@ std::vector Tensor::get_data() const { if (m_tensor_proto->has_raw_data()) { return detail::__get_raw_data(m_tensor_proto->raw_data(), m_tensor_proto->data_type()); } - if (m_tensor_proto->data_type() == ONNX_NAMESPACE::TensorProto_DataType_INT32) { + if (m_tensor_proto->data_type() == TensorProto_DataType::TensorProto_DataType_INT32) { return detail::__get_data(m_tensor_proto->int32_data()); } ONNX_INVALID_DATA_TYPE(m_tensor_proto->data_type(), "INT32, raw data"); @@ -123,7 +124,7 @@ std::vector Tensor::get_data() const { if (m_tensor_proto->has_raw_data()) { return detail::__get_raw_data(m_tensor_proto->raw_data(), m_tensor_proto->data_type()); } - if (m_tensor_proto->data_type() == ONNX_NAMESPACE::TensorProto_DataType_INT64) { + if (m_tensor_proto->data_type() == TensorProto_DataType::TensorProto_DataType_INT64) { return detail::__get_data(m_tensor_proto->int64_data()); } ONNX_INVALID_DATA_TYPE(m_tensor_proto->data_type(), "INT64, raw data"); @@ -137,7 +138,7 @@ std::vector Tensor::get_data() const { if (m_tensor_proto->has_raw_data()) { return detail::__get_raw_data(m_tensor_proto->raw_data(), m_tensor_proto->data_type()); } - if (m_tensor_proto->data_type() == ONNX_NAMESPACE::TensorProto_DataType_UINT8) { + if (m_tensor_proto->data_type() == TensorProto_DataType::TensorProto_DataType_UINT8) { return detail::__get_data(m_tensor_proto->int32_data()); } ONNX_INVALID_DATA_TYPE(m_tensor_proto->data_type(), "UINT8, raw data"); @@ -151,7 +152,7 @@ std::vector Tensor::get_data() const { if (m_tensor_proto->has_raw_data()) { return detail::__get_raw_data(m_tensor_proto->raw_data(), m_tensor_proto->data_type()); } - if (m_tensor_proto->data_type() == ONNX_NAMESPACE::TensorProto_DataType_UINT16) { + if (m_tensor_proto->data_type() == TensorProto_DataType::TensorProto_DataType_UINT16) { return detail::__get_data(m_tensor_proto->int32_data()); } ONNX_INVALID_DATA_TYPE(m_tensor_proto->data_type(), "UINT16, raw data"); @@ -165,7 +166,7 @@ std::vector Tensor::get_data() const { if (m_tensor_proto->has_raw_data()) { return detail::__get_raw_data(m_tensor_proto->raw_data(), m_tensor_proto->data_type()); } - if (m_tensor_proto->data_type() == ONNX_NAMESPACE::TensorProto_DataType_UINT32) { + if (m_tensor_proto->data_type() == TensorProto_DataType::TensorProto_DataType_UINT32) { return detail::__get_data(m_tensor_proto->uint64_data()); } ONNX_INVALID_DATA_TYPE(m_tensor_proto->data_type(), "UINT32, raw data"); @@ -179,7 +180,7 @@ std::vector Tensor::get_data() const { if (m_tensor_proto->has_raw_data()) { return detail::__get_raw_data(m_tensor_proto->raw_data(), m_tensor_proto->data_type()); } - if (m_tensor_proto->data_type() == ONNX_NAMESPACE::TensorProto_DataType_UINT64) { + if (m_tensor_proto->data_type() == TensorProto_DataType::TensorProto_DataType_UINT64) { return detail::__get_data(m_tensor_proto->uint64_data()); } ONNX_INVALID_DATA_TYPE(m_tensor_proto->data_type(), "UINT63, raw data"); @@ -195,11 +196,12 @@ std::vector Tensor::get_data() const { if (m_tensor_proto->has_raw_data()) { return detail::__get_raw_data(m_tensor_proto->raw_data(), m_tensor_proto->data_type()); } - if (m_tensor_proto->data_type() == ONNX_NAMESPACE::TensorProto_DataType_BOOL) { + if (m_tensor_proto->data_type() == TensorProto_DataType::TensorProto_DataType_BOOL) { return detail::__get_data(m_tensor_proto->int32_data()); } ONNX_INVALID_DATA_TYPE(m_tensor_proto->data_type(), "BOOL, raw data"); } -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/core/tensor.hpp b/src/frontends/onnx/frontend/src/core/tensor.hpp index 502211cb03f9df..67f5fbbb1a08f0 100644 --- a/src/frontends/onnx/frontend/src/core/tensor.hpp +++ b/src/frontends/onnx/frontend/src/core/tensor.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -21,22 +21,19 @@ using namespace ov::frontend::onnx::common; -namespace ngraph { -namespace onnx_import { -// Detecting automatically the underlying type used to store the information -// for data type of values a tensor is holding. A bug was discovered in protobuf -// which forced ONNX team to switch from `enum TensorProto_DataType` to `int32` -// in order to workaround the bug. This line allows using both versions of ONNX -// generated wrappers. -using TensorProto_DataType = decltype(ONNX_NAMESPACE::TensorProto{}.data_type()); +namespace ov { +namespace frontend { +namespace onnx { + +using ::ONNX_NAMESPACE::TensorProto; +using ::ONNX_NAMESPACE::TensorProto_DataLocation; +using ::ONNX_NAMESPACE::TensorProto_DataType; +using ::ONNX_NAMESPACE::TensorProto_DataType_Name; #define ONNX_INVALID_DATA_TYPE(data_type, expected) \ - OPENVINO_THROW("Invalid data type ", ONNX_NAMESPACE::TensorProto_DataType_Name(data_type), " expected: ", expected) -#define ONNX_UNSUPPORTED_DATA_TYPE(data_type, expected) \ - OPENVINO_THROW("Unsupported data type ", \ - ONNX_NAMESPACE::TensorProto_DataType_Name(data_type), \ - " expected: ", \ - expected) + OPENVINO_THROW("Invalid data type ", TensorProto_DataType_Name(data_type), " expected: ", expected) +#define ONNX_UNSUPPORTED_DATA_TYPE(data_type, expected) \ + OPENVINO_THROW("Unsupported data type ", TensorProto_DataType_Name(data_type), " expected: ", expected) namespace detail { namespace { @@ -65,38 +62,36 @@ inline std::vector __get_raw_data(const std::string& raw_data, int onnx_data_ class Tensor { public: enum class Type { - undefined = ONNX_NAMESPACE::TensorProto_DataType_UNDEFINED, - float32 = ONNX_NAMESPACE::TensorProto_DataType_FLOAT, - uint8 = ONNX_NAMESPACE::TensorProto_DataType_UINT8, - int8 = ONNX_NAMESPACE::TensorProto_DataType_INT8, - uint16 = ONNX_NAMESPACE::TensorProto_DataType_UINT16, - int16 = ONNX_NAMESPACE::TensorProto_DataType_INT16, - int32 = ONNX_NAMESPACE::TensorProto_DataType_INT32, - int64 = ONNX_NAMESPACE::TensorProto_DataType_INT64, - string = ONNX_NAMESPACE::TensorProto_DataType_STRING, - boolean = ONNX_NAMESPACE::TensorProto_DataType_BOOL, - float16 = ONNX_NAMESPACE::TensorProto_DataType_FLOAT16, - float64 = ONNX_NAMESPACE::TensorProto_DataType_DOUBLE, - uint32 = ONNX_NAMESPACE::TensorProto_DataType_UINT32, - uint64 = ONNX_NAMESPACE::TensorProto_DataType_UINT64, - bfloat16 = ONNX_NAMESPACE::TensorProto_DataType_BFLOAT16, - complex64 = ONNX_NAMESPACE::TensorProto_DataType_COMPLEX64, - complex128 = ONNX_NAMESPACE::TensorProto_DataType_COMPLEX128 + undefined = TensorProto_DataType::TensorProto_DataType_UNDEFINED, + float32 = TensorProto_DataType::TensorProto_DataType_FLOAT, + uint8 = TensorProto_DataType::TensorProto_DataType_UINT8, + int8 = TensorProto_DataType::TensorProto_DataType_INT8, + uint16 = TensorProto_DataType::TensorProto_DataType_UINT16, + int16 = TensorProto_DataType::TensorProto_DataType_INT16, + int32 = TensorProto_DataType::TensorProto_DataType_INT32, + int64 = TensorProto_DataType::TensorProto_DataType_INT64, + string = TensorProto_DataType::TensorProto_DataType_STRING, + boolean = TensorProto_DataType::TensorProto_DataType_BOOL, + float16 = TensorProto_DataType::TensorProto_DataType_FLOAT16, + float64 = TensorProto_DataType::TensorProto_DataType_DOUBLE, + uint32 = TensorProto_DataType::TensorProto_DataType_UINT32, + uint64 = TensorProto_DataType::TensorProto_DataType_UINT64, + bfloat16 = TensorProto_DataType::TensorProto_DataType_BFLOAT16, + complex64 = TensorProto_DataType::TensorProto_DataType_COMPLEX64, + complex128 = TensorProto_DataType::TensorProto_DataType_COMPLEX128 }; Tensor() = delete; - Tensor(const ONNX_NAMESPACE::TensorProto& tensor, - const std::string& model_dir, - detail::MappedMemoryHandles mmap_cache) + Tensor(const TensorProto& tensor, const std::string& model_dir, detail::MappedMemoryHandles mmap_cache) : m_tensor_proto{&tensor}, m_shape{std::begin(tensor.dims()), std::end(tensor.dims())}, m_model_dir{model_dir}, m_mmap_cache{mmap_cache} { - if (m_shape == Shape{0}) { + if (m_shape == ov::Shape{0}) { // It's possible to construct a tensor in ONNX with "dims: 0" property - // Such tensor contains a scalar. This results in a Shape{0} stored in m_shape. - // In OpenVINO a scalar is represented with Shape{} and thus this replacement. - m_shape = Shape{}; + // Such tensor contains a scalar. This results in a ov::Shape{0} stored in m_shape. + // In OpenVINO a scalar is represented with ov::Shape{} and thus this replacement. + m_shape = ov::Shape{}; } } @@ -106,7 +101,7 @@ class Tensor { Tensor& operator=(const Tensor&) = delete; Tensor& operator=(Tensor&&) = delete; - const Shape& get_shape() const { + const ov::Shape& get_shape() const { return m_shape; } template @@ -136,33 +131,33 @@ class Tensor { FRONT_END_THROW("Tensor has no specified data type"); } switch (m_tensor_proto->data_type()) { - case ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_BOOL: + case TensorProto_DataType::TensorProto_DataType_BOOL: return ov::element::boolean; - case ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_FLOAT: + case TensorProto_DataType::TensorProto_DataType_FLOAT: return ov::element::f32; - case ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_FLOAT16: + case TensorProto_DataType::TensorProto_DataType_FLOAT16: return ov::element::f16; - case ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_DOUBLE: + case TensorProto_DataType::TensorProto_DataType_DOUBLE: return ov::element::f64; - case ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_INT8: + case TensorProto_DataType::TensorProto_DataType_INT8: return ov::element::i8; - case ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_INT16: + case TensorProto_DataType::TensorProto_DataType_INT16: return ov::element::i16; - case ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_INT32: + case TensorProto_DataType::TensorProto_DataType_INT32: return ov::element::i32; - case ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_INT64: + case TensorProto_DataType::TensorProto_DataType_INT64: return ov::element::i64; - case ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_UINT8: + case TensorProto_DataType::TensorProto_DataType_UINT8: return ov::element::u8; - case ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_UINT16: + case TensorProto_DataType::TensorProto_DataType_UINT16: return ov::element::u16; - case ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_UINT32: + case TensorProto_DataType::TensorProto_DataType_UINT32: return ov::element::u32; - case ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_UINT64: + case TensorProto_DataType::TensorProto_DataType_UINT64: return ov::element::u64; - case ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_BFLOAT16: + case TensorProto_DataType::TensorProto_DataType_BFLOAT16: return ov::element::bf16; - case ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_UNDEFINED: + case TensorProto_DataType::TensorProto_DataType_UNDEFINED: FRONT_END_THROW("Data type is Undefined"); default: ONNX_UNSUPPORTED_DATA_TYPE( @@ -172,7 +167,7 @@ class Tensor { } operator TensorProto_DataType() const { - return m_tensor_proto->data_type(); + return static_cast(m_tensor_proto->data_type()); } std::shared_ptr get_ov_constant() const { @@ -180,31 +175,31 @@ class Tensor { FRONT_END_THROW("Loading segments isn't supported"); } switch (m_tensor_proto->data_type()) { - case ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_BOOL: + case TensorProto_DataType::TensorProto_DataType_BOOL: return make_ov_constant(ov::element::boolean); - case ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_FLOAT: + case TensorProto_DataType::TensorProto_DataType_FLOAT: return make_ov_constant(ov::element::f32); - case ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_FLOAT16: + case TensorProto_DataType::TensorProto_DataType_FLOAT16: return make_ov_constant(ov::element::f16); - case ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_DOUBLE: + case TensorProto_DataType::TensorProto_DataType_DOUBLE: return make_ov_constant(ov::element::f64); - case ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_INT8: + case TensorProto_DataType::TensorProto_DataType_INT8: return make_ov_constant(ov::element::i8); - case ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_INT16: + case TensorProto_DataType::TensorProto_DataType_INT16: return make_ov_constant(ov::element::i16); - case ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_INT32: + case TensorProto_DataType::TensorProto_DataType_INT32: return make_ov_constant(ov::element::i32); - case ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_INT64: + case TensorProto_DataType::TensorProto_DataType_INT64: return make_ov_constant(ov::element::i64); - case ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_UINT8: + case TensorProto_DataType::TensorProto_DataType_UINT8: return make_ov_constant(ov::element::u8); - case ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_UINT16: + case TensorProto_DataType::TensorProto_DataType_UINT16: return make_ov_constant(ov::element::u16); - case ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_UINT32: + case TensorProto_DataType::TensorProto_DataType_UINT32: return make_ov_constant(ov::element::u32); - case ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_UINT64: + case TensorProto_DataType::TensorProto_DataType_UINT64: return make_ov_constant(ov::element::u64); - case ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_BFLOAT16: + case TensorProto_DataType::TensorProto_DataType_BFLOAT16: return make_ov_constant(ov::element::bf16); default: ONNX_UNSUPPORTED_DATA_TYPE( @@ -276,8 +271,7 @@ class Tensor { bool has_external_data() const { return m_tensor_proto->has_data_location() && - m_tensor_proto->data_location() == - ONNX_NAMESPACE::TensorProto_DataLocation::TensorProto_DataLocation_EXTERNAL; + m_tensor_proto->data_location() == TensorProto_DataLocation::TensorProto_DataLocation_EXTERNAL; } template @@ -297,15 +291,15 @@ class Tensor { return m_tensor_proto->raw_data().data(); } switch (m_tensor_proto->data_type()) { - case ONNX_NAMESPACE::TensorProto_DataType_FLOAT: + case TensorProto_DataType::TensorProto_DataType_FLOAT: return m_tensor_proto->float_data().data(); - case ONNX_NAMESPACE::TensorProto_DataType_INT32: + case TensorProto_DataType::TensorProto_DataType_INT32: return m_tensor_proto->int32_data().data(); - case ONNX_NAMESPACE::TensorProto_DataType_INT64: + case TensorProto_DataType::TensorProto_DataType_INT64: return m_tensor_proto->int64_data().data(); - case ONNX_NAMESPACE::TensorProto_DataType_UINT64: + case TensorProto_DataType::TensorProto_DataType_UINT64: return m_tensor_proto->uint64_data().data(); - case ONNX_NAMESPACE::TensorProto_DataType_DOUBLE: + case TensorProto_DataType::TensorProto_DataType_DOUBLE: return m_tensor_proto->double_data().data(); } ONNX_INVALID_DATA_TYPE(m_tensor_proto->data_type(), "FLOAT, INT32, INT64, UINT64, DOUBLE"); @@ -316,22 +310,22 @@ class Tensor { return m_tensor_proto->raw_data().size() / get_onnx_data_size(m_tensor_proto->data_type()); } switch (m_tensor_proto->data_type()) { - case ONNX_NAMESPACE::TensorProto_DataType_FLOAT: + case TensorProto_DataType::TensorProto_DataType_FLOAT: return m_tensor_proto->float_data_size(); - case ONNX_NAMESPACE::TensorProto_DataType_INT32: + case TensorProto_DataType::TensorProto_DataType_INT32: return m_tensor_proto->int32_data_size(); - case ONNX_NAMESPACE::TensorProto_DataType_INT64: + case TensorProto_DataType::TensorProto_DataType_INT64: return m_tensor_proto->int64_data_size(); - case ONNX_NAMESPACE::TensorProto_DataType_UINT64: + case TensorProto_DataType::TensorProto_DataType_UINT64: return m_tensor_proto->uint64_data_size(); - case ONNX_NAMESPACE::TensorProto_DataType_DOUBLE: + case TensorProto_DataType::TensorProto_DataType_DOUBLE: return m_tensor_proto->double_data_size(); } ONNX_INVALID_DATA_TYPE(m_tensor_proto->data_type(), "FLOAT, INT32, INT64, UINT64, DOUBLE"); } - const ONNX_NAMESPACE::TensorProto* m_tensor_proto; - Shape m_shape; + const TensorProto* m_tensor_proto; + ov::Shape m_shape; std::string m_model_dir; detail::MappedMemoryHandles m_mmap_cache; }; @@ -379,5 +373,6 @@ std::vector Tensor::get_data() const; template <> std::vector Tensor::get_data() const; -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/core/transform.cpp b/src/frontends/onnx/frontend/src/core/transform.cpp index b39665aa9b1da4..39e828edeae104 100644 --- a/src/frontends/onnx/frontend/src/core/transform.cpp +++ b/src/frontends/onnx/frontend/src/core/transform.cpp @@ -20,11 +20,14 @@ #include "openvino/util/log.hpp" #include "ops_bridge.hpp" -namespace ngraph { -namespace onnx_import { +using namespace ::ONNX_NAMESPACE; + +namespace ov { +namespace frontend { +namespace onnx { namespace transform { namespace { -ONNX_NAMESPACE::TypeProto get_input_type(std::string const& name, ONNX_NAMESPACE::GraphProto& graph) { +TypeProto get_input_type(std::string const& name, GraphProto& graph) { for (const auto& input : graph.input()) { if (input.name() == name) { return input.type(); @@ -32,7 +35,7 @@ ONNX_NAMESPACE::TypeProto get_input_type(std::string const& name, ONNX_NAMESPACE } for (const auto& initializer : graph.initializer()) { if (initializer.name() == name) { - ONNX_NAMESPACE::TypeProto ret; + TypeProto ret; auto* tensor_type = ret.mutable_tensor_type(); tensor_type->set_elem_type(initializer.data_type()); @@ -51,15 +54,15 @@ ONNX_NAMESPACE::TypeProto get_input_type(std::string const& name, ONNX_NAMESPACE return value_info.type(); } } - return ONNX_NAMESPACE::TypeProto(); + return TypeProto(); } -void function_expand_and_remove_original_node(const ONNX_NAMESPACE::NodeProto& node, - const ONNX_NAMESPACE::FunctionProto& func_proto, - ONNX_NAMESPACE::GraphProto* graph, +void function_expand_and_remove_original_node(const NodeProto& node, + const FunctionProto& func_proto, + GraphProto* graph, int current_node_idx) { const auto before_expand_size = graph->node().size(); - ONNX_NAMESPACE::FunctionExpandHelper(node, func_proto, *graph); + FunctionExpandHelper(node, func_proto, *graph); const auto added_nodes = graph->node().size() - before_expand_size; // Remove the original node which contained the function @@ -73,14 +76,15 @@ void function_expand_and_remove_original_node(const ONNX_NAMESPACE::NodeProto& n } // namespace } // namespace transform -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov -void ngraph::onnx_import::transform::expand_onnx_functions(ONNX_NAMESPACE::ModelProto& model_proto) { +void ov::frontend::onnx::transform::expand_onnx_functions(ModelProto& model_proto) { auto graph_proto = model_proto.mutable_graph(); for (int i = 0; i < graph_proto->node().size(); ++i) { - ONNX_NAMESPACE::NodeProto node = graph_proto->node().Get(i); + NodeProto node = graph_proto->node().Get(i); // Check if node operation is one of the functions we want to expand if (std::find(onnx_functions_to_expand.begin(), onnx_functions_to_expand.end(), node.op_type()) == @@ -90,7 +94,7 @@ void ngraph::onnx_import::transform::expand_onnx_functions(ONNX_NAMESPACE::Model // Retrieve the operation schema from ONNX library int opset_version = static_cast(get_opset_version(model_proto, node.domain())); - const auto* schema_registry = ONNX_NAMESPACE::OpSchemaRegistry::Instance(); + const auto* schema_registry = OpSchemaRegistry::Instance(); const auto node_op_schema = schema_registry->GetSchema(node.op_type(), opset_version, node.domain()); // Check if operation schema found @@ -108,18 +112,18 @@ void ngraph::onnx_import::transform::expand_onnx_functions(ONNX_NAMESPACE::Model else if (node_op_schema->HasContextDependentFunction()) { // In order to expand a context-dependent function, we need to infer types try { - ONNX_NAMESPACE::shape_inference::InferShapes(model_proto); + shape_inference::InferShapes(model_proto); } catch (const std::exception& e) { - OPENVINO_WARN << "ONNX Shape inference failed: " << e.what(); + OPENVINO_WARN << "ONNX ov::Shape inference failed: " << e.what(); } - std::vector input_types; + std::vector input_types; for (const auto& input : node.input()) { input_types.push_back(get_input_type(input, *graph_proto)); } - ONNX_NAMESPACE::FunctionBodyBuildContextImpl ctx(node, input_types); - ONNX_NAMESPACE::FunctionProto func_proto; + FunctionBodyBuildContextImpl ctx(node, input_types); + FunctionProto func_proto; node_op_schema->BuildContextDependentFunction(ctx, func_proto); // Move index to the previous position because a first node of expanded function can have also function function_expand_and_remove_original_node(node, func_proto, graph_proto, i--); @@ -127,7 +131,7 @@ void ngraph::onnx_import::transform::expand_onnx_functions(ONNX_NAMESPACE::Model } } -void ngraph::onnx_import::transform::fixup_legacy_operators(ONNX_NAMESPACE::ModelProto& model_proto) { +void ov::frontend::onnx::transform::fixup_legacy_operators(ModelProto& model_proto) { auto graph_proto = model_proto.mutable_graph(); for (auto& node : *graph_proto->mutable_node()) { auto it = std::find(legacy_ops_to_fixup.begin(), legacy_ops_to_fixup.end(), node.op_type()); diff --git a/src/frontends/onnx/frontend/src/core/transform.hpp b/src/frontends/onnx/frontend/src/core/transform.hpp index 77ab1676c22a96..fd33ac5a7bcfc0 100644 --- a/src/frontends/onnx/frontend/src/core/transform.hpp +++ b/src/frontends/onnx/frontend/src/core/transform.hpp @@ -6,17 +6,15 @@ #include -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace transform { -static const std::vector onnx_functions_to_expand = {"AffineGrid", - "Bernoulli", - "Celu", - "CenterCropPad", - "NegativeLogLikelihoodLoss", - "SoftmaxCrossEntropyLoss", - "LayerNormalization"}; +using ::ONNX_NAMESPACE::ModelProto; + +static const std::vector onnx_functions_to_expand = + {"AffineGrid", "Bernoulli", "Celu", "CenterCropPad", "NegativeLogLikelihoodLoss", "SoftmaxCrossEntropyLoss"}; /// \brief Replace nodes with expanded body of ONNX functions /// @@ -26,7 +24,7 @@ static const std::vector onnx_functions_to_expand = {"AffineGrid", /// with their expanded subgraphs. /// /// \param model_proto Protobuf message with ONNX model to transform. -void expand_onnx_functions(ONNX_NAMESPACE::ModelProto& model_proto); +void expand_onnx_functions(ModelProto& model_proto); static const std::vector legacy_ops_to_fixup = {"DeformableConv2D", "DetectionOutput", @@ -53,8 +51,9 @@ static const std::vector legacy_ops_to_fixup = {"DeformableConv2D", /// in the OpenVINO ONNX Frontend. /// /// \param model_proto Protobuf message with ONNX model to transform. -void fixup_legacy_operators(ONNX_NAMESPACE::ModelProto& model_proto); +void fixup_legacy_operators(ModelProto& model_proto); } // namespace transform -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/core/value_info.hpp b/src/frontends/onnx/frontend/src/core/value_info.hpp index 1ef671476f7ed5..2c47b7711c6f6f 100644 --- a/src/frontends/onnx/frontend/src/core/value_info.hpp +++ b/src/frontends/onnx/frontend/src/core/value_info.hpp @@ -6,26 +6,26 @@ #include +#include "core/node.hpp" #include "core/tensor.hpp" #include "onnx_common/utils.hpp" -#include "onnx_import/core/node.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/parameter.hpp" #include "utils/common.hpp" -using namespace ov::frontend::onnx::common; +namespace ov { +namespace frontend { +namespace onnx { -using namespace ov::op; +using ::ONNX_NAMESPACE::ValueInfoProto; -namespace ngraph { -namespace onnx_import { class ValueInfo { public: ValueInfo(ValueInfo&&) = default; ValueInfo(const ValueInfo&) = default; ValueInfo() = delete; - explicit ValueInfo(const ONNX_NAMESPACE::ValueInfoProto& value_info_proto) : m_value_info_proto{&value_info_proto} { + explicit ValueInfo(const ValueInfoProto& value_info_proto) : m_value_info_proto{&value_info_proto} { if (value_info_proto.type().has_tensor_type()) { const auto& onnx_tensor = value_info_proto.type().tensor_type(); @@ -62,19 +62,19 @@ class ValueInfo { } protected: - std::shared_ptr get_ov_parameter() const { - auto parameter = std::make_shared(get_element_type(), get_shape()); + std::shared_ptr get_ov_parameter() const { + auto parameter = std::make_shared(get_element_type(), get_shape()); parameter->set_friendly_name(get_name()); parameter->get_output_tensor(0).set_names({get_name()}); return parameter; } - std::shared_ptr get_ov_constant(const Tensor& tensor) const { + std::shared_ptr get_ov_constant(const Tensor& tensor) const { return tensor.get_ov_constant(); } private: - const ONNX_NAMESPACE::ValueInfoProto* m_value_info_proto; + const ValueInfoProto* m_value_info_proto; ov::PartialShape m_partial_shape = ov::PartialShape::dynamic(); }; @@ -82,6 +82,6 @@ inline std::ostream& operator<<(std::ostream& outs, const ValueInfo& info) { return (outs << ""); } -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/default_opset.hpp b/src/frontends/onnx/frontend/src/default_opset.hpp deleted file mode 100644 index 5e8b191d05746e..00000000000000 --- a/src/frontends/onnx/frontend/src/default_opset.hpp +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "openvino/opsets/opset12.hpp" - -namespace ngraph { -namespace onnx_import { -namespace default_opset = ov::opset12; -} -} // namespace ngraph diff --git a/src/frontends/onnx/frontend/src/detail/subgraph_extraction.cpp b/src/frontends/onnx/frontend/src/detail/subgraph_extraction.cpp index f2341a7fccc711..2c4a1bc9c94fe3 100644 --- a/src/frontends/onnx/frontend/src/detail/subgraph_extraction.cpp +++ b/src/frontends/onnx/frontend/src/detail/subgraph_extraction.cpp @@ -15,12 +15,13 @@ #include "openvino/frontend/exception.hpp" -using namespace ov::onnx_editor; +using namespace ::ONNX_NAMESPACE; +using namespace ov::frontend::onnx; enum class PortType { InputPort, OutputPort }; namespace { -void validate_node_index(const ONNX_NAMESPACE::GraphProto& graph, const int node_idx) { +void validate_node_index(const GraphProto& graph, const int node_idx) { FRONT_END_GENERAL_CHECK(node_idx >= 0 && node_idx < graph.node_size(), "The specified node index is out of range of nodes in the original model(idx: ", std::to_string(node_idx), @@ -29,10 +30,7 @@ void validate_node_index(const ONNX_NAMESPACE::GraphProto& graph, const int node ")"); } -void validate_port_index(const ONNX_NAMESPACE::GraphProto& graph, - const int node_idx, - const int port_idx, - const PortType& port_type) { +void validate_port_index(const GraphProto& graph, const int node_idx, const int port_idx, const PortType& port_type) { const int ports_number = (port_type == PortType::InputPort) ? graph.node(node_idx).input().size() : graph.node(node_idx).output().size(); FRONT_END_GENERAL_CHECK(port_idx >= 0 && port_idx < ports_number, @@ -67,21 +65,19 @@ bool already_exists(const Container& items, const std::string& name) { } /// \brief Checks if a tensor with name "name" is produced by an input of the graph -bool is_graph_input(const ONNX_NAMESPACE::GraphProto& graph, const std::string& name) { +bool is_graph_input(const GraphProto& graph, const std::string& name) { return already_exists(graph.input(), name); } /// \brief Checks if a tensor with name "name" is produced by an initializer of the graph -bool is_graph_initializer(const ONNX_NAMESPACE::GraphProto& graph, const std::string& name) { +bool is_graph_initializer(const GraphProto& graph, const std::string& name) { return already_exists(graph.initializer(), name); } /// \brief Looks up the index of a node that produces a tensor "input_name". Used to traverse /// the graph bottom-up. Starts from a node index "current_node_idx" because it operates /// on a topologically sorted graph. -int find_source_node_idx(const ONNX_NAMESPACE::GraphProto& graph, - const int current_node_idx, - const std::string& input_name) { +int find_source_node_idx(const GraphProto& graph, const int current_node_idx, const std::string& input_name) { // Some operators (e.g. Clip) have optional inputs if (input_name.empty()) return -1; @@ -101,11 +97,10 @@ int find_source_node_idx(const ONNX_NAMESPACE::GraphProto& graph, /// \brief Looks up a descriptor for a given tensor name. This descriptor contains inferred /// shape information which is required to create new inputs and outputs in the graph. -const ONNX_NAMESPACE::ValueInfoProto find_tensor_descriptor(const ONNX_NAMESPACE::GraphProto& graph, - const std::string& tensor_name) { +const ValueInfoProto find_tensor_descriptor(const GraphProto& graph, const std::string& tensor_name) { const auto it = std::find_if(std::begin(graph.value_info()), std::end(graph.value_info()), - name_equals(tensor_name)); + name_equals(tensor_name)); if (it != std::end(graph.value_info())) { return *it; @@ -114,23 +109,23 @@ const ONNX_NAMESPACE::ValueInfoProto find_tensor_descriptor(const ONNX_NAMESPACE // as fully dynamic: // - Fully dynamic shape // - Unknown data type - auto dynamic_value_info = ONNX_NAMESPACE::ValueInfoProto(); + auto dynamic_value_info = ValueInfoProto(); dynamic_value_info.set_name(tensor_name); auto type = dynamic_value_info.mutable_type(); auto tensor_type = type->mutable_tensor_type(); - tensor_type->set_elem_type(ONNX_NAMESPACE::TensorProto_DataType::TensorProto_DataType_UNDEFINED); + tensor_type->set_elem_type(TensorProto_DataType::TensorProto_DataType_UNDEFINED); return dynamic_value_info; } } -std::string get_input_tensor_name(const ONNX_NAMESPACE::GraphProto& graph, const InputEdge& edge) { +std::string get_input_tensor_name(const GraphProto& graph, const InputEdge& edge) { validate_node_index(graph, edge.m_node_idx); validate_port_index(graph, edge.m_node_idx, edge.m_port_idx, PortType::InputPort); return graph.node(edge.m_node_idx).input(edge.m_port_idx); } -std::string get_output_tensor_name(const ONNX_NAMESPACE::GraphProto& graph, const OutputEdge& edge) { +std::string get_output_tensor_name(const GraphProto& graph, const OutputEdge& edge) { validate_node_index(graph, edge.m_node_idx); validate_port_index(graph, edge.m_node_idx, edge.m_port_idx, PortType::OutputPort); @@ -139,11 +134,11 @@ std::string get_output_tensor_name(const ONNX_NAMESPACE::GraphProto& graph, cons /// \brief Inserts a new input to the graph and removes an initializer that produced a tensor /// specified by an input edge passed to this function. -void replace_initializer_with_new_input(ONNX_NAMESPACE::GraphProto& graph, const InputEdge& edge) { +void replace_initializer_with_new_input(GraphProto& graph, const InputEdge& edge) { const auto tensor_name = get_input_tensor_name(graph, edge); const auto it = std::find_if(std::begin(graph.initializer()), std::end(graph.initializer()), - name_equals(tensor_name)); + name_equals(tensor_name)); FRONT_END_GENERAL_CHECK(it != std::end(graph.initializer()), "Could not find an initializer in the graph: '", @@ -173,9 +168,7 @@ void replace_initializer_with_new_input(ONNX_NAMESPACE::GraphProto& graph, const /// \note input_consumers is number of nodes which consume a new input /// \return A new input edge (along with "true") if a new input was added to the graph, /// false + the original edge otherwise. -std::pair append_new_graph_input(ONNX_NAMESPACE::GraphProto& graph, - const InputEdge& edge, - int input_consumers) { +std::pair append_new_graph_input(GraphProto& graph, const InputEdge& edge, int input_consumers) { const auto tensor_name = get_input_tensor_name(graph, edge); if (already_exists(graph.input(), tensor_name) && !is_graph_initializer(graph, tensor_name)) { // no need to append a new input if an edge points to an existing one in the model @@ -222,7 +215,7 @@ std::pair append_new_graph_input(ONNX_NAMESPACE::GraphProto& /// \brief Adds new outputs to the ONNX graph for an edge specified by a user /// The shape for this output is taken from a previously executed shape inference of the /// original model. -void append_new_graph_output(ONNX_NAMESPACE::GraphProto& graph, const OutputEdge& edge) { +void append_new_graph_output(GraphProto& graph, const OutputEdge& edge) { const auto tensor_name = get_output_tensor_name(graph, edge); auto& new_output = *(graph.add_output()); // copy the intermediate tensor's properties to the newly created @@ -234,8 +227,8 @@ void append_new_graph_output(ONNX_NAMESPACE::GraphProto& graph, const OutputEdge /// It's intended to work with ONNX graph inputs, outputs and initializers only. template void discard_by_name(Container& all_items, const std::set& items_to_keep) { - static_assert(std::is_same::value || - std::is_same::value, + static_assert(std::is_same::value || + std::is_same::value, "Unsupported value type of the container"); // The tested item can be discarded if its name is not found in the items_to_keep set @@ -255,7 +248,7 @@ void discard_by_name(Container& all_items, const std::set& items_to /// \brief Removes all nodes from a container keeping the ones whose index is in nodes_to_keep template void discard_nodes(Container& all_nodes, const std::set& nodes_to_keep) { - static_assert(std::is_same::value, + static_assert(std::is_same::value, "Unsupported value type of the container"); int idx = 0; @@ -274,9 +267,7 @@ void discard_nodes(Container& all_nodes, const std::set& nodes_to_keep) { /* -----------------------------------------------------------------------------------------------*/ -SubgraphExtractor::SubgraphExtractor(ONNX_NAMESPACE::GraphProto& graph) - : m_onnx_graph(graph), - m_node_inputs(graph.node_size()) { +SubgraphExtractor::SubgraphExtractor(GraphProto& graph) : m_onnx_graph(graph), m_node_inputs(graph.node_size()) { // gathers information about the graph - input edges of every node and number of "consumers" // of all tensors in the graph for (int i = 0; i < graph.node_size(); ++i) { diff --git a/src/frontends/onnx/frontend/src/detail/subgraph_extraction.hpp b/src/frontends/onnx/frontend/src/detail/subgraph_extraction.hpp index d16db361b95333..b520ac80b80b63 100644 --- a/src/frontends/onnx/frontend/src/detail/subgraph_extraction.hpp +++ b/src/frontends/onnx/frontend/src/detail/subgraph_extraction.hpp @@ -19,10 +19,14 @@ class ValueInfoProto; } // namespace ONNX_NAMESPACE namespace ov { -namespace onnx_editor { +namespace frontend { +namespace onnx { + +using ::ONNX_NAMESPACE::GraphProto; + /// \brief Subgraph extraction helper structure struct SubgraphExtractor { - SubgraphExtractor(ONNX_NAMESPACE::GraphProto& graph); + SubgraphExtractor(GraphProto& graph); /// \brief Adds new inputs to the graph and connects them to the nodes indicated by /// the provided input edges. @@ -70,7 +74,7 @@ struct SubgraphExtractor { }; private: - ONNX_NAMESPACE::GraphProto& m_onnx_graph; + GraphProto& m_onnx_graph; // Graph traversal helper: the input names of each node std::vector> m_node_inputs; @@ -96,5 +100,6 @@ struct SubgraphExtractor { /// \param subgraph An object describing the subgraph to be extracted (elems to be kept) void extract_subgraph_from_onnx_model(const SubgraphComponents& subgraph); }; -} // namespace onnx_editor +} // namespace onnx +} // namespace frontend } // namespace ov diff --git a/src/frontends/onnx/frontend/src/edge_mapper.cpp b/src/frontends/onnx/frontend/src/edge_mapper.cpp index 22e1fb4b8bc009..aad4b09e32bf89 100644 --- a/src/frontends/onnx/frontend/src/edge_mapper.cpp +++ b/src/frontends/onnx/frontend/src/edge_mapper.cpp @@ -12,9 +12,9 @@ #include "openvino/frontend/exception.hpp" using namespace ov; -using namespace ov::onnx_editor; +using namespace ov::frontend::onnx; -onnx_editor::EdgeMapper::EdgeMapper(const ONNX_NAMESPACE::GraphProto& graph_proto) +EdgeMapper::EdgeMapper(const GraphProto& graph_proto) : m_node_inputs(graph_proto.node().size()), m_node_outputs(graph_proto.node().size()) { int topological_index = 0; @@ -36,8 +36,7 @@ onnx_editor::EdgeMapper::EdgeMapper(const ONNX_NAMESPACE::GraphProto& graph_prot } } -std::vector onnx_editor::EdgeMapper::find_node_indexes(const std::string& node_name, - const std::string& output_name) const { +std::vector EdgeMapper::find_node_indexes(const std::string& node_name, const std::string& output_name) const { if (!output_name.empty()) { const auto& index_iter = m_node_output_name_to_index.find(output_name); if (index_iter != std::end(m_node_output_name_to_index)) { @@ -57,7 +56,7 @@ std::vector onnx_editor::EdgeMapper::find_node_indexes(const std::string& n return result; }; -int onnx_editor::EdgeMapper::get_node_output_idx(int node_index, const std::string& output_name) const { +int EdgeMapper::get_node_output_idx(int node_index, const std::string& output_name) const { FRONT_END_GENERAL_CHECK(node_index >= 0 && node_index < static_cast(m_node_outputs.size()), "Node with index: ", std::to_string(node_index), @@ -73,7 +72,7 @@ int onnx_editor::EdgeMapper::get_node_output_idx(int node_index, const std::stri return static_cast(out_port_idx - std::begin(node_outputs)); } -std::vector onnx_editor::EdgeMapper::get_node_input_indexes(int node_index, const std::string& input_name) const { +std::vector EdgeMapper::get_node_input_indexes(int node_index, const std::string& input_name) const { FRONT_END_GENERAL_CHECK(node_index >= 0 && node_index < static_cast(m_node_inputs.size()), "Node with index: ", std::to_string(node_index), @@ -96,7 +95,7 @@ std::vector onnx_editor::EdgeMapper::get_node_input_indexes(int node_index, return node_inputs_indexes; } -InputEdge onnx_editor::EdgeMapper::find_input_edge(const EditorNode& node, const EditorInput& in) const { +InputEdge EdgeMapper::find_input_edge(const EditorNode& node, const EditorInput& in) const { int node_index = node.m_node_index; if (node_index == -1) { // the node index is not provided // identification can be both based on node name and output name (if the node index is not provided) @@ -160,7 +159,7 @@ InputEdge onnx_editor::EdgeMapper::find_input_edge(const EditorNode& node, const } } -OutputEdge onnx_editor::EdgeMapper::find_output_edge(const EditorNode& node, const EditorOutput& out) const { +OutputEdge EdgeMapper::find_output_edge(const EditorNode& node, const EditorOutput& out) const { int node_index = node.m_node_index; if (node_index == -1) { // the node index is not provided // identification can be both based on node name and output name (if the node index is not provided) @@ -210,11 +209,11 @@ OutputEdge onnx_editor::EdgeMapper::find_output_edge(const EditorNode& node, con return OutputEdge{node_index, output_idx}; } -OutputEdge onnx_editor::EdgeMapper::find_output_edge(const std::string& output_name) const { +OutputEdge EdgeMapper::find_output_edge(const std::string& output_name) const { return find_output_edge(EditorNode{EditorOutput{output_name}}, EditorOutput{output_name}); } -std::vector onnx_editor::EdgeMapper::find_output_consumers(const std::string& output_name) const { +std::vector EdgeMapper::find_output_consumers(const std::string& output_name) const { const auto matched_nodes_range = m_output_consumers_index.equal_range(output_name); std::vector input_edges; for (auto it = matched_nodes_range.first; it != matched_nodes_range.second; ++it) { @@ -233,7 +232,7 @@ std::vector onnx_editor::EdgeMapper::find_output_consumers(const std: return input_edges; } -bool onnx_editor::EdgeMapper::is_correct_and_unambiguous_node(const EditorNode& node) const { +bool EdgeMapper::is_correct_and_unambiguous_node(const EditorNode& node) const { if (node.m_node_index >= 0 && node.m_node_index < static_cast(m_node_inputs.size())) { return true; } @@ -250,7 +249,7 @@ void check_node(bool condition, const EditorNode& node) { } } // namespace -int onnx_editor::EdgeMapper::get_node_index(const EditorNode& node) const { +int EdgeMapper::get_node_index(const EditorNode& node) const { if (node.m_node_index != -1) { // the node index provided check_node_index(node.m_node_index); return node.m_node_index; @@ -260,7 +259,7 @@ int onnx_editor::EdgeMapper::get_node_index(const EditorNode& node) const { return indexes[0]; } -bool onnx_editor::EdgeMapper::is_correct_tensor_name(const std::string& name) const { +bool EdgeMapper::is_correct_tensor_name(const std::string& name) const { if (m_node_output_name_to_index.find(name) != std::end(m_node_output_name_to_index)) { return true; } @@ -270,7 +269,7 @@ bool onnx_editor::EdgeMapper::is_correct_tensor_name(const std::string& name) co return false; } -std::vector onnx_editor::EdgeMapper::get_input_ports(const EditorNode& node) const { +std::vector EdgeMapper::get_input_ports(const EditorNode& node) const { check_node(is_correct_and_unambiguous_node(node), node); auto node_index = node.m_node_index; if (node_index == -1) { // the node index is provided @@ -281,7 +280,7 @@ std::vector onnx_editor::EdgeMapper::get_input_ports(const EditorNo return m_node_inputs[node_index]; } -std::vector onnx_editor::EdgeMapper::get_output_ports(const EditorNode& node) const { +std::vector EdgeMapper::get_output_ports(const EditorNode& node) const { check_node(is_correct_and_unambiguous_node(node), node); auto node_index = node.m_node_index; if (node_index == -1) // the node index is provided @@ -293,7 +292,7 @@ std::vector onnx_editor::EdgeMapper::get_output_ports(const EditorN return m_node_outputs[node_index]; } -std::string onnx_editor::EdgeMapper::get_source_tensor_name(const InputEdge& edge) const { +std::string EdgeMapper::get_source_tensor_name(const InputEdge& edge) const { if (edge.m_node_idx >= 0 && edge.m_node_idx < static_cast(m_node_inputs.size()) && edge.m_port_idx >= 0 && edge.m_port_idx < static_cast(m_node_inputs[edge.m_node_idx].size())) { return m_node_inputs[edge.m_node_idx][edge.m_port_idx]; @@ -301,7 +300,7 @@ std::string onnx_editor::EdgeMapper::get_source_tensor_name(const InputEdge& edg return ""; } -std::string onnx_editor::EdgeMapper::get_target_tensor_name(const OutputEdge& edge) const { +std::string EdgeMapper::get_target_tensor_name(const OutputEdge& edge) const { if (edge.m_node_idx >= 0 && edge.m_node_idx < static_cast(m_node_outputs.size()) && edge.m_port_idx >= 0 && edge.m_port_idx < static_cast(m_node_outputs[edge.m_node_idx].size())) { return m_node_outputs[edge.m_node_idx][edge.m_port_idx]; @@ -309,7 +308,7 @@ std::string onnx_editor::EdgeMapper::get_target_tensor_name(const OutputEdge& ed return ""; } -void onnx_editor::EdgeMapper::check_node_index(int node_index) const { +void EdgeMapper::check_node_index(int node_index) const { FRONT_END_GENERAL_CHECK(node_index >= 0 && node_index < static_cast(m_node_inputs.size()), "Provided node index: " + std::to_string(node_index) + " is out of scope"); } diff --git a/src/frontends/onnx/frontend/src/edge_mapper.hpp b/src/frontends/onnx/frontend/src/edge_mapper.hpp index b4b4d846337bbb..2c4ae25259efb5 100644 --- a/src/frontends/onnx/frontend/src/edge_mapper.hpp +++ b/src/frontends/onnx/frontend/src/edge_mapper.hpp @@ -17,7 +17,10 @@ class GraphProto; } // namespace ONNX_NAMESPACE namespace ov { -namespace onnx_editor { +namespace frontend { +namespace onnx { +using ::ONNX_NAMESPACE::GraphProto; + /// \brief A class which allows specifying InputEdge and OutputEdge by user-friendly ONNX /// names. class EdgeMapper { @@ -30,7 +33,7 @@ class EdgeMapper { /// is outdated. In such a case the update method should be called. /// /// \param graph_proto Reference to a GraphProto object. - EdgeMapper(const ONNX_NAMESPACE::GraphProto& graph_proto); + EdgeMapper(const GraphProto& graph_proto); /// \brief Returns the InputEdge based on a node (node name or output name) /// and an input (input name or input index). @@ -148,5 +151,6 @@ class EdgeMapper { std::map m_node_output_name_to_index; std::multimap m_output_consumers_index; }; -} // namespace onnx_editor +} // namespace onnx +} // namespace frontend } // namespace ov diff --git a/src/frontends/onnx/frontend/src/editor.cpp b/src/frontends/onnx/frontend/src/editor.cpp index b3b0d28f99c24d..b141ef9bffc91b 100644 --- a/src/frontends/onnx/frontend/src/editor.cpp +++ b/src/frontends/onnx/frontend/src/editor.cpp @@ -19,14 +19,11 @@ #include "utils/onnx_internal.hpp" using namespace ov; -using namespace ov::onnx_editor; +using namespace ov::frontend::onnx; using namespace ov::frontend::onnx::common; - -OPENVINO_SUPPRESS_DEPRECATED_START +using namespace ::ONNX_NAMESPACE; namespace { -using namespace ONNX_NAMESPACE; - ValueInfoProto* find_graph_input(GraphProto& graph, const std::string& name) { for (int i = 0; i < graph.input_size(); ++i) { auto* input_desc = graph.mutable_input(i); @@ -92,7 +89,7 @@ void modify_input_type(ValueInfoProto& onnx_input, const ov::element::Type_t ele tensor_type->set_elem_type(ov_to_onnx_data_type(elem_type)); } -void add_dim_to_onnx_shape(const Dimension& dim, ONNX_NAMESPACE::TensorShapeProto& onnx_shape) { +void add_dim_to_onnx_shape(const Dimension& dim, TensorShapeProto& onnx_shape) { auto* new_dim = onnx_shape.add_dim(); if (dim.is_static()) { new_dim->set_dim_value(dim.get_length()); @@ -179,15 +176,15 @@ bool is_topologically_sorted(const GraphProto& graph) { std::transform(std::begin(graph.input()), std::end(graph.input()), std::inserter(known_tensors, std::end(known_tensors)), - extract_name); + extract_name); std::transform(std::begin(graph.output()), std::end(graph.output()), std::inserter(known_tensors, std::end(known_tensors)), - extract_name); + extract_name); std::transform(std::begin(graph.initializer()), std::end(graph.initializer()), std::inserter(known_tensors, std::end(known_tensors)), - extract_name); + extract_name); for (const auto& node : graph.node()) { for (const auto& input : node.input()) { @@ -256,13 +253,13 @@ void graph_topological_sort(GraphProto* graph) { class InferShapesAutoRelease { public: - InferShapesAutoRelease(std::shared_ptr model_proto) + InferShapesAutoRelease(std::shared_ptr model_proto) : m_model_proto{model_proto}, m_infer_shapes_was_run{false} {} bool infer_shapes() { try { // unexpected exceptions of external onnx lib - ONNX_NAMESPACE::shape_inference::InferShapes(*m_model_proto); + shape_inference::InferShapes(*m_model_proto); m_infer_shapes_was_run = true; } catch (...) { release(); @@ -284,38 +281,35 @@ class InferShapesAutoRelease { } private: - std::shared_ptr m_model_proto; + std::shared_ptr m_model_proto; bool m_infer_shapes_was_run; }; } // namespace /// \brief A helper class used to hold the ModelProto object as its field -struct onnx_editor::ONNXModelEditor::Impl { - std::shared_ptr m_model_proto; +struct ONNXModelEditor::Impl { + std::shared_ptr m_model_proto; EdgeMapper m_edge_mapper; bool m_is_mapper_updated = false; Impl() = delete; - Impl(const std::shared_ptr& model_proto) : m_model_proto{model_proto} { + Impl(const std::shared_ptr& model_proto) : m_model_proto{model_proto} { graph_topological_sort(m_model_proto->mutable_graph()); } - Impl(const std::string& model_path) - : Impl(std::make_shared(parse_from_file(model_path))) {} + Impl(const std::string& model_path) : Impl(std::make_shared(parse_from_file(model_path))) {} - Impl(std::istream& model_stream) - : Impl(std::make_shared(parse_from_istream(model_stream))) {} + Impl(std::istream& model_stream) : Impl(std::make_shared(parse_from_istream(model_stream))) {} #if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32) - Impl(const std::wstring& model_path) - : Impl(std::make_shared(parse_from_file(model_path))) {} + Impl(const std::wstring& model_path) : Impl(std::make_shared(parse_from_file(model_path))) {} #endif }; -onnx_editor::ONNXModelEditor::ONNXModelEditor(const std::string& model_path, - const bool enable_mmap, - frontend::ExtensionHolder extensions) +ONNXModelEditor::ONNXModelEditor(const std::string& model_path, + const bool enable_mmap, + frontend::ExtensionHolder extensions) : m_model_path{model_path}, m_mmap_cache{enable_mmap ? std::make_shared>>() : nullptr}, @@ -325,9 +319,9 @@ onnx_editor::ONNXModelEditor::ONNXModelEditor(const std::string& model_path, }} {} #if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32) -onnx_editor::ONNXModelEditor::ONNXModelEditor(const std::wstring& model_path, - const bool enable_mmap, - frontend::ExtensionHolder extensions) +ONNXModelEditor::ONNXModelEditor(const std::wstring& model_path, + const bool enable_mmap, + frontend::ExtensionHolder extensions) : m_extensions{std::move(extensions)}, m_model_path{ov::util::wstring_to_string(model_path)}, m_mmap_cache{enable_mmap ? std::make_shared>>() @@ -337,10 +331,10 @@ onnx_editor::ONNXModelEditor::ONNXModelEditor(const std::wstring& model_path, }} {} #endif -onnx_editor::ONNXModelEditor::ONNXModelEditor(std::istream& model_stream, - const std::string& model_path, - const bool enable_mmap, - frontend::ExtensionHolder extensions) +ONNXModelEditor::ONNXModelEditor(std::istream& model_stream, + const std::string& model_path, + const bool enable_mmap, + frontend::ExtensionHolder extensions) : m_model_path{model_path}, m_mmap_cache{enable_mmap ? std::make_shared>>() : nullptr}, @@ -349,11 +343,11 @@ onnx_editor::ONNXModelEditor::ONNXModelEditor(std::istream& model_stream, delete impl; }} {} -const std::string& onnx_editor::ONNXModelEditor::model_path() const { +const std::string& ONNXModelEditor::model_path() const { return m_model_path; } -void onnx_editor::ONNXModelEditor::serialize(const std::string& out_file_path) const { +void ONNXModelEditor::serialize(const std::string& out_file_path) const { std::ofstream out_file{out_file_path, std::ios::out | std::ios::binary}; OPENVINO_ASSERT(out_file.is_open(), "Could not open the file: ", out_file_path); @@ -364,7 +358,7 @@ void onnx_editor::ONNXModelEditor::serialize(const std::string& out_file_path) c out_file.close(); } -void onnx_editor::ONNXModelEditor::set_input_types(const std::map& input_types) { +void ONNXModelEditor::set_input_types(const std::map& input_types) { auto* onnx_graph = m_pimpl->m_model_proto->mutable_graph(); for (const auto& input_desc : input_types) { @@ -377,7 +371,7 @@ void onnx_editor::ONNXModelEditor::set_input_types(const std::mapm_model_proto->mutable_graph(); auto* onnx_input = find_graph_input(*onnx_graph, tensor_name); @@ -389,10 +383,10 @@ ov::element::Type_t onnx_editor::ONNXModelEditor::get_input_type(const std::stri onnx_input->name()); auto& tensor_type = type_proto.tensor_type(); auto type = tensor_type.elem_type(); - return ngraph::onnx_import::common::get_ov_element_type(type); + return ov::frontend::onnx::common::get_ov_element_type(type); } -void onnx_editor::ONNXModelEditor::set_input_shapes(const std::map& input_shapes) { +void ONNXModelEditor::set_input_shapes(const std::map& input_shapes) { auto* onnx_graph = m_pimpl->m_model_proto->mutable_graph(); for (const auto& input_desc : input_shapes) { @@ -405,7 +399,7 @@ void onnx_editor::ONNXModelEditor::set_input_shapes(const std::mapm_model_proto->mutable_graph(); @@ -447,9 +441,9 @@ PartialShape onnx_editor::ONNXModelEditor::get_tensor_shape(const std::string& t } } -void onnx_editor::ONNXModelEditor::extract_subgraph(const std::vector& inputs, - const std::vector& outputs, - const bool merge_inputs) { +void ONNXModelEditor::extract_subgraph(const std::vector& inputs, + const std::vector& outputs, + const bool merge_inputs) { if (inputs.empty() && outputs.empty()) { return; } @@ -469,7 +463,7 @@ void onnx_editor::ONNXModelEditor::extract_subgraph(const std::vector m_pimpl->m_is_mapper_updated = false; } -std::vector onnx_editor::ONNXModelEditor::model_inputs() const { +std::vector ONNXModelEditor::model_inputs() const { const auto& graph = m_pimpl->m_model_proto->graph(); std::vector inputs; for (const auto& in : graph.input()) { @@ -483,7 +477,7 @@ std::vector onnx_editor::ONNXModelEditor::model_inputs() const { return inputs; } -std::vector onnx_editor::ONNXModelEditor::model_outputs() const { +std::vector ONNXModelEditor::model_outputs() const { const auto& graph = m_pimpl->m_model_proto->graph(); std::vector outputs; outputs.reserve(graph.output_size()); @@ -491,17 +485,17 @@ std::vector onnx_editor::ONNXModelEditor::model_outputs() const { std::transform(graph.output().begin(), graph.output().end(), std::back_inserter(outputs), - extract_name); + extract_name); return outputs; } -std::string onnx_editor::ONNXModelEditor::get_source_tensor_name(const InputEdge& edge) const { +std::string ONNXModelEditor::get_source_tensor_name(const InputEdge& edge) const { update_mapper_if_needed(); return m_pimpl->m_edge_mapper.get_source_tensor_name(edge); } -bool onnx_editor::ONNXModelEditor::is_input(const InputEdge& edge) const { +bool ONNXModelEditor::is_input(const InputEdge& edge) const { const auto& tensor_name = get_source_tensor_name(edge); if (tensor_name.empty()) { return false; @@ -511,12 +505,12 @@ bool onnx_editor::ONNXModelEditor::is_input(const InputEdge& edge) const { } } -std::string onnx_editor::ONNXModelEditor::get_target_tensor_name(const OutputEdge& edge) const { +std::string ONNXModelEditor::get_target_tensor_name(const OutputEdge& edge) const { update_mapper_if_needed(); return m_pimpl->m_edge_mapper.get_target_tensor_name(edge); } -bool onnx_editor::ONNXModelEditor::is_output(const OutputEdge& edge) const { +bool ONNXModelEditor::is_output(const OutputEdge& edge) const { const auto& tensor_name = get_target_tensor_name(edge); if (tensor_name.empty()) { return false; @@ -526,20 +520,18 @@ bool onnx_editor::ONNXModelEditor::is_output(const OutputEdge& edge) const { } } -std::string onnx_editor::ONNXModelEditor::model_string() const { +std::string ONNXModelEditor::model_string() const { return m_pimpl->m_model_proto->SerializeAsString(); } -std::shared_ptr onnx_editor::ONNXModelEditor::get_function() const { - OPENVINO_SUPPRESS_DEPRECATED_START - return ngraph::onnx_import::detail::import_onnx_model(m_pimpl->m_model_proto, - m_model_path, - m_mmap_cache, - m_extensions); - OPENVINO_SUPPRESS_DEPRECATED_END +std::shared_ptr ONNXModelEditor::get_function() const { + return ov::frontend::onnx::detail::import_onnx_model(m_pimpl->m_model_proto, + m_model_path, + m_mmap_cache, + m_extensions); } -void onnx_editor::ONNXModelEditor::set_input_values( +void ONNXModelEditor::set_input_values( const std::map>& input_values) { auto onnx_graph = m_pimpl->m_model_proto->mutable_graph(); @@ -563,7 +555,7 @@ void onnx_editor::ONNXModelEditor::set_input_values( } } -void onnx_editor::ONNXModelEditor::set_tensor_name(const std::string& current_name, const std::string& new_name) { +void ONNXModelEditor::set_tensor_name(const std::string& current_name, const std::string& new_name) { OPENVINO_ASSERT(!new_name.empty(), "New name must not be empty."); const auto graph = m_pimpl->m_model_proto->mutable_graph(); @@ -606,7 +598,7 @@ void onnx_editor::ONNXModelEditor::set_tensor_name(const std::string& current_na } } -void onnx_editor::ONNXModelEditor::set_node_name(const EditorNode& node, const std::string& new_name) { +void ONNXModelEditor::set_node_name(const EditorNode& node, const std::string& new_name) { const auto node_idx = m_pimpl->m_edge_mapper.get_node_index(node); const auto graph = m_pimpl->m_model_proto->mutable_graph(); @@ -615,7 +607,7 @@ void onnx_editor::ONNXModelEditor::set_node_name(const EditorNode& node, const s *graph->mutable_node(node_idx)->mutable_name() = new_name; } -std::string onnx_editor::ONNXModelEditor::get_node_name(const EditorNode& node) const { +std::string ONNXModelEditor::get_node_name(const EditorNode& node) const { if (node.m_node_index >= 0) { if (node.m_node_index >= m_pimpl->m_model_proto->graph().node().size()) { return ""; @@ -627,7 +619,7 @@ std::string onnx_editor::ONNXModelEditor::get_node_name(const EditorNode& node) } } -void onnx_editor::ONNXModelEditor::clear_nodes_name(const std::string& name) { +void ONNXModelEditor::clear_nodes_name(const std::string& name) { const auto graph = m_pimpl->m_model_proto->mutable_graph(); m_pimpl->m_is_mapper_updated = false; @@ -639,9 +631,9 @@ void onnx_editor::ONNXModelEditor::clear_nodes_name(const std::string& name) { } } -void onnx_editor::ONNXModelEditor::set_name_for_dimension(const std::string& node_name, - size_t shape_dim_index, - const std::string& dim_name) { +void ONNXModelEditor::set_name_for_dimension(const std::string& node_name, + size_t shape_dim_index, + const std::string& dim_name) { OPENVINO_ASSERT(!dim_name.empty(), "Dimension name must not be empty."); const auto graph = m_pimpl->m_model_proto->mutable_graph(); @@ -674,68 +666,68 @@ void onnx_editor::ONNXModelEditor::set_name_for_dimension(const std::string& nod set_dim_param(value_info); } -void onnx_editor::ONNXModelEditor::update_mapper_if_needed() const { +void ONNXModelEditor::update_mapper_if_needed() const { if (!m_pimpl->m_is_mapper_updated) { m_pimpl->m_edge_mapper = EdgeMapper(m_pimpl->m_model_proto->graph()); } m_pimpl->m_is_mapper_updated = true; } -InputEdge onnx_editor::ONNXModelEditor::find_input_edge(const EditorNode& node, const EditorInput& input) const { +InputEdge ONNXModelEditor::find_input_edge(const EditorNode& node, const EditorInput& input) const { update_mapper_if_needed(); return m_pimpl->m_edge_mapper.find_input_edge(node, input); } -OutputEdge onnx_editor::ONNXModelEditor::find_output_edge(const EditorNode& node, const EditorOutput& input) const { +OutputEdge ONNXModelEditor::find_output_edge(const EditorNode& node, const EditorOutput& input) const { update_mapper_if_needed(); return m_pimpl->m_edge_mapper.find_output_edge(node, input); } -OutputEdge onnx_editor::ONNXModelEditor::find_output_edge(const std::string& output_name) const { +OutputEdge ONNXModelEditor::find_output_edge(const std::string& output_name) const { update_mapper_if_needed(); return m_pimpl->m_edge_mapper.find_output_edge(output_name); } -std::vector onnx_editor::ONNXModelEditor::find_output_consumers(const std::string& output_name) const { +std::vector ONNXModelEditor::find_output_consumers(const std::string& output_name) const { update_mapper_if_needed(); return m_pimpl->m_edge_mapper.find_output_consumers(output_name); } -bool onnx_editor::ONNXModelEditor::is_correct_and_unambiguous_node(const EditorNode& node) const { +bool ONNXModelEditor::is_correct_and_unambiguous_node(const EditorNode& node) const { update_mapper_if_needed(); return m_pimpl->m_edge_mapper.is_correct_and_unambiguous_node(node); } -int onnx_editor::ONNXModelEditor::get_node_index(const EditorNode& node) const { +int ONNXModelEditor::get_node_index(const EditorNode& node) const { update_mapper_if_needed(); return m_pimpl->m_edge_mapper.get_node_index(node); } -bool onnx_editor::ONNXModelEditor::is_correct_tensor_name(const std::string& name) const { +bool ONNXModelEditor::is_correct_tensor_name(const std::string& name) const { update_mapper_if_needed(); return m_pimpl->m_edge_mapper.is_correct_tensor_name(name); } -std::vector onnx_editor::ONNXModelEditor::get_input_ports(const EditorNode& node) const { +std::vector ONNXModelEditor::get_input_ports(const EditorNode& node) const { update_mapper_if_needed(); return m_pimpl->m_edge_mapper.get_input_ports(node); } -std::vector onnx_editor::ONNXModelEditor::get_output_ports(const EditorNode& node) const { +std::vector ONNXModelEditor::get_output_ports(const EditorNode& node) const { update_mapper_if_needed(); return m_pimpl->m_edge_mapper.get_output_ports(node); } -std::shared_ptr onnx_editor::ONNXModelEditor::decode() { - return ngraph::onnx_import::detail::decode_to_framework_nodes(m_pimpl->m_model_proto, - m_model_path, - m_mmap_cache, - m_extensions); +std::shared_ptr ONNXModelEditor::decode() { + return ov::frontend::onnx::detail::decode_to_framework_nodes(m_pimpl->m_model_proto, + m_model_path, + m_mmap_cache, + m_extensions); } -void onnx_editor::ONNXModelEditor::add_output(const OutputEdge& output_edge) const { +void ONNXModelEditor::add_output(const OutputEdge& output_edge) const { auto onnx_graph = m_pimpl->m_model_proto->mutable_graph(); - std::vector onnx_output; + std::vector onnx_output; onnx_output.push_back(output_edge); SubgraphExtractor editor{*onnx_graph}; editor.add_new_outputs(onnx_output); diff --git a/src/frontends/onnx/frontend/src/editor.hpp b/src/frontends/onnx/frontend/src/editor.hpp index 477dbda9480bd7..ee5a159d8a4cb3 100644 --- a/src/frontends/onnx/frontend/src/editor.hpp +++ b/src/frontends/onnx/frontend/src/editor.hpp @@ -9,8 +9,6 @@ #include #include "editor_types.hpp" -#include "onnx_import/onnx_importer_visibility.hpp" -#include "openvino/core/deprecated.hpp" #include "openvino/core/model.hpp" #include "openvino/frontend/extension/holder.hpp" #include "openvino/frontend/extension/progress_reporter.hpp" @@ -19,13 +17,14 @@ #include "utils/tensor_external_data.hpp" namespace ov { -namespace onnx_editor { +namespace frontend { +namespace onnx { /// \brief A class representing a set of utilities allowing modification of an ONNX model /// /// \note This class can be used to modify an ONNX model before it gets translated to /// an ov::Model by the frontend->convert method. It lets you modify the /// model's input types and shapes, extract a subgraph and more. -class ONNX_IMPORTER_API ONNXModelEditor final { +class ONNXModelEditor final { public: /// \brief Creates an editor from a model file located on a storage device. The file /// is parsed and loaded into the m_model_proto member variable. @@ -306,11 +305,12 @@ class ONNX_IMPORTER_API ONNXModelEditor final { void update_mapper_if_needed() const; const std::string m_model_path; - ngraph::onnx_import::detail::MappedMemoryHandles m_mmap_cache; + ov::frontend::onnx::detail::MappedMemoryHandles m_mmap_cache; frontend::ExtensionHolder m_extensions; struct Impl; std::unique_ptr m_pimpl; }; -} // namespace onnx_editor +} // namespace onnx +} // namespace frontend } // namespace ov diff --git a/src/frontends/onnx/frontend/src/editor_types.hpp b/src/frontends/onnx/frontend/src/editor_types.hpp index 56b341e2c903ec..75d8659c263340 100644 --- a/src/frontends/onnx/frontend/src/editor_types.hpp +++ b/src/frontends/onnx/frontend/src/editor_types.hpp @@ -22,7 +22,8 @@ struct Edge { const int m_port_idx; const std::string m_new_input_name; }; -namespace onnx_editor { +namespace frontend { +namespace onnx { /// \brief Defines an edge connected to an input of any node in the graph. /// It consists of a node index in the processed ONNX model and the port index. /// The node index should point to a node in the topological sort of the underlying @@ -123,5 +124,6 @@ struct EditorNode { std::string m_output_name = ""; int m_node_index = -1; }; -} // namespace onnx_editor +} // namespace onnx +} // namespace frontend } // namespace ov diff --git a/src/frontends/onnx/frontend/src/exceptions.cpp b/src/frontends/onnx/frontend/src/exceptions.cpp index 95cc74d5009d16..ffbf966b2130c9 100644 --- a/src/frontends/onnx/frontend/src/exceptions.cpp +++ b/src/frontends/onnx/frontend/src/exceptions.cpp @@ -6,15 +6,11 @@ #include -#include "openvino/core/deprecated.hpp" - -OPENVINO_SUPPRESS_DEPRECATED_START - namespace ov { namespace frontend { namespace onnx_error { namespace detail { -std::string get_error_msg_prefix(const ngraph::onnx_import::Node& node) { +std::string get_error_msg_prefix(const ov::frontend::onnx::Node& node) { std::stringstream ss; ss << "While validating ONNX node '" << node << "'"; return ss.str(); @@ -24,7 +20,7 @@ std::string get_error_msg_prefix(const ngraph::onnx_import::Node& node) { void OnnxNodeValidationFailure::create(const char* file, int line, const char* check_string, - const ngraph::onnx_import::Node& node, + const ov::frontend::onnx::Node& node, const std::string& explanation) { throw OnnxNodeValidationFailure( make_what(file, line, check_string, detail::get_error_msg_prefix(node), explanation)); @@ -32,5 +28,3 @@ void OnnxNodeValidationFailure::create(const char* file, } // namespace onnx_error } // namespace frontend } // namespace ov - -OPENVINO_SUPPRESS_DEPRECATED_END diff --git a/src/frontends/onnx/frontend/src/exceptions.hpp b/src/frontends/onnx/frontend/src/exceptions.hpp index b8a40bef9ad010..388c9a4241f55e 100644 --- a/src/frontends/onnx/frontend/src/exceptions.hpp +++ b/src/frontends/onnx/frontend/src/exceptions.hpp @@ -6,7 +6,7 @@ #include -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/core/deprecated.hpp" #include "openvino/core/except.hpp" #include "utils/tensor_external_data.hpp" @@ -17,7 +17,7 @@ namespace onnx_error { namespace detail { OPENVINO_SUPPRESS_DEPRECATED_START -std::string get_error_msg_prefix(const ngraph::onnx_import::Node& node); +std::string get_error_msg_prefix(const ov::frontend::onnx::Node& node); OPENVINO_SUPPRESS_DEPRECATED_END } // namespace detail @@ -26,7 +26,7 @@ class OnnxNodeValidationFailure : public ov::AssertFailure { OPENVINO_SUPPRESS_DEPRECATED_START [[noreturn]] static void create(const char* file, int line, const char* check_string, - const ngraph::onnx_import::Node& node, + const ov::frontend::onnx::Node& node, const std::string& explanation); OPENVINO_SUPPRESS_DEPRECATED_END @@ -36,7 +36,7 @@ class OnnxNodeValidationFailure : public ov::AssertFailure { OPENVINO_SUPPRESS_DEPRECATED_START struct invalid_external_data : ov::Exception { - invalid_external_data(const ngraph::onnx_import::detail::TensorExternalData& external_data) + invalid_external_data(const ov::frontend::onnx::detail::TensorExternalData& external_data) : ov::Exception{std::string{"invalid external data: "} + external_data.to_string()} {} invalid_external_data(const std::string& what_arg) : ov::Exception{what_arg} {} }; @@ -46,13 +46,15 @@ OPENVINO_SUPPRESS_DEPRECATED_END } // namespace frontend } // namespace ov -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace error { using namespace ov::frontend::onnx_error; } // namespace error -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov #define CHECK_VALID_NODE(node_, cond_, ...) \ OPENVINO_ASSERT_HELPER(ov::frontend::onnx_error::OnnxNodeValidationFailure, (node_), (cond_), ##__VA_ARGS__) diff --git a/src/frontends/onnx/frontend/src/frontend.cpp b/src/frontends/onnx/frontend/src/frontend.cpp index d239aab2ba90ff..27ccd18a5f757c 100644 --- a/src/frontends/onnx/frontend/src/frontend.cpp +++ b/src/frontends/onnx/frontend/src/frontend.cpp @@ -16,9 +16,7 @@ #include #include "input_model.hpp" -#include "legacy_op_extension.hpp" #include "onnx_common/onnx_model_validator.hpp" -#include "onnx_import/onnx_utils.hpp" #include "openvino/core/so_extension.hpp" #include "openvino/frontend/exception.hpp" #include "openvino/frontend/extension/telemetry.hpp" @@ -29,7 +27,6 @@ #include "ops_bridge.hpp" #include "transformations/resolve_names_collisions.hpp" #include "utils/common.hpp" -#include "utils/legacy_conversion_extension.hpp" #include "utils/onnx_internal.hpp" using namespace ov; @@ -121,7 +118,7 @@ void FrontEnd::normalize(const std::shared_ptr& model) const { std::shared_ptr FrontEnd::convert(const InputModel::Ptr& model) const { const auto partially_converted = convert_partially(model); - const auto error_message = ngraph::onnx_import::common::collect_translation_exceptions(partially_converted); + const auto error_message = ov::frontend::onnx::common::collect_translation_exceptions(partially_converted); FRONT_END_GENERAL_CHECK(error_message.empty(), error_message); normalize(partially_converted); @@ -130,7 +127,7 @@ std::shared_ptr FrontEnd::convert(const InputModel::Ptr& model) const } void FrontEnd::convert(const std::shared_ptr& partially_converted) const { - ngraph::onnx_import::detail::convert_decoded_model(partially_converted); + ov::frontend::onnx::detail::convert_decoded_model(partially_converted); normalize(partially_converted); } @@ -196,13 +193,6 @@ bool FrontEnd::supported_impl(const std::vector& variants) const { return false; } -namespace { -const auto legacy_conversion_extension = std::make_shared(); -const ngraph::onnx_import::LegacyConversionExtension::Ptr get_legacy_conversion_extension() { - return legacy_conversion_extension; -} -} // namespace - void FrontEnd::add_extension(const std::shared_ptr& extension) { if (auto telemetry = std::dynamic_pointer_cast(extension)) { m_extensions.telemetry = telemetry; @@ -217,10 +207,5 @@ void FrontEnd::add_extension(const std::shared_ptr& extension) { m_extensions.conversions.push_back(onnx_conv_ext); } else if (auto progress_reporter = std::dynamic_pointer_cast(extension)) { m_extensions.progress_reporter = progress_reporter; - } else if (const auto& legacy_ext = std::dynamic_pointer_cast(extension)) { - m_other_extensions.push_back(legacy_ext); - std::call_once(has_legacy_extension, [this] { - m_extensions.conversions.push_back(get_legacy_conversion_extension()); - }); } } diff --git a/src/frontends/onnx/frontend/src/input_model.cpp b/src/frontends/onnx/frontend/src/input_model.cpp index ae24f22b3fc84d..aa367b5c5ecf6f 100644 --- a/src/frontends/onnx/frontend/src/input_model.cpp +++ b/src/frontends/onnx/frontend/src/input_model.cpp @@ -12,25 +12,22 @@ using namespace ov; using namespace ov::frontend::onnx; -OPENVINO_SUPPRESS_DEPRECATED_START - InputModel::InputModel(const std::string& path, const bool enable_mmap, frontend::ExtensionHolder extensions) - : m_editor{std::make_shared(path, enable_mmap, std::move(extensions))} {} + : m_editor{std::make_shared(path, enable_mmap, std::move(extensions))} {} #if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32) InputModel::InputModel(const std::wstring& path, const bool enable_mmap, frontend::ExtensionHolder extensions) - : m_editor{std::make_shared(path, enable_mmap, std::move(extensions))} {} + : m_editor{std::make_shared(path, enable_mmap, std::move(extensions))} {} #endif InputModel::InputModel(std::istream& model_stream, const bool enable_mmap, frontend::ExtensionHolder extensions) - : m_editor{std::make_shared(model_stream, "", enable_mmap, std::move(extensions))} {} + : m_editor{std::make_shared(model_stream, "", enable_mmap, std::move(extensions))} {} InputModel::InputModel(std::istream& model_stream, const std::string& path, const bool enable_mmap, frontend::ExtensionHolder extensions) - : m_editor{std::make_shared(model_stream, path, enable_mmap, std::move(extensions))} { -} + : m_editor{std::make_shared(model_stream, path, enable_mmap, std::move(extensions))} {} #ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT InputModel::InputModel(std::istream& model_stream, @@ -69,8 +66,8 @@ ov::frontend::Place::Ptr InputModel::get_place_by_tensor_name(const std::string& ov::frontend::Place::Ptr InputModel::get_place_by_operation_name(const std::string& operation_name) const { if (m_editor->is_correct_and_unambiguous_node(operation_name)) { - const auto node_index = m_editor->get_node_index(onnx_editor::EditorNode{operation_name}); - onnx_editor::EditorNode node{node_index}; + const auto node_index = m_editor->get_node_index(EditorNode{operation_name}); + EditorNode node{node_index}; node.m_node_name = operation_name; return std::make_shared(node, m_editor); } @@ -340,8 +337,8 @@ void InputModel::override_all_inputs(const std::vector void InputModel::extract_subgraph(const std::vector& inputs, const std::vector& outputs) { - std::vector onnx_inputs = convert_place_to_input_edge(inputs); - std::vector onnx_outputs = convert_place_to_output_edge(outputs); + std::vector onnx_inputs = convert_place_to_input_edge(inputs); + std::vector onnx_outputs = convert_place_to_output_edge(outputs); m_editor->extract_subgraph(onnx_inputs, onnx_outputs); } @@ -442,9 +439,8 @@ void InputModel::set_tensor_value(const ov::frontend::Place::Ptr& place, const v } } -std::vector InputModel::convert_place_to_input_edge( - const std::vector& inputs) { - std::vector onnx_inputs; +std::vector InputModel::convert_place_to_input_edge(const std::vector& inputs) { + std::vector onnx_inputs; onnx_inputs.reserve(inputs.size()); for (const auto& input : inputs) { if (const auto input_port = std::dynamic_pointer_cast(input)) { @@ -456,7 +452,7 @@ std::vector InputModel::convert_place_to_input_edge( std::transform(std::begin(consumers), std::end(consumers), std::back_inserter(onnx_inputs), - [](const onnx_editor::InputEdge& edge) { + [](const InputEdge& edge) { return edge; }); } else if (const auto op = std::dynamic_pointer_cast(input)) { @@ -469,7 +465,7 @@ std::vector InputModel::convert_place_to_input_edge( std::end(op_inputs), std::back_inserter(onnx_inputs), [&node_idx, &port_idx](const std::string&) { - return onnx_editor::InputEdge{node_idx, port_idx++}; + return InputEdge{node_idx, port_idx++}; }); } } @@ -477,9 +473,8 @@ std::vector InputModel::convert_place_to_input_edge( return onnx_inputs; } -std::vector InputModel::convert_place_to_output_edge( - const std::vector& outputs) { - std::vector onnx_outputs; +std::vector InputModel::convert_place_to_output_edge(const std::vector& outputs) { + std::vector onnx_outputs; onnx_outputs.reserve(outputs.size()); for (const auto& output : outputs) { if (const auto output_port = std::dynamic_pointer_cast(output)) { @@ -501,7 +496,7 @@ std::vector InputModel::convert_place_to_output_edge( std::end(op_outputs), std::back_inserter(onnx_outputs), [&node_idx, &port_idx](const std::string&) { - return onnx_editor::OutputEdge{node_idx, port_idx++}; + return OutputEdge{node_idx, port_idx++}; }); } } diff --git a/src/frontends/onnx/frontend/src/input_model.hpp b/src/frontends/onnx/frontend/src/input_model.hpp index 803766ae25af8c..eeba81b8cbd7c2 100644 --- a/src/frontends/onnx/frontend/src/input_model.hpp +++ b/src/frontends/onnx/frontend/src/input_model.hpp @@ -78,13 +78,11 @@ class InputModel : public ov::frontend::InputModel { void set_tensor_value(const ov::frontend::Place::Ptr& place, const void* value) override; // internal usage - std::vector convert_place_to_input_edge( - const std::vector& inputs); - std::vector convert_place_to_output_edge( - const std::vector& outputs); + std::vector convert_place_to_input_edge(const std::vector& inputs); + std::vector convert_place_to_output_edge(const std::vector& outputs); private: - std::shared_ptr m_editor; + std::shared_ptr m_editor; bool is_correct_place(const ov::frontend::Place::Ptr& place) const; std::unordered_map> m_additional_tensor_names; diff --git a/src/frontends/onnx/frontend/src/node_context.cpp b/src/frontends/onnx/frontend/src/node_context.cpp index 821f89c19e506e..91a0d7bdf49b31 100644 --- a/src/frontends/onnx/frontend/src/node_context.cpp +++ b/src/frontends/onnx/frontend/src/node_context.cpp @@ -2,15 +2,14 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include #include #include -OPENVINO_SUPPRESS_DEPRECATED_START -ov::frontend::onnx::NodeContext::NodeContext(const ngraph::onnx_import::Node& context) +ov::frontend::onnx::NodeContext::NodeContext(const ov::frontend::onnx::Node& context) : ov::frontend::NodeContext(context.op_type()), m_context(context), - m_inputs(context.get_ng_inputs()) {} + m_inputs(context.get_ov_inputs()) {} ov::Output ov::frontend::onnx::NodeContext::get_input(int port_idx) const { return m_inputs.at(port_idx); @@ -19,7 +18,7 @@ ov::Output ov::frontend::onnx::NodeContext::get_input(int port_idx) co ov::Any ov::frontend::onnx::NodeContext::get_attribute_as_any(const std::string& name) const { try { return m_context.get_attribute_value(name); - } catch (ngraph::onnx_import::error::node::UnknownAttribute&) { + } catch (ov::frontend::onnx::error::node::UnknownAttribute&) { return ov::Any(); } } @@ -31,16 +30,15 @@ size_t ov::frontend::onnx::NodeContext::get_input_size() const { ov::Any ov::frontend::onnx::NodeContext::apply_additional_conversion_rules(const ov::Any& data, const std::type_info& type_info) const { if (data.is() && type_info == typeid(ov::element::Type)) { - return ngraph::onnx_import::common::get_ov_element_type(data.as()); + return ov::frontend::onnx::common::get_ov_element_type(data.as()); } else if (data.is>() && type_info == typeid(std::vector)) { const auto& casted = data.as>(); std::vector types(casted.size()); for (size_t i = 0; i < casted.size(); ++i) { - types[i] = ngraph::onnx_import::common::get_ov_element_type(casted[i]); + types[i] = ov::frontend::onnx::common::get_ov_element_type(casted[i]); } return types; } // no conversion rules found return data; } -OPENVINO_SUPPRESS_DEPRECATED_END diff --git a/src/frontends/onnx/frontend/src/onnx.cpp b/src/frontends/onnx/frontend/src/onnx.cpp deleted file mode 100644 index e92889a09ebb91..00000000000000 --- a/src/frontends/onnx/frontend/src/onnx.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "onnx_import/onnx.hpp" - -#include - -#include -#include - -#include "onnx_common/parser.hpp" -#include "onnx_import/onnx_utils.hpp" -#include "ops_bridge.hpp" -#include "utils/common.hpp" -#include "utils/legacy_conversion_extension.hpp" -#include "utils/onnx_internal.hpp" - -using namespace ov::frontend::onnx::common; - -namespace { -const auto legacy_conversion_extension = std::make_shared(); -} // namespace - -namespace ngraph { -namespace onnx_import { -std::shared_ptr import_onnx_model(std::istream& stream, - const std::string& model_path, - const bool enable_mmap) { - const auto model_proto = std::make_shared(parse_from_istream(stream)); - ov::frontend::ExtensionHolder extensions; - extensions.conversions.push_back(legacy_conversion_extension); - OPENVINO_SUPPRESS_DEPRECATED_START - const auto model = detail::import_onnx_model( - model_proto, - model_path, - enable_mmap ? std::make_shared>>() : nullptr, - std::move(extensions)); - OPENVINO_SUPPRESS_DEPRECATED_END - const auto error_message = common::collect_translation_exceptions(model); - OPENVINO_ASSERT(error_message.empty(), error_message); - return model; -} - -std::shared_ptr import_onnx_model(const std::string& file_path, const bool enable_mmap) { - std::ifstream model_stream{file_path, std::ios::in | std::ios::binary}; - - if (!model_stream.is_open()) { - OPENVINO_THROW("Error during import of ONNX model expected to be in file: " + file_path + - ". Could not open the file."); - }; - OPENVINO_SUPPRESS_DEPRECATED_START - const auto model = import_onnx_model(model_stream, file_path, enable_mmap); - OPENVINO_SUPPRESS_DEPRECATED_END - const auto error_message = common::collect_translation_exceptions(model); - OPENVINO_ASSERT(error_message.empty(), error_message); - return model; -} - -std::set get_supported_operators(std::int64_t version, const std::string& domain) { - return legacy_conversion_extension->ops_bridge().get_supported_operators(version, domain); -} - -bool is_operator_supported(const std::string& op_name, std::int64_t version, const std::string& domain) { - return legacy_conversion_extension->ops_bridge().is_operator_registered(op_name, - version, - domain == "ai.onnx" ? "" : domain); -} - -void register_operator(const std::string& name, std::int64_t version, const std::string& domain, Operator fn) { - legacy_conversion_extension->register_operator(name, version, domain, std::move(fn)); -} - -void unregister_operator(const std::string& name, std::int64_t version, const std::string& domain) { - legacy_conversion_extension->unregister_operator(name, version, domain); -} - -const LegacyConversionExtension::Ptr detail::get_legacy_conversion_extension() { - return legacy_conversion_extension; -} -} // namespace onnx_import - -} // namespace ngraph diff --git a/src/frontends/onnx/frontend/src/onnx_framework_node.cpp b/src/frontends/onnx/frontend/src/onnx_framework_node.cpp index 989bd69c68864d..0a3f148983cac1 100644 --- a/src/frontends/onnx/frontend/src/onnx_framework_node.cpp +++ b/src/frontends/onnx/frontend/src/onnx_framework_node.cpp @@ -1,5 +1,5 @@ //***************************************************************************** -// Copyright 2017-2022 Intel Corporation +// Copyright (C) 2017-2024 Intel Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -16,17 +16,18 @@ #include "onnx_framework_node.hpp" -namespace ngraph { +namespace ov { namespace frontend { -std::shared_ptr ONNXFrameworkNode::clone_with_new_inputs(const ov::OutputVector& inputs) const { +namespace onnx { +std::shared_ptr ONNXFrameworkNode::clone_with_new_inputs(const ov::OutputVector& inputs) const { return std::make_shared(m_node, inputs); } -std::shared_ptr ONNXSubgraphFrameworkNode::clone_with_new_inputs(const ov::OutputVector& inputs) const { +std::shared_ptr ONNXSubgraphFrameworkNode::clone_with_new_inputs(const ov::OutputVector& inputs) const { return std::make_shared(m_node, m_models, inputs); } -std::shared_ptr NotSupportedONNXNode::clone_with_new_inputs(const ov::OutputVector& inputs) const { +std::shared_ptr NotSupportedONNXNode::clone_with_new_inputs(const ov::OutputVector& inputs) const { const auto& attrs = get_attrs(); std::string error_message = attrs.at(failed_conversion_key); return std::make_shared(inputs, @@ -45,5 +46,6 @@ bool NotSupportedONNXNode::visit_attributes(ov::AttributeVisitor& visitor) { return true; } +} // namespace onnx } // namespace frontend -} // namespace ngraph +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/onnx_framework_node.hpp b/src/frontends/onnx/frontend/src/onnx_framework_node.hpp index e705025613e9a7..f1807abc4e9543 100644 --- a/src/frontends/onnx/frontend/src/onnx_framework_node.hpp +++ b/src/frontends/onnx/frontend/src/onnx_framework_node.hpp @@ -1,5 +1,5 @@ //***************************************************************************** -// Copyright 2017-2022 Intel Corporation +// Copyright (C) 2017-2024 Intel Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ #pragma once #include "core/graph.hpp" -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/core/model.hpp" #include "openvino/op/util/framework_node.hpp" @@ -26,20 +26,18 @@ namespace ONNX_NAMESPACE { class ModelProto; } // namespace ONNX_NAMESPACE -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { class Model; -} -namespace frontend { -OPENVINO_SUPPRESS_DEPRECATED_START class ONNXFrameworkNode : public ov::op::util::FrameworkNode { public: OPENVINO_OP("ONNXFrameworkNode", "util", ov::op::util::FrameworkNode); - ONNXFrameworkNode(const onnx_import::Node& node) : ONNXFrameworkNode(node, node.get_ng_inputs()) {} + ONNXFrameworkNode(const ov::frontend::onnx::Node& node) : ONNXFrameworkNode(node, node.get_ov_inputs()) {} - ONNXFrameworkNode(const onnx_import::Node& node, const ov::OutputVector& inputs) + ONNXFrameworkNode(const ov::frontend::onnx::Node& node, const ov::OutputVector& inputs) : ov::op::util::FrameworkNode(inputs, node.get_outputs_size()), m_node(node) { ov::op::util::FrameworkNodeAttrs attrs; @@ -48,7 +46,7 @@ class ONNXFrameworkNode : public ov::op::util::FrameworkNode { set_attrs(attrs); } - ov::OutputVector get_ov_nodes(const std::shared_ptr& graph) const { + ov::OutputVector get_ov_nodes(const std::shared_ptr& graph) const { ov::OutputVector ov_nodes{graph->make_ov_nodes(m_node)}; if (ov_nodes.size() > get_output_size()) { ov_nodes.resize(get_output_size()); @@ -56,7 +54,7 @@ class ONNXFrameworkNode : public ov::op::util::FrameworkNode { return ov_nodes; } - virtual std::shared_ptr clone_with_new_inputs(const ov::OutputVector& inputs) const override; + virtual std::shared_ptr clone_with_new_inputs(const ov::OutputVector& inputs) const override; virtual bool visit_attributes(ov::AttributeVisitor& visitor) override { // TODO: implement reading as well, now it work for serialization only @@ -68,14 +66,14 @@ class ONNXFrameworkNode : public ov::op::util::FrameworkNode { } protected: - onnx_import::Node m_node; + ov::frontend::onnx::Node m_node; }; class ONNXSubgraphFrameworkNode : public ONNXFrameworkNode { public: OPENVINO_OP("ONNXSubgraphFrameworkNode", "util", ONNXFrameworkNode); - ONNXSubgraphFrameworkNode(const onnx_import::Node& node, + ONNXSubgraphFrameworkNode(const ov::frontend::onnx::Node& node, const std::vector>& models, const ov::OutputVector& inputs) : ONNXFrameworkNode(node, inputs), @@ -90,14 +88,13 @@ class ONNXSubgraphFrameworkNode : public ONNXFrameworkNode { return m_models; } - virtual std::shared_ptr clone_with_new_inputs(const ov::OutputVector& inputs) const override; + virtual std::shared_ptr clone_with_new_inputs(const ov::OutputVector& inputs) const override; private: std::vector> m_models; }; -OPENVINO_SUPPRESS_DEPRECATED_END -// Be careful with using protobuf references (also onnx_import::Node) inside NotSupportedONNXNode +// Be careful with using protobuf references (also ov::frontend::onnx::Node) inside NotSupportedONNXNode // which are inserted into ov::Model due to different lifetime and problematic sharing between dynamic libs. class NotSupportedONNXNode : public ov::op::util::FrameworkNode { static constexpr const char* failed_conversion_key = "onnx::NotSupportedONNXNode::failed_conversion_key"; @@ -123,9 +120,10 @@ class NotSupportedONNXNode : public ov::op::util::FrameworkNode { return attrs[failed_conversion_key]; } - virtual std::shared_ptr clone_with_new_inputs(const ov::OutputVector& inputs) const override; + virtual std::shared_ptr clone_with_new_inputs(const ov::OutputVector& inputs) const override; virtual bool visit_attributes(ov::AttributeVisitor& visitor) override; }; +} // namespace onnx } // namespace frontend -} // namespace ngraph +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/abs.hpp b/src/frontends/onnx/frontend/src/op/abs.hpp index 19966e6ba77d55..ff6eab7a7fd74d 100644 --- a/src/frontends/onnx/frontend/src/op/abs.hpp +++ b/src/frontends/onnx/frontend/src/op/abs.hpp @@ -4,22 +4,20 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - +#include "core/node.hpp" #include "exceptions.hpp" -#include "onnx_import/core/node.hpp" #include "openvino/op/abs.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector abs(const Node& node) { +inline ov::OutputVector abs(const ov::frontend::onnx::Node& node) { CHECK_VALID_NODE(node, !node.has_attribute("consumed_inputs"), "consumed_inputs legacy attribute of Abs op is not supported"); - return {std::make_shared(node.get_ng_inputs().at(0))}; + return {std::make_shared(node.get_ov_inputs().at(0))}; } } // namespace set_1 @@ -30,10 +28,7 @@ using set_1::abs; namespace set_13 { using set_6::abs; } // namespace set_13 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/acos.hpp b/src/frontends/onnx/frontend/src/op/acos.hpp index 323bd3f868cc71..d26956409233a3 100644 --- a/src/frontends/onnx/frontend/src/op/acos.hpp +++ b/src/frontends/onnx/frontend/src/op/acos.hpp @@ -1,27 +1,22 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/acos.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_7 { -inline ov::OutputVector acos(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0))}; +inline ov::OutputVector acos(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0))}; } } // namespace set_7 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/acosh.hpp b/src/frontends/onnx/frontend/src/op/acosh.hpp index 3f326b2076b1a5..fe7b07d0ab60c9 100644 --- a/src/frontends/onnx/frontend/src/op/acosh.hpp +++ b/src/frontends/onnx/frontend/src/op/acosh.hpp @@ -4,24 +4,19 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/acosh.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_9 { -inline ov::OutputVector acosh(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0))}; +inline ov::OutputVector acosh(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0))}; } } // namespace set_9 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/adaptive_avg_pooling2d.cpp b/src/frontends/onnx/frontend/src/op/adaptive_avg_pooling2d.cpp index ee11de0e02cb56..c7e260e50eafc5 100644 --- a/src/frontends/onnx/frontend/src/op/adaptive_avg_pooling2d.cpp +++ b/src/frontends/onnx/frontend/src/op/adaptive_avg_pooling2d.cpp @@ -9,14 +9,13 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { - -ov::OutputVector adaptive_avg_pooling2d(const Node& node) { - const auto inputs = node.get_ng_inputs(); +ov::OutputVector adaptive_avg_pooling2d(const ov::frontend::onnx::Node& node) { + const auto inputs = node.get_ov_inputs(); const auto num_inputs = inputs.size(); CHECK_VALID_NODE(node, num_inputs == 2, "adaptive_avg_pooling2d expects 2 input tensors. Got: ", num_inputs); @@ -26,6 +25,6 @@ ov::OutputVector adaptive_avg_pooling2d(const Node& node) { } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/adaptive_avg_pooling2d.hpp b/src/frontends/onnx/frontend/src/op/adaptive_avg_pooling2d.hpp index 0b40579d53618d..b7c3fc8b9b06c7 100644 --- a/src/frontends/onnx/frontend/src/op/adaptive_avg_pooling2d.hpp +++ b/src/frontends/onnx/frontend/src/op/adaptive_avg_pooling2d.hpp @@ -3,18 +3,16 @@ // #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector adaptive_avg_pooling2d(const Node& node); +ov::OutputVector adaptive_avg_pooling2d(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/add.cpp b/src/frontends/onnx/frontend/src/op/add.cpp index 853c11d21eda78..4b4babda2239b9 100644 --- a/src/frontends/onnx/frontend/src/op/add.cpp +++ b/src/frontends/onnx/frontend/src/op/add.cpp @@ -10,12 +10,12 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector add(const Node& node) { +ov::OutputVector add(const ov::frontend::onnx::Node& node) { CHECK_VALID_NODE(node, !node.has_attribute("consumed_inputs"), "consumed_inputs legacy attribute of Add op is not supported"); @@ -24,20 +24,17 @@ ov::OutputVector add(const Node& node) { } // namespace set_1 namespace set_6 { -ov::OutputVector add(const Node& node) { +ov::OutputVector add(const ov::frontend::onnx::Node& node) { return common::handle_opset6_binary_op(node); } } // namespace set_6 namespace set_7 { -ov::OutputVector add(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0), node.get_ng_inputs().at(1))}; +ov::OutputVector add(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0), node.get_ov_inputs().at(1))}; } } // namespace set_7 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/add.hpp b/src/frontends/onnx/frontend/src/op/add.hpp index 5d81481677b77f..ab84790178d8da 100644 --- a/src/frontends/onnx/frontend/src/op/add.hpp +++ b/src/frontends/onnx/frontend/src/op/add.hpp @@ -4,26 +4,24 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector add(const Node& node); +ov::OutputVector add(const ov::frontend::onnx::Node& node); } // namespace set_1 namespace set_6 { -ov::OutputVector add(const Node& node); +ov::OutputVector add(const ov::frontend::onnx::Node& node); } // namespace set_6 namespace set_7 { -ov::OutputVector add(const Node& node); +ov::OutputVector add(const ov::frontend::onnx::Node& node); } // namespace set_7 @@ -34,10 +32,7 @@ using set_7::add; namespace set_14 { using set_13::add; } // namespace set_14 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/affine.cpp b/src/frontends/onnx/frontend/src/op/affine.cpp index c6c2de23c55f08..651edea79ce7af 100644 --- a/src/frontends/onnx/frontend/src/op/affine.cpp +++ b/src/frontends/onnx/frontend/src/op/affine.cpp @@ -10,17 +10,17 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector affine(const Node& node) { +ov::OutputVector affine(const ov::frontend::onnx::Node& node) { // Affine is an obsolete experimental ONNX operation. // It takes one input tensor and produces one output tensor where // the affine function, y = alpha * x + beta, is applied to the input // elementwise. - const auto inputs = node.get_ng_inputs(); + const auto inputs = node.get_ov_inputs(); CHECK_VALID_NODE(node, inputs.size() == 1, "Affine expects 1 input tensor. Got: ", inputs.size()); CHECK_VALID_NODE(node, node.has_attribute("alpha"), "\"alpha\" attribute is required."); @@ -34,10 +34,7 @@ ov::OutputVector affine(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/affine.hpp b/src/frontends/onnx/frontend/src/op/affine.hpp index 233bd4892908a4..7b0f15743fe7f4 100644 --- a/src/frontends/onnx/frontend/src/op/affine.hpp +++ b/src/frontends/onnx/frontend/src/op/affine.hpp @@ -4,22 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector affine(const Node& node); +ov::OutputVector affine(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/and.hpp b/src/frontends/onnx/frontend/src/op/and.hpp index 97e64d13bc812d..b791a797aeb11f 100644 --- a/src/frontends/onnx/frontend/src/op/and.hpp +++ b/src/frontends/onnx/frontend/src/op/and.hpp @@ -4,28 +4,25 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/logical_and.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector logical_and(const Node& node) { +inline ov::OutputVector logical_and(const ov::frontend::onnx::Node& node) { return common::handle_opset6_binary_op(node); } } // namespace set_1 namespace set_7 { -inline ov::OutputVector logical_and(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0), node.get_ng_inputs().at(1))}; +inline ov::OutputVector logical_and(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0), node.get_ov_inputs().at(1))}; } } // namespace set_7 - } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/argmax.cpp b/src/frontends/onnx/frontend/src/op/argmax.cpp index cd04b737c782b7..8a6c414a4cd0e6 100644 --- a/src/frontends/onnx/frontend/src/op/argmax.cpp +++ b/src/frontends/onnx/frontend/src/op/argmax.cpp @@ -7,12 +7,12 @@ #include "exceptions.hpp" #include "utils/arg_min_max_factory.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector argmax(const Node& node) { +ov::OutputVector argmax(const ov::frontend::onnx::Node& node) { const utils::ArgMinMaxFactory arg_factory(node); return {arg_factory.make_arg_max()}; } @@ -20,16 +20,13 @@ ov::OutputVector argmax(const Node& node) { } // namespace set_1 namespace set_12 { -ov::OutputVector argmax(const Node& node) { +ov::OutputVector argmax(const ov::frontend::onnx::Node& node) { const utils::ArgMinMaxFactory arg_factory(node); return {arg_factory.make_arg_max()}; } } // namespace set_12 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/argmax.hpp b/src/frontends/onnx/frontend/src/op/argmax.hpp index 571b5a672fc429..380c7297f7c8e2 100644 --- a/src/frontends/onnx/frontend/src/op/argmax.hpp +++ b/src/frontends/onnx/frontend/src/op/argmax.hpp @@ -4,13 +4,11 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { /// \brief Convert ONNX ArgMax operation to an OV node. @@ -19,7 +17,7 @@ namespace set_1 { /// /// \return The vector containing an OV node which produces the output /// of an ONNX ArgMax operation. -ov::OutputVector argmax(const Node& node); +ov::OutputVector argmax(const ov::frontend::onnx::Node& node); } // namespace set_1 @@ -30,13 +28,10 @@ namespace set_12 { /// /// \return The vector containing an OV node which produces the output /// of an ONNX ArgMax operation. -ov::OutputVector argmax(const Node& node); +ov::OutputVector argmax(const ov::frontend::onnx::Node& node); } // namespace set_12 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/argmin.cpp b/src/frontends/onnx/frontend/src/op/argmin.cpp index cf5074d89ba284..a2ed93569c07ff 100644 --- a/src/frontends/onnx/frontend/src/op/argmin.cpp +++ b/src/frontends/onnx/frontend/src/op/argmin.cpp @@ -7,12 +7,12 @@ #include "exceptions.hpp" #include "utils/arg_min_max_factory.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector argmin(const Node& node) { +ov::OutputVector argmin(const ov::frontend::onnx::Node& node) { const utils::ArgMinMaxFactory arg_factory(node); return {arg_factory.make_arg_min()}; } @@ -20,16 +20,13 @@ ov::OutputVector argmin(const Node& node) { } // namespace set_1 namespace set_12 { -ov::OutputVector argmin(const Node& node) { +ov::OutputVector argmin(const ov::frontend::onnx::Node& node) { const utils::ArgMinMaxFactory arg_factory(node); return {arg_factory.make_arg_min()}; } } // namespace set_12 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/argmin.hpp b/src/frontends/onnx/frontend/src/op/argmin.hpp index ecd4b4dec6872e..25712fd1d49626 100644 --- a/src/frontends/onnx/frontend/src/op/argmin.hpp +++ b/src/frontends/onnx/frontend/src/op/argmin.hpp @@ -4,13 +4,11 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { /// \brief Convert ONNX ArgMin operation to an OV node. @@ -19,7 +17,7 @@ namespace set_1 { /// /// \return The vector containing an OV node which produces the output /// of an ONNX ArgMin operation. -ov::OutputVector argmin(const Node& node); +ov::OutputVector argmin(const ov::frontend::onnx::Node& node); } // namespace set_1 @@ -30,13 +28,10 @@ namespace set_12 { /// /// \return The vector containing an OV node which produces the output /// of an ONNX ArgMax operation. -ov::OutputVector argmin(const Node& node); +ov::OutputVector argmin(const ov::frontend::onnx::Node& node); } // namespace set_12 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/asin.hpp b/src/frontends/onnx/frontend/src/op/asin.hpp index 759b5a1473bccb..e9cb09e322efd1 100644 --- a/src/frontends/onnx/frontend/src/op/asin.hpp +++ b/src/frontends/onnx/frontend/src/op/asin.hpp @@ -4,24 +4,19 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/asin.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector asin(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0))}; +inline ov::OutputVector asin(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0))}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/asinh.hpp b/src/frontends/onnx/frontend/src/op/asinh.hpp index 81d26f88a90b0d..927d38abb06666 100644 --- a/src/frontends/onnx/frontend/src/op/asinh.hpp +++ b/src/frontends/onnx/frontend/src/op/asinh.hpp @@ -4,24 +4,19 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/asinh.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector asinh(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0))}; +inline ov::OutputVector asinh(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0))}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/atan.hpp b/src/frontends/onnx/frontend/src/op/atan.hpp index 79e6d5d1094854..42d4b5379bcbb9 100644 --- a/src/frontends/onnx/frontend/src/op/atan.hpp +++ b/src/frontends/onnx/frontend/src/op/atan.hpp @@ -4,24 +4,19 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/atan.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector atan(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0))}; +inline ov::OutputVector atan(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0))}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/atanh.hpp b/src/frontends/onnx/frontend/src/op/atanh.hpp index 7794f202bb35aa..3de6abe6599e2a 100644 --- a/src/frontends/onnx/frontend/src/op/atanh.hpp +++ b/src/frontends/onnx/frontend/src/op/atanh.hpp @@ -4,23 +4,19 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/atanh.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector atanh(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0))}; +inline ov::OutputVector atanh(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0))}; } } // namespace set_1 } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/aten.cpp b/src/frontends/onnx/frontend/src/op/aten.cpp index 46f49bc7ff9f9e..b357d43fa116e8 100644 --- a/src/frontends/onnx/frontend/src/op/aten.cpp +++ b/src/frontends/onnx/frontend/src/op/aten.cpp @@ -1,11 +1,11 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include "op/aten.hpp" +#include "core/null_node.hpp" #include "exceptions.hpp" -#include "onnx_import/core/null_node.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/constant.hpp" @@ -19,14 +19,14 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector aten(const Node& node) { - ov::OutputVector inputs{node.get_ng_inputs()}; +ov::OutputVector aten(const ov::frontend::onnx::Node& node) { + ov::OutputVector inputs{node.get_ov_inputs()}; const auto operator_name = node.get_attribute_value("operator", ""); CHECK_VALID_NODE(node, @@ -65,12 +65,12 @@ ov::OutputVector aten(const Node& node) { const auto data_type = emb_tbl_in.get_element_type(); const auto ind_type = indices_in.get_element_type(); - const auto zero_const = std::make_shared(ind_type, Shape{}, 0); + const auto zero_const = std::make_shared(ind_type, ov::Shape{}, 0); // Shape aligned node, filled with zeros - const auto zero_of_data_type_const = std::make_shared(data_type, Shape{1}, 0); + const auto zero_of_data_type_const = std::make_shared(data_type, ov::Shape{1}, 0); const auto weights_shape_node = std::make_shared(emb_tbl_in, ind_type); - const auto weights_last_dim_idx = std::make_shared(ov::element::i32, Shape{1}, -1); + const auto weights_last_dim_idx = std::make_shared(ov::element::i32, ov::Shape{1}, -1); const auto weights_last_dim = std::make_shared(weights_shape_node, weights_last_dim_idx, zero_const); const auto zero_col_node = std::make_shared(zero_of_data_type_const, weights_last_dim); @@ -98,6 +98,6 @@ ov::OutputVector aten(const Node& node) { } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/aten.hpp b/src/frontends/onnx/frontend/src/op/aten.hpp index abd6b06592e25f..2393eb0fc152f7 100644 --- a/src/frontends/onnx/frontend/src/op/aten.hpp +++ b/src/frontends/onnx/frontend/src/op/aten.hpp @@ -4,20 +4,18 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector aten(const Node& node); +ov::OutputVector aten(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/average_pool.cpp b/src/frontends/onnx/frontend/src/op/average_pool.cpp index bc646c83ddd0b6..5e731ab8580e46 100644 --- a/src/frontends/onnx/frontend/src/op/average_pool.cpp +++ b/src/frontends/onnx/frontend/src/op/average_pool.cpp @@ -6,20 +6,17 @@ #include "utils/pooling_factory.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector average_pool(const Node& node) { +ov::OutputVector average_pool(const ov::frontend::onnx::Node& node) { return pooling::PoolingFactory(node).make_avg_pool(); } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/average_pool.hpp b/src/frontends/onnx/frontend/src/op/average_pool.hpp index 9364445830dbb0..c80aa54517b99b 100644 --- a/src/frontends/onnx/frontend/src/op/average_pool.hpp +++ b/src/frontends/onnx/frontend/src/op/average_pool.hpp @@ -4,13 +4,11 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { /// \brief Convert ONNX AveragePool operation to an OV node. @@ -19,13 +17,10 @@ namespace set_1 { /// /// \return The vector containing OV nodes producing output of ONNX AveragePool /// operation. -ov::OutputVector average_pool(const Node& node); +ov::OutputVector average_pool(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/batch_norm.cpp b/src/frontends/onnx/frontend/src/op/batch_norm.cpp index 1fa91030bce29d..67daaddf0539c6 100644 --- a/src/frontends/onnx/frontend/src/op/batch_norm.cpp +++ b/src/frontends/onnx/frontend/src/op/batch_norm.cpp @@ -7,20 +7,20 @@ #include #include +#include "core/null_node.hpp" #include "exceptions.hpp" -#include "onnx_import/core/null_node.hpp" #include "openvino/op/batch_norm.hpp" using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { // This version supports ONNX BatchNormalization-1 and BatchNormalization-6 -ov::OutputVector batch_norm(const Node& node) { - ov::OutputVector inputs{node.get_ng_inputs()}; +ov::OutputVector batch_norm(const ov::frontend::onnx::Node& node) { + ov::OutputVector inputs{node.get_ov_inputs()}; auto x = inputs.at(0); auto scale = inputs.at(1); auto bias = inputs.at(2); @@ -55,8 +55,8 @@ ov::OutputVector batch_norm(const Node& node) { namespace set_7 { // This version supports ONNX BatchNormalization-7 and BatchNormalization-9 -ov::OutputVector batch_norm(const Node& node) { - ov::OutputVector inputs{node.get_ng_inputs()}; +ov::OutputVector batch_norm(const ov::frontend::onnx::Node& node) { + ov::OutputVector inputs{node.get_ov_inputs()}; auto x = inputs.at(0); auto scale = inputs.at(1); auto bias = inputs.at(2); @@ -73,10 +73,7 @@ ov::OutputVector batch_norm(const Node& node) { } } // namespace set_7 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/batch_norm.hpp b/src/frontends/onnx/frontend/src/op/batch_norm.hpp index 94a7767d3fde9f..f060b740eb0fad 100644 --- a/src/frontends/onnx/frontend/src/op/batch_norm.hpp +++ b/src/frontends/onnx/frontend/src/op/batch_norm.hpp @@ -4,27 +4,22 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector batch_norm(const Node& node); +ov::OutputVector batch_norm(const ov::frontend::onnx::Node& node); } // namespace set_1 namespace set_7 { -ov::OutputVector batch_norm(const Node& node); +ov::OutputVector batch_norm(const ov::frontend::onnx::Node& node); } // namespace set_7 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/bitshift.cpp b/src/frontends/onnx/frontend/src/op/bitshift.cpp index 3cc224c9d17202..63b5b37304d4af 100644 --- a/src/frontends/onnx/frontend/src/op/bitshift.cpp +++ b/src/frontends/onnx/frontend/src/op/bitshift.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -12,14 +12,14 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector bitshift(const Node& node) { - const ov::Output input_x = node.get_ng_inputs().at(0); - const ov::Output input_y = node.get_ng_inputs().at(1); +ov::OutputVector bitshift(const ov::frontend::onnx::Node& node) { + const ov::Output input_x = node.get_ov_inputs().at(0); + const ov::Output input_y = node.get_ov_inputs().at(1); std::string direction = node.get_attribute_value("direction", ""); @@ -31,7 +31,8 @@ ov::OutputVector bitshift(const Node& node) { "attribute. Given: ", direction); - auto shift = std::make_shared(v0::Constant::create(input_y.get_element_type(), Shape{1}, {2}), input_y); + auto shift = + std::make_shared(v0::Constant::create(input_y.get_element_type(), ov::Shape{1}, {2}), input_y); if (direction == "RIGHT") { return {std::make_shared(input_x, shift)}; @@ -41,10 +42,7 @@ ov::OutputVector bitshift(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/bitshift.hpp b/src/frontends/onnx/frontend/src/op/bitshift.hpp index d1e755167bc24b..6450a88bf22b30 100644 --- a/src/frontends/onnx/frontend/src/op/bitshift.hpp +++ b/src/frontends/onnx/frontend/src/op/bitshift.hpp @@ -4,22 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector bitshift(const Node& node); +ov::OutputVector bitshift(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/bitwise_and.cpp b/src/frontends/onnx/frontend/src/op/bitwise_and.cpp index d13ea78c249dde..5d88117815121a 100644 --- a/src/frontends/onnx/frontend/src/op/bitwise_and.cpp +++ b/src/frontends/onnx/frontend/src/op/bitwise_and.cpp @@ -3,22 +3,23 @@ // #include "op/bitwise_and.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START #include "openvino/op/bitwise_and.hpp" using namespace ov::op; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector bitwise_and(const Node& node) { - const auto inputs = node.get_ng_inputs(); +ov::OutputVector bitwise_and(const ov::frontend::onnx::Node& node) { + const auto inputs = node.get_ov_inputs(); OPENVINO_ASSERT(inputs.size() == 2); return {std::make_shared(inputs[0], inputs[1])}; } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/bitwise_and.hpp b/src/frontends/onnx/frontend/src/op/bitwise_and.hpp index 69436bb58b8402..5b30fe5adf76a2 100644 --- a/src/frontends/onnx/frontend/src/op/bitwise_and.hpp +++ b/src/frontends/onnx/frontend/src/op/bitwise_and.hpp @@ -4,21 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector bitwise_and(const Node& node); +ov::OutputVector bitwise_and(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/bitwise_not.cpp b/src/frontends/onnx/frontend/src/op/bitwise_not.cpp index 77528b0b4780c2..4e9dd55052c292 100644 --- a/src/frontends/onnx/frontend/src/op/bitwise_not.cpp +++ b/src/frontends/onnx/frontend/src/op/bitwise_not.cpp @@ -3,21 +3,23 @@ // #include "op/bitwise_not.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START -#include "default_opset.hpp" +#include "openvino/op/bitwise_not.hpp" using namespace ov::op; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector bitwise_not(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0))}; +ov::OutputVector bitwise_not(const ov::frontend::onnx::Node& node) { + const auto inputs = node.get_ov_inputs(); + OPENVINO_ASSERT(inputs.size() == 1); + return {std::make_shared(inputs[0])}; } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/bitwise_not.hpp b/src/frontends/onnx/frontend/src/op/bitwise_not.hpp index 38d69385f96033..e1ac92a436dc6f 100644 --- a/src/frontends/onnx/frontend/src/op/bitwise_not.hpp +++ b/src/frontends/onnx/frontend/src/op/bitwise_not.hpp @@ -4,22 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector bitwise_not(const Node& node); +ov::OutputVector bitwise_not(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/bitwise_or.cpp b/src/frontends/onnx/frontend/src/op/bitwise_or.cpp index 7a7b6a415825a0..f0278dde8f3ced 100644 --- a/src/frontends/onnx/frontend/src/op/bitwise_or.cpp +++ b/src/frontends/onnx/frontend/src/op/bitwise_or.cpp @@ -3,22 +3,23 @@ // #include "op/bitwise_or.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START #include "openvino/op/bitwise_or.hpp" using namespace ov::op; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector bitwise_or(const Node& node) { - const auto inputs = node.get_ng_inputs(); +ov::OutputVector bitwise_or(const ov::frontend::onnx::Node& node) { + const auto inputs = node.get_ov_inputs(); OPENVINO_ASSERT(inputs.size() == 2); return {std::make_shared(inputs[0], inputs[1])}; } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/bitwise_or.hpp b/src/frontends/onnx/frontend/src/op/bitwise_or.hpp index 9ccb4380dfc0a7..7bee82aacc24d7 100644 --- a/src/frontends/onnx/frontend/src/op/bitwise_or.hpp +++ b/src/frontends/onnx/frontend/src/op/bitwise_or.hpp @@ -4,21 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector bitwise_or(const Node& node); +ov::OutputVector bitwise_or(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/bitwise_xor.cpp b/src/frontends/onnx/frontend/src/op/bitwise_xor.cpp index 8eed1800cece3e..0e965aebb081cc 100644 --- a/src/frontends/onnx/frontend/src/op/bitwise_xor.cpp +++ b/src/frontends/onnx/frontend/src/op/bitwise_xor.cpp @@ -3,22 +3,23 @@ // #include "op/bitwise_xor.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START #include "openvino/op/bitwise_xor.hpp" using namespace ov::op; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector bitwise_xor(const Node& node) { - const auto inputs = node.get_ng_inputs(); +ov::OutputVector bitwise_xor(const ov::frontend::onnx::Node& node) { + const auto inputs = node.get_ov_inputs(); OPENVINO_ASSERT(inputs.size() == 2); return {std::make_shared(inputs[0], inputs[1])}; } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/bitwise_xor.hpp b/src/frontends/onnx/frontend/src/op/bitwise_xor.hpp index e49581b4287e83..682082c00bc367 100644 --- a/src/frontends/onnx/frontend/src/op/bitwise_xor.hpp +++ b/src/frontends/onnx/frontend/src/op/bitwise_xor.hpp @@ -4,21 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector bitwise_xor(const Node& node); +ov::OutputVector bitwise_xor(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/blackmanwindow.cpp b/src/frontends/onnx/frontend/src/op/blackmanwindow.cpp index da32d73f11314e..7636b79e08d62d 100644 --- a/src/frontends/onnx/frontend/src/op/blackmanwindow.cpp +++ b/src/frontends/onnx/frontend/src/op/blackmanwindow.cpp @@ -19,13 +19,13 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector blackmanwindow(const Node& node) { - const auto size = node.get_ng_inputs().at(0); +ov::OutputVector blackmanwindow(const ov::frontend::onnx::Node& node) { + const auto size = node.get_ov_inputs().at(0); const auto output_datatype = common::get_ov_element_type(node.get_attribute_value("output_datatype", 1)); const bool periodic = node.get_attribute_value("periodic", 1) == 1; @@ -78,6 +78,6 @@ ov::OutputVector blackmanwindow(const Node& node) { } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/blackmanwindow.hpp b/src/frontends/onnx/frontend/src/op/blackmanwindow.hpp index 769264dfa36c2f..719c75ef7b8c37 100644 --- a/src/frontends/onnx/frontend/src/op/blackmanwindow.hpp +++ b/src/frontends/onnx/frontend/src/op/blackmanwindow.hpp @@ -3,20 +3,18 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector blackmanwindow(const Node& node); +ov::OutputVector blackmanwindow(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/cast.cpp b/src/frontends/onnx/frontend/src/op/cast.cpp index f3a4fb1c5cd9e2..18edc116f4f511 100644 --- a/src/frontends/onnx/frontend/src/op/cast.cpp +++ b/src/frontends/onnx/frontend/src/op/cast.cpp @@ -9,14 +9,14 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector cast(const Node& node) { - auto data = node.get_ng_inputs().at(0); +ov::OutputVector cast(const ov::frontend::onnx::Node& node) { + auto data = node.get_ov_inputs().at(0); int64_t target_type = node.get_attribute_value("to"); ov::element::Type elem_type = common::get_ov_element_type(target_type); @@ -25,6 +25,6 @@ ov::OutputVector cast(const Node& node) { } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/cast.hpp b/src/frontends/onnx/frontend/src/op/cast.hpp index 944c66cac3e8bd..313fac756e1a16 100644 --- a/src/frontends/onnx/frontend/src/op/cast.hpp +++ b/src/frontends/onnx/frontend/src/op/cast.hpp @@ -4,20 +4,18 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector cast(const Node& node); +ov::OutputVector cast(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/cast_like.cpp b/src/frontends/onnx/frontend/src/op/cast_like.cpp index 508b678f9fa3df..7eea8c808206d4 100644 --- a/src/frontends/onnx/frontend/src/op/cast_like.cpp +++ b/src/frontends/onnx/frontend/src/op/cast_like.cpp @@ -8,19 +8,19 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector cast_like(const Node& node) { - auto inputs = node.get_ng_inputs(); +ov::OutputVector cast_like(const ov::frontend::onnx::Node& node) { + auto inputs = node.get_ov_inputs(); return {std::make_shared(inputs.at(0), inputs.at(1))}; } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/cast_like.hpp b/src/frontends/onnx/frontend/src/op/cast_like.hpp index e452c6898924b0..aa7f65326b5e30 100644 --- a/src/frontends/onnx/frontend/src/op/cast_like.hpp +++ b/src/frontends/onnx/frontend/src/op/cast_like.hpp @@ -4,20 +4,18 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector cast_like(const Node& node); +ov::OutputVector cast_like(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/ceil.hpp b/src/frontends/onnx/frontend/src/op/ceil.hpp index 166f1e25e7b1e1..f7ba5c8c2ca015 100644 --- a/src/frontends/onnx/frontend/src/op/ceil.hpp +++ b/src/frontends/onnx/frontend/src/op/ceil.hpp @@ -4,25 +4,20 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/ceiling.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector ceil(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0))}; +inline ov::OutputVector ceil(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0))}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/clip.cpp b/src/frontends/onnx/frontend/src/op/clip.cpp index 706ea77dbca9df..5442b54465cda8 100644 --- a/src/frontends/onnx/frontend/src/op/clip.cpp +++ b/src/frontends/onnx/frontend/src/op/clip.cpp @@ -6,8 +6,7 @@ #include -#include "default_opset.hpp" -#include "onnx_import/core/null_node.hpp" +#include "core/null_node.hpp" #include "openvino/op/clamp.hpp" #include "openvino/op/maximum.hpp" #include "openvino/op/minimum.hpp" @@ -15,13 +14,13 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector clip(const Node& node) { - const auto data = node.get_ng_inputs().at(0); +ov::OutputVector clip(const ov::frontend::onnx::Node& node) { + const auto data = node.get_ov_inputs().at(0); const double max_value = node.get_attribute_value("max", std::numeric_limits::max()); @@ -72,8 +71,8 @@ std::shared_ptr get_constant_max_of_type(ov::element::Type } } // namespace -ov::OutputVector clip(const Node& node) { - const ov::OutputVector inputs{node.get_ng_inputs()}; +ov::OutputVector clip(const ov::frontend::onnx::Node& node) { + const ov::OutputVector inputs{node.get_ov_inputs()}; const ov::Output data = inputs.at(0); const ov::element::Type data_type = data.get_element_type(); ov::Output min; @@ -101,10 +100,7 @@ ov::OutputVector clip(const Node& node) { } } // namespace set_11 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/clip.hpp b/src/frontends/onnx/frontend/src/op/clip.hpp index 7fca94cd32753b..fb1cb1759e5069 100644 --- a/src/frontends/onnx/frontend/src/op/clip.hpp +++ b/src/frontends/onnx/frontend/src/op/clip.hpp @@ -4,27 +4,22 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector clip(const Node& node); +ov::OutputVector clip(const ov::frontend::onnx::Node& node); } // namespace set_1 namespace set_11 { -ov::OutputVector clip(const Node& node); +ov::OutputVector clip(const ov::frontend::onnx::Node& node); } // namespace set_11 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/com.microsoft/attention.cpp b/src/frontends/onnx/frontend/src/op/com.microsoft/attention.cpp index 43f1c909c614af..375e90f5084c43 100644 --- a/src/frontends/onnx/frontend/src/op/com.microsoft/attention.cpp +++ b/src/frontends/onnx/frontend/src/op/com.microsoft/attention.cpp @@ -1,10 +1,10 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include "op/com.microsoft/attention.hpp" -#include "onnx_import/core/null_node.hpp" +#include "core/null_node.hpp" #include "openvino/frontend/exception.hpp" #include "openvino/op/add.hpp" #include "openvino/op/broadcast.hpp" @@ -36,12 +36,14 @@ #include "openvino/op/subtract.hpp" #include "openvino/op/transpose.hpp" #include "openvino/op/unsqueeze.hpp" -#include "ov_models/ov_builders/split.hpp" +#include "utils/split.hpp" using namespace ov::op; +using ov::Shape; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace detail { namespace { @@ -69,8 +71,8 @@ std::shared_ptr get_present_state(const std::shared_ptr& K, } // namespace detail namespace set_1 { -ov::OutputVector attention(const Node& node) { - auto nodes = node.get_ng_inputs(); +ov::OutputVector attention(const ov::frontend::onnx::Node& node) { + auto nodes = node.get_ov_inputs(); const auto& input = nodes[0]; const auto& weights = nodes[1]; const auto& bias = nodes[2]; @@ -119,8 +121,8 @@ namespace detail { namespace { std::shared_ptr get_dimensions(const std::shared_ptr& shape, const std::vector& dims) { - static const auto zero = v0::Constant::create(ov::element::i32, Shape{}, {0}); - const auto dims_const = v0::Constant::create(ov::element::i32, Shape{dims.size()}, dims); + static const auto zero = v0::Constant::create(ov::element::i32, ov::Shape{}, {0}); + const auto dims_const = v0::Constant::create(ov::element::i32, ov::Shape{dims.size()}, dims); return std::make_shared(shape, dims_const, zero); } @@ -130,9 +132,9 @@ std::shared_ptr get_dimensions(const std::shared_ptr& node, std::shared_ptr get_hidden_size(const std::shared_ptr& node_shape) { // node has shape (batch_size, sequence_length, 3 * hidden_size) - const auto zero = v0::Constant::create(ov::element::i32, Shape{}, {0}); + const auto zero = v0::Constant::create(ov::element::i32, ov::Shape{}, {0}); const auto hidden_size_x3 = get_dimensions(node_shape, {2}); - const auto three = v0::Constant::create(ov::element::i64, Shape{}, {3}); + const auto three = v0::Constant::create(ov::element::i64, ov::Shape{}, {3}); const auto hidden_size = std::make_shared(hidden_size_x3, three); return hidden_size; } @@ -147,13 +149,13 @@ ov::NodeVector split_to_QKV(const std::shared_ptr& node, // node has shape (batch_size, sequence_length, 3 * hidden_size) // fetch the first two dimensions const auto batch_size_seq_len = get_dimensions(node_shape, {0, 1}); - const auto num_heads_node = v0::Constant::create(ov::element::i64, Shape{1}, {num_heads}); + const auto num_heads_node = v0::Constant::create(ov::element::i64, ov::Shape{1}, {num_heads}); if (qkv_hidden_sizes.size() == 0) { const auto hidden_size = get_hidden_size(node_shape); // head_size = hidden_size / num_heads head_size = std::make_shared(hidden_size, num_heads_node); // split the node into 3 even parts Q, K, V with shape (batch_size, sequence_len, hidden_size) - split = ov::op::util::split(node, 3, 2); + split = ov::op::util::make_split(node, 3, 2); // and reshape each part to new shape (batch_size, sequence_len, num_heads, head_size) auto new_shape = std::make_shared(ov::NodeVector{batch_size_seq_len, num_heads_node, head_size}, 0); for (size_t i = 0; i < split.size(); i++) { @@ -171,23 +173,23 @@ ov::NodeVector split_to_QKV(const std::shared_ptr& node, // Q: (batch_size, sequence_len, qkv_hidden_sizes[0]) // K: (batch_size, sequence_len, qkv_hidden_sizes[1]) // V: (batch_size, sequence_len, qkv_hidden_sizes[2]) - split = ov::op::util::split(node, qkv_hidden_sizes, 2); + split = ov::op::util::make_split(node, qkv_hidden_sizes, 2); // and reshape each part to new shape (batch_size, sequence_len, num_heads, head_size) for (size_t i = 0; i < split.size(); i++) { auto new_shape = std::make_shared( ov::NodeVector{batch_size_seq_len, num_heads_node, - v0::Constant::create(ov::element::i64, Shape{1}, {qkv_hidden_sizes[i] / num_heads})}, + v0::Constant::create(ov::element::i64, ov::Shape{1}, {qkv_hidden_sizes[i] / num_heads})}, 0); split[i] = std::make_shared(split[i], new_shape, false); } float head_size_val = qkv_hidden_sizes[0] > 0 ? static_cast(qkv_hidden_sizes[0]) / num_heads : static_cast(qkv_hidden_sizes[2]) / num_heads; - head_size = v0::Constant::create(node_type, Shape{1}, {head_size_val}); + head_size = v0::Constant::create(node_type, ov::Shape{1}, {head_size_val}); } // transpose Q, K and V to (batch_size, num_heads, sequence_len, head_size) - auto perm = v0::Constant::create(ov::element::i64, Shape{4}, {0, 2, 1, 3}); + auto perm = v0::Constant::create(ov::element::i64, ov::Shape{4}, {0, 2, 1, 3}); auto Q = std::make_shared(split[0], perm); auto K = std::make_shared(split[1], perm); auto V = std::make_shared(split[2], perm); @@ -269,42 +271,43 @@ std::shared_ptr attention_mask_from_indices(const ov::Output const ov::element::Type_t& type, const std::shared_ptr& batch_size, const std::shared_ptr& all_seq_len) { - const auto zero = v0::Constant::create(ov::element::i64, Shape{}, {0}); - const auto one = v0::Constant::create(ov::element::i64, Shape{}, {1}); + const auto zero = v0::Constant::create(ov::element::i64, ov::Shape{}, {0}); + const auto one = v0::Constant::create(ov::element::i64, ov::Shape{}, {1}); const auto stop = std::make_shared(all_seq_len, zero); std::shared_ptr base = std::make_shared(zero, stop, one, mask_index.get_element_type()); const auto target_shape = std::make_shared(ov::NodeVector{batch_size, all_seq_len}, 0); // broadcast 'base' to (batch_size, all_seq_len) base = std::make_shared(base, target_shape); - const auto indices_shape = - std::make_shared(ov::NodeVector{v0::Constant::create(ov::element::i64, Shape{1}, {-1}), batch_size}, - 0); + const auto indices_shape = std::make_shared( + ov::NodeVector{v0::Constant::create(ov::element::i64, ov::Shape{1}, {-1}), batch_size}, + + 0); std::shared_ptr indices = std::make_shared(mask_index, indices_shape, false); // fetch first row from indices std::shared_ptr tail_range_indices = std::make_shared(indices, zero, zero); tail_range_indices = std::make_shared(tail_range_indices, - v0::Constant::create(ov::element::i32, Shape{2}, {-1, 1}), + v0::Constant::create(ov::element::i32, ov::Shape{2}, {-1, 1}), false); const auto greater_eq = std::make_shared(base, tail_range_indices); std::shared_ptr tail_range_mask = std::make_shared(std::make_shared(greater_eq, type), - v0::Constant::create(type, Shape{}, {-10000})); + v0::Constant::create(type, ov::Shape{}, {-10000})); tail_range_mask = - std::make_shared(tail_range_mask, v0::Constant::create(ov::element::i64, Shape{2}, {1, 2})); + std::make_shared(tail_range_mask, v0::Constant::create(ov::element::i64, ov::Shape{2}, {1, 2})); - const auto gather_index = std::make_shared(v0::Constant::create(ov::element::i64, Shape{}, {1}), + const auto gather_index = std::make_shared(v0::Constant::create(ov::element::i64, ov::Shape{}, {1}), get_dimensions(indices, {0})); // fetch indices from the second row (or first if not available) std::shared_ptr head_range_indices = std::make_shared(indices, gather_index, zero); head_range_indices = std::make_shared(head_range_indices, - v0::Constant::create(ov::element::i32, Shape{2}, {-1, 1}), + v0::Constant::create(ov::element::i32, ov::Shape{2}, {-1, 1}), false); const auto less = std::make_shared(base, head_range_indices); std::shared_ptr mask = std::make_shared(less, greater_eq); mask = std::make_shared(std::make_shared(mask, type), - v0::Constant::create(type, Shape{}, {-10000})); + v0::Constant::create(type, ov::Shape{}, {-10000})); // reshape from (batch_size, all_seq_len) to (batch_size, 1, 1, all_seq_len) - mask = std::make_shared(mask, v0::Constant::create(ov::element::i64, Shape{2}, {1, 2})); + mask = std::make_shared(mask, v0::Constant::create(ov::element::i64, ov::Shape{2}, {1, 2})); const auto mask_index_first_dim = get_dimensions(mask_index.get_node_shared_ptr(), {0}); // compare mask_index.shape[0] with batch_size value @@ -345,8 +348,8 @@ NodeTuple unidirectional_mask(const ov::element::Type_t& type, const std::shared_ptr& seq_len, const std::shared_ptr& all_seq_len, const std::shared_ptr& past_seq_len) { - const auto zero = v0::Constant::create(ov::element::i64, Shape{}, {0}); - const auto one = v0::Constant::create(ov::element::i64, Shape{}, {1}); + const auto zero = v0::Constant::create(ov::element::i64, ov::Shape{}, {0}); + const auto one = v0::Constant::create(ov::element::i64, ov::Shape{}, {1}); const auto stop = std::make_shared(all_seq_len, zero); std::shared_ptr bin_mask = std::make_shared(zero, stop, one, ov::element::i32); auto target_shape = std::make_shared(ov::NodeVector{seq_len, all_seq_len}, 0); @@ -354,11 +357,11 @@ NodeTuple unidirectional_mask(const ov::element::Type_t& type, auto start = std::make_shared(std::make_shared(past_seq_len, one), zero); auto end = std::make_shared(std::make_shared(all_seq_len, one), zero); auto indices = std::make_shared(std::make_shared(start, end, one, ov::element::i32), - v0::Constant::create(ov::element::i32, Shape{1}, {1})); + v0::Constant::create(ov::element::i32, ov::Shape{1}, {1})); bin_mask = std::make_shared(bin_mask, indices); std::shared_ptr attention_mask = std::make_shared(std::make_shared(bin_mask, type), - v0::Constant::create(type, Shape{}, {-10000})); + v0::Constant::create(type, ov::Shape{}, {-10000})); bin_mask = std::make_shared(std::make_shared(bin_mask), type); return NodeTuple{attention_mask, bin_mask}; } @@ -372,27 +375,29 @@ NodeTuple unidirectional_mask(const ov::element::Type_t& type, // (batch_size, past_sequence_length + sequence_length) or // (batch_size, sequence_length, past_sequence_length + sequence_length) // -// Shape (batch_size, 1, max_sequence_length, max_sequence_length) is not supported in onnxruntime: +// ov::Shape (batch_size, 1, max_sequence_length, max_sequence_length) is not supported in onnxruntime: // https://github.com/microsoft/onnxruntime/blob/851554536ca8185b3413ee57449ea5ac93370193/onnxruntime/contrib_ops/cpu/bert/attention_helper.h#L78 std::shared_ptr raw_mask(const ov::Output& mask_index, ov::Dimension::value_type mask_rank, const ov::element::Type_t& type) { std::shared_ptr mask = std::make_shared(mask_index, type); mask = std::make_shared(mask, type); - mask = std::make_shared(v0::Constant::create(type, Shape{}, {1}), mask); - mask = std::make_shared(mask, v0::Constant::create(type, Shape{}, {-10000})); + mask = std::make_shared(v0::Constant::create(type, ov::Shape{}, {1}), mask); + mask = std::make_shared(mask, v0::Constant::create(type, ov::Shape{}, {-10000})); switch (mask_rank) { // Handle mask_index with (batch_size, past_sequence_length + sequence_length) shape // Reshape it to (batch_size, 1, 1, past_sequence_length + sequence_length) case 2: - mask = - std::make_shared(mask, v0::Constant::create(ov::element::i64, Shape{4}, {0, 1, 1, -1}), true); + mask = std::make_shared(mask, + v0::Constant::create(ov::element::i64, ov::Shape{4}, {0, 1, 1, -1}), + true); break; // Handle mask_index with (batch_size, sequence_length, past_sequence_length + sequence_length) shape // Reshape it to (batch_size, 1, sequence_length, past_sequence_length + sequence_length) case 3: - mask = - std::make_shared(mask, v0::Constant::create(ov::element::i64, Shape{4}, {0, 1, 0, -1}), true); + mask = std::make_shared(mask, + v0::Constant::create(ov::element::i64, ov::Shape{4}, {0, 1, 0, -1}), + true); break; } return mask; @@ -403,8 +408,8 @@ bool is_past_input_available(const ov::OutputVector& op_inputs) { } NodeTuple get_attention_mask(const ov::OutputVector& op_inputs, bool unidirectional) { - const auto zero = v0::Constant::create(ov::element::i64, Shape{1}, {0}); - const auto one = v0::Constant::create(ov::element::i64, Shape{1}, {1}); + const auto zero = v0::Constant::create(ov::element::i64, ov::Shape{1}, {0}); + const auto one = v0::Constant::create(ov::element::i64, ov::Shape{1}, {1}); std::shared_ptr past_seq_len; // get the value of past_sequence_length @@ -463,7 +468,7 @@ std::shared_ptr attention_softmax(const ov::OutputVector& op_inputs, const std::shared_ptr& bin_mask, const std::shared_ptr& head_size, bool unidirectional) { - auto zero = v0::Constant::create(ov::element::i64, Shape{}, {0}); + auto zero = v0::Constant::create(ov::element::i64, ov::Shape{}, {0}); if (is_past_input_available(op_inputs)) { // concat past K and V with present ones const auto& past = op_inputs[4]; @@ -472,7 +477,7 @@ std::shared_ptr attention_softmax(const ov::OutputVector& op_inputs, // (2, batch_size, num_heads, past_sequence_length + sequence_length, head_size) // so we need to split it into two parts, remove first dimension from each part and concatenate first part // with current K and second part with current V - const auto split = ov::op::util::split(past, 2, 0); + const auto split = ov::op::util::make_split(past, 2, 0); const auto past_K = std::make_shared(split[0], zero); K = std::make_shared(ov::NodeVector{past_K, K}, 2); const auto past_V = std::make_shared(split[1], zero); @@ -507,9 +512,9 @@ std::shared_ptr attention_softmax(const ov::OutputVector& op_inputs, std::shared_ptr output = std::make_shared(softmax, V); // transpose the result from (batch_size, num_heads, sequence_length, head_size) // to (batch_size, sequence_length, num_heads, head_size) - const auto perm = v0::Constant::create(ov::element::i64, Shape{4}, {0, 2, 1, 3}); + const auto perm = v0::Constant::create(ov::element::i64, ov::Shape{4}, {0, 2, 1, 3}); output = std::make_shared(output, perm); - auto new_shape = v0::Constant::create(ov::element::i32, Shape{3}, {0, 0, -1}); + auto new_shape = v0::Constant::create(ov::element::i32, ov::Shape{3}, {0, 0, -1}); // reshape the result from (batch_size, sequence_length, num_heads, head_size) to (batch_size, sequence_length, // num_heads * head_size) output = std::make_shared(output, new_shape, true); @@ -524,7 +529,7 @@ std::shared_ptr attention_softmax(const ov::OutputVector& op_inputs, std::shared_ptr get_present_state(const std::shared_ptr& K, const std::shared_ptr& V, const ov::OutputVector& op_inputs) { - auto zero = v0::Constant::create(ov::element::i64, Shape{1}, {0}); + auto zero = v0::Constant::create(ov::element::i64, ov::Shape{1}, {0}); // expand K shape (batch_size, num_heads, sequence_length, head_size) to // (1, batch_size, num_heads, sequence_length, head_size) auto K_unsqueezed = std::make_shared(K, zero); @@ -556,5 +561,6 @@ std::shared_ptr get_present_state(const std::shared_ptr& K, } // namespace } // namespace detail } // namespace op -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/com.microsoft/attention.hpp b/src/frontends/onnx/frontend/src/op/com.microsoft/attention.hpp index 037858021c862c..9b851563526a56 100644 --- a/src/frontends/onnx/frontend/src/op/com.microsoft/attention.hpp +++ b/src/frontends/onnx/frontend/src/op/com.microsoft/attention.hpp @@ -4,17 +4,16 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector attention(const Node& node); +ov::OutputVector attention(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/com.microsoft/bias_gelu.cpp b/src/frontends/onnx/frontend/src/op/com.microsoft/bias_gelu.cpp index 9011638b1e0ef1..a0eec5fceeaf20 100644 --- a/src/frontends/onnx/frontend/src/op/com.microsoft/bias_gelu.cpp +++ b/src/frontends/onnx/frontend/src/op/com.microsoft/bias_gelu.cpp @@ -10,16 +10,18 @@ using namespace ov::op; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector bias_gelu(const Node& node) { - auto nodes = node.get_ng_inputs(); +ov::OutputVector bias_gelu(const ov::frontend::onnx::Node& node) { + auto nodes = node.get_ov_inputs(); FRONT_END_GENERAL_CHECK(nodes.size() == 2, "BiasGelu takes 2 inputs. Provided " + std::to_string(nodes.size())); return {std::make_shared(std::make_shared(nodes.at(0), nodes.at(1)))}; } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/com.microsoft/bias_gelu.hpp b/src/frontends/onnx/frontend/src/op/com.microsoft/bias_gelu.hpp index 784d5c1a5d9aca..6bf0ad41033a4a 100644 --- a/src/frontends/onnx/frontend/src/op/com.microsoft/bias_gelu.hpp +++ b/src/frontends/onnx/frontend/src/op/com.microsoft/bias_gelu.hpp @@ -4,17 +4,16 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector bias_gelu(const Node& node); +ov::OutputVector bias_gelu(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/com.microsoft/embed_layer_normalization.cpp b/src/frontends/onnx/frontend/src/op/com.microsoft/embed_layer_normalization.cpp index 22a44c041ae3b2..eae772aaeac2f4 100644 --- a/src/frontends/onnx/frontend/src/op/com.microsoft/embed_layer_normalization.cpp +++ b/src/frontends/onnx/frontend/src/op/com.microsoft/embed_layer_normalization.cpp @@ -1,10 +1,10 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include "op/com.microsoft/embed_layer_normalization.hpp" -#include "onnx_import/core/null_node.hpp" +#include "core/null_node.hpp" #include "openvino/frontend/exception.hpp" #include "openvino/op/add.hpp" #include "openvino/op/broadcast.hpp" @@ -17,13 +17,15 @@ #include "openvino/op/slice.hpp" using namespace ov::op; +using ov::Shape; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector embed_layer_normalization(const Node& node) { - auto nodes = node.get_ng_inputs(); +ov::OutputVector embed_layer_normalization(const ov::frontend::onnx::Node& node) { + auto nodes = node.get_ov_inputs(); auto num_nodes = nodes.size(); FRONT_END_GENERAL_CHECK(num_nodes >= 7 && num_nodes <= 9, @@ -38,7 +40,7 @@ ov::OutputVector embed_layer_normalization(const Node& node) { const auto& gamma = nodes[5]; const auto& beta = nodes[6]; - const auto zero = v0::Constant::create(ov::element::i32, Shape{1}, {0}); + const auto zero = v0::Constant::create(ov::element::i32, ov::Shape{1}, {0}); std::shared_ptr input = std::make_shared(word_embeddings, input_ids, zero, 0); // add position embeddings if (num_nodes > 8 && !ov::op::util::is_null(nodes[8])) { @@ -54,7 +56,7 @@ ov::OutputVector embed_layer_normalization(const Node& node) { // therefore input and position_embeddings cannot be added together // so we need slice the position_embeddings to [sequence_length, hidden_size] first // then add it with input. - const auto one = v0::Constant::create(ov::element::i32, Shape{1}, {1}); + const auto one = v0::Constant::create(ov::element::i32, ov::Shape{1}, {1}); const auto input_ids_shape = std::make_shared(input_ids, ov::element::i32); const auto seqlen = std::make_shared(input_ids_shape, one, zero, 0); const auto gathered_position_embeddings = @@ -75,7 +77,7 @@ ov::OutputVector embed_layer_normalization(const Node& node) { // hidden_size dimension is 2 here, because the shape after Gather(word_embedding, input_ids) // is (batch_size, seq_len, hidden_size) int hidden_size_dim = 2; - const auto reduction_axes = v0::Constant::create(ov::element::i32, Shape{1}, {hidden_size_dim}); + const auto reduction_axes = v0::Constant::create(ov::element::i32, ov::Shape{1}, {hidden_size_dim}); std::shared_ptr result = std::make_shared(input, reduction_axes, true, eps, ov::op::MVNEpsMode::INSIDE_SQRT); @@ -87,7 +89,7 @@ ov::OutputVector embed_layer_normalization(const Node& node) { std::shared_ptr mask_index; if (num_nodes > 7 && !ov::op::util::is_null(nodes[7])) { FRONT_END_GENERAL_CHECK(nodes[7].get_element_type() == ov::element::i32, "mask must have int32 type"); - auto axis = v0::Constant::create(ov::element::i32, Shape{}, {1}); + auto axis = v0::Constant::create(ov::element::i32, ov::Shape{}, {1}); mask_index = std::make_shared(nodes[7], axis, false); } else { auto batch_size = std::make_shared(std::make_shared(nodes[0]), @@ -99,5 +101,6 @@ ov::OutputVector embed_layer_normalization(const Node& node) { } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/com.microsoft/embed_layer_normalization.hpp b/src/frontends/onnx/frontend/src/op/com.microsoft/embed_layer_normalization.hpp index b838092c0b987b..2106b64aadcd36 100644 --- a/src/frontends/onnx/frontend/src/op/com.microsoft/embed_layer_normalization.hpp +++ b/src/frontends/onnx/frontend/src/op/com.microsoft/embed_layer_normalization.hpp @@ -4,17 +4,16 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector embed_layer_normalization(const Node& node); +ov::OutputVector embed_layer_normalization(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/com.microsoft/fused_conv.cpp b/src/frontends/onnx/frontend/src/op/com.microsoft/fused_conv.cpp index dea8a9ca5e8183..79badc0d048bf0 100644 --- a/src/frontends/onnx/frontend/src/op/com.microsoft/fused_conv.cpp +++ b/src/frontends/onnx/frontend/src/op/com.microsoft/fused_conv.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -20,16 +20,18 @@ #include "openvino/op/tanh.hpp" using namespace ov::op; +using ov::Shape; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector fused_conv(const Node& node) { +ov::OutputVector fused_conv(const ov::frontend::onnx::Node& node) { auto conv_res = conv(node).at(0); - if (node.get_ng_inputs().size() == 4) { // Z input provided - conv_res = std::make_shared(conv_res, node.get_ng_inputs()[3]); + if (node.get_ov_inputs().size() == 4) { // Z input provided + conv_res = std::make_shared(conv_res, node.get_ov_inputs()[3]); } const auto activation_type = node.get_attribute_value("activation"); @@ -50,14 +52,14 @@ ov::OutputVector fused_conv(const Node& node) { CHECK_VALID_NODE(node, activation_params.size() == 1, "activation_alpha attribute of LeakyRelu activation function was not provided"); - const auto activation_alpha_node = v0::Constant::create(ov::element::f32, Shape{}, activation_params); + const auto activation_alpha_node = v0::Constant::create(ov::element::f32, ov::Shape{}, activation_params); return {std::make_shared(conv_res, activation_alpha_node)}; } else if (activation_type == "HardSigmoid") { CHECK_VALID_NODE(node, activation_params.size() == 2, "alpha and beta attributes of HardSigmoid activation function were not provided"); - const auto alpha = v0::Constant::create(ov::element::f32, Shape{}, {activation_params[0]}); - const auto beta = v0::Constant::create(ov::element::f32, Shape{}, {activation_params[1]}); + const auto alpha = v0::Constant::create(ov::element::f32, ov::Shape{}, {activation_params[0]}); + const auto beta = v0::Constant::create(ov::element::f32, ov::Shape{}, {activation_params[1]}); return {std::make_shared(conv_res, alpha, beta)}; } CHECK_VALID_NODE(node, @@ -70,9 +72,7 @@ ov::OutputVector fused_conv(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/com.microsoft/fused_conv.hpp b/src/frontends/onnx/frontend/src/op/com.microsoft/fused_conv.hpp index 719764c4f52066..2d46fceeded4be 100644 --- a/src/frontends/onnx/frontend/src/op/com.microsoft/fused_conv.hpp +++ b/src/frontends/onnx/frontend/src/op/com.microsoft/fused_conv.hpp @@ -4,17 +4,16 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector fused_conv(const Node& node); +ov::OutputVector fused_conv(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/com.microsoft/fusedgemm.cpp b/src/frontends/onnx/frontend/src/op/com.microsoft/fusedgemm.cpp index f6491b7a169825..8359d76617b79a 100644 --- a/src/frontends/onnx/frontend/src/op/com.microsoft/fusedgemm.cpp +++ b/src/frontends/onnx/frontend/src/op/com.microsoft/fusedgemm.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -6,7 +6,7 @@ #include -#include "onnx_import/core/null_node.hpp" +#include "core/null_node.hpp" #include "openvino/frontend/exception.hpp" #include "openvino/op/add.hpp" #include "openvino/op/constant.hpp" @@ -16,13 +16,15 @@ #include "openvino/op/relu.hpp" using namespace ov::op; +using ov::Shape; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector fusedgemm(const Node& node) { - ov::OutputVector inputs{node.get_ng_inputs()}; +ov::OutputVector fusedgemm(const ov::frontend::onnx::Node& node) { + ov::OutputVector inputs{node.get_ov_inputs()}; auto num_inputs = inputs.size(); FRONT_END_GENERAL_CHECK(num_inputs == 2 || num_inputs == 3, "FusedGemm takes 2/3 inputs. Provided " + std::to_string(num_inputs)); @@ -55,16 +57,14 @@ ov::OutputVector fusedgemm(const Node& node) { if (activation_type == "LeakyRelu") { double activation_alpha = node.get_attribute_value("activation_alpha", 0.01); std::shared_ptr activation_alpha_node = - v0::Constant::create(input_c.get_element_type(), Shape{1}, {activation_alpha}); + v0::Constant::create(input_c.get_element_type(), ov::Shape{1}, {activation_alpha}); return {std::make_shared(gemm_res, activation_alpha_node)}; } return {std::make_shared(gemm_res)}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/com.microsoft/fusedgemm.hpp b/src/frontends/onnx/frontend/src/op/com.microsoft/fusedgemm.hpp index 02b104f8b6b135..630a03154a2ef7 100644 --- a/src/frontends/onnx/frontend/src/op/com.microsoft/fusedgemm.hpp +++ b/src/frontends/onnx/frontend/src/op/com.microsoft/fusedgemm.hpp @@ -4,17 +4,16 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector fusedgemm(const Node& node); +ov::OutputVector fusedgemm(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/com.microsoft/skip_layer_normalization.cpp b/src/frontends/onnx/frontend/src/op/com.microsoft/skip_layer_normalization.cpp index c062808a9abc29..f003ace40cdfd2 100644 --- a/src/frontends/onnx/frontend/src/op/com.microsoft/skip_layer_normalization.cpp +++ b/src/frontends/onnx/frontend/src/op/com.microsoft/skip_layer_normalization.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -11,13 +11,15 @@ #include "openvino/op/mvn.hpp" using namespace ov::op; +using ov::Shape; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector skip_layer_normalization(const Node& node) { - auto nodes = node.get_ng_inputs(); +ov::OutputVector skip_layer_normalization(const ov::frontend::onnx::Node& node) { + auto nodes = node.get_ov_inputs(); auto num_nodes = nodes.size(); FRONT_END_GENERAL_CHECK(num_nodes >= 3 && num_nodes <= 5, "SkipLayerNormalization takes 3, 4 or 5 inputs. Provided " + std::to_string(num_nodes)); @@ -31,7 +33,7 @@ ov::OutputVector skip_layer_normalization(const Node& node) { float eps = node.get_attribute_value("epsilon"); // reduce over hidden_size int hidden_size_dim = 2; - const auto reduction_axes = v0::Constant::create(ov::element::i32, Shape{1}, {hidden_size_dim}); + const auto reduction_axes = v0::Constant::create(ov::element::i32, ov::Shape{1}, {hidden_size_dim}); std::shared_ptr result = std::make_shared(input, reduction_axes, true, eps, ov::op::MVNEpsMode::INSIDE_SQRT); // multiply by gamma @@ -47,5 +49,6 @@ ov::OutputVector skip_layer_normalization(const Node& node) { } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/com.microsoft/skip_layer_normalization.hpp b/src/frontends/onnx/frontend/src/op/com.microsoft/skip_layer_normalization.hpp index abc9d28058eb1b..7f54e5e9344dcf 100644 --- a/src/frontends/onnx/frontend/src/op/com.microsoft/skip_layer_normalization.hpp +++ b/src/frontends/onnx/frontend/src/op/com.microsoft/skip_layer_normalization.hpp @@ -4,17 +4,16 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector skip_layer_normalization(const Node& node); +ov::OutputVector skip_layer_normalization(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/compress.cpp b/src/frontends/onnx/frontend/src/op/compress.cpp index 118754375282dc..84a11c2f17734a 100644 --- a/src/frontends/onnx/frontend/src/op/compress.cpp +++ b/src/frontends/onnx/frontend/src/op/compress.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -8,18 +8,19 @@ #include "openvino/op/gather.hpp" #include "openvino/op/non_zero.hpp" #include "openvino/op/squeeze.hpp" -#include "ov_models/ov_builders/reshape.hpp" +#include "utils/reshape.hpp" using namespace ov::op; +using ov::Shape; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector compress(const Node& node) { - auto data = node.get_ng_inputs().at(0); - auto condition = node.get_ng_inputs().at(1); +ov::OutputVector compress(const ov::frontend::onnx::Node& node) { + auto data = node.get_ov_inputs().at(0); + auto condition = node.get_ov_inputs().at(1); int64_t axis = 0; if (node.has_attribute("axis")) { @@ -29,8 +30,8 @@ ov::OutputVector compress(const Node& node) { data = std::make_shared(ov::op::util::flatten(data, static_cast(axis))); data = std::make_shared(ov::op::util::flatten(data, static_cast(axis))); } - auto axis_node = v0::Constant::create(ov::element::i64, Shape{}, {axis}); - auto zero_node = v0::Constant::create(ov::element::i64, Shape{}, {0}); + auto axis_node = v0::Constant::create(ov::element::i64, ov::Shape{}, {axis}); + auto zero_node = v0::Constant::create(ov::element::i64, ov::Shape{}, {0}); auto result = std::make_shared(data, std::make_shared(std::make_shared(condition), zero_node), @@ -39,10 +40,7 @@ ov::OutputVector compress(const Node& node) { return {result}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/compress.hpp b/src/frontends/onnx/frontend/src/op/compress.hpp index 671133432c2df1..7ea4ed5fc5a999 100644 --- a/src/frontends/onnx/frontend/src/op/compress.hpp +++ b/src/frontends/onnx/frontend/src/op/compress.hpp @@ -4,19 +4,16 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector compress(const Node& node); +ov::OutputVector compress(const ov::frontend::onnx::Node& node); } } // namespace op -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/concat.cpp b/src/frontends/onnx/frontend/src/op/concat.cpp index 6c9e87daaf8ec3..23bbf970657457 100644 --- a/src/frontends/onnx/frontend/src/op/concat.cpp +++ b/src/frontends/onnx/frontend/src/op/concat.cpp @@ -9,13 +9,13 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector concat(const Node& node) { - ov::OutputVector inputs{node.get_ng_inputs()}; +ov::OutputVector concat(const ov::frontend::onnx::Node& node) { + ov::OutputVector inputs{node.get_ov_inputs()}; std::int64_t axis = node.get_attribute_value("axis"); ov::OutputVector valid_inputs; std::copy_if(inputs.begin(), inputs.end(), std::back_inserter(valid_inputs), [](ov::Output& in) -> bool { @@ -25,10 +25,7 @@ ov::OutputVector concat(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/concat.hpp b/src/frontends/onnx/frontend/src/op/concat.hpp index 8936cb9b382d99..026c253c433df7 100644 --- a/src/frontends/onnx/frontend/src/op/concat.hpp +++ b/src/frontends/onnx/frontend/src/op/concat.hpp @@ -4,22 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector concat(const Node& node); +ov::OutputVector concat(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/constant.cpp b/src/frontends/onnx/frontend/src/op/constant.cpp index 3642eaa48196b5..79a001aeefd615 100644 --- a/src/frontends/onnx/frontend/src/op/constant.cpp +++ b/src/frontends/onnx/frontend/src/op/constant.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -9,15 +9,15 @@ #include "core/attribute.hpp" #include "core/sparse_tensor.hpp" #include "core/tensor.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/frontend/exception.hpp" #include "openvino/op/constant.hpp" using namespace ov::op; +using ov::Shape; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace { template @@ -39,7 +39,7 @@ std::vector get_dense_vector(const std::vector& values, const std::vector< template std::shared_ptr make_dense_tensor_as_constant(const std::vector& indices, const Tensor& values_tensor, - const Shape& shape) { + const ov::Shape& shape) { auto values = values_tensor.get_data(); auto dense_vector = get_dense_vector(values, indices, shape_size(shape)); return v0::Constant::create(values_tensor.get_ov_type(), shape, dense_vector); @@ -47,7 +47,7 @@ std::shared_ptr make_dense_tensor_as_constant(const std::vector get_dense_tensor_as_constant(const std::vector& absolute_indices, const Tensor& values_tensor, - const Shape& shape) { + const ov::Shape& shape) { switch (values_tensor.get_ov_type()) { case ov::element::boolean: return make_dense_tensor_as_constant(absolute_indices, values_tensor, shape); @@ -80,7 +80,7 @@ std::shared_ptr get_dense_tensor_as_constant(const std::vector get_absolute_indices(const Tensor& indices_tensor, const Shape& shape, const size_t& nnz) { +std::vector get_absolute_indices(const Tensor& indices_tensor, const ov::Shape& shape, const size_t& nnz) { auto rank = shape.size(); auto indices = indices_tensor.get_data(); auto indices_shape = indices_tensor.get_shape(); @@ -107,7 +107,7 @@ std::vector get_absolute_indices(const Tensor& indices_tensor, const Sh } // namespace namespace set_1 { -ov::OutputVector constant(const onnx_import::Node& node) { +ov::OutputVector constant(const ov::frontend::onnx::Node& node) { auto tensor = node.get_attribute_value("value"); return {tensor.get_ov_constant()}; } @@ -115,7 +115,7 @@ ov::OutputVector constant(const onnx_import::Node& node) { } // namespace set_1 namespace set_13 { -ov::OutputVector constant(const onnx_import::Node& node) { +ov::OutputVector constant(const ov::frontend::onnx::Node& node) { auto attributes_names = node.get_attribute_names(); FRONT_END_GENERAL_CHECK(attributes_names.size() == 1, "The Constant op expects exactly one attribute." @@ -138,7 +138,7 @@ ov::OutputVector constant(const onnx_import::Node& node) { auto sparse_tensor = attribute.get_sparse_tensor(); const Tensor& values_tensor = sparse_tensor.get_values(); const Tensor& indices_tensor = sparse_tensor.get_indices(); - const Shape& shape = sparse_tensor.get_shape(); + const ov::Shape& shape = sparse_tensor.get_shape(); auto rank = shape.size(); // NNZ - the number of non-zero values in the sparse-tensor auto nnz = values_tensor.get_shape().at(0); @@ -185,6 +185,6 @@ ov::OutputVector constant(const onnx_import::Node& node) { } } // namespace set_13 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/constant.hpp b/src/frontends/onnx/frontend/src/op/constant.hpp index adb9270f263074..d5f9e0e9ab58c7 100644 --- a/src/frontends/onnx/frontend/src/op/constant.hpp +++ b/src/frontends/onnx/frontend/src/op/constant.hpp @@ -4,27 +4,22 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector constant(const Node& node); +ov::OutputVector constant(const ov::frontend::onnx::Node& node); } // namespace set_1 namespace set_13 { -ov::OutputVector constant(const Node& node); +ov::OutputVector constant(const ov::frontend::onnx::Node& node); } // namespace set_13 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/constant_fill.cpp b/src/frontends/onnx/frontend/src/op/constant_fill.cpp index f800d0c876fbb4..619891101ba6b3 100644 --- a/src/frontends/onnx/frontend/src/op/constant_fill.cpp +++ b/src/frontends/onnx/frontend/src/op/constant_fill.cpp @@ -6,6 +6,8 @@ #include // onnx types +using namespace ::ONNX_NAMESPACE; + #include "exceptions.hpp" #include "onnx_common/utils.hpp" #include "openvino/op/broadcast.hpp" @@ -14,12 +16,12 @@ using namespace ov::op; using namespace ov::frontend::onnx::common; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector constant_fill(const Node& node) { +ov::OutputVector constant_fill(const ov::frontend::onnx::Node& node) { ov::Output target_shape; const auto dtype = node.get_attribute_value("dtype", static_cast(TensorProto_DataType_FLOAT)); const auto ng_type = onnx_to_ov_data_type(static_cast(dtype)); @@ -28,9 +30,9 @@ ov::OutputVector constant_fill(const Node& node) { if (input_as_shape == 1) // use the first input as target shape { CHECK_VALID_NODE(node, - node.get_ng_inputs().size() > 0, + node.get_ov_inputs().size() > 0, "The input which determines output shape was not provided"); - target_shape = node.get_ng_inputs().at(0); + target_shape = node.get_ov_inputs().at(0); if (node.has_attribute("extra_shape")) { const auto extra_shape_const = node.get_attribute_as_constant>("extra_shape", target_shape.get_element_type()); @@ -46,7 +48,6 @@ ov::OutputVector constant_fill(const Node& node) { } // namespace set_1 } // namespace op -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/constant_fill.hpp b/src/frontends/onnx/frontend/src/op/constant_fill.hpp index 78810d70fbf2e8..ddd1f7a230dc0f 100644 --- a/src/frontends/onnx/frontend/src/op/constant_fill.hpp +++ b/src/frontends/onnx/frontend/src/op/constant_fill.hpp @@ -4,22 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { // ConstantFill is a deprecated experimental operator removed in ONNX 1.4 -ov::OutputVector constant_fill(const Node& node); +ov::OutputVector constant_fill(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/constant_of_shape.cpp b/src/frontends/onnx/frontend/src/op/constant_of_shape.cpp index e2f559b9f3669f..4e1bf529f6ba0e 100644 --- a/src/frontends/onnx/frontend/src/op/constant_of_shape.cpp +++ b/src/frontends/onnx/frontend/src/op/constant_of_shape.cpp @@ -4,8 +4,8 @@ #include "op/constant_of_shape.hpp" +#include "core/null_node.hpp" #include "core/tensor.hpp" -#include "onnx_import/core/null_node.hpp" #include "op/constant.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/constant.hpp" @@ -14,12 +14,12 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector constant_of_shape(const onnx_import::Node& node) { +ov::OutputVector constant_of_shape(const ov::frontend::onnx::Node& node) { ov::Output constant_value; if (node.has_attribute("value")) { auto value_tensor = node.get_attribute_value("value"); @@ -28,7 +28,7 @@ ov::OutputVector constant_of_shape(const onnx_import::Node& node) { } else { constant_value = v0::Constant::create(ov::element::f32, {}, {0}); } - const auto& inputs = node.get_ng_inputs(); + const auto& inputs = node.get_ov_inputs(); if (inputs.size() == 0 || common::is_failsafe_node(inputs[0].get_node_shared_ptr()) || ov::op::util::is_null(inputs[0])) { return {constant_value}; @@ -37,10 +37,7 @@ ov::OutputVector constant_of_shape(const onnx_import::Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/constant_of_shape.hpp b/src/frontends/onnx/frontend/src/op/constant_of_shape.hpp index 4890fb95696b3d..41c82fdee90009 100644 --- a/src/frontends/onnx/frontend/src/op/constant_of_shape.hpp +++ b/src/frontends/onnx/frontend/src/op/constant_of_shape.hpp @@ -4,22 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector constant_of_shape(const Node& node); +ov::OutputVector constant_of_shape(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/conv.cpp b/src/frontends/onnx/frontend/src/op/conv.cpp index 2bb7e2ed1b2134..24a53af88eeff9 100644 --- a/src/frontends/onnx/frontend/src/op/conv.cpp +++ b/src/frontends/onnx/frontend/src/op/conv.cpp @@ -4,21 +4,20 @@ #include "op/conv.hpp" +#include "core/null_node.hpp" #include "exceptions.hpp" -#include "onnx_import/core/null_node.hpp" #include "openvino/frontend/exception.hpp" #include "openvino/op/add.hpp" #include "openvino/op/shape_of.hpp" -#include "ov_models/ov_builders/reshape.hpp" #include "utils/conv_factory.hpp" #include "utils/convpool.hpp" #include "utils/reshape.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START using namespace ov::op; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { namespace detail { @@ -30,7 +29,7 @@ std::shared_ptr add_bias(const ov::Output& ng_conv, const ov return {std::make_shared(ng_conv, reshape::reshape_channel_shaped_node_to_nchw(bias, conv_rank))}; } -ov::OutputVector conv(const Node& node, +ov::OutputVector conv(const ov::frontend::onnx::Node& node, ov::Output data, ov::Output filters, ov::Output bias) { @@ -73,15 +72,12 @@ ov::OutputVector conv(const Node& node, } } // namespace detail -ov::OutputVector conv(const Node& node) { - const ov::OutputVector& inputs = node.get_ng_inputs(); +ov::OutputVector conv(const ov::frontend::onnx::Node& node) { + const ov::OutputVector& inputs = node.get_ov_inputs(); return detail::conv(node, inputs[0], inputs[1], inputs.size() < 3 ? std::make_shared() : inputs[2]); } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/conv.hpp b/src/frontends/onnx/frontend/src/op/conv.hpp index 4c55a76866621b..9882758056ad7b 100644 --- a/src/frontends/onnx/frontend/src/op/conv.hpp +++ b/src/frontends/onnx/frontend/src/op/conv.hpp @@ -4,18 +4,16 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/core/node.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { namespace detail { -ov::OutputVector conv(const Node& node, +ov::OutputVector conv(const ov::frontend::onnx::Node& node, ov::Output data, ov::Output filters, ov::Output bias); @@ -26,13 +24,10 @@ ov::OutputVector conv(const Node& node, /// /// \return The vector containing OV nodes producing output of ONNX convolution /// operation. -ov::OutputVector conv(const Node& node); +ov::OutputVector conv(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/conv_integer.cpp b/src/frontends/onnx/frontend/src/op/conv_integer.cpp index b729e00cfd4e1b..e40453655bf01e 100644 --- a/src/frontends/onnx/frontend/src/op/conv_integer.cpp +++ b/src/frontends/onnx/frontend/src/op/conv_integer.cpp @@ -16,9 +16,9 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace { std::shared_ptr get_filter_zero_point(const ov::OutputVector& inputs) { const auto& original_zero_point = @@ -45,8 +45,8 @@ std::shared_ptr get_filter_zero_point(const ov::OutputVector& inputs) namespace op { namespace set_1 { -ov::OutputVector conv_integer(const Node& node) { - const ov::OutputVector& inputs = node.get_ng_inputs(); +ov::OutputVector conv_integer(const ov::frontend::onnx::Node& node) { + const ov::OutputVector& inputs = node.get_ov_inputs(); const auto& input = inputs.at(0); const auto& filter = inputs.at(1); @@ -82,6 +82,6 @@ ov::OutputVector conv_integer(const Node& node) { } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/conv_integer.hpp b/src/frontends/onnx/frontend/src/op/conv_integer.hpp index 730f0ca6b6fdcf..2d86bec3176f99 100644 --- a/src/frontends/onnx/frontend/src/op/conv_integer.hpp +++ b/src/frontends/onnx/frontend/src/op/conv_integer.hpp @@ -4,13 +4,11 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { /// \brief Performs ONNX ConvInteger operation. @@ -19,13 +17,10 @@ namespace set_1 { /// /// \return The vector containing OV nodes producing output of quantized ONNX /// convolution operation. -ov::OutputVector conv_integer(const Node& node); +ov::OutputVector conv_integer(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/conv_transpose.cpp b/src/frontends/onnx/frontend/src/op/conv_transpose.cpp index 2e0276ada0172f..2cdc88ba784d22 100644 --- a/src/frontends/onnx/frontend/src/op/conv_transpose.cpp +++ b/src/frontends/onnx/frontend/src/op/conv_transpose.cpp @@ -1,10 +1,11 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include "op/conv_transpose.hpp" #include "exceptions.hpp" +#include "openvino/core/coordinate_diff.hpp" #include "openvino/op/add.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/concat.hpp" @@ -15,21 +16,24 @@ #include "openvino/op/shape_of.hpp" #include "openvino/op/strided_slice.hpp" #include "openvino/op/subtract.hpp" -#include "ov_models/ov_builders/reshape.hpp" #include "utils/convpool.hpp" +#include "utils/reshape.hpp" using namespace ov::op; +using ov::CoordinateDiff; +using ov::Shape; +using ov::Strides; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { namespace { ov::Output make_group_conv_backprop(const ov::Output& data, const ov::Output& filters, - const Strides& strides, - const Strides& dilations, + const ov::Strides& strides, + const ov::Strides& dilations, const ov::CoordinateDiff& pads_begin, const ov::CoordinateDiff& pads_end, const ov::op::PadType& auto_pad_type, @@ -49,7 +53,7 @@ ov::Output make_group_conv_backprop(const ov::Output& data, return std::make_shared( data, filters, - v0::Constant::create(ov::element::i64, Shape{output_shape.size()}, output_shape), + v0::Constant::create(ov::element::i64, ov::Shape{output_shape.size()}, output_shape), strides, dilations, auto_pad_type, @@ -59,8 +63,8 @@ ov::Output make_group_conv_backprop(const ov::Output& data, ov::Output make_conv_backprop(const ov::Output& data, const ov::Output& filters, - const Strides& strides, - const Strides& dilations, + const ov::Strides& strides, + const ov::Strides& dilations, const ov::CoordinateDiff& pads_begin, const ov::CoordinateDiff& pads_end, const ov::op::PadType& auto_pad_type, @@ -80,7 +84,7 @@ ov::Output make_conv_backprop(const ov::Output& data, return std::make_shared( data, filters, - v0::Constant::create(ov::element::i64, Shape{output_shape.size()}, output_shape), + v0::Constant::create(ov::element::i64, ov::Shape{output_shape.size()}, output_shape), strides, pads_begin, pads_end, @@ -96,17 +100,17 @@ ov::Output get_prepared_bias(const ov::Output& bias, const o std::shared_ptr bias_shape_node; if (conv_pshape.rank().is_static() && conv_pshape[1].is_static()) { - Shape new_bias_shape(conv_pshape.rank().get_length(), 1); + ov::Shape new_bias_shape(conv_pshape.rank().get_length(), 1); new_bias_shape[1] = conv_pshape[1].get_length(); - bias_shape_node = v0::Constant::create(ov::element::i64, Shape{new_bias_shape.size()}, new_bias_shape); + bias_shape_node = v0::Constant::create(ov::element::i64, ov::Shape{new_bias_shape.size()}, new_bias_shape); } else { const auto conv_shape = std::make_shared(conv); const auto conv_rank = std::make_shared(conv_shape); // Prepare new bias shape base: [1, 1, 1, 1, ... ] - const auto one_node = v0::Constant::create(ov::element::i64, Shape{1}, {1}); - const auto two_node = v0::Constant::create(ov::element::i64, Shape{1}, {2}); + const auto one_node = v0::Constant::create(ov::element::i64, ov::Shape{1}, {1}); + const auto two_node = v0::Constant::create(ov::element::i64, ov::Shape{1}, {2}); const auto remaining_shape_length = std::make_shared(conv_rank, two_node); const auto remaining_bias_shape_ones = std::make_shared(one_node, remaining_shape_length); @@ -124,8 +128,8 @@ ov::Output get_prepared_bias(const ov::Output& bias, const o } } // namespace -ov::OutputVector conv_transpose(const Node& node) { - const ov::OutputVector& inputs = node.get_ng_inputs(); +ov::OutputVector conv_transpose(const ov::frontend::onnx::Node& node) { + const ov::OutputVector& inputs = node.get_ov_inputs(); CHECK_VALID_NODE(node, inputs.size() == 2 || inputs.size() == 3, @@ -139,7 +143,7 @@ ov::OutputVector conv_transpose(const Node& node) { const auto& filters_pshape = filters.get_partial_shape(); std::size_t num_spatial_dims = 0; - Strides strides, dilations; + ov::Strides strides, dilations; std::pair paddings; ov::op::PadType auto_pad_type = convpool::get_auto_pad(node); @@ -211,10 +215,7 @@ ov::OutputVector conv_transpose(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/conv_transpose.hpp b/src/frontends/onnx/frontend/src/op/conv_transpose.hpp index c023b63f39fae1..40e59d65c8764d 100644 --- a/src/frontends/onnx/frontend/src/op/conv_transpose.hpp +++ b/src/frontends/onnx/frontend/src/op/conv_transpose.hpp @@ -4,13 +4,11 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { /// \brief Performs ONNX Transposed Convolution operation. @@ -19,13 +17,10 @@ namespace set_1 { /// /// \return The vector containing OV nodes producing output of ONNX convolution /// operation. -ov::OutputVector conv_transpose(const Node& node); +ov::OutputVector conv_transpose(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/cos.cpp b/src/frontends/onnx/frontend/src/op/cos.cpp index e1aa371b04d94b..ff55e15c5d0bee 100644 --- a/src/frontends/onnx/frontend/src/op/cos.cpp +++ b/src/frontends/onnx/frontend/src/op/cos.cpp @@ -8,19 +8,16 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector cos(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0))}; +ov::OutputVector cos(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0))}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/cos.hpp b/src/frontends/onnx/frontend/src/op/cos.hpp index 29c395990ecf52..039e5129649c73 100644 --- a/src/frontends/onnx/frontend/src/op/cos.hpp +++ b/src/frontends/onnx/frontend/src/op/cos.hpp @@ -4,20 +4,16 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector cos(const Node& node); +ov::OutputVector cos(const ov::frontend::onnx::Node& node); } } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/cosh.cpp b/src/frontends/onnx/frontend/src/op/cosh.cpp index 8f291542ee978f..cc3d81e32b8dd3 100644 --- a/src/frontends/onnx/frontend/src/op/cosh.cpp +++ b/src/frontends/onnx/frontend/src/op/cosh.cpp @@ -8,19 +8,16 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector cosh(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0))}; +ov::OutputVector cosh(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0))}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/cosh.hpp b/src/frontends/onnx/frontend/src/op/cosh.hpp index c5158f8360b90c..974352d8ba416f 100644 --- a/src/frontends/onnx/frontend/src/op/cosh.hpp +++ b/src/frontends/onnx/frontend/src/op/cosh.hpp @@ -4,19 +4,16 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector cosh(const Node& node); +ov::OutputVector cosh(const ov::frontend::onnx::Node& node); } } // namespace op -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/crop.cpp b/src/frontends/onnx/frontend/src/op/crop.cpp index 11353bd2190208..3dad7bb587863b 100644 --- a/src/frontends/onnx/frontend/src/op/crop.cpp +++ b/src/frontends/onnx/frontend/src/op/crop.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -11,17 +11,18 @@ #include "openvino/op/strided_slice.hpp" using namespace ov::op; +using ov::Shape; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector crop(const Node& node) { +ov::OutputVector crop(const ov::frontend::onnx::Node& node) { // Crop is an obsolete experimental ONNX operation. // Crops an image's spatial dimensions. - const auto inputs = node.get_ng_inputs(); + const auto inputs = node.get_ov_inputs(); const auto& input_data = inputs.at(0); // Border values: leftBorder, topBorder, rightBorder, bottomBorder. @@ -31,7 +32,7 @@ ov::OutputVector crop(const Node& node) { // Set slice begin values to border values (note order of indexes) const auto begin = - v0::Constant::create(ov::element::i64, Shape{4}, std::vector{0, 0, border[1], border[0]}); + v0::Constant::create(ov::element::i64, ov::Shape{4}, std::vector{0, 0, border[1], border[0]}); // If scale is given, then start crop at left/top `border` // and end on left/top `border` + `scale`. @@ -47,7 +48,7 @@ ov::OutputVector crop(const Node& node) { // Set slice end values to topBorder+heightScale and leftBorder+widthScale // Note that indexes don't match, e.g. border[0] + scale[1] end = v0::Constant::create(ov::element::i64, - Shape{4}, + ov::Shape{4}, std::vector{0, 0, border[1] + scale[0], border[0] + scale[1]}); } // If scale is not provided, crop the image by values provided in `border`. @@ -59,8 +60,9 @@ ov::OutputVector crop(const Node& node) { // Calculate ends as shape(input) - border[2:3] const auto input_shape = std::make_shared(input_data); - const auto end_offset = - v0::Constant::create(ov::element::i64, Shape{4}, std::vector{0, 0, -border[3], -border[2]}); + const auto end_offset = v0::Constant::create(ov::element::i64, + ov::Shape{4}, + std::vector{0, 0, -border[3], -border[2]}); end = std::make_shared(input_shape, end_offset); } @@ -72,10 +74,7 @@ ov::OutputVector crop(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/crop.hpp b/src/frontends/onnx/frontend/src/op/crop.hpp index 4e84e714556b2a..e9bff06481e7ab 100644 --- a/src/frontends/onnx/frontend/src/op/crop.hpp +++ b/src/frontends/onnx/frontend/src/op/crop.hpp @@ -4,22 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector crop(const Node& node); +ov::OutputVector crop(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/cum_sum.cpp b/src/frontends/onnx/frontend/src/op/cum_sum.cpp index 5ddabe73f9ffaf..127551c208460e 100644 --- a/src/frontends/onnx/frontend/src/op/cum_sum.cpp +++ b/src/frontends/onnx/frontend/src/op/cum_sum.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -10,13 +10,13 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector cum_sum(const Node& node) { - auto inputs = node.get_ng_inputs(); +ov::OutputVector cum_sum(const ov::frontend::onnx::Node& node) { + auto inputs = node.get_ov_inputs(); auto data = inputs.at(0); bool exclusive = node.get_attribute_value("exclusive", 0); bool reverse = node.get_attribute_value("reverse", 0); @@ -25,18 +25,15 @@ ov::OutputVector cum_sum(const Node& node) { if (inputs.size() > 1) { // optional input, 0-D or 1-D tensor const auto& axis_shape = inputs.at(1).get_partial_shape(); - axis = axis_shape.is_dynamic() ? inputs.at(1) : ngraph::onnx_import::reshape::interpret_as_scalar(inputs.at(1)); + axis = axis_shape.is_dynamic() ? inputs.at(1) : ov::frontend::onnx::reshape::interpret_as_scalar(inputs.at(1)); } else { - axis = v0::Constant::create(ov::element::i64, Shape{}, {0}); // default + axis = v0::Constant::create(ov::element::i64, ov::Shape{}, {0}); // default } return ov::OutputVector{std::make_shared(data, axis, exclusive, reverse)}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/cum_sum.hpp b/src/frontends/onnx/frontend/src/op/cum_sum.hpp index 732960551189a2..94ca7d0bc35110 100644 --- a/src/frontends/onnx/frontend/src/op/cum_sum.hpp +++ b/src/frontends/onnx/frontend/src/op/cum_sum.hpp @@ -4,22 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector cum_sum(const Node& node); +ov::OutputVector cum_sum(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/depth_to_space.cpp b/src/frontends/onnx/frontend/src/op/depth_to_space.cpp index 2fccf37d7245fc..d78624ef0c82cf 100644 --- a/src/frontends/onnx/frontend/src/op/depth_to_space.cpp +++ b/src/frontends/onnx/frontend/src/op/depth_to_space.cpp @@ -9,13 +9,13 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector depth_to_space(const Node& node) { - auto data = node.get_ng_inputs().at(0); +ov::OutputVector depth_to_space(const ov::frontend::onnx::Node& node) { + auto data = node.get_ov_inputs().at(0); const auto& shape = data.get_partial_shape(); FRONT_END_GENERAL_CHECK(shape.rank().is_static() && shape.rank().get_length() == 4, "Input must be 4-dimensional"); @@ -32,10 +32,7 @@ ov::OutputVector depth_to_space(const Node& node) { return ov::OutputVector{std::make_shared(data, ov_mode, block_size)}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/depth_to_space.hpp b/src/frontends/onnx/frontend/src/op/depth_to_space.hpp index 78c168d7bf3705..31e100cb3cca5a 100644 --- a/src/frontends/onnx/frontend/src/op/depth_to_space.hpp +++ b/src/frontends/onnx/frontend/src/op/depth_to_space.hpp @@ -4,13 +4,11 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { /// \brief Permutes input tensor data from depth into blocks of spatial data. @@ -22,12 +20,9 @@ namespace set_1 { /// /// \return ov::OutputVector containing Tensor with shape: /// [N, C/(blocksize * blocksize), H * blocksize, W * blocksize] -ov::OutputVector depth_to_space(const Node& node); +ov::OutputVector depth_to_space(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/dequantize_linear.cpp b/src/frontends/onnx/frontend/src/op/dequantize_linear.cpp index de8ca326aa70f4..4082368fd68163 100644 --- a/src/frontends/onnx/frontend/src/op/dequantize_linear.cpp +++ b/src/frontends/onnx/frontend/src/op/dequantize_linear.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -7,7 +7,7 @@ #include #include -#include "onnx_import/core/null_node.hpp" +#include "core/null_node.hpp" #include "openvino/frontend/exception.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/convert.hpp" @@ -19,9 +19,9 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace detail { std::shared_ptr get_zero_point(const ov::OutputVector& inputs) { @@ -38,8 +38,8 @@ std::shared_ptr get_zero_point(const ov::OutputVector& inputs) { } } // namespace detail namespace set_1 { -ov::OutputVector dequantize_linear(const Node& node) { - const ov::OutputVector inputs{node.get_ng_inputs()}; +ov::OutputVector dequantize_linear(const ov::frontend::onnx::Node& node) { + const ov::OutputVector inputs{node.get_ov_inputs()}; FRONT_END_GENERAL_CHECK(2 <= inputs.size() && inputs.size() <= 3, "The DequantizeLinear op expects 2 required and one optional input. Got: ", @@ -131,7 +131,7 @@ std::shared_ptr reshape_input(const ov::Output& input, target_dims.push_back(1); } - const auto target_shape = v0::Constant::create(ov::element::i64, Shape{target_dims.size()}, target_dims); + const auto target_shape = v0::Constant::create(ov::element::i64, ov::Shape{target_dims.size()}, target_dims); return std::make_shared(input, target_shape, true); } @@ -162,8 +162,8 @@ ov::OutputVector dequantize_linear(const ov::Output& x, } } // namespace detail -ov::OutputVector dequantize_linear(const Node& node) { - const ov::OutputVector inputs{node.get_ng_inputs()}; +ov::OutputVector dequantize_linear(const ov::frontend::onnx::Node& node) { + const ov::OutputVector inputs{node.get_ov_inputs()}; FRONT_END_GENERAL_CHECK(2 <= inputs.size() && inputs.size() <= 3, "The DequantizeLinear op expects 2 required and one optional " @@ -191,6 +191,6 @@ ov::OutputVector dequantize_linear(const Node& node) { } } // namespace set_13 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/dequantize_linear.hpp b/src/frontends/onnx/frontend/src/op/dequantize_linear.hpp index cb0a1b39d168f8..dffd8c7762b18d 100644 --- a/src/frontends/onnx/frontend/src/op/dequantize_linear.hpp +++ b/src/frontends/onnx/frontend/src/op/dequantize_linear.hpp @@ -4,18 +4,16 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/core/node.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector dequantize_linear(const Node& node); +ov::OutputVector dequantize_linear(const ov::frontend::onnx::Node& node); } // namespace set_1 @@ -27,12 +25,9 @@ ov::OutputVector dequantize_linear(const ov::Output& x, int64_t axis, const Node& node); } -ov::OutputVector dequantize_linear(const Node& node); +ov::OutputVector dequantize_linear(const ov::frontend::onnx::Node& node); } // namespace set_13 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/dft.cpp b/src/frontends/onnx/frontend/src/op/dft.cpp index 58c1a359098786..5120f0b7e17901 100644 --- a/src/frontends/onnx/frontend/src/op/dft.cpp +++ b/src/frontends/onnx/frontend/src/op/dft.cpp @@ -4,17 +4,17 @@ #include "op/dft.hpp" -#include "onnx_import/core/null_node.hpp" +#include "core/null_node.hpp" #include "utils/common.hpp" #include "utils/dft.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector dft(const Node& node) { - const ov::OutputVector ng_inputs{node.get_ng_inputs()}; +ov::OutputVector dft(const ov::frontend::onnx::Node& node) { + const ov::OutputVector ng_inputs{node.get_ov_inputs()}; const ov::Output data = ng_inputs.at(0); const auto dft_length_provided = ng_inputs.size() > 1 && !ov::op::util::is_null(ng_inputs[1]); @@ -30,10 +30,7 @@ ov::OutputVector dft(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/dft.hpp b/src/frontends/onnx/frontend/src/op/dft.hpp index 146a9c5b6c8aab..d3c35133e7d9a7 100644 --- a/src/frontends/onnx/frontend/src/op/dft.hpp +++ b/src/frontends/onnx/frontend/src/op/dft.hpp @@ -4,22 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector dft(const Node& node); +ov::OutputVector dft(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/div.hpp b/src/frontends/onnx/frontend/src/op/div.hpp index 2b45c67cac9f9a..c133d5908a0d44 100644 --- a/src/frontends/onnx/frontend/src/op/div.hpp +++ b/src/frontends/onnx/frontend/src/op/div.hpp @@ -4,32 +4,27 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/divide.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector div(const Node& node) { +inline ov::OutputVector div(const ov::frontend::onnx::Node& node) { return common::handle_opset6_binary_op(node); } } // namespace set_1 namespace set_7 { -inline ov::OutputVector div(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0), node.get_ng_inputs().at(1))}; +inline ov::OutputVector div(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0), node.get_ov_inputs().at(1))}; } } // namespace set_7 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/dropout.cpp b/src/frontends/onnx/frontend/src/op/dropout.cpp index e7536cfc63fee3..636bc9dda486f0 100644 --- a/src/frontends/onnx/frontend/src/op/dropout.cpp +++ b/src/frontends/onnx/frontend/src/op/dropout.cpp @@ -1,11 +1,11 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include "op/dropout.hpp" +#include "core/null_node.hpp" #include "exceptions.hpp" -#include "onnx_import/core/null_node.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/shape_of.hpp" @@ -13,20 +13,21 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace { -ov::OutputVector build_dropout(const Node& node, bool training_mode) { +ov::OutputVector build_dropout(const ov::frontend::onnx::Node& node, bool training_mode) { CHECK_VALID_NODE(node, !training_mode, "Training mode is not supported for Dropout op"); - const auto input_data = node.get_ng_inputs().at(0); + const auto input_data = node.get_ov_inputs().at(0); const bool return_mask = node.get_outputs_size() > 1; if (return_mask) { - const auto mask = std::make_shared(v0::Constant::create(ov::element::boolean, Shape{}, {true}), - std::make_shared(input_data)); + const auto mask = + std::make_shared(v0::Constant::create(ov::element::boolean, ov::Shape{}, {true}), + std::make_shared(input_data)); return {input_data, mask}; } else { return {input_data}; @@ -35,8 +36,8 @@ ov::OutputVector build_dropout(const Node& node, bool training_mode) { } // namespace namespace set_12 { -ov::OutputVector dropout(const Node& node) { - const auto ng_inputs = node.get_ng_inputs(); +ov::OutputVector dropout(const ov::frontend::onnx::Node& node) { + const auto ng_inputs = node.get_ov_inputs(); // seed attribute and ratio input are ignored because traning mode is not // supported anyway bool training_mode = false; // default value @@ -51,7 +52,7 @@ ov::OutputVector dropout(const Node& node) { } // namespace set_12 namespace set_7 { -ov::OutputVector dropout(const Node& node) { +ov::OutputVector dropout(const ov::frontend::onnx::Node& node) { // "is_test" attribute was removed // ratio attribute is ignored because traning mode is not supported const bool training_mode = false; @@ -61,7 +62,7 @@ ov::OutputVector dropout(const Node& node) { } // namespace set_7 namespace set_1 { -ov::OutputVector dropout(const Node& node) { +ov::OutputVector dropout(const ov::frontend::onnx::Node& node) { // legacy consumed_inputs attribute ignored // ratio attribute is ignored because traning mode is not supported const bool training_mode = !node.get_attribute_value("is_test", 0); @@ -69,10 +70,7 @@ ov::OutputVector dropout(const Node& node) { return build_dropout(node, training_mode); } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/dropout.hpp b/src/frontends/onnx/frontend/src/op/dropout.hpp index 0c4217257b4ad2..e0826063c2ae94 100644 --- a/src/frontends/onnx/frontend/src/op/dropout.hpp +++ b/src/frontends/onnx/frontend/src/op/dropout.hpp @@ -4,29 +4,24 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_12 { -ov::OutputVector dropout(const Node& node); +ov::OutputVector dropout(const ov::frontend::onnx::Node& node); } // namespace set_12 namespace set_7 { -ov::OutputVector dropout(const Node& node); +ov::OutputVector dropout(const ov::frontend::onnx::Node& node); } // namespace set_7 namespace set_1 { -ov::OutputVector dropout(const Node& node); +ov::OutputVector dropout(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/dynamic_quantize_linear.cpp b/src/frontends/onnx/frontend/src/op/dynamic_quantize_linear.cpp index fad323df1026f5..1009d05d8d9018 100644 --- a/src/frontends/onnx/frontend/src/op/dynamic_quantize_linear.cpp +++ b/src/frontends/onnx/frontend/src/op/dynamic_quantize_linear.cpp @@ -1,10 +1,10 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include "op/dynamic_quantize_linear.hpp" -#include "onnx_import/core/null_node.hpp" +#include "core/null_node.hpp" #include "openvino/op/add.hpp" #include "openvino/op/clamp.hpp" #include "openvino/op/constant.hpp" @@ -23,14 +23,15 @@ #include "utils/common.hpp" using namespace ov::op; +using ov::Shape; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace { std::shared_ptr find_min_value(const ov::Output& input) { - const auto& zero_node = v0::Constant::create(ov::element::i64, Shape{}, {0}); - const auto& one_node = v0::Constant::create(ov::element::i64, Shape{}, {1}); + const auto& zero_node = v0::Constant::create(ov::element::i64, ov::Shape{}, {0}); + const auto& one_node = v0::Constant::create(ov::element::i64, ov::Shape{}, {1}); const auto& input_shape = std::make_shared(input); const auto& input_rank = std::make_shared(input_shape); @@ -40,13 +41,13 @@ std::shared_ptr find_min_value(const ov::Output& input) { const auto& input_min = std::make_shared(input, reduce_axes); - const auto& zero_node_u8 = v0::Constant::create(ov::element::f32, Shape{}, {0}); + const auto& zero_node_u8 = v0::Constant::create(ov::element::f32, ov::Shape{}, {0}); return std::make_shared(zero_node_u8, input_min); } std::shared_ptr find_max_value(const ov::Output& input) { - const auto& zero_node = v0::Constant::create(ov::element::i64, Shape{}, {0}); - const auto& one_node = v0::Constant::create(ov::element::i64, Shape{}, {1}); + const auto& zero_node = v0::Constant::create(ov::element::i64, ov::Shape{}, {0}); + const auto& one_node = v0::Constant::create(ov::element::i64, ov::Shape{}, {1}); const auto& input_shape = std::make_shared(input); const auto& input_rank = std::make_shared(input_shape); @@ -56,7 +57,7 @@ std::shared_ptr find_max_value(const ov::Output& input) { const auto& input_max = std::make_shared(input, reduce_axes); - const auto& zero_node_u8 = v0::Constant::create(ov::element::f32, Shape{}, {0}); + const auto& zero_node_u8 = v0::Constant::create(ov::element::f32, ov::Shape{}, {0}); return std::make_shared(zero_node_u8, input_max); } @@ -78,13 +79,13 @@ std::shared_ptr quantize_linear(ov::Output x, } // namespace namespace op { namespace set_1 { -ov::OutputVector dynamic_quantize_linear(const Node& node) { - const ov::OutputVector& inputs = node.get_ng_inputs(); +ov::OutputVector dynamic_quantize_linear(const ov::frontend::onnx::Node& node) { + const ov::OutputVector& inputs = node.get_ov_inputs(); const auto& x = inputs.at(0); // quantization range in case of uint8 is [0, 255] - const auto& quant_range_min = v0::Constant::create(ov::element::f32, Shape{}, {0}); - const auto& quant_range_max = v0::Constant::create(ov::element::f32, Shape{}, {255}); + const auto& quant_range_min = v0::Constant::create(ov::element::f32, ov::Shape{}, {0}); + const auto& quant_range_max = v0::Constant::create(ov::element::f32, ov::Shape{}, {255}); const auto& quant_range_span = std::make_shared(quant_range_max, quant_range_min); const auto& x_max = find_max_value(x); @@ -107,6 +108,6 @@ ov::OutputVector dynamic_quantize_linear(const Node& node) { } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/dynamic_quantize_linear.hpp b/src/frontends/onnx/frontend/src/op/dynamic_quantize_linear.hpp index e94edad9239828..2218f74c40a95a 100644 --- a/src/frontends/onnx/frontend/src/op/dynamic_quantize_linear.hpp +++ b/src/frontends/onnx/frontend/src/op/dynamic_quantize_linear.hpp @@ -4,19 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector dynamic_quantize_linear(const Node& node); +ov::OutputVector dynamic_quantize_linear(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/einsum.cpp b/src/frontends/onnx/frontend/src/op/einsum.cpp index 204f770bf055a9..2cf832a78e1af2 100644 --- a/src/frontends/onnx/frontend/src/op/einsum.cpp +++ b/src/frontends/onnx/frontend/src/op/einsum.cpp @@ -8,22 +8,19 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector einsum(const Node& node) { +ov::OutputVector einsum(const ov::frontend::onnx::Node& node) { const std::string& equation{node.get_attribute_value("equation")}; - return ov::OutputVector{std::make_shared(node.get_ng_inputs(), equation)}; + return {std::make_shared(node.get_ov_inputs(), equation)}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/einsum.hpp b/src/frontends/onnx/frontend/src/op/einsum.hpp index 97a8079d58f6c5..22821224537918 100644 --- a/src/frontends/onnx/frontend/src/op/einsum.hpp +++ b/src/frontends/onnx/frontend/src/op/einsum.hpp @@ -4,21 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector einsum(const Node& node); +ov::OutputVector einsum(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/elu.cpp b/src/frontends/onnx/frontend/src/op/elu.cpp index fc8345df202d67..fb45f05a1c53ec 100644 --- a/src/frontends/onnx/frontend/src/op/elu.cpp +++ b/src/frontends/onnx/frontend/src/op/elu.cpp @@ -8,23 +8,20 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector elu(const Node& node) { - auto data = node.get_ng_inputs().at(0); +ov::OutputVector elu(const ov::frontend::onnx::Node& node) { + auto data = node.get_ov_inputs().at(0); double alpha = node.get_attribute_value("alpha", 1); - return ov::OutputVector{std::make_shared(data, alpha)}; + return {std::make_shared(data, alpha)}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/elu.hpp b/src/frontends/onnx/frontend/src/op/elu.hpp index 3c86b8333042e1..87ef5d46639726 100644 --- a/src/frontends/onnx/frontend/src/op/elu.hpp +++ b/src/frontends/onnx/frontend/src/op/elu.hpp @@ -4,22 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector elu(const Node& node); +ov::OutputVector elu(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/equal.hpp b/src/frontends/onnx/frontend/src/op/equal.hpp index 37c447beae5c89..4591e7da6da44e 100644 --- a/src/frontends/onnx/frontend/src/op/equal.hpp +++ b/src/frontends/onnx/frontend/src/op/equal.hpp @@ -4,25 +4,20 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/equal.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector equal(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0), node.get_ng_inputs().at(1))}; +inline ov::OutputVector equal(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0), node.get_ov_inputs().at(1))}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/erf.hpp b/src/frontends/onnx/frontend/src/op/erf.hpp index 0e567bdb7851b0..83a6b19ffccaa8 100644 --- a/src/frontends/onnx/frontend/src/op/erf.hpp +++ b/src/frontends/onnx/frontend/src/op/erf.hpp @@ -4,24 +4,19 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/erf.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector erf(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0))}; +inline ov::OutputVector erf(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0))}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/exp.hpp b/src/frontends/onnx/frontend/src/op/exp.hpp index 889d78d71ca2db..44c243670f1594 100644 --- a/src/frontends/onnx/frontend/src/op/exp.hpp +++ b/src/frontends/onnx/frontend/src/op/exp.hpp @@ -4,25 +4,20 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/exp.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector exp(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0))}; +inline ov::OutputVector exp(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0))}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/expand.cpp b/src/frontends/onnx/frontend/src/op/expand.cpp index 41aa4ed3b59e88..c96331627c43a7 100644 --- a/src/frontends/onnx/frontend/src/op/expand.cpp +++ b/src/frontends/onnx/frontend/src/op/expand.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -9,21 +9,22 @@ #include "utils/common.hpp" using namespace ov::op; +using ov::Shape; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector expand(const Node& node) { - const ov::Output data{node.get_ng_inputs().at(0)}; - const ov::Output shape{node.get_ng_inputs().at(1)}; +ov::OutputVector expand(const ov::frontend::onnx::Node& node) { + const ov::Output data{node.get_ov_inputs().at(0)}; + const ov::Output shape{node.get_ov_inputs().at(1)}; if (common::is_failsafe_node(shape.get_node_shared_ptr())) { // in case the "shape" input is connected to a failsafe node created in place of an invalid initializer // the target shape should be ignored and this Expand operation should not modify its input tensor // the Broadcast created below should be eliminated later on by an appropriate optimization pass - const auto identity_broadcast = v0::Constant::create(ov::element::i64, Shape{1}, {1}); + const auto identity_broadcast = v0::Constant::create(ov::element::i64, ov::Shape{1}, {1}); return {std::make_shared(data, identity_broadcast, ov::op::BroadcastType::BIDIRECTIONAL)}; } else { return {std::make_shared(data, shape, ov::op::BroadcastType::BIDIRECTIONAL)}; @@ -31,10 +32,7 @@ ov::OutputVector expand(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/expand.hpp b/src/frontends/onnx/frontend/src/op/expand.hpp index e7f546c8cea0e8..7ffd8478465c14 100644 --- a/src/frontends/onnx/frontend/src/op/expand.hpp +++ b/src/frontends/onnx/frontend/src/op/expand.hpp @@ -4,25 +4,20 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 // Expand operator has been available since version 8 of the default ONNX operator set. // Currently, Expand is assigned to version 1 due to temporary reason. { -ov::OutputVector expand(const Node& node); +ov::OutputVector expand(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/eye_like.cpp b/src/frontends/onnx/frontend/src/op/eye_like.cpp index 6b1bd5088eda77..aae1f88edf0b74 100644 --- a/src/frontends/onnx/frontend/src/op/eye_like.cpp +++ b/src/frontends/onnx/frontend/src/op/eye_like.cpp @@ -13,9 +13,9 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace detail { namespace { @@ -33,8 +33,8 @@ ov::OutputVector get_shape_width_and_height(const ov::Output& shape) { namespace set_1 { -ov::OutputVector eye_like(const Node& node) { - const auto input = node.get_ng_inputs().at(0); +ov::OutputVector eye_like(const ov::frontend::onnx::Node& node) { + const auto input = node.get_ov_inputs().at(0); const auto& input_rank = input.get_partial_shape().rank(); CHECK_VALID_NODE(node, @@ -65,6 +65,6 @@ ov::OutputVector eye_like(const Node& node) { } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/eye_like.hpp b/src/frontends/onnx/frontend/src/op/eye_like.hpp index 6f956448c41c80..700a57e61ce032 100644 --- a/src/frontends/onnx/frontend/src/op/eye_like.hpp +++ b/src/frontends/onnx/frontend/src/op/eye_like.hpp @@ -4,20 +4,18 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector eye_like(const Node& node); +ov::OutputVector eye_like(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/flatten.cpp b/src/frontends/onnx/frontend/src/op/flatten.cpp index 7a8e29a11a816b..2e07903270e051 100644 --- a/src/frontends/onnx/frontend/src/op/flatten.cpp +++ b/src/frontends/onnx/frontend/src/op/flatten.cpp @@ -5,18 +5,18 @@ #include "op/flatten.hpp" #include "exceptions.hpp" -#include "ov_models/ov_builders/reshape.hpp" +#include "utils/reshape.hpp" #include "validation_util.hpp" using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector flatten(const Node& node) { - ov::OutputVector inputs{node.get_ng_inputs()}; +ov::OutputVector flatten(const ov::frontend::onnx::Node& node) { + ov::OutputVector inputs{node.get_ov_inputs()}; auto data = inputs.at(0); auto axis = node.get_attribute_value("axis", 1); const auto data_rank = data.get_partial_shape().rank(); @@ -31,9 +31,7 @@ ov::OutputVector flatten(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/flatten.hpp b/src/frontends/onnx/frontend/src/op/flatten.hpp index 5aafedc79f3972..aa3165f12d0798 100644 --- a/src/frontends/onnx/frontend/src/op/flatten.hpp +++ b/src/frontends/onnx/frontend/src/op/flatten.hpp @@ -4,21 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector flatten(const Node& node); +ov::OutputVector flatten(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/floor.hpp b/src/frontends/onnx/frontend/src/op/floor.hpp index 04176788360501..ce4640bf730b67 100644 --- a/src/frontends/onnx/frontend/src/op/floor.hpp +++ b/src/frontends/onnx/frontend/src/op/floor.hpp @@ -4,25 +4,20 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/floor.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector floor(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0))}; +inline ov::OutputVector floor(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0))}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/gather.hpp b/src/frontends/onnx/frontend/src/op/gather.hpp index f8335407e5e7cc..e36f6eecaedd6b 100644 --- a/src/frontends/onnx/frontend/src/op/gather.hpp +++ b/src/frontends/onnx/frontend/src/op/gather.hpp @@ -1,33 +1,31 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/gather.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector gather(const Node& node) { - ov::OutputVector ng_inputs{node.get_ng_inputs()}; +inline ov::OutputVector gather(const ov::frontend::onnx::Node& node) { + ov::OutputVector ng_inputs{node.get_ov_inputs()}; auto data = ng_inputs.at(0); auto indices = ng_inputs.at(1); auto axis = node.get_attribute_value("axis", 0); return {std::make_shared(data, indices, - ov::op::v0::Constant::create(ov::element::i64, Shape{}, {axis}))}; + ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {axis}))}; } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/gather_elements.hpp b/src/frontends/onnx/frontend/src/op/gather_elements.hpp index f2f4536392aefd..d225fdd7c2911c 100644 --- a/src/frontends/onnx/frontend/src/op/gather_elements.hpp +++ b/src/frontends/onnx/frontend/src/op/gather_elements.hpp @@ -4,17 +4,15 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - #include "openvino/op/gather_elements.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector gather_elements(const Node& node) { - ov::OutputVector ng_inputs{node.get_ng_inputs()}; +inline ov::OutputVector gather_elements(const ov::frontend::onnx::Node& node) { + ov::OutputVector ng_inputs{node.get_ov_inputs()}; auto data = ng_inputs.at(0); auto indices = ng_inputs.at(1); auto axis = node.get_attribute_value("axis", 0); @@ -23,6 +21,6 @@ inline ov::OutputVector gather_elements(const Node& node) { } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/gather_nd.cpp b/src/frontends/onnx/frontend/src/op/gather_nd.cpp index 2f2c21560a5c50..c9f6d241d8b98a 100644 --- a/src/frontends/onnx/frontend/src/op/gather_nd.cpp +++ b/src/frontends/onnx/frontend/src/op/gather_nd.cpp @@ -11,13 +11,13 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector gather_nd(const Node& node) { - const ov::OutputVector ng_inputs{node.get_ng_inputs()}; +ov::OutputVector gather_nd(const ov::frontend::onnx::Node& node) { + const ov::OutputVector ng_inputs{node.get_ov_inputs()}; const auto data = ng_inputs.at(0); const auto indices = ng_inputs.at(1); const auto batch_dims = node.get_attribute_value("batch_dims", 0); @@ -26,10 +26,7 @@ ov::OutputVector gather_nd(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/gather_nd.hpp b/src/frontends/onnx/frontend/src/op/gather_nd.hpp index 7207a2e9ef788a..5053780c00a215 100644 --- a/src/frontends/onnx/frontend/src/op/gather_nd.hpp +++ b/src/frontends/onnx/frontend/src/op/gather_nd.hpp @@ -7,22 +7,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector gather_nd(const Node& node); +ov::OutputVector gather_nd(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/gelu.cpp b/src/frontends/onnx/frontend/src/op/gelu.cpp index 31e3a2caeee4ad..e7950a29ad9967 100644 --- a/src/frontends/onnx/frontend/src/op/gelu.cpp +++ b/src/frontends/onnx/frontend/src/op/gelu.cpp @@ -9,13 +9,13 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector gelu(const Node& node) { - const auto& inputs = node.get_ng_inputs(); +ov::OutputVector gelu(const ov::frontend::onnx::Node& node) { + const auto& inputs = node.get_ov_inputs(); std::string approximate = node.get_attribute_value("approximate", ""); FRONT_END_GENERAL_CHECK(inputs.size() == 1, "Wrong number of inputs, expected 1, found ", inputs.size()); @@ -34,6 +34,6 @@ ov::OutputVector gelu(const Node& node) { } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/gelu.hpp b/src/frontends/onnx/frontend/src/op/gelu.hpp index 23caef0210a674..242da0fb5b7730 100644 --- a/src/frontends/onnx/frontend/src/op/gelu.hpp +++ b/src/frontends/onnx/frontend/src/op/gelu.hpp @@ -3,20 +3,18 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector gelu(const Node& node); +ov::OutputVector gelu(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/gemm.cpp b/src/frontends/onnx/frontend/src/op/gemm.cpp index 1c4a7dac1d125d..b679a407d51707 100644 --- a/src/frontends/onnx/frontend/src/op/gemm.cpp +++ b/src/frontends/onnx/frontend/src/op/gemm.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -8,17 +8,18 @@ #include "openvino/op/constant.hpp" #include "openvino/op/matmul.hpp" #include "openvino/op/multiply.hpp" -#include "ov_models/ov_builders/reshape.hpp" +#include "utils/reshape.hpp" using namespace ov::op; +using ov::Shape; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector gemm(const Node& node) { - ov::OutputVector inputs{node.get_ng_inputs()}; +ov::OutputVector gemm(const ov::frontend::onnx::Node& node) { + ov::OutputVector inputs{node.get_ov_inputs()}; ov::Output input_a = inputs.at(0); ov::Output input_b = inputs.at(1); ov::Output input_c; @@ -49,7 +50,7 @@ ov::OutputVector gemm(const Node& node) { std::shared_ptr matmul_node = std::make_shared(input_a, input_b); if (alpha != 1) { - const auto alpha_node = v0::Constant::create(input_b.get_element_type(), Shape{}, {alpha}); + const auto alpha_node = v0::Constant::create(input_b.get_element_type(), ov::Shape{}, {alpha}); matmul_node = std::make_shared(matmul_node, alpha_node); } @@ -61,8 +62,8 @@ ov::OutputVector gemm(const Node& node) { } // namespace set_1 namespace set_6 { -ov::OutputVector gemm(const Node& node) { - ov::OutputVector inputs{node.get_ng_inputs()}; +ov::OutputVector gemm(const ov::frontend::onnx::Node& node) { + ov::OutputVector inputs{node.get_ov_inputs()}; ov::Output input_a = inputs.at(0); ov::Output input_b = inputs.at(1); ov::Output input_c; @@ -89,9 +90,7 @@ ov::OutputVector gemm(const Node& node) { } } // namespace set_6 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/gemm.hpp b/src/frontends/onnx/frontend/src/op/gemm.hpp index 7368e4bef35643..71b43dea77cca6 100644 --- a/src/frontends/onnx/frontend/src/op/gemm.hpp +++ b/src/frontends/onnx/frontend/src/op/gemm.hpp @@ -4,26 +4,22 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector gemm(const Node& node); +ov::OutputVector gemm(const ov::frontend::onnx::Node& node); } // namespace set_1 namespace set_6 { -ov::OutputVector gemm(const Node& node); +ov::OutputVector gemm(const ov::frontend::onnx::Node& node); } // namespace set_6 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/global_average_pool.cpp b/src/frontends/onnx/frontend/src/op/global_average_pool.cpp index 633e6d1f11e125..a37c346a7a5118 100644 --- a/src/frontends/onnx/frontend/src/op/global_average_pool.cpp +++ b/src/frontends/onnx/frontend/src/op/global_average_pool.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -11,13 +11,14 @@ #include "openvino/op/squeeze.hpp" using namespace ov::op; +using ov::Shape; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector global_average_pool(const Node& node) { +ov::OutputVector global_average_pool(const ov::frontend::onnx::Node& node) { // Generate axes for reduce operation which contain all spatial dims indexes. // Examples: // Input shape: [N, C, H, W] @@ -27,11 +28,11 @@ ov::OutputVector global_average_pool(const Node& node) { // Input shape: [N, C, H, W, D] // Input spatial dimensions are H, W and D // Expected spatial dims indexes: [2, 3, 4] - auto data = node.get_ng_inputs()[0]; + auto data = node.get_ov_inputs()[0]; - const auto zero_node = v0::Constant::create(ov::element::i64, Shape{}, {0}); - const auto one_node = v0::Constant::create(ov::element::i64, Shape{}, {1}); - const auto two_node = v0::Constant::create(ov::element::i64, Shape{}, {2}); + const auto zero_node = v0::Constant::create(ov::element::i64, ov::Shape{}, {0}); + const auto one_node = v0::Constant::create(ov::element::i64, ov::Shape{}, {1}); + const auto two_node = v0::Constant::create(ov::element::i64, ov::Shape{}, {2}); const auto data_shape = std::make_shared(data); const auto data_rank = std::make_shared(data_shape); @@ -43,10 +44,7 @@ ov::OutputVector global_average_pool(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/global_average_pool.hpp b/src/frontends/onnx/frontend/src/op/global_average_pool.hpp index 51761a206bb22a..798055ff530afd 100644 --- a/src/frontends/onnx/frontend/src/op/global_average_pool.hpp +++ b/src/frontends/onnx/frontend/src/op/global_average_pool.hpp @@ -4,13 +4,11 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { /// \brief Convert ONNX GlobalAveragePool operation to an OV node. @@ -19,13 +17,10 @@ namespace set_1 { /// /// \return The vector containing OV nodes producing output of ONNX /// GlobalAveragePool operation. -ov::OutputVector global_average_pool(const Node& node); +ov::OutputVector global_average_pool(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/global_max_pool.cpp b/src/frontends/onnx/frontend/src/op/global_max_pool.cpp index 7878fe797313ec..e975c4fe423e9b 100644 --- a/src/frontends/onnx/frontend/src/op/global_max_pool.cpp +++ b/src/frontends/onnx/frontend/src/op/global_max_pool.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -11,13 +11,14 @@ #include "openvino/op/squeeze.hpp" using namespace ov::op; +using ov::Shape; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector global_max_pool(const Node& node) { +ov::OutputVector global_max_pool(const ov::frontend::onnx::Node& node) { // Generate axes for reduce operation which contain all spatial dims indexes. // Examples: // Input shape: [N, C, H, W] @@ -27,11 +28,11 @@ ov::OutputVector global_max_pool(const Node& node) { // Input shape: [N, C, H, W, D] // Input spatial dimensions are H, W and D // Expected spatial dims indexes: [2, 3, 4] - auto data = node.get_ng_inputs()[0]; + auto data = node.get_ov_inputs()[0]; - const auto zero_node = v0::Constant::create(ov::element::i64, Shape{}, {0}); - const auto one_node = v0::Constant::create(ov::element::i64, Shape{}, {1}); - const auto two_node = v0::Constant::create(ov::element::i64, Shape{}, {2}); + const auto zero_node = v0::Constant::create(ov::element::i64, ov::Shape{}, {0}); + const auto one_node = v0::Constant::create(ov::element::i64, ov::Shape{}, {1}); + const auto two_node = v0::Constant::create(ov::element::i64, ov::Shape{}, {2}); const auto data_shape = std::make_shared(data); const auto data_rank = std::make_shared(data_shape); @@ -43,10 +44,7 @@ ov::OutputVector global_max_pool(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/global_max_pool.hpp b/src/frontends/onnx/frontend/src/op/global_max_pool.hpp index fdcbe7ede2ecc8..b282fdd2993e71 100644 --- a/src/frontends/onnx/frontend/src/op/global_max_pool.hpp +++ b/src/frontends/onnx/frontend/src/op/global_max_pool.hpp @@ -4,13 +4,11 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { /// \brief Convert ONNX GlobalMaxPool operation to an OV node. @@ -19,13 +17,10 @@ namespace set_1 { /// /// \return The vector containing OV nodes producing output of ONNX /// GlobalMaxPool operation. -ov::OutputVector global_max_pool(const Node& node); +ov::OutputVector global_max_pool(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/greater.hpp b/src/frontends/onnx/frontend/src/op/greater.hpp index 0cc9b6412e1932..e9a162a6bcec4c 100644 --- a/src/frontends/onnx/frontend/src/op/greater.hpp +++ b/src/frontends/onnx/frontend/src/op/greater.hpp @@ -4,25 +4,20 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/greater.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector greater(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0), node.get_ng_inputs().at(1))}; +inline ov::OutputVector greater(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0), node.get_ov_inputs().at(1))}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/greater_or_equal.cpp b/src/frontends/onnx/frontend/src/op/greater_or_equal.cpp index f21531a4a2e80e..52c8f798858294 100644 --- a/src/frontends/onnx/frontend/src/op/greater_or_equal.cpp +++ b/src/frontends/onnx/frontend/src/op/greater_or_equal.cpp @@ -10,14 +10,14 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector greater_or_equal(const Node& node) { - const auto A = node.get_ng_inputs().at(0); - const auto B = node.get_ng_inputs().at(1); +ov::OutputVector greater_or_equal(const ov::frontend::onnx::Node& node) { + const auto A = node.get_ov_inputs().at(0); + const auto B = node.get_ov_inputs().at(1); FRONT_END_GENERAL_CHECK(A.get_element_type() != ov::element::bf16 && B.get_element_type() != ov::element::bf16, "The input data bfloat16 isn't supported in opset 12"); @@ -29,9 +29,9 @@ ov::OutputVector greater_or_equal(const Node& node) { } // namespace set_1 namespace set_16 { -ov::OutputVector greater_or_equal(const Node& node) { - const auto A = node.get_ng_inputs().at(0); - const auto B = node.get_ng_inputs().at(1); +ov::OutputVector greater_or_equal(const ov::frontend::onnx::Node& node) { + const auto A = node.get_ov_inputs().at(0); + const auto B = node.get_ov_inputs().at(1); const auto C = std::make_shared(A, B); @@ -39,6 +39,6 @@ ov::OutputVector greater_or_equal(const Node& node) { } } // namespace set_16 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/greater_or_equal.hpp b/src/frontends/onnx/frontend/src/op/greater_or_equal.hpp index 5cdc2f24637e02..ecdaa2fe6020a4 100644 --- a/src/frontends/onnx/frontend/src/op/greater_or_equal.hpp +++ b/src/frontends/onnx/frontend/src/op/greater_or_equal.hpp @@ -4,24 +4,22 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector greater_or_equal(const Node& node); +ov::OutputVector greater_or_equal(const ov::frontend::onnx::Node& node); } // namespace set_1 namespace set_16 { -ov::OutputVector greater_or_equal(const Node& node); +ov::OutputVector greater_or_equal(const ov::frontend::onnx::Node& node); } // namespace set_16 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/grid_sample.cpp b/src/frontends/onnx/frontend/src/op/grid_sample.cpp index 63f2cb0166fd41..8a7e6785311055 100644 --- a/src/frontends/onnx/frontend/src/op/grid_sample.cpp +++ b/src/frontends/onnx/frontend/src/op/grid_sample.cpp @@ -8,14 +8,14 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector grid_sample(const Node& node) { - const auto data = node.get_ng_inputs().at(0); - const auto grid = node.get_ng_inputs().at(1); +ov::OutputVector grid_sample(const ov::frontend::onnx::Node& node) { + const auto data = node.get_ov_inputs().at(0); + const auto grid = node.get_ov_inputs().at(1); v9::GridSample::Attributes attributes{}; attributes.align_corners = node.get_attribute_value("align_corners", 0); @@ -30,6 +30,6 @@ ov::OutputVector grid_sample(const Node& node) { } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/grid_sample.hpp b/src/frontends/onnx/frontend/src/op/grid_sample.hpp index 9549ec8e979eb8..2997f1581c95ec 100644 --- a/src/frontends/onnx/frontend/src/op/grid_sample.hpp +++ b/src/frontends/onnx/frontend/src/op/grid_sample.hpp @@ -4,22 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector grid_sample(const Node& node); +ov::OutputVector grid_sample(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/group_normalization.cpp b/src/frontends/onnx/frontend/src/op/group_normalization.cpp index 233b55ad994ee4..5c5339748d4ce3 100644 --- a/src/frontends/onnx/frontend/src/op/group_normalization.cpp +++ b/src/frontends/onnx/frontend/src/op/group_normalization.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -14,14 +14,15 @@ #include "openvino/op/unsqueeze.hpp" using namespace ov::op; +using ov::Shape; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector group_normalization(const Node& node) { - const auto inputs = node.get_ng_inputs(); +ov::OutputVector group_normalization(const ov::frontend::onnx::Node& node) { + const auto inputs = node.get_ov_inputs(); OPENVINO_ASSERT(inputs.size() == 3); const auto& data = inputs[0]; // Shape [N, C, ...] @@ -31,10 +32,10 @@ ov::OutputVector group_normalization(const Node& node) { const auto eps = node.get_attribute_value("epsilon", 1e-05f); const auto num_groups = node.get_attribute_value("num_groups"); - const auto zero = v0::Constant::create(ov::element::i64, Shape{1}, {0}); - const auto one = v0::Constant::create(ov::element::i64, Shape{1}, {1}); + const auto zero = v0::Constant::create(ov::element::i64, ov::Shape{1}, {0}); + const auto one = v0::Constant::create(ov::element::i64, ov::Shape{1}, {1}); const auto c_dim = std::make_shared(std::make_shared(data), one, zero); - const auto g_dim = v0::Constant::create(ov::element::i64, Shape{1}, {num_groups}); + const auto g_dim = v0::Constant::create(ov::element::i64, ov::Shape{1}, {num_groups}); const auto c_g_div = std::make_shared(c_dim, g_dim); @@ -53,6 +54,6 @@ ov::OutputVector group_normalization(const Node& node) { } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/group_normalization.hpp b/src/frontends/onnx/frontend/src/op/group_normalization.hpp index c1e44110bdf8d7..a7d13af83293f3 100644 --- a/src/frontends/onnx/frontend/src/op/group_normalization.hpp +++ b/src/frontends/onnx/frontend/src/op/group_normalization.hpp @@ -4,19 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector group_normalization(const Node& node); +ov::OutputVector group_normalization(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/gru.cpp b/src/frontends/onnx/frontend/src/op/gru.cpp index 4726a18e52a116..1fa59be80b6d3f 100644 --- a/src/frontends/onnx/frontend/src/op/gru.cpp +++ b/src/frontends/onnx/frontend/src/op/gru.cpp @@ -1,23 +1,24 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include "op/gru.hpp" -#include "onnx_import/core/null_node.hpp" +#include "core/null_node.hpp" #include "openvino/op/add.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/gru_sequence.hpp" -#include "ov_models/ov_builders/reshape.hpp" -#include "ov_models/ov_builders/split.hpp" #include "utils/recurrent.hpp" +#include "utils/reshape.hpp" +#include "utils/split.hpp" using namespace ov::op; +using ov::Shape; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { namespace { @@ -27,14 +28,14 @@ struct GRUInputMap : public recurrent::OpInputMap { // Override bias, since we need separated W and R biases for `h` gate. if (linear_before_reset) { - const auto& ng_inputs = node.get_ng_inputs(); + const auto& ng_inputs = node.get_ov_inputs(); const auto el_type = ng_inputs.at(0).get_element_type(); if (ng_inputs.size() > 3 && !ov::op::util::is_null(ng_inputs.at(3))) { auto bias = ng_inputs.at(3); // gates_count * 2 since B is: [Wb, Rb] const int split_parts = 2 * 3; - const auto split_bias = ov::op::util::split(bias, split_parts, 1); + const auto split_bias = ov::op::util::make_split(bias, split_parts, 1); const auto wr_z_bias = std::make_shared(split_bias.at(0), split_bias.at(3)); const auto wr_r_bias = std::make_shared(split_bias.at(1), split_bias.at(4)); // The result has shape: [num_directions, 4 * hidden_size] @@ -55,7 +56,7 @@ struct GRUInputMap : public recurrent::OpInputMap { m_map[recurrent::OpInput::B] = std::make_shared(el_type, - Shape{num_directions, (gates_count + 1) * hidden_size}, + ov::Shape{num_directions, (gates_count + 1) * hidden_size}, 0.f); } } @@ -77,7 +78,7 @@ struct GRUAttributes : public recurrent::OpAttributes { }; } // namespace -ov::OutputVector gru(const Node& node) { +ov::OutputVector gru(const ov::frontend::onnx::Node& node) { constexpr std::size_t gates_count = 3; GRUInputMap input_map{node, gates_count}; GRUAttributes attributes{node}; @@ -103,10 +104,7 @@ ov::OutputVector gru(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/gru.hpp b/src/frontends/onnx/frontend/src/op/gru.hpp index 15f7a5a8eea367..3d79096b2d69d9 100644 --- a/src/frontends/onnx/frontend/src/op/gru.hpp +++ b/src/frontends/onnx/frontend/src/op/gru.hpp @@ -4,22 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector gru(const Node& node); +ov::OutputVector gru(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/hammingwindow.cpp b/src/frontends/onnx/frontend/src/op/hammingwindow.cpp index 91ed09a1efa94a..e090e30a1ea145 100644 --- a/src/frontends/onnx/frontend/src/op/hammingwindow.cpp +++ b/src/frontends/onnx/frontend/src/op/hammingwindow.cpp @@ -18,13 +18,13 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector hammingwindow(const Node& node) { - const auto size = node.get_ng_inputs().at(0); +ov::OutputVector hammingwindow(const ov::frontend::onnx::Node& node) { + const auto size = node.get_ov_inputs().at(0); const auto output_datatype = common::get_ov_element_type(node.get_attribute_value("output_datatype", 1)); const bool periodic = node.get_attribute_value("periodic", 1) == 1; @@ -69,6 +69,6 @@ ov::OutputVector hammingwindow(const Node& node) { } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/hammingwindow.hpp b/src/frontends/onnx/frontend/src/op/hammingwindow.hpp index 852611b7bdf080..c6feeaa3ade805 100644 --- a/src/frontends/onnx/frontend/src/op/hammingwindow.hpp +++ b/src/frontends/onnx/frontend/src/op/hammingwindow.hpp @@ -3,20 +3,18 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector hammingwindow(const Node& node); +ov::OutputVector hammingwindow(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/hannwindow.cpp b/src/frontends/onnx/frontend/src/op/hannwindow.cpp index c35e0c6c9791ad..bf021025474f6a 100644 --- a/src/frontends/onnx/frontend/src/op/hannwindow.cpp +++ b/src/frontends/onnx/frontend/src/op/hannwindow.cpp @@ -18,13 +18,13 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector hannwindow(const Node& node) { - const auto size = node.get_ng_inputs().at(0); +ov::OutputVector hannwindow(const ov::frontend::onnx::Node& node) { + const auto size = node.get_ov_inputs().at(0); const auto output_datatype = common::get_ov_element_type(node.get_attribute_value("output_datatype", 1)); const bool periodic = node.get_attribute_value("periodic", 1) == 1; @@ -65,6 +65,6 @@ ov::OutputVector hannwindow(const Node& node) { } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/hannwindow.hpp b/src/frontends/onnx/frontend/src/op/hannwindow.hpp index 5c6c671ae64942..120a8af9ef3d37 100644 --- a/src/frontends/onnx/frontend/src/op/hannwindow.hpp +++ b/src/frontends/onnx/frontend/src/op/hannwindow.hpp @@ -3,20 +3,18 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector hannwindow(const Node& node); +ov::OutputVector hannwindow(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/hard_sigmoid.cpp b/src/frontends/onnx/frontend/src/op/hard_sigmoid.cpp index 4375eb113693df..a252ccafc811cd 100644 --- a/src/frontends/onnx/frontend/src/op/hard_sigmoid.cpp +++ b/src/frontends/onnx/frontend/src/op/hard_sigmoid.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -8,32 +8,30 @@ #include "openvino/op/hard_sigmoid.hpp" using namespace ov::op; +using ov::Shape; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector hard_sigmoid(const Node& node) { - const auto data = node.get_ng_inputs().at(0); +ov::OutputVector hard_sigmoid(const ov::frontend::onnx::Node& node) { + const auto data = node.get_ov_inputs().at(0); const auto alpha = v0::Constant::create(data.get_element_type(), - Shape{}, + ov::Shape{}, std::vector{node.get_attribute_value("alpha", 0.2)}); const auto beta = v0::Constant::create(data.get_element_type(), - Shape{}, + ov::Shape{}, std::vector{node.get_attribute_value("beta", 0.5)}); return {std::make_shared(data, alpha, beta)}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/hard_sigmoid.hpp b/src/frontends/onnx/frontend/src/op/hard_sigmoid.hpp index 4879f0f835a05c..3b6d36c38d8a74 100644 --- a/src/frontends/onnx/frontend/src/op/hard_sigmoid.hpp +++ b/src/frontends/onnx/frontend/src/op/hard_sigmoid.hpp @@ -4,22 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector hard_sigmoid(const Node& node); +ov::OutputVector hard_sigmoid(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/hard_swish.hpp b/src/frontends/onnx/frontend/src/op/hard_swish.hpp index 163928037c31dc..fc38bfb6a7d8c2 100644 --- a/src/frontends/onnx/frontend/src/op/hard_swish.hpp +++ b/src/frontends/onnx/frontend/src/op/hard_swish.hpp @@ -4,24 +4,19 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/hswish.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector hard_swish(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0))}; +inline ov::OutputVector hard_swish(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0))}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/hardmax.cpp b/src/frontends/onnx/frontend/src/op/hardmax.cpp index 65803381c6920a..10a5e254abbdce 100644 --- a/src/frontends/onnx/frontend/src/op/hardmax.cpp +++ b/src/frontends/onnx/frontend/src/op/hardmax.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -12,20 +12,20 @@ #include "openvino/op/reshape.hpp" #include "openvino/op/shape_of.hpp" #include "openvino/op/topk.hpp" -#include "ov_models/ov_builders/reshape.hpp" #include "utils/common.hpp" #include "utils/reshape.hpp" #include "validation_util.hpp" using namespace ov::op; +using ov::Shape; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector hardmax(const Node& node) { - const auto input = node.get_ng_inputs().at(0); +ov::OutputVector hardmax(const ov::frontend::onnx::Node& node) { + const auto input = node.get_ov_inputs().at(0); const auto& input_shape = input.get_partial_shape(); auto axis = node.get_attribute_value("axis", 1); @@ -41,17 +41,17 @@ ov::OutputVector hardmax(const Node& node) { std::make_shared(coerced_tensor_shape, ov::op::v0::Constant::create(ov::element::i64, {1}, {1}), ov::op::v0::Constant::create(ov::element::i64, {}, {0})); - row_size = ngraph::onnx_import::reshape::interpret_as_scalar(row_size); + row_size = ov::frontend::onnx::reshape::interpret_as_scalar(row_size); const auto indices_axis = 1; const auto topk = std::make_shared(coerced_tensor, - ov::op::v0::Constant::create(ov::element::i64, Shape{}, {1}), + ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {1}), indices_axis, ov::op::v11::TopK::Mode::MAX, ov::op::v11::TopK::SortType::NONE); - const auto on_value = ov::op::v0::Constant::create(ov::element::i64, Shape{}, {1}); - const auto off_value = ov::op::v0::Constant::create(ov::element::i64, Shape{}, {0}); + const auto on_value = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {1}); + const auto off_value = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {0}); const auto results = std::make_shared(topk->output(1), row_size, on_value, off_value, indices_axis); const auto converted_results = std::make_shared(results, input.get_element_type()); @@ -62,8 +62,8 @@ ov::OutputVector hardmax(const Node& node) { } // namespace set_1 namespace set_13 { -ov::OutputVector hardmax(const Node& node) { - const auto input = node.get_ng_inputs().at(0); +ov::OutputVector hardmax(const ov::frontend::onnx::Node& node) { + const auto input = node.get_ov_inputs().at(0); const auto& input_shape = input.get_partial_shape(); auto axis = node.get_attribute_value("axis", -1); @@ -74,16 +74,16 @@ ov::OutputVector hardmax(const Node& node) { std::make_shared(input_runtime_shape, ov::op::v0::Constant::create(ov::element::i64, {1}, {axis}), ov::op::v0::Constant::create(ov::element::i64, {}, {0})); - row_size = ngraph::onnx_import::reshape::interpret_as_scalar(row_size); + row_size = ov::frontend::onnx::reshape::interpret_as_scalar(row_size); const auto topk = std::make_shared(input, - ov::op::v0::Constant::create(ov::element::i64, Shape{}, {1}), + ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {1}), axis, ov::op::v11::TopK::Mode::MAX, ov::op::v11::TopK::SortType::NONE); - const auto on_value = ov::op::v0::Constant::create(ov::element::i64, Shape{}, {1}); - const auto off_value = ov::op::v0::Constant::create(ov::element::i64, Shape{}, {0}); + const auto on_value = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {1}); + const auto off_value = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {0}); const auto results = std::make_shared(topk->output(1), row_size, on_value, off_value, axis); const auto converted_results = std::make_shared(results, input.get_element_type()); @@ -94,8 +94,6 @@ ov::OutputVector hardmax(const Node& node) { } // namespace set_13 } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/hardmax.hpp b/src/frontends/onnx/frontend/src/op/hardmax.hpp index 5010bda389053b..a75c38538f421d 100644 --- a/src/frontends/onnx/frontend/src/op/hardmax.hpp +++ b/src/frontends/onnx/frontend/src/op/hardmax.hpp @@ -4,24 +4,20 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector hardmax(const Node& node); +ov::OutputVector hardmax(const ov::frontend::onnx::Node& node); } // namespace set_1 namespace set_13 { -ov::OutputVector hardmax(const Node& node); +ov::OutputVector hardmax(const ov::frontend::onnx::Node& node); } // namespace set_13 } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/identity.hpp b/src/frontends/onnx/frontend/src/op/identity.hpp index 94fc37441d7e69..e70aeb8a04dabe 100644 --- a/src/frontends/onnx/frontend/src/op/identity.hpp +++ b/src/frontends/onnx/frontend/src/op/identity.hpp @@ -4,28 +4,23 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "utils/common.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector identity(const Node& node) { - ov::OutputVector outputs = node.get_ng_inputs(); +inline ov::OutputVector identity(const ov::frontend::onnx::Node& node) { + ov::OutputVector outputs = node.get_ov_inputs(); for (auto& out : outputs) { common::mark_as_optimized_out(out); } return outputs; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/if.cpp b/src/frontends/onnx/frontend/src/op/if.cpp index 9db991311a6ac4..f06bf83315a801 100644 --- a/src/frontends/onnx/frontend/src/op/if.cpp +++ b/src/frontends/onnx/frontend/src/op/if.cpp @@ -5,18 +5,19 @@ #include "op/if.hpp" #include "core/graph.hpp" +#include "openvino/core/model.hpp" #include "openvino/frontend/exception.hpp" #include "openvino/op/if.hpp" using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector if_op(const Node& node) { - const auto& ng_inputs = node.get_ng_inputs(); +ov::OutputVector if_op(const ov::frontend::onnx::Node& node) { + const auto& ng_inputs = node.get_ov_inputs(); FRONT_END_GENERAL_CHECK(ng_inputs.size() == 1, "If operator takes only one input"); const auto& subgraphs = node.get_subgraphs(); @@ -68,6 +69,6 @@ ov::OutputVector if_op(const Node& node) { } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/if.hpp b/src/frontends/onnx/frontend/src/op/if.hpp index 84a7441e58eb72..97ed4b0e5129a3 100644 --- a/src/frontends/onnx/frontend/src/op/if.hpp +++ b/src/frontends/onnx/frontend/src/op/if.hpp @@ -4,13 +4,11 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { /// \brief Convert ONNX If operation to an OV node. @@ -19,10 +17,10 @@ namespace set_1 { /// /// \return The vector containing OV nodes producing output of ONNX If /// operation. -ov::OutputVector if_op(const Node& node); +ov::OutputVector if_op(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/image_scaler.cpp b/src/frontends/onnx/frontend/src/op/image_scaler.cpp index b0a595ed607491..a17e3d4d9f644f 100644 --- a/src/frontends/onnx/frontend/src/op/image_scaler.cpp +++ b/src/frontends/onnx/frontend/src/op/image_scaler.cpp @@ -11,13 +11,13 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector image_scaler(const Node& node) { - const auto inputs = node.get_ng_inputs(); +ov::OutputVector image_scaler(const ov::frontend::onnx::Node& node) { + const auto inputs = node.get_ov_inputs(); FRONT_END_GENERAL_CHECK(inputs.size() == 1, "ImageScaler 1 input tensor. Got: ", inputs.size()); const auto data = inputs[0]; @@ -44,6 +44,6 @@ ov::OutputVector image_scaler(const Node& node) { } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/image_scaler.hpp b/src/frontends/onnx/frontend/src/op/image_scaler.hpp index 112d4fd1cef78a..21fb1970fe2d07 100644 --- a/src/frontends/onnx/frontend/src/op/image_scaler.hpp +++ b/src/frontends/onnx/frontend/src/op/image_scaler.hpp @@ -4,18 +4,16 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector image_scaler(const Node& node); +ov::OutputVector image_scaler(const ov::frontend::onnx::Node& node); } } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/instance_norm.cpp b/src/frontends/onnx/frontend/src/op/instance_norm.cpp index 2cb00787c6e377..f834bd4efc96d1 100644 --- a/src/frontends/onnx/frontend/src/op/instance_norm.cpp +++ b/src/frontends/onnx/frontend/src/op/instance_norm.cpp @@ -14,15 +14,15 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector instance_norm(const Node& node) { - ov::Output data(node.get_ng_inputs().at(0)); - ov::Output scale(node.get_ng_inputs().at(1)); - ov::Output bias(node.get_ng_inputs().at(2)); +ov::OutputVector instance_norm(const ov::frontend::onnx::Node& node) { + ov::Output data(node.get_ov_inputs().at(0)); + ov::Output scale(node.get_ov_inputs().at(1)); + ov::Output bias(node.get_ov_inputs().at(2)); const ov::PartialShape& data_pshape = data.get_partial_shape(); const ov::PartialShape& scale_pshape = scale.get_partial_shape(); const ov::PartialShape& bias_pshape = bias.get_partial_shape(); @@ -78,10 +78,7 @@ ov::OutputVector instance_norm(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/instance_norm.hpp b/src/frontends/onnx/frontend/src/op/instance_norm.hpp index 85fe109f681a95..d8c4063c15abba 100644 --- a/src/frontends/onnx/frontend/src/op/instance_norm.hpp +++ b/src/frontends/onnx/frontend/src/op/instance_norm.hpp @@ -4,13 +4,11 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { /// \brief Creates OV node representing ONNX InstanceNormalization @@ -24,12 +22,9 @@ namespace set_1 { /// /// \return Vector of nodes containting resulting OV nodes. /// -ov::OutputVector instance_norm(const Node& node); +ov::OutputVector instance_norm(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/is_finite.cpp b/src/frontends/onnx/frontend/src/op/is_finite.cpp index aa33d3cdaf1e94..89923ac23fb276 100644 --- a/src/frontends/onnx/frontend/src/op/is_finite.cpp +++ b/src/frontends/onnx/frontend/src/op/is_finite.cpp @@ -8,19 +8,19 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector is_finite(const Node& node) { - const auto data = node.get_ng_inputs().at(0); +ov::OutputVector is_finite(const ov::frontend::onnx::Node& node) { + const auto data = node.get_ov_inputs().at(0); return {std::make_shared(data)}; } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/is_finite.hpp b/src/frontends/onnx/frontend/src/op/is_finite.hpp index 87ba9ae8d77041..8988aa5d8002a9 100644 --- a/src/frontends/onnx/frontend/src/op/is_finite.hpp +++ b/src/frontends/onnx/frontend/src/op/is_finite.hpp @@ -4,20 +4,18 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector is_finite(const Node& node); +ov::OutputVector is_finite(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/is_inf.cpp b/src/frontends/onnx/frontend/src/op/is_inf.cpp index f206d74fe90def..d9462cbbb0af57 100644 --- a/src/frontends/onnx/frontend/src/op/is_inf.cpp +++ b/src/frontends/onnx/frontend/src/op/is_inf.cpp @@ -8,13 +8,13 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector is_inf(const Node& node) { - const auto data = node.get_ng_inputs().at(0); +ov::OutputVector is_inf(const ov::frontend::onnx::Node& node) { + const auto data = node.get_ov_inputs().at(0); ov::opset10::IsInf::Attributes attributes{}; attributes.detect_negative = node.get_attribute_value("detect_negative", 1); @@ -24,6 +24,6 @@ ov::OutputVector is_inf(const Node& node) { } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/is_inf.hpp b/src/frontends/onnx/frontend/src/op/is_inf.hpp index 2d276148e8ce8f..c168141b8b9337 100644 --- a/src/frontends/onnx/frontend/src/op/is_inf.hpp +++ b/src/frontends/onnx/frontend/src/op/is_inf.hpp @@ -4,19 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector is_inf(const Node& node); +ov::OutputVector is_inf(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/is_nan.cpp b/src/frontends/onnx/frontend/src/op/is_nan.cpp index 523a0fb4ebecdd..74e345e15acf6b 100644 --- a/src/frontends/onnx/frontend/src/op/is_nan.cpp +++ b/src/frontends/onnx/frontend/src/op/is_nan.cpp @@ -8,19 +8,19 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector is_nan(const Node& node) { - const auto data = node.get_ng_inputs().at(0); +ov::OutputVector is_nan(const ov::frontend::onnx::Node& node) { + const auto data = node.get_ov_inputs().at(0); return {std::make_shared(data)}; } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/is_nan.hpp b/src/frontends/onnx/frontend/src/op/is_nan.hpp index 0dd9fbb1ed869b..065253f66a473e 100644 --- a/src/frontends/onnx/frontend/src/op/is_nan.hpp +++ b/src/frontends/onnx/frontend/src/op/is_nan.hpp @@ -4,20 +4,18 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector is_nan(const Node& node); +ov::OutputVector is_nan(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/layer_normalization.cpp b/src/frontends/onnx/frontend/src/op/layer_normalization.cpp new file mode 100644 index 00000000000000..c8d1d6b4c7b798 --- /dev/null +++ b/src/frontends/onnx/frontend/src/op/layer_normalization.cpp @@ -0,0 +1,104 @@ +// Copyright (C) 2018-2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "op/layer_normalization.hpp" + +#include "exceptions.hpp" +#include "openvino/op/add.hpp" +#include "openvino/op/broadcast.hpp" +#include "openvino/op/concat.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/convert.hpp" +#include "openvino/op/convert_like.hpp" +#include "openvino/op/divide.hpp" +#include "openvino/op/multiply.hpp" +#include "openvino/op/negative.hpp" +#include "openvino/op/reduce_mean.hpp" +#include "openvino/op/reshape.hpp" +#include "openvino/op/shape_of.hpp" +#include "openvino/op/slice.hpp" +#include "openvino/op/sqrt.hpp" +#include "openvino/op/subtract.hpp" +#include "utils/common.hpp" +#include "utils/reshape.hpp" + +using namespace ov::op; +using namespace ov::op::v0; +using namespace ov::op::v1; +using namespace ov::op::v8; +using ::ONNX_NAMESPACE::TensorProto_DataType; +using ov::Shape; + +namespace ov { +namespace frontend { +namespace onnx { +namespace op { +namespace set_1 { + +ov::OutputVector layer_normalization(const ov::frontend::onnx::Node& node) { + const auto inputs = node.get_ov_inputs(); + const auto num_inputs = inputs.size(); + CHECK_VALID_NODE(node, + num_inputs == 2 || num_inputs == 3, + "LayerNormalization expects 2 or 3 input tensors. Got: ", + num_inputs); + + const auto& X = inputs.at(0); + const auto& Scale = inputs.at(1); + + auto axis = node.get_attribute_value("axis", -1); + double epsilon = node.get_attribute_value("epsilon", 1e-5); + int64_t stash_type_i = + node.get_attribute_value("stash_type", + static_cast(TensorProto_DataType::TensorProto_DataType_FLOAT)); + element::Type stash_type = common::get_ov_element_type(stash_type_i); + + // following calculations are kept as close to the onnx\defs.cc description as possible + auto FloatEpsilon = Constant::create(ov::element::f32, Shape{}, {epsilon}); + auto Epsilon = std::make_shared(FloatEpsilon, stash_type); + auto XShape = std::make_shared(X); + auto Rank = std::make_shared(XShape); + auto Zero1D = Constant::create(ov::element::i64, {1}, {0}); + auto One1D = Constant::create(ov::element::i64, {1}, {1}); + auto Axis1D = Constant::create(ov::element::i64, {1}, {axis}); + auto PrefixShape = std::make_shared(XShape, Zero1D, Axis1D, One1D); + ov::Output NumReducedAxes = (axis >= 0 ? std::make_shared(Rank, Axis1D)->output(0) + : std::make_shared(Axis1D)->output(0)); + auto SuffixShape = std::make_shared(One1D, NumReducedAxes); + auto ReducedShape = std::make_shared(ov::OutputVector{PrefixShape, SuffixShape}, 0); + + auto X2D = ov::op::util::flatten(X, static_cast(axis)); + auto XU = std::make_shared(X2D, stash_type); + + auto Mean2D = std::make_shared(XU, One1D, true); + auto Square = std::make_shared(XU, XU); + auto MeanOfSquare = std::make_shared(Square, One1D, true); + auto SquareOfMean = std::make_shared(Mean2D, Mean2D); + + auto Var = std::make_shared(MeanOfSquare, SquareOfMean); + auto VarPlusEpsilon = std::make_shared(Var, Epsilon); + auto StdDev = std::make_shared(VarPlusEpsilon); + auto Deviation = std::make_shared(XU, Mean2D); + auto Normalized = std::make_shared(Deviation, StdDev); + auto NormalizedT = std::make_shared(Normalized, X); + + auto Scale2D = ov::op::util::flatten(Scale, 0); + auto Scaled = std::make_shared(NormalizedT, Scale2D); + ov::Output Biased = + (num_inputs == 3 ? std::make_shared(Scaled, ov::op::util::flatten(inputs.at(2), 0))->output(0) + : Scaled->output(0)); + + auto Y = std::make_shared(Biased, XShape, false); + auto InvStdDev2D = std::make_shared(Constant::create(stash_type, {1}, {1}), StdDev); + auto Mean = std::make_shared(Mean2D, ReducedShape, false); + auto InvStdDev = std::make_shared(InvStdDev2D, ReducedShape, false); + + return ov::OutputVector{Y, Mean, InvStdDev}; +} + +} // namespace set_1 +} // namespace op +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/layer_normalization.hpp b/src/frontends/onnx/frontend/src/op/layer_normalization.hpp new file mode 100644 index 00000000000000..b0b79213be4cd7 --- /dev/null +++ b/src/frontends/onnx/frontend/src/op/layer_normalization.hpp @@ -0,0 +1,22 @@ +// Copyright (C) 2018-2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// +#pragma once + +#include "openvino/core/deprecated.hpp" +OPENVINO_SUPPRESS_DEPRECATED_START + +#include "core/node.hpp" + +namespace ov { +namespace frontend { +namespace onnx { +namespace op { +namespace set_1 { +ov::OutputVector layer_normalization(const ov::frontend::onnx::Node& node); +} // namespace set_1 +} // namespace op +} // namespace onnx +} // namespace frontend +} // namespace ov +OPENVINO_SUPPRESS_DEPRECATED_END diff --git a/src/frontends/onnx/frontend/src/op/leaky_relu.cpp b/src/frontends/onnx/frontend/src/op/leaky_relu.cpp index 92bcdde845e5c6..15b108bf5730d7 100644 --- a/src/frontends/onnx/frontend/src/op/leaky_relu.cpp +++ b/src/frontends/onnx/frontend/src/op/leaky_relu.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -9,25 +9,23 @@ #include "openvino/op/prelu.hpp" using namespace ov::op; +using ov::Shape; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector leaky_relu(const Node& node) { - auto data = node.get_ng_inputs().at(0); +ov::OutputVector leaky_relu(const ov::frontend::onnx::Node& node) { + auto data = node.get_ov_inputs().at(0); double alpha = node.get_attribute_value("alpha", 0.01); - std::shared_ptr alpha_node = v0::Constant::create(data.get_element_type(), Shape{1}, {alpha}); + std::shared_ptr alpha_node = v0::Constant::create(data.get_element_type(), ov::Shape{1}, {alpha}); return {std::make_shared(data, alpha_node)}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/leaky_relu.hpp b/src/frontends/onnx/frontend/src/op/leaky_relu.hpp index 8b1532b1a7baa2..49c390a78d07ce 100644 --- a/src/frontends/onnx/frontend/src/op/leaky_relu.hpp +++ b/src/frontends/onnx/frontend/src/op/leaky_relu.hpp @@ -4,22 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector leaky_relu(const Node& node); +ov::OutputVector leaky_relu(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/less.hpp b/src/frontends/onnx/frontend/src/op/less.hpp index e19fbc25f5d2be..07d30b80a5fb3e 100644 --- a/src/frontends/onnx/frontend/src/op/less.hpp +++ b/src/frontends/onnx/frontend/src/op/less.hpp @@ -4,25 +4,20 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/less.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector less(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0), node.get_ng_inputs().at(1))}; +inline ov::OutputVector less(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0), node.get_ov_inputs().at(1))}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/less_or_equal.cpp b/src/frontends/onnx/frontend/src/op/less_or_equal.cpp index cf4bd6ae5ebbf6..c44d0de6334a69 100644 --- a/src/frontends/onnx/frontend/src/op/less_or_equal.cpp +++ b/src/frontends/onnx/frontend/src/op/less_or_equal.cpp @@ -10,13 +10,13 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector less_or_equal(const Node& node) { - const auto& input = node.get_ng_inputs(); +ov::OutputVector less_or_equal(const ov::frontend::onnx::Node& node) { + const auto& input = node.get_ov_inputs(); const auto a = input.at(0); const auto b = input.at(1); FRONT_END_GENERAL_CHECK(a.get_element_type() != ov::element::bf16 && b.get_element_type() != ov::element::bf16, @@ -26,14 +26,14 @@ ov::OutputVector less_or_equal(const Node& node) { } // namespace set_1 namespace set_16 { -ov::OutputVector less_or_equal(const Node& node) { - const auto& input = node.get_ng_inputs(); +ov::OutputVector less_or_equal(const ov::frontend::onnx::Node& node) { + const auto& input = node.get_ov_inputs(); const auto a = input.at(0); const auto b = input.at(1); return {std::make_shared(a, b)}; } } // namespace set_16 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/less_or_equal.hpp b/src/frontends/onnx/frontend/src/op/less_or_equal.hpp index 326591f3804d2c..bae2e37014ec73 100644 --- a/src/frontends/onnx/frontend/src/op/less_or_equal.hpp +++ b/src/frontends/onnx/frontend/src/op/less_or_equal.hpp @@ -4,26 +4,24 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector less_or_equal(const Node& node); +ov::OutputVector less_or_equal(const ov::frontend::onnx::Node& node); } // namespace set_1 namespace set_16 { -ov::OutputVector less_or_equal(const Node& node); +ov::OutputVector less_or_equal(const ov::frontend::onnx::Node& node); } // namespace set_16 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/log.cpp b/src/frontends/onnx/frontend/src/op/log.cpp index 22cf9d809399c3..294c824ca574ed 100644 --- a/src/frontends/onnx/frontend/src/op/log.cpp +++ b/src/frontends/onnx/frontend/src/op/log.cpp @@ -8,20 +8,17 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector log(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0))}; +ov::OutputVector log(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0))}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/log.hpp b/src/frontends/onnx/frontend/src/op/log.hpp index fdf95552516897..02b8332cd7c649 100644 --- a/src/frontends/onnx/frontend/src/op/log.hpp +++ b/src/frontends/onnx/frontend/src/op/log.hpp @@ -4,20 +4,16 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector log(const Node& node); +ov::OutputVector log(const ov::frontend::onnx::Node& node); } } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/log_softmax.cpp b/src/frontends/onnx/frontend/src/op/log_softmax.cpp index a37ca0eeecc9b3..1a660d535f251b 100644 --- a/src/frontends/onnx/frontend/src/op/log_softmax.cpp +++ b/src/frontends/onnx/frontend/src/op/log_softmax.cpp @@ -1,24 +1,24 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include "op/log_softmax.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/frontend/exception.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/log.hpp" #include "openvino/op/log_softmax.hpp" #include "openvino/op/reshape.hpp" #include "openvino/op/shape_of.hpp" -#include "ov_models/ov_builders/reshape.hpp" +#include "utils/reshape.hpp" #include "validation_util.hpp" using namespace ov::op; +using ov::Shape; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace { std::shared_ptr onnx_logsoftmax(const ov::Output data, const int64_t axis) { const auto coerced_data = ov::op::util::flatten(data, static_cast(axis)); @@ -27,8 +27,8 @@ std::shared_ptr onnx_logsoftmax(const ov::Output data, const return std::make_shared(result, data_shape, false); } -ov::OutputVector log_softmax(const Node& node, const int64_t DEFAULT_AXIS) { - ov::OutputVector inputs{node.get_ng_inputs()}; +ov::OutputVector log_softmax(const ov::frontend::onnx::Node& node, const int64_t DEFAULT_AXIS) { + ov::OutputVector inputs{node.get_ov_inputs()}; const auto data = inputs.at(0); const auto data_rank = data.get_partial_shape().rank(); @@ -39,7 +39,7 @@ ov::OutputVector log_softmax(const Node& node, const int64_t DEFAULT_AXIS) { std::shared_ptr result; switch (data_rank.get_length()) { case 0: { - result = v0::Constant::create(data.get_element_type(), Shape{}, {1}); + result = v0::Constant::create(data.get_element_type(), ov::Shape{}, {1}); break; } case 1: { @@ -62,21 +62,18 @@ ov::OutputVector log_softmax(const Node& node, const int64_t DEFAULT_AXIS) { namespace op { namespace set_1 { -ov::OutputVector log_softmax(const Node& node) { - return ngraph::onnx_import::log_softmax(node, 1); +ov::OutputVector log_softmax(const ov::frontend::onnx::Node& node) { + return ov::frontend::onnx::log_softmax(node, 1); } } // namespace set_1 namespace set_13 { -ov::OutputVector log_softmax(const Node& node) { +ov::OutputVector log_softmax(const ov::frontend::onnx::Node& node) { const auto axis = node.get_attribute_value("axis", -1); - return {std::make_shared(node.get_ng_inputs()[0], axis)}; + return {std::make_shared(node.get_ov_inputs()[0], axis)}; } } // namespace set_13 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/log_softmax.hpp b/src/frontends/onnx/frontend/src/op/log_softmax.hpp index 0aee91d17258a0..2a9d799d949bb8 100644 --- a/src/frontends/onnx/frontend/src/op/log_softmax.hpp +++ b/src/frontends/onnx/frontend/src/op/log_softmax.hpp @@ -4,27 +4,22 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector log_softmax(const Node& node); +ov::OutputVector log_softmax(const ov::frontend::onnx::Node& node); } // namespace set_1 namespace set_13 { -ov::OutputVector log_softmax(const Node& node); +ov::OutputVector log_softmax(const ov::frontend::onnx::Node& node); } // namespace set_13 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/loop.cpp b/src/frontends/onnx/frontend/src/op/loop.cpp index 97af7d85355380..20d1c4f9f0ae57 100644 --- a/src/frontends/onnx/frontend/src/op/loop.cpp +++ b/src/frontends/onnx/frontend/src/op/loop.cpp @@ -5,8 +5,8 @@ #include "op/loop.hpp" #include "core/graph.hpp" +#include "core/null_node.hpp" #include "exceptions.hpp" -#include "onnx_import/core/null_node.hpp" #include "openvino/core/model.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/loop.hpp" @@ -16,9 +16,9 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { namespace { @@ -39,8 +39,8 @@ bool is_termination_condition_always_true(const ov::Node* cond_in, const ov::Nod } } // namespace -ov::OutputVector loop(const Node& node) { - const auto& ng_inputs = node.get_ng_inputs(); +ov::OutputVector loop(const ov::frontend::onnx::Node& node) { + const auto& ng_inputs = node.get_ov_inputs(); const ov::OutputVector loop_carried_dependencies{std::next(ng_inputs.begin(), 2), ng_inputs.end()}; @@ -175,6 +175,6 @@ ov::OutputVector loop(const Node& node) { } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/loop.hpp b/src/frontends/onnx/frontend/src/op/loop.hpp index 13cf2ef28d50c7..94702c2412e640 100644 --- a/src/frontends/onnx/frontend/src/op/loop.hpp +++ b/src/frontends/onnx/frontend/src/op/loop.hpp @@ -4,13 +4,11 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { /// \brief Creates OV node representing ONNX loop operator. @@ -22,12 +20,9 @@ namespace set_1 { /// /// \return Vector of nodes containting resulting OV nodes. /// -ov::OutputVector loop(const Node& node); +ov::OutputVector loop(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/lp_norm.cpp b/src/frontends/onnx/frontend/src/op/lp_norm.cpp index 42072ab3883be6..836be70c76eb83 100644 --- a/src/frontends/onnx/frontend/src/op/lp_norm.cpp +++ b/src/frontends/onnx/frontend/src/op/lp_norm.cpp @@ -5,26 +5,23 @@ #include "op/lp_norm.hpp" #include "exceptions.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/divide.hpp" -#include "ov_models/ov_builders/norm.hpp" +#include "utils/norm.hpp" #include "validation_util.hpp" using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector lp_norm(const Node& node) { - const ov::Output data{node.get_ng_inputs().at(0)}; +ov::OutputVector lp_norm(const ov::frontend::onnx::Node& node) { + const ov::Output data{node.get_ov_inputs().at(0)}; const auto data_shape = data.get_partial_shape(); const auto data_rank = data_shape.rank(); - const std::int64_t p_norm{node.get_attribute_value("p", 2)}; - const std::int64_t axis{node.get_attribute_value("axis", -1)}; const size_t normalize_axis = ov::util::normalize_axis(node.get_description(), axis, data_rank); @@ -42,10 +39,7 @@ ov::OutputVector lp_norm(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/lp_norm.hpp b/src/frontends/onnx/frontend/src/op/lp_norm.hpp index d8a13f8c80a59c..9cd7fdf86a7432 100644 --- a/src/frontends/onnx/frontend/src/op/lp_norm.hpp +++ b/src/frontends/onnx/frontend/src/op/lp_norm.hpp @@ -4,13 +4,11 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { /// \brief Creates OV node representing ONNX LpNormalization operator. @@ -25,12 +23,9 @@ namespace set_1 { /// /// \return Vector of nodes containting resulting OV nodes. /// -ov::OutputVector lp_norm(const Node& node); +ov::OutputVector lp_norm(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/lp_pool.cpp b/src/frontends/onnx/frontend/src/op/lp_pool.cpp index 824ae2c7d331b5..715d1f49d929ef 100644 --- a/src/frontends/onnx/frontend/src/op/lp_pool.cpp +++ b/src/frontends/onnx/frontend/src/op/lp_pool.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -9,19 +9,20 @@ #include "openvino/op/concat.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/reshape.hpp" -#include "ov_models/ov_builders/norm.hpp" -#include "ov_models/ov_builders/split.hpp" #include "utils/common.hpp" +#include "utils/norm.hpp" +#include "utils/split.hpp" using namespace ov::op; +using ov::Shape; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector global_lp_pool(const Node& node) { - const ov::Output data{node.get_ng_inputs().at(0)}; +ov::OutputVector global_lp_pool(const ov::frontend::onnx::Node& node) { + const ov::Output data{node.get_ov_inputs().at(0)}; const std::size_t channel_axis{1}; const auto data_shape = data.get_partial_shape(); @@ -35,7 +36,7 @@ ov::OutputVector global_lp_pool(const Node& node) { CHECK_VALID_NODE(node, p_norm >= 0, "Only positive (including zero) values are supported for 'p' attribute."); - ov::OutputVector slices = ov::op::util::split(data, channels_count, channel_axis); + ov::OutputVector slices = ov::op::util::make_split(data, channels_count, channel_axis); for (auto& slice : slices) { // all dimensions except spatial/feature @@ -44,10 +45,11 @@ ov::OutputVector global_lp_pool(const Node& node) { slice = ov::op::util::lp_norm(slice, reduction_axes, static_cast(p_norm)); // output shape is all ones except N channel - Shape output_shape(data_shape.rank().get_length(), 1); + ov::Shape output_shape(data_shape.rank().get_length(), 1); output_shape.at(0) = data_shape[0].get_length(); - const auto reshape_pattern = v0::Constant::create(ov::element::i64, Shape{output_shape.size()}, output_shape); + const auto reshape_pattern = + v0::Constant::create(ov::element::i64, ov::Shape{output_shape.size()}, output_shape); slice = std::make_shared(slice, reshape_pattern, false); } @@ -56,10 +58,7 @@ ov::OutputVector global_lp_pool(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/lp_pool.hpp b/src/frontends/onnx/frontend/src/op/lp_pool.hpp index 71e8cc7ac5cb81..f56012c21f3c8e 100644 --- a/src/frontends/onnx/frontend/src/op/lp_pool.hpp +++ b/src/frontends/onnx/frontend/src/op/lp_pool.hpp @@ -4,13 +4,11 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { /// \brief Creates OV node representing ONNX GlobalLpPool operator. @@ -30,12 +28,9 @@ namespace set_1 { /// /// \return Vector of nodes containting resulting OV nodes. /// -ov::OutputVector global_lp_pool(const Node& node); +ov::OutputVector global_lp_pool(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/lrn.cpp b/src/frontends/onnx/frontend/src/op/lrn.cpp index 08e7e5c64c067d..f389ebfb8c6bb0 100644 --- a/src/frontends/onnx/frontend/src/op/lrn.cpp +++ b/src/frontends/onnx/frontend/src/op/lrn.cpp @@ -8,13 +8,13 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector lrn(const Node& node) { - auto data = node.get_ng_inputs().at(0); +ov::OutputVector lrn(const ov::frontend::onnx::Node& node) { + auto data = node.get_ov_inputs().at(0); double alpha = node.get_attribute_value("alpha", 1e-4); double beta = node.get_attribute_value("beta", 0.75); double bias = node.get_attribute_value("bias", 1); @@ -24,10 +24,7 @@ ov::OutputVector lrn(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/lrn.hpp b/src/frontends/onnx/frontend/src/op/lrn.hpp index ecfa625422d4cd..ce2e048973fe11 100644 --- a/src/frontends/onnx/frontend/src/op/lrn.hpp +++ b/src/frontends/onnx/frontend/src/op/lrn.hpp @@ -4,21 +4,16 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector lrn(const Node& node); +ov::OutputVector lrn(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/lstm.cpp b/src/frontends/onnx/frontend/src/op/lstm.cpp index 72d45c9f915d87..907bb881ca0067 100644 --- a/src/frontends/onnx/frontend/src/op/lstm.cpp +++ b/src/frontends/onnx/frontend/src/op/lstm.cpp @@ -1,11 +1,11 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include "op/lstm.hpp" +#include "core/null_node.hpp" #include "exceptions.hpp" -#include "onnx_import/core/null_node.hpp" #include "openvino/op/add.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/concat.hpp" @@ -15,14 +15,15 @@ #include "openvino/op/multiply.hpp" #include "openvino/op/shape_of.hpp" #include "openvino/util/common_util.hpp" -#include "ov_models/ov_builders/reshape.hpp" -#include "ov_models/ov_builders/split.hpp" +#include "utils/reshape.hpp" +#include "utils/split.hpp" using namespace ov::op; +using ov::Shape; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ INPUT NODES PARSING ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -40,7 +41,7 @@ enum class LSTMInput { struct LSTMNgInputMap { explicit LSTMNgInputMap(const Node& node) { - const auto& ng_inputs = node.get_ng_inputs(); + const auto& ng_inputs = node.get_ov_inputs(); // We have input, output, forget and cell gates constexpr std::size_t gates_count{4}; constexpr std::size_t P_gates_count{3}; @@ -69,24 +70,24 @@ struct LSTMNgInputMap { // Get dimensions needed for default inputs creation auto shape_of_x = std::make_shared(m_input_map[LSTMInput::LSTM_INPUT_X]); - auto axes = v0::Constant::create(ov::element::Type_t::i32, Shape{1}, {0}); + auto axes = v0::Constant::create(ov::element::Type_t::i32, ov::Shape{1}, {0}); auto batch_size_node = std::make_shared(shape_of_x, - v0::Constant::create(ov::element::Type_t::i32, Shape{1}, {0}), + v0::Constant::create(ov::element::Type_t::i32, ov::Shape{1}, {0}), axes); auto seq_length_node = std::make_shared(shape_of_x, - v0::Constant::create(ov::element::Type_t::i32, Shape{1}, {1}), + v0::Constant::create(ov::element::Type_t::i32, ov::Shape{1}, {1}), axes); auto shape_of_r = std::make_shared(m_input_map[LSTMInput::LSTM_INPUT_R]); auto num_directions_node = std::make_shared(shape_of_r, - v0::Constant::create(ov::element::Type_t::i32, Shape{1}, {0}), + v0::Constant::create(ov::element::Type_t::i32, ov::Shape{1}, {0}), axes); auto hidden_size_node = std::make_shared(shape_of_r, - v0::Constant::create(ov::element::Type_t::i32, Shape{1}, {2}), + v0::Constant::create(ov::element::Type_t::i32, ov::Shape{1}, {2}), axes); // ------ Optional inputs ------ @@ -95,7 +96,7 @@ struct LSTMNgInputMap { // OpenVino Shape: [num_directions, 4*hidden_size] if (ng_inputs.size() > 3 && !ov::op::util::is_null(ng_inputs.at(3))) { auto bias = ng_inputs.at(3); - auto split_bias = ov::op::util::split(bias, 2, 1); + auto split_bias = ov::op::util::make_split(bias, 2, 1); m_input_map[LSTMInput::LSTM_INPUT_B] = std::make_shared(split_bias.at(0), split_bias.at(1)); m_input_map[LSTMInput::LSTM_INPUT_B] = ov::op::util::convert_lstm_node_format(m_input_map[LSTMInput::LSTM_INPUT_B], @@ -106,11 +107,11 @@ struct LSTMNgInputMap { auto b_shape = std::make_shared( ov::OutputVector{num_directions_node, std::make_shared( - v0::Constant::create(ov::element::Type_t::i64, Shape{1}, {gates_count}), + v0::Constant::create(ov::element::Type_t::i64, ov::Shape{1}, {gates_count}), hidden_size_node)}, 0); m_input_map[LSTMInput::LSTM_INPUT_B] = std::make_shared( - v0::Constant::create(m_input_map[LSTMInput::LSTM_INPUT_X].get_element_type(), Shape{}, {0}), + v0::Constant::create(m_input_map[LSTMInput::LSTM_INPUT_X].get_element_type(), ov::Shape{}, {0}), b_shape); } // `sequence_lens`- The lengths of the sequences in a batch. @@ -131,7 +132,7 @@ struct LSTMNgInputMap { std::make_shared(ov::OutputVector{batch_size_node, num_directions_node, hidden_size_node}, 0); m_input_map[LSTMInput::LSTM_INPUT_INIT_H] = std::make_shared( - v0::Constant::create(m_input_map[LSTMInput::LSTM_INPUT_X].get_element_type(), Shape{}, {0}), + v0::Constant::create(m_input_map[LSTMInput::LSTM_INPUT_X].get_element_type(), ov::Shape{}, {0}), init_h_shape); } // `initial_c` - The initial value of the cell. @@ -144,7 +145,7 @@ struct LSTMNgInputMap { std::make_shared(ov::OutputVector{batch_size_node, num_directions_node, hidden_size_node}, 0); m_input_map[LSTMInput::LSTM_INPUT_INIT_C] = std::make_shared( - v0::Constant::create(m_input_map[LSTMInput::LSTM_INPUT_X].get_element_type(), Shape{}, {0}), + v0::Constant::create(m_input_map[LSTMInput::LSTM_INPUT_X].get_element_type(), ov::Shape{}, {0}), init_c_shape); } // `P` - The weight tensor for peepholes. @@ -160,11 +161,11 @@ struct LSTMNgInputMap { auto p_shape = std::make_shared( ov::OutputVector{num_directions_node, std::make_shared( - v0::Constant::create(ov::element::Type_t::i64, Shape{1}, {P_gates_count}), + v0::Constant::create(ov::element::Type_t::i64, ov::Shape{1}, {P_gates_count}), hidden_size_node)}, 0); m_input_map[LSTMInput::LSTM_INPUT_P] = std::make_shared( - v0::Constant::create(m_input_map[LSTMInput::LSTM_INPUT_X].get_element_type(), Shape{}, {0}), + v0::Constant::create(m_input_map[LSTMInput::LSTM_INPUT_X].get_element_type(), ov::Shape{}, {0}), p_shape); m_input_map[LSTMInput::LSTM_INPUT_P].set_names({"P_blank"}); } @@ -189,9 +190,8 @@ struct LSTMAttributes { m_activation_beta{node.get_attribute_value>("activation_beta", std::vector{})}, m_input_forget{static_cast(node.get_attribute_value("input_forget", 0))} { m_clip_threshold = std::abs(m_clip_threshold); - OPENVINO_SUPPRESS_DEPRECATED_START + std::string direction = ov::util::to_lower(node.get_attribute_value("direction", "forward")); - OPENVINO_SUPPRESS_DEPRECATED_END m_direction = ov::as_enum(direction); } @@ -208,7 +208,7 @@ struct LSTMAttributes { } // anonymous namespace namespace set_1 { -ov::OutputVector lstm(const Node& node) { +ov::OutputVector lstm(const ov::frontend::onnx::Node& node) { LSTMNgInputMap input_map{node}; LSTMAttributes attributes{node}; std::shared_ptr lstm_sequence; @@ -256,10 +256,7 @@ ov::OutputVector lstm(const Node& node) { ov::op::util::reorder_axes(Y_c, {1, 0, 2})}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/lstm.hpp b/src/frontends/onnx/frontend/src/op/lstm.hpp index ef676d0697bd9d..c7a94162744582 100644 --- a/src/frontends/onnx/frontend/src/op/lstm.hpp +++ b/src/frontends/onnx/frontend/src/op/lstm.hpp @@ -4,22 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector lstm(const Node& node); +ov::OutputVector lstm(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/matmul.hpp b/src/frontends/onnx/frontend/src/op/matmul.hpp index c70422b0c2980d..1389daa09bbabf 100644 --- a/src/frontends/onnx/frontend/src/op/matmul.hpp +++ b/src/frontends/onnx/frontend/src/op/matmul.hpp @@ -4,14 +4,12 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/matmul.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace detail { inline ov::OutputVector matmul(const ov::Output& a, const ov::Output& b) { @@ -19,11 +17,11 @@ inline ov::OutputVector matmul(const ov::Output& a, const ov::Output(node.get_ng_inputs().at(0), node.get_ng_inputs().at(1))}; +inline ov::OutputVector matmul(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0), node.get_ov_inputs().at(1))}; } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/matmul_integer.cpp b/src/frontends/onnx/frontend/src/op/matmul_integer.cpp index 8cc090509da18c..3faa4f23c5ab8f 100644 --- a/src/frontends/onnx/frontend/src/op/matmul_integer.cpp +++ b/src/frontends/onnx/frontend/src/op/matmul_integer.cpp @@ -12,13 +12,13 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector matmul_integer(const Node& node) { - const ov::OutputVector& inputs = node.get_ng_inputs(); +ov::OutputVector matmul_integer(const ov::frontend::onnx::Node& node) { + const ov::OutputVector& inputs = node.get_ov_inputs(); const auto& A = inputs.at(0); const auto& B = inputs.at(1); @@ -51,6 +51,6 @@ ov::OutputVector matmul_integer(const Node& node) { } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/matmul_integer.hpp b/src/frontends/onnx/frontend/src/op/matmul_integer.hpp index 8efd8fedb8a496..855b2d4f9a78ff 100644 --- a/src/frontends/onnx/frontend/src/op/matmul_integer.hpp +++ b/src/frontends/onnx/frontend/src/op/matmul_integer.hpp @@ -4,13 +4,11 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { /// \brief Performs ONNX MatMulInteger operation. @@ -19,9 +17,9 @@ namespace set_1 { /// /// \return The vector containing OV nodes producing output of ONNX quantizied /// matrix multiplication integer operation. -ov::OutputVector matmul_integer(const Node& node); +ov::OutputVector matmul_integer(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/max.hpp b/src/frontends/onnx/frontend/src/op/max.hpp index cabafac802a070..421bd52e530945 100644 --- a/src/frontends/onnx/frontend/src/op/max.hpp +++ b/src/frontends/onnx/frontend/src/op/max.hpp @@ -4,33 +4,28 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/maximum.hpp" #include "utils/variadic.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector max(const Node& node) { +inline ov::OutputVector max(const ov::frontend::onnx::Node& node) { return variadic::make_ng_variadic_op(node, ov::op::AutoBroadcastType::NONE); } } // namespace set_1 namespace set_8 { -inline ov::OutputVector max(const Node& node) { +inline ov::OutputVector max(const ov::frontend::onnx::Node& node) { return variadic::make_ng_variadic_op(node); } } // namespace set_8 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/max_pool.cpp b/src/frontends/onnx/frontend/src/op/max_pool.cpp index 38ab79465d3899..78371705456b2d 100644 --- a/src/frontends/onnx/frontend/src/op/max_pool.cpp +++ b/src/frontends/onnx/frontend/src/op/max_pool.cpp @@ -4,18 +4,18 @@ #include "op/max_pool.hpp" -#include "onnx_import/core/null_node.hpp" +#include "core/null_node.hpp" #include "openvino/util/log.hpp" #include "utils/pooling_factory.hpp" using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector max_pool(const Node& node) { +ov::OutputVector max_pool(const ov::frontend::onnx::Node& node) { if (node.get_outputs_size() > 1) { OPENVINO_WARN << "MaxPool: Indices output is not supported and was ignored"; } @@ -27,14 +27,11 @@ ov::OutputVector max_pool(const Node& node) { } // namespace set_1 namespace set_8 { -ov::OutputVector max_pool(const Node& node) { +ov::OutputVector max_pool(const ov::frontend::onnx::Node& node) { return pooling::PoolingFactory(node).make_max_pool_with_indices(); } } // namespace set_8 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/max_pool.hpp b/src/frontends/onnx/frontend/src/op/max_pool.hpp index 88b5b39f778111..a9e305941e8f27 100644 --- a/src/frontends/onnx/frontend/src/op/max_pool.hpp +++ b/src/frontends/onnx/frontend/src/op/max_pool.hpp @@ -4,13 +4,11 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { /// @@ -21,7 +19,7 @@ namespace set_1 { /// \return The vector containing OV nodes producing output of ONNX MaxPool /// operation. /// -ov::OutputVector max_pool(const Node& node); +ov::OutputVector max_pool(const ov::frontend::onnx::Node& node); } // namespace set_1 @@ -34,13 +32,10 @@ namespace set_8 { /// \return The vector containing OV nodes producing output of ONNX MaxPool /// operation. /// -ov::OutputVector max_pool(const Node& node); +ov::OutputVector max_pool(const ov::frontend::onnx::Node& node); } // namespace set_8 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/max_roi_pool.cpp b/src/frontends/onnx/frontend/src/op/max_roi_pool.cpp index be9bc4c8dadb99..c19d3c0fee57e6 100644 --- a/src/frontends/onnx/frontend/src/op/max_roi_pool.cpp +++ b/src/frontends/onnx/frontend/src/op/max_roi_pool.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -9,13 +9,13 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector max_roi_pool(const Node& node) { - const auto& inputs = node.get_ng_inputs(); +ov::OutputVector max_roi_pool(const ov::frontend::onnx::Node& node) { + const auto& inputs = node.get_ov_inputs(); const auto X = inputs.at(0); const auto rois = inputs.at(1); @@ -26,10 +26,10 @@ ov::OutputVector max_roi_pool(const Node& node) { const auto pooled_shape = node.get_attribute_value>("pooled_shape"); const auto spatial_scale = node.get_attribute_value("spatial_scale", 1.0); - return {std::make_shared(X, rois, Shape(pooled_shape), spatial_scale, "max")}; + return {std::make_shared(X, rois, ov::Shape(pooled_shape), spatial_scale, "max")}; } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/max_roi_pool.hpp b/src/frontends/onnx/frontend/src/op/max_roi_pool.hpp index 2cf66940843998..62bc77f0282ebc 100644 --- a/src/frontends/onnx/frontend/src/op/max_roi_pool.hpp +++ b/src/frontends/onnx/frontend/src/op/max_roi_pool.hpp @@ -4,20 +4,18 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector max_roi_pool(const Node& node); +ov::OutputVector max_roi_pool(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/mean.cpp b/src/frontends/onnx/frontend/src/op/mean.cpp index c0cb27b7c0579c..d4ab881bbe34f6 100644 --- a/src/frontends/onnx/frontend/src/op/mean.cpp +++ b/src/frontends/onnx/frontend/src/op/mean.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -11,23 +11,20 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector mean(const Node& node) { +ov::OutputVector mean(const ov::frontend::onnx::Node& node) { auto sum = variadic::make_ng_variadic_op(node).front(); - auto count = v0::Constant::create(sum.get_element_type(), Shape{}, {node.get_ng_inputs().size()}); + auto count = v0::Constant::create(sum.get_element_type(), ov::Shape{}, {node.get_ov_inputs().size()}); return {std::make_shared(sum, count)}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/mean.hpp b/src/frontends/onnx/frontend/src/op/mean.hpp index 5669eaf506704b..792ad97b335356 100644 --- a/src/frontends/onnx/frontend/src/op/mean.hpp +++ b/src/frontends/onnx/frontend/src/op/mean.hpp @@ -4,22 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector mean(const Node& node); +ov::OutputVector mean(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/mean_variance_normalization.cpp b/src/frontends/onnx/frontend/src/op/mean_variance_normalization.cpp index 8c29c790f287bb..b92acbdc1cca8d 100644 --- a/src/frontends/onnx/frontend/src/op/mean_variance_normalization.cpp +++ b/src/frontends/onnx/frontend/src/op/mean_variance_normalization.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -10,13 +10,13 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector mean_variance_normalization(const Node& node) { - auto data = node.get_ng_inputs().at(0); +ov::OutputVector mean_variance_normalization(const ov::frontend::onnx::Node& node) { + auto data = node.get_ov_inputs().at(0); bool across_channels = node.get_attribute_value("across_channels", 0); bool normalize_variance = node.get_attribute_value("normalize_variance", 1); @@ -26,20 +26,17 @@ ov::OutputVector mean_variance_normalization(const Node& node) { } // namespace set_1 namespace set_9 { -ov::OutputVector mean_variance_normalization(const Node& node) { - auto data = node.get_ng_inputs().at(0); +ov::OutputVector mean_variance_normalization(const ov::frontend::onnx::Node& node) { + auto data = node.get_ov_inputs().at(0); auto axes = node.get_attribute_value>("axes", {0, 2, 3}); const std::vector normalized_axes = ov::util::normalize_axes(node.get_description(), axes, data.get_partial_shape().rank()); - auto const_axes = v0::Constant::create(ov::element::i64, Shape{normalized_axes.size()}, normalized_axes); + auto const_axes = v0::Constant::create(ov::element::i64, ov::Shape{normalized_axes.size()}, normalized_axes); return {std::make_shared(data, const_axes, true, 1e-09f, ov::op::MVNEpsMode::OUTSIDE_SQRT)}; } } // namespace set_9 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/mean_variance_normalization.hpp b/src/frontends/onnx/frontend/src/op/mean_variance_normalization.hpp index 4a62ad97f47aa1..4544600b4c0611 100644 --- a/src/frontends/onnx/frontend/src/op/mean_variance_normalization.hpp +++ b/src/frontends/onnx/frontend/src/op/mean_variance_normalization.hpp @@ -4,25 +4,20 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector mean_variance_normalization(const Node& node); +ov::OutputVector mean_variance_normalization(const ov::frontend::onnx::Node& node); } // namespace set_1 namespace set_9 { -ov::OutputVector mean_variance_normalization(const Node& node); +ov::OutputVector mean_variance_normalization(const ov::frontend::onnx::Node& node); } // namespace set_9 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/min.hpp b/src/frontends/onnx/frontend/src/op/min.hpp index a0ec5f636d23c9..66c6c629cea9a9 100644 --- a/src/frontends/onnx/frontend/src/op/min.hpp +++ b/src/frontends/onnx/frontend/src/op/min.hpp @@ -4,32 +4,27 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/minimum.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector min(const Node& node) { +inline ov::OutputVector min(const ov::frontend::onnx::Node& node) { return variadic::make_ng_variadic_op(node, ov::op::AutoBroadcastType::NONE); } } // namespace set_1 namespace set_8 { -inline ov::OutputVector min(const Node& node) { +inline ov::OutputVector min(const ov::frontend::onnx::Node& node) { return variadic::make_ng_variadic_op(node); } } // namespace set_8 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/mod.cpp b/src/frontends/onnx/frontend/src/op/mod.cpp index 53239b372045ce..25891670647d97 100644 --- a/src/frontends/onnx/frontend/src/op/mod.cpp +++ b/src/frontends/onnx/frontend/src/op/mod.cpp @@ -11,14 +11,14 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector mod(const Node& node) { - ov::Output dividend{node.get_ng_inputs().at(0)}; - ov::Output divisor{node.get_ng_inputs().at(1)}; +ov::OutputVector mod(const ov::frontend::onnx::Node& node) { + ov::Output dividend{node.get_ov_inputs().at(0)}; + ov::Output divisor{node.get_ov_inputs().at(1)}; std::int64_t fmod = node.get_attribute_value("fmod", 0); ov::OutputVector output; @@ -36,10 +36,7 @@ ov::OutputVector mod(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/mod.hpp b/src/frontends/onnx/frontend/src/op/mod.hpp index 2c53bb160812dc..472bc3693fde78 100644 --- a/src/frontends/onnx/frontend/src/op/mod.hpp +++ b/src/frontends/onnx/frontend/src/op/mod.hpp @@ -4,21 +4,16 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector mod(const Node& node); +ov::OutputVector mod(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/mul.hpp b/src/frontends/onnx/frontend/src/op/mul.hpp index e64adddbd9554c..ef73e65555bbdf 100644 --- a/src/frontends/onnx/frontend/src/op/mul.hpp +++ b/src/frontends/onnx/frontend/src/op/mul.hpp @@ -4,32 +4,27 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/multiply.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector mul(const Node& node) { +inline ov::OutputVector mul(const ov::frontend::onnx::Node& node) { return common::handle_opset6_binary_op(node); } } // namespace set_1 namespace set_7 { -inline ov::OutputVector mul(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0), node.get_ng_inputs().at(1))}; +inline ov::OutputVector mul(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0), node.get_ov_inputs().at(1))}; } } // namespace set_7 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/neg.hpp b/src/frontends/onnx/frontend/src/op/neg.hpp index f0088b8df153c6..febdb25cdb32d1 100644 --- a/src/frontends/onnx/frontend/src/op/neg.hpp +++ b/src/frontends/onnx/frontend/src/op/neg.hpp @@ -4,24 +4,19 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/negative.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector neg(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0))}; +inline ov::OutputVector neg(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0))}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/nms_rotated.hpp b/src/frontends/onnx/frontend/src/op/nms_rotated.hpp index 13a92b7f916cee..b03b47db50da2b 100644 --- a/src/frontends/onnx/frontend/src/op/nms_rotated.hpp +++ b/src/frontends/onnx/frontend/src/op/nms_rotated.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -6,27 +6,25 @@ #include -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/nms_rotated.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector nms_rotated(const Node& node) { +inline ov::OutputVector nms_rotated(const ov::frontend::onnx::Node& node) { auto iou_threshold = node.get_attribute_value("iou_threshold"); auto score_threshold = node.get_attribute_value("score_threshold"); auto max_output_boxes_per_class = - ov::op::v0::Constant::create(ov::element::i64, Shape{1}, {std::numeric_limits::max()}); - auto iou_threshold_const = ov::op::v0::Constant::create(ov::element::f32, Shape{}, {iou_threshold}); - auto score_threshold_const = ov::op::v0::Constant::create(ov::element::f32, Shape{}, {score_threshold}); + ov::op::v0::Constant::create(ov::element::i64, ov::Shape{1}, {std::numeric_limits::max()}); + auto iou_threshold_const = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{}, {iou_threshold}); + auto score_threshold_const = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{}, {score_threshold}); - auto nms = std::make_shared(node.get_ng_inputs().at(0), - node.get_ng_inputs().at(1), + auto nms = std::make_shared(node.get_ov_inputs().at(0), + node.get_ov_inputs().at(1), max_output_boxes_per_class, iou_threshold_const, score_threshold_const, @@ -36,6 +34,6 @@ inline ov::OutputVector nms_rotated(const Node& node) { } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/non_max_suppression.cpp b/src/frontends/onnx/frontend/src/op/non_max_suppression.cpp index d1e6f71632aa9d..1375d089538a1b 100644 --- a/src/frontends/onnx/frontend/src/op/non_max_suppression.cpp +++ b/src/frontends/onnx/frontend/src/op/non_max_suppression.cpp @@ -1,49 +1,50 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include "openvino/op/non_max_suppression.hpp" +#include "core/null_node.hpp" #include "exceptions.hpp" -#include "onnx_import/core/null_node.hpp" #include "openvino/op/constant.hpp" #include "utils/reshape.hpp" using namespace ov::op; +using ov::Shape; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector non_max_suppression(const Node& node) { +ov::OutputVector non_max_suppression(const ov::frontend::onnx::Node& node) { using ov::op::util::is_null; // TODO: this op will not be tested until at least // a reference implementation is added - const auto ng_inputs = node.get_ng_inputs(); + const auto ng_inputs = node.get_ov_inputs(); const ov::Output boxes = ng_inputs.at(0); const ov::Output scores = ng_inputs.at(1); ov::Output max_output_boxes_per_class; if (ng_inputs.size() > 2 && !is_null(ng_inputs.at(2))) { - max_output_boxes_per_class = ngraph::onnx_import::reshape::interpret_as_scalar(ng_inputs.at(2)); + max_output_boxes_per_class = ov::frontend::onnx::reshape::interpret_as_scalar(ng_inputs.at(2)); } else { - max_output_boxes_per_class = v0::Constant::create(ov::element::i64, Shape{}, {0}); + max_output_boxes_per_class = v0::Constant::create(ov::element::i64, ov::Shape{}, {0}); } ov::Output iou_threshold; if (ng_inputs.size() > 3 && !is_null(ng_inputs.at(3))) { - iou_threshold = ngraph::onnx_import::reshape::interpret_as_scalar(ng_inputs.at(3)); + iou_threshold = ov::frontend::onnx::reshape::interpret_as_scalar(ng_inputs.at(3)); } else { - iou_threshold = v0::Constant::create(ov::element::f32, Shape{}, {.0f}); + iou_threshold = v0::Constant::create(ov::element::f32, ov::Shape{}, {.0f}); } ov::Output score_threshold; if (ng_inputs.size() > 4 && !is_null(ng_inputs.at(4))) { - score_threshold = ngraph::onnx_import::reshape::interpret_as_scalar(ng_inputs.at(4)); + score_threshold = ov::frontend::onnx::reshape::interpret_as_scalar(ng_inputs.at(4)); } else { - score_threshold = v0::Constant::create(ov::element::f32, Shape{}, {-std::numeric_limits::max()}); + score_threshold = v0::Constant::create(ov::element::f32, ov::Shape{}, {-std::numeric_limits::max()}); } const auto center_point_box = node.get_attribute_value("center_point_box", 0); @@ -65,10 +66,7 @@ ov::OutputVector non_max_suppression(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/non_max_suppression.hpp b/src/frontends/onnx/frontend/src/op/non_max_suppression.hpp index 81ed14995e384e..471d0b262757aa 100644 --- a/src/frontends/onnx/frontend/src/op/non_max_suppression.hpp +++ b/src/frontends/onnx/frontend/src/op/non_max_suppression.hpp @@ -4,21 +4,16 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector non_max_suppression(const Node& node); +ov::OutputVector non_max_suppression(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/non_zero.cpp b/src/frontends/onnx/frontend/src/op/non_zero.cpp index 3e4bf800852438..60d04b2d0dcd9a 100644 --- a/src/frontends/onnx/frontend/src/op/non_zero.cpp +++ b/src/frontends/onnx/frontend/src/op/non_zero.cpp @@ -8,21 +8,18 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector non_zero(const Node& node) { - auto data = node.get_ng_inputs().at(0); +ov::OutputVector non_zero(const ov::frontend::onnx::Node& node) { + auto data = node.get_ov_inputs().at(0); return {std::make_shared(data, ov::element::i64)}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/non_zero.hpp b/src/frontends/onnx/frontend/src/op/non_zero.hpp index 965a89ff2de055..dbef0efc410974 100644 --- a/src/frontends/onnx/frontend/src/op/non_zero.hpp +++ b/src/frontends/onnx/frontend/src/op/non_zero.hpp @@ -4,13 +4,11 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { /// \brief Convert ONNX NonZero operation to an OV node. @@ -19,13 +17,10 @@ namespace set_1 { /// /// \return The vector containing OV nodes producing output of ONNX NonZero /// operation. -ov::OutputVector non_zero(const Node& node); +ov::OutputVector non_zero(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/not.hpp b/src/frontends/onnx/frontend/src/op/not.hpp index e64c423f5dbb30..3002027518a140 100644 --- a/src/frontends/onnx/frontend/src/op/not.hpp +++ b/src/frontends/onnx/frontend/src/op/not.hpp @@ -4,25 +4,20 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/logical_not.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector logical_not(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0))}; +inline ov::OutputVector logical_not(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0))}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/onehot.cpp b/src/frontends/onnx/frontend/src/op/onehot.cpp index dde66e955ad971..f545b93f0cb767 100644 --- a/src/frontends/onnx/frontend/src/op/onehot.cpp +++ b/src/frontends/onnx/frontend/src/op/onehot.cpp @@ -12,13 +12,13 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector onehot(const Node& node) { - ov::OutputVector inputs{node.get_ng_inputs()}; +ov::OutputVector onehot(const ov::frontend::onnx::Node& node) { + ov::OutputVector inputs{node.get_ov_inputs()}; auto indices = std::make_shared(inputs.at(0), ov::element::i64); auto depth = std::make_shared(reshape::interpret_as_scalar(inputs.at(1)), ov::element::i64); // Rank 1 tensor containing exactly two elements: [off_value, on_value] @@ -34,9 +34,7 @@ ov::OutputVector onehot(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/onehot.hpp b/src/frontends/onnx/frontend/src/op/onehot.hpp index 452fa8c30d7395..8b8a15ad4b5e45 100644 --- a/src/frontends/onnx/frontend/src/op/onehot.hpp +++ b/src/frontends/onnx/frontend/src/op/onehot.hpp @@ -4,21 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector onehot(const Node& node); +ov::OutputVector onehot(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/or.hpp b/src/frontends/onnx/frontend/src/op/or.hpp index fa56835b2be4d0..423b631fdf26df 100644 --- a/src/frontends/onnx/frontend/src/op/or.hpp +++ b/src/frontends/onnx/frontend/src/op/or.hpp @@ -4,25 +4,20 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/logical_or.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector logical_or(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0), node.get_ng_inputs().at(1))}; +inline ov::OutputVector logical_or(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0), node.get_ov_inputs().at(1))}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/deformable_conv_2d.cpp b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/deformable_conv_2d.cpp index b2c1f01342a2c9..7abb16859b9dcc 100644 --- a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/deformable_conv_2d.cpp +++ b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/deformable_conv_2d.cpp @@ -21,12 +21,13 @@ using namespace ov::op; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector deformable_conv_2d(const Node& node) { - const ov::OutputVector& inputs = node.get_ng_inputs(); +ov::OutputVector deformable_conv_2d(const ov::frontend::onnx::Node& node) { + const ov::OutputVector& inputs = node.get_ov_inputs(); const auto strides = convpool::get_strides(node); const auto dilations = convpool::get_dilations(node); const auto paddings = convpool::get_pads(node); @@ -47,9 +48,7 @@ ov::OutputVector deformable_conv_2d(const Node& node) { deformable_groups)}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/deformable_conv_2d.hpp b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/deformable_conv_2d.hpp index c96cca7de8ebd9..225b8980873cd7 100644 --- a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/deformable_conv_2d.hpp +++ b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/deformable_conv_2d.hpp @@ -16,21 +16,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector deformable_conv_2d(const Node& node); +ov::OutputVector deformable_conv_2d(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/detection_output.cpp b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/detection_output.cpp index f360c019758a9c..a248e79cb30d6c 100644 --- a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/detection_output.cpp +++ b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/detection_output.cpp @@ -4,18 +4,19 @@ #include "op/org.openvinotoolkit/detection_output.hpp" -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/frontend/exception.hpp" #include "openvino/op/detection_output.hpp" using namespace ov::op; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector detection_output(const Node& node) { - auto inputs = node.get_ng_inputs(); +ov::OutputVector detection_output(const ov::frontend::onnx::Node& node) { + auto inputs = node.get_ov_inputs(); auto box_logits = inputs[0]; auto class_preds = inputs[1]; @@ -67,9 +68,7 @@ ov::OutputVector detection_output(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/detection_output.hpp b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/detection_output.hpp index 6912024340c9c1..1dca062281e902 100644 --- a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/detection_output.hpp +++ b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/detection_output.hpp @@ -4,21 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector detection_output(const Node& node); +ov::OutputVector detection_output(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/detection_output.cpp b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/detection_output.cpp index 2b190aa0a88f62..0a825f8defdcfa 100644 --- a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/detection_output.cpp +++ b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/detection_output.cpp @@ -4,19 +4,20 @@ #include "op/org.openvinotoolkit/experimental_detectron/detection_output.hpp" -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/experimental_detectron_detection_output.hpp" using namespace ov::op; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector experimental_detectron_detection_output(const Node& node) { +ov::OutputVector experimental_detectron_detection_output(const ov::frontend::onnx::Node& node) { using DetectionOutput = v6::ExperimentalDetectronDetectionOutput; - auto inputs = node.get_ng_inputs(); + auto inputs = node.get_ov_inputs(); auto rois = inputs[0]; auto deltas = inputs[1]; auto scores = inputs[2]; @@ -37,9 +38,7 @@ ov::OutputVector experimental_detectron_detection_output(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/detection_output.hpp b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/detection_output.hpp index 06fa2c884cee1e..07b09d782c0ae3 100644 --- a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/detection_output.hpp +++ b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/detection_output.hpp @@ -4,20 +4,16 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector experimental_detectron_detection_output(const Node& node); +ov::OutputVector experimental_detectron_detection_output(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/generate_proposals_single_image.cpp b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/generate_proposals_single_image.cpp index 7fad18259ea5f5..f8c1e843d44340 100644 --- a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/generate_proposals_single_image.cpp +++ b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/generate_proposals_single_image.cpp @@ -4,20 +4,21 @@ #include "op/org.openvinotoolkit/experimental_detectron/generate_proposals_single_image.hpp" -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/frontend/exception.hpp" #include "openvino/op/experimental_detectron_generate_proposals.hpp" using namespace ov::op; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector experimental_detectron_generate_proposals(const Node& node) { +ov::OutputVector experimental_detectron_generate_proposals(const ov::frontend::onnx::Node& node) { using GenerateProposalsSingleImage = v6::ExperimentalDetectronGenerateProposalsSingleImage; - const auto inputs = node.get_ng_inputs(); + const auto inputs = node.get_ov_inputs(); FRONT_END_GENERAL_CHECK(inputs.size() == 4, "ExperimentalDetectronGenerateProposalsSingleImage expects 4 " "inputs, received: ", @@ -39,9 +40,7 @@ ov::OutputVector experimental_detectron_generate_proposals(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/generate_proposals_single_image.hpp b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/generate_proposals_single_image.hpp index 53154f9aac48f1..ef1779bf236aad 100644 --- a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/generate_proposals_single_image.hpp +++ b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/generate_proposals_single_image.hpp @@ -4,20 +4,16 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector experimental_detectron_generate_proposals(const Node& node); +ov::OutputVector experimental_detectron_generate_proposals(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/prior_grid_generator.cpp b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/prior_grid_generator.cpp index dab2545430af80..691a242128410d 100644 --- a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/prior_grid_generator.cpp +++ b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/prior_grid_generator.cpp @@ -4,19 +4,20 @@ #include "op/org.openvinotoolkit/experimental_detectron/prior_grid_generator.hpp" -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/experimental_detectron_prior_grid_generator.hpp" using namespace ov::op; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector experimental_detectron_prior_grid_generator(const Node& node) { +ov::OutputVector experimental_detectron_prior_grid_generator(const ov::frontend::onnx::Node& node) { using PriorGridGenerator = v6::ExperimentalDetectronPriorGridGenerator; - auto inputs = node.get_ng_inputs(); + auto inputs = node.get_ov_inputs(); auto priors = inputs[0]; auto feature_map = inputs[1]; auto im_data = inputs[2]; @@ -31,9 +32,7 @@ ov::OutputVector experimental_detectron_prior_grid_generator(const Node& node) { return {std::make_shared(priors, feature_map, im_data, attrs)}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/prior_grid_generator.hpp b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/prior_grid_generator.hpp index 06669a6f067407..0f8d1f18da8f3c 100644 --- a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/prior_grid_generator.hpp +++ b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/prior_grid_generator.hpp @@ -4,21 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector experimental_detectron_prior_grid_generator(const Node& node); +ov::OutputVector experimental_detectron_prior_grid_generator(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/roi_feature_extractor.cpp b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/roi_feature_extractor.cpp index 497a04ae0754e5..819ffcdf76b636 100644 --- a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/roi_feature_extractor.cpp +++ b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/roi_feature_extractor.cpp @@ -4,19 +4,20 @@ #include "op/org.openvinotoolkit/experimental_detectron/roi_feature_extractor.hpp" -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/experimental_detectron_roi_feature.hpp" using namespace ov::op; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector experimental_detectron_roi_feature_extractor(const Node& node) { +ov::OutputVector experimental_detectron_roi_feature_extractor(const ov::frontend::onnx::Node& node) { using ROIFeatureExtractor = v6::ExperimentalDetectronROIFeatureExtractor; - auto inputs = node.get_ng_inputs(); + auto inputs = node.get_ov_inputs(); ROIFeatureExtractor::Attributes attrs{}; attrs.output_size = node.get_attribute_value("output_size", 7); @@ -28,9 +29,7 @@ ov::OutputVector experimental_detectron_roi_feature_extractor(const Node& node) } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/roi_feature_extractor.hpp b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/roi_feature_extractor.hpp index a2d251bb6aaf65..4c0216486d2ac0 100644 --- a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/roi_feature_extractor.hpp +++ b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/roi_feature_extractor.hpp @@ -4,20 +4,16 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector experimental_detectron_roi_feature_extractor(const Node& node); +ov::OutputVector experimental_detectron_roi_feature_extractor(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/topk_rios.cpp b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/topk_rios.cpp index 0d63b9ae314e68..34d5cf5ed33fcb 100644 --- a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/topk_rios.cpp +++ b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/topk_rios.cpp @@ -4,19 +4,20 @@ #include "op/org.openvinotoolkit/experimental_detectron/topk_rios.hpp" -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/experimental_detectron_topkrois.hpp" using namespace ov::op; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector experimental_detectron_topk_rois(const Node& node) { +ov::OutputVector experimental_detectron_topk_rois(const ov::frontend::onnx::Node& node) { using TopKROIs = v6::ExperimentalDetectronTopKROIs; - auto inputs = node.get_ng_inputs(); + auto inputs = node.get_ov_inputs(); auto input_rois = inputs[0]; auto rois_probs = inputs[1]; auto max_rois = static_cast(node.get_attribute_value("max_rois", 1000)); @@ -25,9 +26,7 @@ ov::OutputVector experimental_detectron_topk_rois(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/topk_rios.hpp b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/topk_rios.hpp index 64af528bdb1798..0cb0c1fc477dc8 100644 --- a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/topk_rios.hpp +++ b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/experimental_detectron/topk_rios.hpp @@ -4,21 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector experimental_detectron_topk_rois(const Node& node); +ov::OutputVector experimental_detectron_topk_rois(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/fake_quantize.cpp b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/fake_quantize.cpp index ae49aa07a8405c..2f0ccce704d9ef 100644 --- a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/fake_quantize.cpp +++ b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/fake_quantize.cpp @@ -10,12 +10,13 @@ using namespace ov::op; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector fake_quantize(const Node& node) { - const auto inputs = node.get_ng_inputs(); +ov::OutputVector fake_quantize(const ov::frontend::onnx::Node& node) { + const auto inputs = node.get_ov_inputs(); const auto X = inputs.at(0); const auto input_low = inputs.at(1); const auto input_high = inputs.at(2); @@ -28,9 +29,7 @@ ov::OutputVector fake_quantize(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/fake_quantize.hpp b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/fake_quantize.hpp index 2ae94cd4a0d819..599a6d3c4ef6d3 100644 --- a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/fake_quantize.hpp +++ b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/fake_quantize.hpp @@ -4,21 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector fake_quantize(const Node& node); +ov::OutputVector fake_quantize(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/generate_proposals.cpp b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/generate_proposals.cpp index d2c03b71edcda8..2099c3ca8aa872 100644 --- a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/generate_proposals.cpp +++ b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/generate_proposals.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2022 Intel Corporation +// Copyright (C) 2022-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -12,9 +12,11 @@ #include "openvino/op/shape_of.hpp" using namespace ov::op; +using ov::Shape; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { @@ -34,8 +36,8 @@ void validate_generate_proposals_inputs(const ov::OutputVector& inputs) { } } // namespace -ov::OutputVector generate_proposals(const Node& node) { - const auto inputs = node.get_ng_inputs(); +ov::OutputVector generate_proposals(const ov::frontend::onnx::Node& node) { + const auto inputs = node.get_ov_inputs(); validate_generate_proposals_inputs(inputs); const auto& scores = inputs[0]; // shape [N, A, H, W] @@ -51,10 +53,10 @@ ov::OutputVector generate_proposals(const Node& node) { attrs.normalized = !node.get_attribute_value("legacy_plus_one", true); // Broadcast anchors from [A, 4] to [H, W, A, 4] where [H, W] is taken from scores shape. - const auto zero = v0::Constant::create(ov::element::i64, Shape{1}, {0}); + const auto zero = v0::Constant::create(ov::element::i64, ov::Shape{1}, {0}); const auto scores_shape = std::make_shared(scores); const auto anchors_shape = std::make_shared(anchors); - const auto scores_shape_tail = v0::Constant::create(ov::element::i64, Shape{2}, {2, 3}); + const auto scores_shape_tail = v0::Constant::create(ov::element::i64, ov::Shape{2}, {2, 3}); const auto new_anchors_shape_front = std::make_shared(scores_shape, scores_shape_tail, zero); const auto new_anchors_shape = std::make_shared(ov::OutputVector{new_anchors_shape_front, anchors_shape}, 0); @@ -66,5 +68,6 @@ ov::OutputVector generate_proposals(const Node& node) { } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/generate_proposals.hpp b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/generate_proposals.hpp index 082c8111a07836..d3d57ae9280e0d 100644 --- a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/generate_proposals.hpp +++ b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/generate_proposals.hpp @@ -4,17 +4,16 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector generate_proposals(const Node& node); +ov::OutputVector generate_proposals(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/group_norm.cpp b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/group_norm.cpp index 0fa767023852af..dd92b4a6d1bcfc 100644 --- a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/group_norm.cpp +++ b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/group_norm.cpp @@ -4,19 +4,20 @@ #include "op/org.openvinotoolkit/group_norm.hpp" -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/frontend/exception.hpp" #include "openvino/op/group_normalization.hpp" #include "openvino/op/squeeze.hpp" using namespace ov::op; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector group_norm(const Node& node) { - auto inputs = node.get_ng_inputs(); +ov::OutputVector group_norm(const ov::frontend::onnx::Node& node) { + auto inputs = node.get_ov_inputs(); FRONT_END_GENERAL_CHECK(inputs.size() == 3, "Invalid number of inputs. Expected 3, actual " + std::to_string(inputs.size())); @@ -38,9 +39,7 @@ ov::OutputVector group_norm(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/group_norm.hpp b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/group_norm.hpp index 49e9a391c41da4..d75e2b91d32d66 100644 --- a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/group_norm.hpp +++ b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/group_norm.hpp @@ -4,23 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector group_norm(const Node& node); +ov::OutputVector group_norm(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph - -// namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/normalize.cpp b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/normalize.cpp index 76e40c143a0664..e556580401a502 100644 --- a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/normalize.cpp +++ b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/normalize.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -13,13 +13,15 @@ #include "utils/common.hpp" using namespace ov::op; +using ov::Shape; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector normalize(const Node& node) { - auto inputs = node.get_ng_inputs(); +ov::OutputVector normalize(const ov::frontend::onnx::Node& node) { + auto inputs = node.get_ov_inputs(); FRONT_END_GENERAL_CHECK(inputs.size() == 2, "Invalid number of inputs"); auto data = inputs[0]; @@ -46,13 +48,14 @@ ov::OutputVector normalize(const Node& node) { for (int64_t i = 2; i < data_shape.rank().get_length(); ++i) { weights_shape.push_back(1); } - auto new_shape = std::make_shared(ov::element::i64, Shape{weights_shape.size()}, weights_shape); + auto new_shape = + std::make_shared(ov::element::i64, ov::Shape{weights_shape.size()}, weights_shape); weights = std::make_shared(inputs[1], new_shape, true); } std::shared_ptr axes; if (!across_spatial) { - axes = std::make_shared(ov::element::i64, Shape{1}, std::vector{1}); + axes = std::make_shared(ov::element::i64, ov::Shape{1}, std::vector{1}); } else { axes = common::get_monotonic_range_along_node_rank(data, 1); } @@ -62,9 +65,7 @@ ov::OutputVector normalize(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/normalize.hpp b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/normalize.hpp index 9de65418d5cf39..cdce213ac65ea1 100644 --- a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/normalize.hpp +++ b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/normalize.hpp @@ -4,20 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector normalize(const Node& node); +ov::OutputVector normalize(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/prior_box.cpp b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/prior_box.cpp index 22dd23ca210282..33987df84bcfbd 100644 --- a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/prior_box.cpp +++ b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/prior_box.cpp @@ -1,11 +1,11 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include "op/org.openvinotoolkit/prior_box.hpp" +#include "core/node.hpp" #include "exceptions.hpp" -#include "onnx_import/core/node.hpp" #include "openvino/frontend/exception.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/prior_box.hpp" @@ -15,17 +15,19 @@ #include "openvino/op/unsqueeze.hpp" using namespace ov::op; +using ov::Shape; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace detail { namespace { std::shared_ptr make_slice(std::shared_ptr node, int64_t start, int64_t end) { return std::make_shared( node, - v0::Constant::create(ov::element::i64, Shape{1}, std::vector{start}), - v0::Constant::create(ov::element::i64, Shape{1}, std::vector{end}), + v0::Constant::create(ov::element::i64, ov::Shape{1}, std::vector{start}), + v0::Constant::create(ov::element::i64, ov::Shape{1}, std::vector{end}), std::vector{0}, // begin mask std::vector{0}); // end mask } @@ -33,8 +35,8 @@ std::shared_ptr make_slice(std::shared_ptr node, int } // namespace detail namespace set_1 { -ov::OutputVector prior_box(const Node& node) { - auto inputs = node.get_ng_inputs(); +ov::OutputVector prior_box(const ov::frontend::onnx::Node& node) { + auto inputs = node.get_ov_inputs(); FRONT_END_GENERAL_CHECK(inputs.size() == 2, "Invalid number of inputs"); auto output_shape = std::make_shared(inputs[0]); @@ -57,15 +59,15 @@ ov::OutputVector prior_box(const Node& node) { attrs.density = node.get_attribute_value>("density", {}); attrs.min_max_aspect_ratios_order = node.get_attribute_value("min_max_aspect_ratios_order", 1); - auto axes = v0::Constant::create(ov::element::i64, Shape{1}, std::vector{0}); + auto axes = v0::Constant::create(ov::element::i64, ov::Shape{1}, std::vector{0}); return { std::make_shared(std::make_shared(output_shape_slice, image_shape_slice, attrs), axes)}; } -ov::OutputVector prior_box_clustered(const Node& node) { - auto inputs = node.get_ng_inputs(); +ov::OutputVector prior_box_clustered(const ov::frontend::onnx::Node& node) { + auto inputs = node.get_ov_inputs(); FRONT_END_GENERAL_CHECK(inputs.size() == 2, "Invalid number of inputs"); auto output_shape_rank = inputs[0].get_partial_shape().rank().get_length(); @@ -96,7 +98,7 @@ ov::OutputVector prior_box_clustered(const Node& node) { attrs.step = node.get_attribute_value("step", 0.0f); attrs.offset = node.get_attribute_value("offset", 0.0f); - auto axes = v0::Constant::create(ov::element::i64, Shape{1}, std::vector{0}); + auto axes = v0::Constant::create(ov::element::i64, ov::Shape{1}, std::vector{0}); return {std::make_shared( std::make_shared(output_shape_slice, image_shape_slice, attrs), @@ -104,9 +106,7 @@ ov::OutputVector prior_box_clustered(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/prior_box.hpp b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/prior_box.hpp index 878d64b44ba9f6..a52e042dc7fc9e 100644 --- a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/prior_box.hpp +++ b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/prior_box.hpp @@ -4,23 +4,19 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector prior_box(const Node& node); +ov::OutputVector prior_box(const ov::frontend::onnx::Node& node); -ov::OutputVector prior_box_clustered(const Node& node); +ov::OutputVector prior_box_clustered(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/swish.cpp b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/swish.cpp index 70c25e7d4b1f2f..0e90eee634ec68 100644 --- a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/swish.cpp +++ b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/swish.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -10,27 +10,28 @@ #include "utils/reshape.hpp" using namespace ov::op; +using ov::Shape; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector swish(const Node& node) { - ov::OutputVector ng_inputs{node.get_ng_inputs()}; +ov::OutputVector swish(const ov::frontend::onnx::Node& node) { + ov::OutputVector ov_inputs{node.get_ov_inputs()}; ov::Output beta; - if (ng_inputs.size() > 1) { - beta = ngraph::onnx_import::reshape::interpret_as_scalar(ng_inputs.at(1)); + if (ov_inputs.size() > 1) { + beta = ov::frontend::onnx::reshape::interpret_as_scalar(ov_inputs.at(1)); } else { - beta = v0::Constant::create(ov::element::f32, Shape{}, {1.0}); + beta = v0::Constant::create(ov::element::f32, ov::Shape{}, {1.0}); } - return {std::make_shared(ng_inputs.at(0), beta)}; + return {std::make_shared(ov_inputs.at(0), beta)}; } } // namespace set_1 } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/swish.hpp b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/swish.hpp index c2c0a4d28ad3fc..3129e194654f4d 100644 --- a/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/swish.hpp +++ b/src/frontends/onnx/frontend/src/op/org.openvinotoolkit/swish.hpp @@ -4,20 +4,16 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector swish(const Node& node); +ov::OutputVector swish(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/pad.cpp b/src/frontends/onnx/frontend/src/op/pad.cpp index 46abb489df9248..ed4cbad656cdbe 100644 --- a/src/frontends/onnx/frontend/src/op/pad.cpp +++ b/src/frontends/onnx/frontend/src/op/pad.cpp @@ -4,14 +4,14 @@ #include "op/pad.hpp" +#include "core/null_node.hpp" #include "exceptions.hpp" -#include "onnx_import/core/null_node.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/pad.hpp" #include "openvino/op/util/op_types.hpp" -#include "ov_models/ov_builders/split.hpp" #include "utils/convpool.hpp" #include "utils/reshape.hpp" +#include "utils/split.hpp" namespace { ov::op::PadMode get_pad_mode(std::string mode) { @@ -32,15 +32,15 @@ ov::op::PadMode get_pad_mode(std::string mode) { } // namespace using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector pad(const Node& node) { - auto data = node.get_ng_inputs().at(0); +ov::OutputVector pad(const ov::frontend::onnx::Node& node) { + auto data = node.get_ov_inputs().at(0); - const auto data_rank = node.get_ng_inputs().at(0).get_partial_shape().rank(); + const auto data_rank = node.get_ov_inputs().at(0).get_partial_shape().rank(); CHECK_VALID_NODE(node, data_rank.is_static(), "Data rank must be static for pad op"); const auto data_rank_value = data_rank.get_length(); @@ -62,8 +62,8 @@ ov::OutputVector pad(const Node& node) { } // namespace set_1 namespace set_11 { -ov::OutputVector pad(const Node& node) { - const auto inputs = node.get_ng_inputs(); +ov::OutputVector pad(const ov::frontend::onnx::Node& node) { + const auto inputs = node.get_ov_inputs(); const auto& data = inputs[0]; const auto& pads = inputs[1]; ov::Output values; @@ -87,7 +87,7 @@ ov::OutputVector pad(const Node& node) { padding_begin = v0::Constant::create(ov::element::i64, ov::Shape{half_size}, padding_begin_values); padding_end = v0::Constant::create(ov::element::i64, ov::Shape{half_size}, padding_end_values); } else { - ov::OutputVector padding = ov::op::util::split(pads, 2, 0); + ov::OutputVector padding = ov::op::util::make_split(pads, 2, 0); padding_begin = padding.at(0); padding_end = padding.at(1); @@ -100,10 +100,7 @@ ov::OutputVector pad(const Node& node) { } } // namespace set_11 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/pad.hpp b/src/frontends/onnx/frontend/src/op/pad.hpp index 76ece817363bb0..da9da5437f305f 100644 --- a/src/frontends/onnx/frontend/src/op/pad.hpp +++ b/src/frontends/onnx/frontend/src/op/pad.hpp @@ -4,27 +4,22 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector pad(const Node& node); +ov::OutputVector pad(const ov::frontend::onnx::Node& node); } // namespace set_1 namespace set_11 { -ov::OutputVector pad(const Node& node); +ov::OutputVector pad(const ov::frontend::onnx::Node& node); } // namespace set_11 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/pow.cpp b/src/frontends/onnx/frontend/src/op/pow.cpp index 8343831cc29563..d09e378172abee 100644 --- a/src/frontends/onnx/frontend/src/op/pow.cpp +++ b/src/frontends/onnx/frontend/src/op/pow.cpp @@ -10,13 +10,13 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector pow(const Node& node) { - auto inputs = node.get_ng_inputs(); +ov::OutputVector pow(const ov::frontend::onnx::Node& node) { + auto inputs = node.get_ov_inputs(); FRONT_END_GENERAL_CHECK(inputs.size() == 2, "Power operation requires 2 inputs. Got: ", inputs.size()); auto base = inputs[0]; @@ -36,10 +36,7 @@ ov::OutputVector pow(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/pow.hpp b/src/frontends/onnx/frontend/src/op/pow.hpp index 8949a88b667b27..6559a683e3f7e3 100644 --- a/src/frontends/onnx/frontend/src/op/pow.hpp +++ b/src/frontends/onnx/frontend/src/op/pow.hpp @@ -4,22 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector pow(const Node& node); +ov::OutputVector pow(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/prelu.cpp b/src/frontends/onnx/frontend/src/op/prelu.cpp index bbc4c2f3ed8b59..6928c85d41c033 100644 --- a/src/frontends/onnx/frontend/src/op/prelu.cpp +++ b/src/frontends/onnx/frontend/src/op/prelu.cpp @@ -8,23 +8,20 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector prelu(const Node& node) { - ov::OutputVector ng_inputs{node.get_ng_inputs()}; - const auto& data = ng_inputs.at(0); - const auto& slope = ng_inputs.at(1); +ov::OutputVector prelu(const ov::frontend::onnx::Node& node) { + ov::OutputVector ov_inputs{node.get_ov_inputs()}; + const auto& data = ov_inputs.at(0); + const auto& slope = ov_inputs.at(1); return {std::make_shared(data, slope)}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/prelu.hpp b/src/frontends/onnx/frontend/src/op/prelu.hpp index 141b1874fa2620..e7b92c46cd388d 100644 --- a/src/frontends/onnx/frontend/src/op/prelu.hpp +++ b/src/frontends/onnx/frontend/src/op/prelu.hpp @@ -4,22 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector prelu(const Node& node); +ov::OutputVector prelu(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/qlinear_conv.cpp b/src/frontends/onnx/frontend/src/op/qlinear_conv.cpp index 4404c5f1473aeb..4621111d76decd 100644 --- a/src/frontends/onnx/frontend/src/op/qlinear_conv.cpp +++ b/src/frontends/onnx/frontend/src/op/qlinear_conv.cpp @@ -8,22 +8,22 @@ #include "op/qlinear_conv.hpp" #include "conv.hpp" +#include "core/null_node.hpp" #include "dequantize_linear.hpp" #include "exceptions.hpp" -#include "onnx_import/core/null_node.hpp" #include "openvino/op/convert.hpp" #include "openvino/op/multiply.hpp" #include "quantize_linear.hpp" using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector qlinear_conv(const Node& node) { - const ov::OutputVector& inputs = node.get_ng_inputs(); +ov::OutputVector qlinear_conv(const ov::frontend::onnx::Node& node) { + const ov::OutputVector& inputs = node.get_ov_inputs(); auto x = inputs.at(0); auto x_scale = inputs.at(1); @@ -60,10 +60,7 @@ ov::OutputVector qlinear_conv(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/qlinear_conv.hpp b/src/frontends/onnx/frontend/src/op/qlinear_conv.hpp index 4f426c87fd7ced..b89911a421cd61 100644 --- a/src/frontends/onnx/frontend/src/op/qlinear_conv.hpp +++ b/src/frontends/onnx/frontend/src/op/qlinear_conv.hpp @@ -7,13 +7,11 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { /// \brief Performs ONNX QLinearConv operation. @@ -22,11 +20,10 @@ namespace set_1 { /// /// \return The vector containing OV nodes producing output of ONNX quantizied /// convolution operation. -ov::OutputVector qlinear_conv(const Node& node); +ov::OutputVector qlinear_conv(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/qlinear_matmul.cpp b/src/frontends/onnx/frontend/src/op/qlinear_matmul.cpp index 5244e578f3bfe4..16240b6fc073f4 100644 --- a/src/frontends/onnx/frontend/src/op/qlinear_matmul.cpp +++ b/src/frontends/onnx/frontend/src/op/qlinear_matmul.cpp @@ -12,13 +12,13 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector qlinear_matmul(const Node& node) { - const ov::OutputVector& inputs = node.get_ng_inputs(); +ov::OutputVector qlinear_matmul(const ov::frontend::onnx::Node& node) { + const ov::OutputVector& inputs = node.get_ov_inputs(); const auto& a = inputs.at(0); const auto& a_scale = reshape::interpret_as_scalar(inputs.at(1)); @@ -50,6 +50,6 @@ ov::OutputVector qlinear_matmul(const Node& node) { } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/qlinear_matmul.hpp b/src/frontends/onnx/frontend/src/op/qlinear_matmul.hpp index 70ba9594c3a8ac..6d117a6159715c 100644 --- a/src/frontends/onnx/frontend/src/op/qlinear_matmul.hpp +++ b/src/frontends/onnx/frontend/src/op/qlinear_matmul.hpp @@ -4,13 +4,11 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { /// \brief Performs ONNX QLinearMatMul operation. @@ -19,9 +17,9 @@ namespace set_1 { /// /// \return The vector containing OV nodes producing output of ONNX quantizied /// matrix multiplication operation. -ov::OutputVector qlinear_matmul(const Node& node); +ov::OutputVector qlinear_matmul(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/quant_conv.cpp b/src/frontends/onnx/frontend/src/op/quant_conv.cpp index 942d877e9f5a7e..a913399e378393 100644 --- a/src/frontends/onnx/frontend/src/op/quant_conv.cpp +++ b/src/frontends/onnx/frontend/src/op/quant_conv.cpp @@ -16,8 +16,7 @@ # include "default_opset.hpp" # include "exceptions.hpp" # include "ngraph/builder/quantization/quantized_linear_convolution.hpp" -# include "ngraph/coordinate_diff.hpp" -# include "ngraph/frontend/onnx_import/utils/convpool.hpp" +# include "ngraph/frontend/utils/convpool.hpp" # include "ngraph/op/util/attr_types.hpp" # include "ngraph/opsets/opset0.hpp" # include "ngraph/strides.hpp" @@ -49,11 +48,11 @@ namespace ngraph std::shared_ptr make_ng_quant_conv(const Output& data, const Output& filters, - const Strides& strides, - const Strides& filter_dilations, + const ov::Strides& strides, + const ov::Strides& filter_dilations, const CoordinateDiff& padding_below, const CoordinateDiff& padding_above, - const Strides& data_dilations, + const ov::Strides& data_dilations, int groups, const OpScale& op_scale, const OpZeroPoint& op_zero_point, @@ -125,9 +124,9 @@ namespace ngraph op_scale.output_scale, op_zero_point.output_zero_point, output_type, - ngraph::AxisSet{}, - ngraph::AxisSet{}, - ngraph::AxisSet{})); + ov::AxisSet{}, + ov::AxisSet{}, + ov::AxisSet{})); } } std::size_t concatenation_axis = 1; @@ -168,16 +167,16 @@ namespace ngraph op_scale.output_scale, op_zero_point.output_zero_point, output_type, - ngraph::AxisSet{}, - ngraph::AxisSet{}, - ngraph::AxisSet{}); + ov::AxisSet{}, + ov::AxisSet{}, + ov::AxisSet{}); } } } } // namespace - ov::OutputVector quant_conv(const Node& node) + ov::OutputVector quant_conv(const ov::frontend::onnx::Node& node) { const ov::OutputVector& inputs = node.get_ng_inputs(); auto data = inputs.at(0); @@ -213,9 +212,9 @@ namespace ngraph "provided group attribute value must be a multiple of filter channels " "count."); - Strides strides = convpool::get_strides(node); - Strides filter_dilations = convpool::get_dilations(node); - Strides data_dilations = Strides(convpool::get_kernel_shape(node).size(), 1UL); + ov::Strides strides = convpool::get_strides(node); + ov::Strides filter_dilations = convpool::get_dilations(node); + ov::Strides data_dilations = Strides(convpool::get_kernel_shape(node).size(), 1UL); auto paddings = convpool::get_pads(node); ngraph::op::PadType auto_pad_type = convpool::get_auto_pad(node); CoordinateDiff& padding_below = paddings.first; @@ -269,8 +268,8 @@ namespace ngraph } // namespace op - } // namespace onnx_import - -} // namespace ngraph + } // namespace onnx +} // namespace frontend +} // namespace ov #endif diff --git a/src/frontends/onnx/frontend/src/op/quant_conv.hpp b/src/frontends/onnx/frontend/src/op/quant_conv.hpp index af554c94bf50b7..38135b34649885 100644 --- a/src/frontends/onnx/frontend/src/op/quant_conv.hpp +++ b/src/frontends/onnx/frontend/src/op/quant_conv.hpp @@ -7,13 +7,11 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { /// \brief Performs ONNX Quant Conv operation. @@ -22,13 +20,10 @@ namespace set_1 { /// /// \return The vector containing Ngraph nodes producing output of ONNX quantizied /// convolution operation. -ov::OutputVector quant_conv(const Node& node); +ov::OutputVector quant_conv(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/quantize_linear.cpp b/src/frontends/onnx/frontend/src/op/quantize_linear.cpp index d28a07d12ff4f5..b19f78dbcf0255 100644 --- a/src/frontends/onnx/frontend/src/op/quantize_linear.cpp +++ b/src/frontends/onnx/frontend/src/op/quantize_linear.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -11,15 +11,15 @@ #include "openvino/op/fake_quantize.hpp" #include "openvino/op/multiply.hpp" #include "openvino/op/subtract.hpp" -#include "ov_models/ov_builders/reshape.hpp" #include "utils/reshape.hpp" #include "validation_util.hpp" using namespace ov::op; +using ov::Shape; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace detail { namespace { @@ -27,7 +27,7 @@ ov::Output get_zero_point(const ov::OutputVector& inputs) { if (inputs.size() > 2) { return inputs.at(2); } else { - return std::make_shared(ov::element::u8, Shape{1}, std::uint8_t(0)); + return std::make_shared(ov::element::u8, ov::Shape{1}, std::uint8_t(0)); } } @@ -70,20 +70,20 @@ std::tuple, std::shared_ptr> get_output_band // should be aligned switch (destination_type) { case ov::element::i8: - output_low = std::make_shared(data_type, Shape{1}, -128); - output_high = std::make_shared(data_type, Shape{1}, 127); + output_low = std::make_shared(data_type, ov::Shape{1}, -128); + output_high = std::make_shared(data_type, ov::Shape{1}, 127); break; case ov::element::u8: - output_low = std::make_shared(data_type, Shape{1}, 0); - output_high = std::make_shared(data_type, Shape{1}, 255); + output_low = std::make_shared(data_type, ov::Shape{1}, 0); + output_high = std::make_shared(data_type, ov::Shape{1}, 255); break; case ov::element::i16: - output_low = std::make_shared(data_type, Shape{1}, -32768); - output_high = std::make_shared(data_type, Shape{1}, 32767); + output_low = std::make_shared(data_type, ov::Shape{1}, -32768); + output_high = std::make_shared(data_type, ov::Shape{1}, 32767); break; case ov::element::u16: - output_low = std::make_shared(data_type, Shape{1}, 0); - output_high = std::make_shared(data_type, Shape{1}, 65535); + output_low = std::make_shared(data_type, ov::Shape{1}, 0); + output_high = std::make_shared(data_type, ov::Shape{1}, 65535); break; default: OPENVINO_THROW("Unsupported element type for QuantizeLinear"); @@ -139,8 +139,8 @@ std::shared_ptr make_fake_quantize(const ov::Output& y_scale } // namespace detail namespace set_1 { -ov::OutputVector quantize_linear(const Node& node) { - ov::OutputVector inputs{node.get_ng_inputs()}; +ov::OutputVector quantize_linear(const ov::frontend::onnx::Node& node) { + ov::OutputVector inputs{node.get_ov_inputs()}; auto x = inputs.at(0); auto y_scale = inputs.at(1); auto y_zero_point = detail::get_zero_point(inputs); @@ -160,7 +160,7 @@ ov::OutputVector quantize_linear(ov::Output x, ov::Output y_zero_point, int64_t axis, Node node) { - namespace detail = ngraph::onnx_import::op::detail; + namespace detail = ov::frontend::onnx::op::detail; x = detail::validate_data(node, x); detail::validate_zero_point_type(node, y_zero_point); @@ -182,7 +182,7 @@ ov::OutputVector quantize_linear(ov::Output x, " must match the number of respective input data axis size: ", x_shape[axis]); - Shape target_shape(x_shape.rank().get_length(), 1); + ov::Shape target_shape(x_shape.rank().get_length(), 1); target_shape[axis] = static_cast(x_shape[axis].get_length()); y_scale = ov::op::util::reshape(y_scale, target_shape); @@ -197,7 +197,7 @@ ov::OutputVector quantize_linear(ov::Output x, " must match the number of respective input data axis size: ", x_shape[axis]); - Shape target_shape(x_shape.rank().get_length(), 1); + ov::Shape target_shape(x_shape.rank().get_length(), 1); target_shape[axis] = static_cast(x_shape[axis].get_length()); y_zero_point = ov::op::util::reshape(y_zero_point, target_shape); @@ -207,8 +207,8 @@ ov::OutputVector quantize_linear(ov::Output x, } } // namespace -ov::OutputVector quantize_linear(const Node& node) { - const ov::OutputVector inputs{node.get_ng_inputs()}; +ov::OutputVector quantize_linear(const ov::frontend::onnx::Node& node) { + const ov::OutputVector inputs{node.get_ov_inputs()}; FRONT_END_GENERAL_CHECK(2 <= inputs.size() && inputs.size() <= 3, "The QuantizeLinear op expects 2 required and one optional " @@ -228,10 +228,7 @@ ov::OutputVector quantize_linear(const Node& node) { return quantize_linear(x, scale, zero_point, node.get_attribute_value("axis", 1), node); } } // namespace set_13 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/quantize_linear.hpp b/src/frontends/onnx/frontend/src/op/quantize_linear.hpp index 9633789c75782d..6460545b937618 100644 --- a/src/frontends/onnx/frontend/src/op/quantize_linear.hpp +++ b/src/frontends/onnx/frontend/src/op/quantize_linear.hpp @@ -4,14 +4,12 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/core/node.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace detail { std::shared_ptr make_fake_quantize(const ov::Output& y_scale, @@ -19,19 +17,16 @@ std::shared_ptr make_fake_quantize(const ov::Output& y_scale const ov::Output& data); } namespace set_1 { -ov::OutputVector quantize_linear(const Node& node); +ov::OutputVector quantize_linear(const ov::frontend::onnx::Node& node); } // namespace set_1 namespace set_13 { -ov::OutputVector quantize_linear(const Node& node); +ov::OutputVector quantize_linear(const ov::frontend::onnx::Node& node); } // namespace set_13 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/random_normal.cpp b/src/frontends/onnx/frontend/src/op/random_normal.cpp index d60f9994bb968b..8dde43a12fde30 100644 --- a/src/frontends/onnx/frontend/src/op/random_normal.cpp +++ b/src/frontends/onnx/frontend/src/op/random_normal.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -10,24 +10,27 @@ #include "utils/common.hpp" using namespace ov::op; +using ::ONNX_NAMESPACE::TensorProto_DataType; +using ov::Shape; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector random_normal(const Node& node) { +ov::OutputVector random_normal(const ov::frontend::onnx::Node& node) { CHECK_VALID_NODE(node, node.has_attribute("shape"), "RandomNormal operator must specify a 'shape' attribute."); const auto dtype = - node.get_attribute_value("dtype", static_cast(ONNX_NAMESPACE::TensorProto_DataType_FLOAT)); + node.get_attribute_value("dtype", + static_cast(TensorProto_DataType::TensorProto_DataType_FLOAT)); const auto target_type = common::get_ov_element_type(dtype); const auto mean = node.get_attribute_value("mean", 0.0f); const auto scale = node.get_attribute_value("scale", 1.0f); - auto scale_node = v0::Constant::create(target_type, Shape{1}, {scale}); - auto mean_node = v0::Constant::create(target_type, Shape{1}, {mean}); + auto scale_node = v0::Constant::create(target_type, ov::Shape{1}, {scale}); + auto mean_node = v0::Constant::create(target_type, ov::Shape{1}, {mean}); const auto seed = node.get_attribute_value("seed", 0); const auto shape = node.get_attribute_as_constant>("shape"); @@ -37,6 +40,6 @@ ov::OutputVector random_normal(const Node& node) { } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/random_normal.hpp b/src/frontends/onnx/frontend/src/op/random_normal.hpp index f16aede9c45421..c6f4b6b86ebcfd 100644 --- a/src/frontends/onnx/frontend/src/op/random_normal.hpp +++ b/src/frontends/onnx/frontend/src/op/random_normal.hpp @@ -4,20 +4,18 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector random_normal(const Node& node); +ov::OutputVector random_normal(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/random_normal_like.cpp b/src/frontends/onnx/frontend/src/op/random_normal_like.cpp index 48214824f1707e..b600469ede33da 100644 --- a/src/frontends/onnx/frontend/src/op/random_normal_like.cpp +++ b/src/frontends/onnx/frontend/src/op/random_normal_like.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -9,15 +9,16 @@ #include "utils/common.hpp" using namespace ov::op; +using ov::Shape; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector random_normal_like(const Node& node) { - const auto input = node.get_ng_inputs().at(0); +ov::OutputVector random_normal_like(const ov::frontend::onnx::Node& node) { + const auto input = node.get_ov_inputs().at(0); ov::element::Type target_type; if (node.has_attribute("dtype")) { @@ -32,8 +33,8 @@ ov::OutputVector random_normal_like(const Node& node) { const auto mean = node.get_attribute_value("mean", 0.0f); const auto scale = node.get_attribute_value("scale", 1.0f); - auto scale_node = v0::Constant::create(target_type, Shape{1}, {scale}); - auto mean_node = v0::Constant::create(target_type, Shape{1}, {mean}); + auto scale_node = v0::Constant::create(target_type, ov::Shape{1}, {scale}); + auto mean_node = v0::Constant::create(target_type, ov::Shape{1}, {mean}); auto res = ov::frontend::make_random_normal(shape, target_type, mean_node, scale_node, seed); return res.first; @@ -41,6 +42,6 @@ ov::OutputVector random_normal_like(const Node& node) { } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/random_normal_like.hpp b/src/frontends/onnx/frontend/src/op/random_normal_like.hpp index ee9e6239ee3885..2359e962bec1df 100644 --- a/src/frontends/onnx/frontend/src/op/random_normal_like.hpp +++ b/src/frontends/onnx/frontend/src/op/random_normal_like.hpp @@ -4,20 +4,18 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector random_normal_like(const Node& node); +ov::OutputVector random_normal_like(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/random_uniform.cpp b/src/frontends/onnx/frontend/src/op/random_uniform.cpp index 6db3217a38b8a2..54094940845e6c 100644 --- a/src/frontends/onnx/frontend/src/op/random_uniform.cpp +++ b/src/frontends/onnx/frontend/src/op/random_uniform.cpp @@ -9,18 +9,20 @@ #include "utils/common.hpp" using namespace ov::op; +using ::ONNX_NAMESPACE::TensorProto_DataType; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector random_uniform(const Node& node) { +ov::OutputVector random_uniform(const ov::frontend::onnx::Node& node) { CHECK_VALID_NODE(node, node.has_attribute("shape"), "RandomUniform operator must specify a 'shape' attribute."); const auto dtype = - node.get_attribute_value("dtype", static_cast(ONNX_NAMESPACE::TensorProto_DataType_FLOAT)); + node.get_attribute_value("dtype", + static_cast(TensorProto_DataType::TensorProto_DataType_FLOAT)); const auto high_const = node.get_attribute_as_constant("high", 1.0f); const auto low_const = node.get_attribute_as_constant("low", 0.0f); const auto seed = node.get_attribute_value("seed", 0.0f); @@ -41,6 +43,6 @@ ov::OutputVector random_uniform(const Node& node) { } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/random_uniform.hpp b/src/frontends/onnx/frontend/src/op/random_uniform.hpp index c957086abdf7b3..a3ff62f13bb72d 100644 --- a/src/frontends/onnx/frontend/src/op/random_uniform.hpp +++ b/src/frontends/onnx/frontend/src/op/random_uniform.hpp @@ -4,20 +4,18 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector random_uniform(const Node& node); +ov::OutputVector random_uniform(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/random_uniform_like.cpp b/src/frontends/onnx/frontend/src/op/random_uniform_like.cpp index 3c15a177b23548..d626017b2a185b 100644 --- a/src/frontends/onnx/frontend/src/op/random_uniform_like.cpp +++ b/src/frontends/onnx/frontend/src/op/random_uniform_like.cpp @@ -11,14 +11,14 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector random_uniform_like(const Node& node) { - ov::OutputVector inputs{node.get_ng_inputs()}; +ov::OutputVector random_uniform_like(const ov::frontend::onnx::Node& node) { + ov::OutputVector inputs{node.get_ov_inputs()}; const auto input = inputs.at(0); ov::element::Type target_type; @@ -48,6 +48,6 @@ ov::OutputVector random_uniform_like(const Node& node) { } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/random_uniform_like.hpp b/src/frontends/onnx/frontend/src/op/random_uniform_like.hpp index 44586ee70edc83..8f5c52f8775b90 100644 --- a/src/frontends/onnx/frontend/src/op/random_uniform_like.hpp +++ b/src/frontends/onnx/frontend/src/op/random_uniform_like.hpp @@ -4,20 +4,18 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector random_uniform_like(const Node& node); +ov::OutputVector random_uniform_like(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/range.cpp b/src/frontends/onnx/frontend/src/op/range.cpp index c38e946d6f334f..3c61c45672b84b 100644 --- a/src/frontends/onnx/frontend/src/op/range.cpp +++ b/src/frontends/onnx/frontend/src/op/range.cpp @@ -10,13 +10,13 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector range(const Node& node) { - const auto inputs = node.get_ng_inputs(); +ov::OutputVector range(const ov::frontend::onnx::Node& node) { + const auto inputs = node.get_ov_inputs(); CHECK_VALID_NODE(node, inputs.size() >= 3, "Minimum 3 inputs are required. Got: ", inputs.size()); ov::Output start{inputs[0]}; @@ -43,7 +43,6 @@ ov::OutputVector range(const Node& node) { } // namespace set_1 } // namespace op -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/range.hpp b/src/frontends/onnx/frontend/src/op/range.hpp index 9f9dbe74859183..f5117a55f4f1eb 100644 --- a/src/frontends/onnx/frontend/src/op/range.hpp +++ b/src/frontends/onnx/frontend/src/op/range.hpp @@ -4,20 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector range(const Node& node); +ov::OutputVector range(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/reciprocal.cpp b/src/frontends/onnx/frontend/src/op/reciprocal.cpp index 46bd6bfc61dae3..e9d275c72bfa81 100644 --- a/src/frontends/onnx/frontend/src/op/reciprocal.cpp +++ b/src/frontends/onnx/frontend/src/op/reciprocal.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -8,24 +8,22 @@ #include "openvino/op/divide.hpp" using namespace ov::op; +using ov::Shape; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector reciprocal(const Node& node) { - auto data = node.get_ng_inputs().at(0); +ov::OutputVector reciprocal(const ov::frontend::onnx::Node& node) { + auto data = node.get_ov_inputs().at(0); - auto one_node = v0::Constant::create(data.get_element_type(), Shape{}, {1}); + auto one_node = v0::Constant::create(data.get_element_type(), ov::Shape{}, {1}); return {std::make_shared(one_node, data)}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/reciprocal.hpp b/src/frontends/onnx/frontend/src/op/reciprocal.hpp index dd203ac1404b72..9f59c8c0d3fd65 100644 --- a/src/frontends/onnx/frontend/src/op/reciprocal.hpp +++ b/src/frontends/onnx/frontend/src/op/reciprocal.hpp @@ -4,22 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector reciprocal(const Node& node); +ov::OutputVector reciprocal(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/reduce.cpp b/src/frontends/onnx/frontend/src/op/reduce.cpp index 1246445119b78e..3322af52e76447 100644 --- a/src/frontends/onnx/frontend/src/op/reduce.cpp +++ b/src/frontends/onnx/frontend/src/op/reduce.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -24,34 +24,35 @@ #include "utils/common.hpp" using namespace ov::op; +using ov::Shape; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace { std::shared_ptr get_dynamic_all_axes_range(const Node& node) { - const auto input = node.get_ng_inputs().at(0); + const auto input = node.get_ov_inputs().at(0); const auto shape_of_input = std::make_shared(input); - const auto scalar = v0::Constant::create(ov::element::i32, Shape{1}, {0}); + const auto scalar = v0::Constant::create(ov::element::i32, ov::Shape{1}, {0}); const auto rank_of_input = std::make_shared(shape_of_input); const auto rank_of_input_scalar = std::make_shared(rank_of_input, scalar); - const auto start = v0::Constant::create(ov::element::i32, Shape{}, {0}); - const auto step = v0::Constant::create(ov::element::i32, Shape{}, {1}); + const auto start = v0::Constant::create(ov::element::i32, ov::Shape{}, {0}); + const auto step = v0::Constant::create(ov::element::i32, ov::Shape{}, {1}); return std::make_shared(start, rank_of_input_scalar, step, ov::element::i64); } std::shared_ptr get_reduction_axes_from_input(const Node& node) { const std::int64_t noop_with_empty_axes = node.get_attribute_value("noop_with_empty_axes", 0); - const auto input = node.get_ng_inputs().at(0); - if (node.get_ng_inputs().size() > 1) { - const auto reduction_axes = node.get_ng_inputs().at(1); + const auto input = node.get_ov_inputs().at(0); + if (node.get_ov_inputs().size() > 1) { + const auto reduction_axes = node.get_ov_inputs().at(1); const auto reduction_axes_rank = reduction_axes.get_partial_shape().rank(); FRONT_END_GENERAL_CHECK(reduction_axes.get_partial_shape().is_static(), "The axes tensor's shape needs to be known(static). Node: ", node.get_description()); - if (reduction_axes_rank.get_length() != 0 && reduction_axes.get_shape() != Shape{0}) { + if (reduction_axes_rank.get_length() != 0 && reduction_axes.get_shape() != ov::Shape{0}) { return reduction_axes.get_node_shared_ptr(); } } @@ -66,11 +67,11 @@ std::shared_ptr get_reduction_axes_from_input(const Node& node) { std::shared_ptr get_reduction_axes_from_attr(const Node& node) { auto reduction_axes = node.get_attribute_value>("axes", {}); - const auto input_rank = node.get_ng_inputs().at(0).get_partial_shape().rank(); + const auto input_rank = node.get_ov_inputs().at(0).get_partial_shape().rank(); if (reduction_axes.empty()) { if (input_rank.is_static()) { - reduction_axes = onnx_import::common::get_monotonic_range(input_rank.get_length()); + reduction_axes = ov::frontend::onnx::common::get_monotonic_range(input_rank.get_length()); } else { return get_dynamic_all_axes_range(node); } @@ -86,7 +87,7 @@ std::shared_ptr get_reduction_axes_from_attr(const Node& node) { ")"); } - return v0::Constant::create(ov::element::i64, Shape{reduction_axes.size()}, reduction_axes); + return v0::Constant::create(ov::element::i64, ov::Shape{reduction_axes.size()}, reduction_axes); } template @@ -105,62 +106,59 @@ std::shared_ptr make_ng_reduction_op(const Node& node, } // namespace namespace set_13 { -ov::OutputVector reduce_sum(const Node& node) { - return {make_ng_reduction_op(node, node.get_ng_inputs().at(0), false)}; +ov::OutputVector reduce_sum(const ov::frontend::onnx::Node& node) { + return {make_ng_reduction_op(node, node.get_ov_inputs().at(0), false)}; } } // namespace set_13 namespace set_1 { -ov::OutputVector reduce_log_sum(const Node& node) { - const ov::Output sum_node = make_ng_reduction_op(node, node.get_ng_inputs().at(0)); +ov::OutputVector reduce_log_sum(const ov::frontend::onnx::Node& node) { + const ov::Output sum_node = make_ng_reduction_op(node, node.get_ov_inputs().at(0)); return {std::make_shared(sum_node)}; } -ov::OutputVector reduce_log_sum_exp(const Node& node) { - const auto exp_node = std::make_shared(node.get_ng_inputs().at(0)); +ov::OutputVector reduce_log_sum_exp(const ov::frontend::onnx::Node& node) { + const auto exp_node = std::make_shared(node.get_ov_inputs().at(0)); const ov::Output sum_node = make_ng_reduction_op(node, exp_node); return {std::make_shared(sum_node)}; } -ov::OutputVector reduce_l1(const Node& node) { - return {make_ng_reduction_op(node, node.get_ng_inputs().at(0))}; +ov::OutputVector reduce_l1(const ov::frontend::onnx::Node& node) { + return {make_ng_reduction_op(node, node.get_ov_inputs().at(0))}; } -ov::OutputVector reduce_l2(const Node& node) { - return {make_ng_reduction_op(node, node.get_ng_inputs().at(0))}; +ov::OutputVector reduce_l2(const ov::frontend::onnx::Node& node) { + return {make_ng_reduction_op(node, node.get_ov_inputs().at(0))}; } -ov::OutputVector reduce_max(const Node& node) { - return {make_ng_reduction_op(node, node.get_ng_inputs().at(0))}; +ov::OutputVector reduce_max(const ov::frontend::onnx::Node& node) { + return {make_ng_reduction_op(node, node.get_ov_inputs().at(0))}; } -ov::OutputVector reduce_mean(const Node& node) { - return {make_ng_reduction_op(node, node.get_ng_inputs().at(0))}; +ov::OutputVector reduce_mean(const ov::frontend::onnx::Node& node) { + return {make_ng_reduction_op(node, node.get_ov_inputs().at(0))}; } -ov::OutputVector reduce_min(const Node& node) { - return {make_ng_reduction_op(node, node.get_ng_inputs().at(0))}; +ov::OutputVector reduce_min(const ov::frontend::onnx::Node& node) { + return {make_ng_reduction_op(node, node.get_ov_inputs().at(0))}; } -ov::OutputVector reduce_prod(const Node& node) { - return {make_ng_reduction_op(node, node.get_ng_inputs().at(0))}; +ov::OutputVector reduce_prod(const ov::frontend::onnx::Node& node) { + return {make_ng_reduction_op(node, node.get_ov_inputs().at(0))}; } -ov::OutputVector reduce_sum(const Node& node) { - return {make_ng_reduction_op(node, node.get_ng_inputs().at(0))}; +ov::OutputVector reduce_sum(const ov::frontend::onnx::Node& node) { + return {make_ng_reduction_op(node, node.get_ov_inputs().at(0))}; } -ov::OutputVector reduce_sum_square(const Node& node) { - const auto input = ov::Output{node.get_ng_inputs().at(0)}; +ov::OutputVector reduce_sum_square(const ov::frontend::onnx::Node& node) { + const auto input = ov::Output{node.get_ov_inputs().at(0)}; const auto square_node = std::make_shared(input, input); return {make_ng_reduction_op(node, square_node)}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/reduce.hpp b/src/frontends/onnx/frontend/src/op/reduce.hpp index f8f1ab6813b086..5c5f4a4a1ae50c 100644 --- a/src/frontends/onnx/frontend/src/op/reduce.hpp +++ b/src/frontends/onnx/frontend/src/op/reduce.hpp @@ -4,13 +4,11 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_13 { /// \brief Compute the sum of the input tensor's elements along the provided @@ -25,7 +23,7 @@ namespace set_13 { /// /// \return The OV node equivalent of the ONNX operation. /// -ov::OutputVector reduce_sum(const Node& node); +ov::OutputVector reduce_sum(const ov::frontend::onnx::Node& node); } // namespace set_13 namespace set_1 { /// \brief Compute the log sum of the input tensor's elements along the @@ -40,7 +38,7 @@ namespace set_1 { /// /// \return The OV node equivalent of the ONNX operation. /// -ov::OutputVector reduce_log_sum(const Node& node); +ov::OutputVector reduce_log_sum(const ov::frontend::onnx::Node& node); /// \brief Compute the log sum exponent of the input tensor's elements along /// the provided axes. @@ -54,7 +52,7 @@ ov::OutputVector reduce_log_sum(const Node& node); /// /// \return The OV node equivalent of the ONNX operation. /// -ov::OutputVector reduce_log_sum_exp(const Node& node); +ov::OutputVector reduce_log_sum_exp(const ov::frontend::onnx::Node& node); /// \brief Compute the L1 norm of the input tensor's element along the provided /// axes. @@ -68,7 +66,7 @@ ov::OutputVector reduce_log_sum_exp(const Node& node); /// /// \return The OV node equivalent of the ONNX operation. /// -ov::OutputVector reduce_l1(const Node& node); +ov::OutputVector reduce_l1(const ov::frontend::onnx::Node& node); /// \brief Compute the L2 norm of the input tensor's element along the provided /// axes. @@ -82,7 +80,7 @@ ov::OutputVector reduce_l1(const Node& node); /// /// \return The OV node equivalent of the ONNX operation. /// -ov::OutputVector reduce_l2(const Node& node); +ov::OutputVector reduce_l2(const ov::frontend::onnx::Node& node); /// \brief Compute the maximum value of the input tensor's elements along the /// provided axes. @@ -96,7 +94,7 @@ ov::OutputVector reduce_l2(const Node& node); /// /// \return The OV node equivalent of the ONNX operation. /// -ov::OutputVector reduce_max(const Node& node); +ov::OutputVector reduce_max(const ov::frontend::onnx::Node& node); /// \brief Compute the mean value of the input tensor's elements along the /// provided axes. @@ -110,7 +108,7 @@ ov::OutputVector reduce_max(const Node& node); /// /// \return The OV node equivalent of the ONNX operation. /// -ov::OutputVector reduce_mean(const Node& node); +ov::OutputVector reduce_mean(const ov::frontend::onnx::Node& node); /// \brief Compute the minimum value of the input tensor's elements along the /// provided axes. @@ -124,7 +122,7 @@ ov::OutputVector reduce_mean(const Node& node); /// /// \return The OV node equivalent of the ONNX operation. /// -ov::OutputVector reduce_min(const Node& node); +ov::OutputVector reduce_min(const ov::frontend::onnx::Node& node); /// \brief Compute the product of the input tensor's elements along the /// provided axes. @@ -138,7 +136,7 @@ ov::OutputVector reduce_min(const Node& node); /// /// \return The OV node equivalent of the ONNX operation. /// -ov::OutputVector reduce_prod(const Node& node); +ov::OutputVector reduce_prod(const ov::frontend::onnx::Node& node); /// \brief Compute the sum of the input tensor's elements along the provided /// axes. @@ -152,7 +150,7 @@ ov::OutputVector reduce_prod(const Node& node); /// /// \return The OV node equivalent of the ONNX operation. /// -ov::OutputVector reduce_sum(const Node& node); +ov::OutputVector reduce_sum(const ov::frontend::onnx::Node& node); /// \brief Compute the sum square of the input tensor's element along the /// provided axes. @@ -166,13 +164,10 @@ ov::OutputVector reduce_sum(const Node& node); /// /// \return The OV node equivalent of the ONNX operation. /// -ov::OutputVector reduce_sum_square(const Node& node); +ov::OutputVector reduce_sum_square(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/relu.hpp b/src/frontends/onnx/frontend/src/op/relu.hpp index 11e4f6610f6f23..e4afc4f7515fcb 100644 --- a/src/frontends/onnx/frontend/src/op/relu.hpp +++ b/src/frontends/onnx/frontend/src/op/relu.hpp @@ -4,26 +4,21 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/op/relu.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector relu(const Node& node) { - ov::OutputVector ng_inputs{node.get_ng_inputs()}; - return {std::make_shared(ng_inputs.at(0))}; +inline ov::OutputVector relu(const ov::frontend::onnx::Node& node) { + ov::OutputVector ov_inputs{node.get_ov_inputs()}; + return {std::make_shared(ov_inputs.at(0))}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/reshape.cpp b/src/frontends/onnx/frontend/src/op/reshape.cpp index 76ece6d66bfa89..c2abfc0e96630f 100644 --- a/src/frontends/onnx/frontend/src/op/reshape.cpp +++ b/src/frontends/onnx/frontend/src/op/reshape.cpp @@ -10,20 +10,20 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector reshape(const Node& node) { - ov::OutputVector ng_inputs{node.get_ng_inputs()}; - const auto data = ng_inputs.at(0); +ov::OutputVector reshape(const ov::frontend::onnx::Node& node) { + ov::OutputVector ov_inputs{node.get_ov_inputs()}; + const auto data = ov_inputs.at(0); ov::Output pattern; bool special_zero = true; // Since opset 5 the target shape is provided as input - if (ng_inputs.size() == 2) { - pattern = ng_inputs.at(1); + if (ov_inputs.size() == 2) { + pattern = ov_inputs.at(1); } else { // Added in onnx reshape version 14 special_zero = !node.get_attribute_value("allowzero", 0); @@ -35,10 +35,7 @@ ov::OutputVector reshape(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/reshape.hpp b/src/frontends/onnx/frontend/src/op/reshape.hpp index 6d25e89de5b3b8..16315e2872c394 100644 --- a/src/frontends/onnx/frontend/src/op/reshape.hpp +++ b/src/frontends/onnx/frontend/src/op/reshape.hpp @@ -4,13 +4,11 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { /// @@ -20,13 +18,10 @@ namespace set_1 { /// /// \return OV node representing this operation. /// -ov::OutputVector reshape(const Node& node); +ov::OutputVector reshape(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/resize.cpp b/src/frontends/onnx/frontend/src/op/resize.cpp index 452872e45890a1..82f5f0f78c509c 100644 --- a/src/frontends/onnx/frontend/src/op/resize.cpp +++ b/src/frontends/onnx/frontend/src/op/resize.cpp @@ -4,16 +4,16 @@ #include "op/resize.hpp" +#include "core/null_node.hpp" #include "exceptions.hpp" -#include "onnx_import/core/null_node.hpp" #include "openvino/op/interpolate.hpp" #include "utils/common.hpp" using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace { static const std::unordered_set supported_modes = {"nearest", "linear", "cubic"}; @@ -59,7 +59,7 @@ static int mode_as_int(const std::map& converting_map, const s using InterpolateAttrs = v11::Interpolate::InterpolateAttrs; -InterpolateAttrs get_resize_attrs(const onnx_import::Node& node) { +InterpolateAttrs get_resize_attrs(const ov::frontend::onnx::Node& node) { auto get_str_attr = [&node](const std::string& name, const std::string& default_value) { return node.get_attribute_value(name, default_value); }; @@ -112,10 +112,10 @@ InterpolateAttrs get_resize_attrs(const onnx_import::Node& node) { } // namespace namespace set_11 { -ov::OutputVector resize(const onnx_import::Node& node) { +ov::OutputVector resize(const ov::frontend::onnx::Node& node) { // roi input (inputs.at(2)) is ignored because it is used only // in "tf_crop_and_resize" which is not handled now - const auto inputs = node.get_ng_inputs(); + const auto inputs = node.get_ov_inputs(); const auto& data = inputs.at(0); auto attrs = get_resize_attrs(node); @@ -133,8 +133,8 @@ ov::OutputVector resize(const onnx_import::Node& node) { } // namespace set_11 namespace set_1 { -ov::OutputVector resize(const onnx_import::Node& node) { - const auto inputs = node.get_ng_inputs(); +ov::OutputVector resize(const ov::frontend::onnx::Node& node) { + const auto inputs = node.get_ov_inputs(); const auto& data = inputs.at(0); const auto& scales = inputs.at(1); @@ -152,6 +152,6 @@ ov::OutputVector resize(const onnx_import::Node& node) { } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/resize.hpp b/src/frontends/onnx/frontend/src/op/resize.hpp index 001cdb67c9a4e5..625afedbf5d5c4 100644 --- a/src/frontends/onnx/frontend/src/op/resize.hpp +++ b/src/frontends/onnx/frontend/src/op/resize.hpp @@ -4,26 +4,22 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector resize(const Node& node); +ov::OutputVector resize(const ov::frontend::onnx::Node& node); } // namespace set_1 namespace set_11 { -ov::OutputVector resize(const Node& node); +ov::OutputVector resize(const ov::frontend::onnx::Node& node); } } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/reverse_sequence.cpp b/src/frontends/onnx/frontend/src/op/reverse_sequence.cpp index fd2706a43ede71..127bab0bc4f148 100644 --- a/src/frontends/onnx/frontend/src/op/reverse_sequence.cpp +++ b/src/frontends/onnx/frontend/src/op/reverse_sequence.cpp @@ -4,7 +4,7 @@ #include "op/reverse_sequence.hpp" -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/core/type/element_type.hpp" #include "openvino/frontend/exception.hpp" #include "openvino/op/convert.hpp" @@ -13,17 +13,17 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector reverse_sequence(const Node& node) { - const auto data = node.get_ng_inputs().at(0); +ov::OutputVector reverse_sequence(const ov::frontend::onnx::Node& node) { + const auto data = node.get_ov_inputs().at(0); - const auto sequence_lengths = node.get_ng_inputs().at(1); + const auto sequence_lengths = node.get_ov_inputs().at(1); // OpenVINO supports only int32 type of sequence_lengths - const auto sequence_lengths_i32 = std::make_shared(node.get_ng_inputs().at(1), ov::element::i32); + const auto sequence_lengths_i32 = std::make_shared(node.get_ov_inputs().at(1), ov::element::i32); const auto data_rank = data.get_partial_shape().rank(); const auto batch_axis = node.get_attribute_value("batch_axis", 1); @@ -48,10 +48,7 @@ ov::OutputVector reverse_sequence(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/reverse_sequence.hpp b/src/frontends/onnx/frontend/src/op/reverse_sequence.hpp index 82d827efa9be78..be9891adee8b83 100644 --- a/src/frontends/onnx/frontend/src/op/reverse_sequence.hpp +++ b/src/frontends/onnx/frontend/src/op/reverse_sequence.hpp @@ -4,22 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector reverse_sequence(const Node& node); +ov::OutputVector reverse_sequence(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/rnn.cpp b/src/frontends/onnx/frontend/src/op/rnn.cpp index 129ea3588177bd..2d9c6aa9287601 100644 --- a/src/frontends/onnx/frontend/src/op/rnn.cpp +++ b/src/frontends/onnx/frontend/src/op/rnn.cpp @@ -5,19 +5,19 @@ #include "op/rnn.hpp" #include "openvino/op/rnn_sequence.hpp" -#include "ov_models/ov_builders/reshape.hpp" #include "utils/recurrent.hpp" +#include "utils/reshape.hpp" using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { namespace { struct RNNInputMap : public recurrent::OpInputMap { - RNNInputMap(const onnx_import::Node& node, std::size_t gates_count) : OpInputMap(node, gates_count) {} + RNNInputMap(const ov::frontend::onnx::Node& node, std::size_t gates_count) : OpInputMap(node, gates_count) {} virtual ~RNNInputMap() = default; }; @@ -29,7 +29,7 @@ struct RNNAttributes : public recurrent::OpAttributes { }; } // namespace -ov::OutputVector rnn(const Node& node) { +ov::OutputVector rnn(const ov::frontend::onnx::Node& node) { constexpr std::size_t gates_count = 1; RNNInputMap input_map{node, gates_count}; RNNAttributes attributes{node}; @@ -54,6 +54,6 @@ ov::OutputVector rnn(const Node& node) { } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/rnn.hpp b/src/frontends/onnx/frontend/src/op/rnn.hpp index aa2ee4326992de..926b08d382d332 100644 --- a/src/frontends/onnx/frontend/src/op/rnn.hpp +++ b/src/frontends/onnx/frontend/src/op/rnn.hpp @@ -4,22 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector rnn(const Node& node); +ov::OutputVector rnn(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/roi_align.cpp b/src/frontends/onnx/frontend/src/op/roi_align.cpp index 38524125f3045c..3c811defbe0757 100644 --- a/src/frontends/onnx/frontend/src/op/roi_align.cpp +++ b/src/frontends/onnx/frontend/src/op/roi_align.cpp @@ -9,15 +9,13 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { - namespace set_1 { - -ov::OutputVector roi_align(const Node& node) { - const auto inputs = node.get_ng_inputs(); +ov::OutputVector roi_align(const ov::frontend::onnx::Node& node) { + const auto inputs = node.get_ov_inputs(); FRONT_END_GENERAL_CHECK(inputs.size() == 3, "The RoiAlign operator expects 3 inputs. Got: ", inputs.size()); @@ -45,8 +43,8 @@ ov::OutputVector roi_align(const Node& node) { } } // namespace set_1 namespace set_16 { -ov::OutputVector roi_align(const Node& node) { - const auto inputs = node.get_ng_inputs(); +ov::OutputVector roi_align(const ov::frontend::onnx::Node& node) { + const auto inputs = node.get_ov_inputs(); FRONT_END_GENERAL_CHECK(inputs.size() == 3, "The RoiAlign operator expects 3 inputs. Got: ", inputs.size()); @@ -80,10 +78,7 @@ ov::OutputVector roi_align(const Node& node) { aligned_mode)}; } } // namespace set_16 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/roi_align.hpp b/src/frontends/onnx/frontend/src/op/roi_align.hpp index a505f8e40b0791..5b4c0305ef2093 100644 --- a/src/frontends/onnx/frontend/src/op/roi_align.hpp +++ b/src/frontends/onnx/frontend/src/op/roi_align.hpp @@ -4,27 +4,22 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector roi_align(const Node& node); +ov::OutputVector roi_align(const ov::frontend::onnx::Node& node); } // namespace set_1 namespace set_16 { -ov::OutputVector roi_align(const Node& node); +ov::OutputVector roi_align(const ov::frontend::onnx::Node& node); } // namespace set_16 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/round.cpp b/src/frontends/onnx/frontend/src/op/round.cpp index 8007b76398afa8..035443b22eb576 100644 --- a/src/frontends/onnx/frontend/src/op/round.cpp +++ b/src/frontends/onnx/frontend/src/op/round.cpp @@ -11,19 +11,16 @@ using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector round(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0), v5::Round::RoundMode::HALF_TO_EVEN)}; +ov::OutputVector round(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0), v5::Round::RoundMode::HALF_TO_EVEN)}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/round.hpp b/src/frontends/onnx/frontend/src/op/round.hpp index 1af4d688a5b2f9..8cabccbe4fd616 100644 --- a/src/frontends/onnx/frontend/src/op/round.hpp +++ b/src/frontends/onnx/frontend/src/op/round.hpp @@ -7,22 +7,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector round(const Node& node); +ov::OutputVector round(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/scan.cpp b/src/frontends/onnx/frontend/src/op/scan.cpp index 3af554a986e6ed..d91c90b047a2ba 100644 --- a/src/frontends/onnx/frontend/src/op/scan.cpp +++ b/src/frontends/onnx/frontend/src/op/scan.cpp @@ -1,22 +1,24 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include "op/scan.hpp" -#include -#include - #include "core/graph.hpp" -#include "default_opset.hpp" +#include "core/null_node.hpp" #include "exceptions.hpp" -#include "ngraph/op/util/op_types.hpp" -#include "onnx_import/core/null_node.hpp" -#include "openvino/core/validation_util.hpp" - -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +#include "openvino/op/constant.hpp" +#include "openvino/op/squeeze.hpp" +#include "openvino/op/tensor_iterator.hpp" +#include "openvino/op/unsqueeze.hpp" +#include "openvino/op/util/op_types.hpp" +#include "validation_util.hpp" + +using namespace ov::op; + +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace { @@ -47,21 +49,19 @@ ov::OutputVector scan_to_tensor_iterator(const ov::OutputVector& node_inputs, for (int64_t i = 0; i < num_scan_inputs; ++i) { const auto in_idx = num_initial_values + i; auto axis = scan_input_axes[i]; - const auto axis_node = default_opset::Constant::create(ov::element::i64, Shape{1}, {axis}); + const auto axis_node = v0::Constant::create(ov::element::i64, ov::Shape{1}, {axis}); auto shape = node_inputs[in_idx + in_offset].get_partial_shape(); if (shape.rank().is_static()) { - OPENVINO_SUPPRESS_DEPRECATED_START - axis = ov::normalize_axis(node_description, - scan_input_axes[i], - node_inputs[in_idx + in_offset].get_partial_shape().rank()); - OPENVINO_SUPPRESS_DEPRECATED_END + axis = ov::util::normalize_axis(node_description, + scan_input_axes[i], + node_inputs[in_idx + in_offset].get_partial_shape().rank()); shape[axis] = 1; } body_inputs[in_idx]->set_partial_shape(shape); body_inputs[in_idx]->validate_and_infer_types(); auto input_consumers = body_inputs[in_idx]->output(0).get_target_inputs(); - auto squeeze = std::make_shared(body_inputs[in_idx], axis_node); + auto squeeze = std::make_shared(body_inputs[in_idx], axis_node); for (auto& input : input_consumers) { input.replace_source_output(squeeze); } @@ -70,23 +70,21 @@ ov::OutputVector scan_to_tensor_iterator(const ov::OutputVector& node_inputs, for (size_t i = 0; i < num_scan_outputs; ++i) { const auto out_idx = num_initial_values + i; const auto axis = scan_output_axes[i]; - const auto axis_node = default_opset::Constant::create(ov::element::i64, Shape{1}, {axis}); - body_outputs[out_idx] = std::make_shared(body_outputs[out_idx], axis_node); + const auto axis_node = v0::Constant::create(ov::element::i64, ov::Shape{1}, {axis}); + body_outputs[out_idx] = std::make_shared(body_outputs[out_idx], axis_node); } // TensorIterator setup - auto tensor_iterator = std::make_shared(); + auto tensor_iterator = std::make_shared(); auto ti_body = std::make_shared(body_outputs, body_inputs); tensor_iterator->set_function(ti_body); // Set slicing for Scan (TensorIterator) inputs for (int64_t i = 0; i < num_scan_inputs; ++i) { const auto in_idx = num_initial_values + i; - OPENVINO_SUPPRESS_DEPRECATED_START - const auto axis = ov::normalize_axis(node_description, - scan_input_axes[i], - node_inputs[in_idx + in_offset].get_partial_shape().rank()); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto axis = ov::util::normalize_axis(node_description, + scan_input_axes[i], + node_inputs[in_idx + in_offset].get_partial_shape().rank()); if (scan_input_directions[i]) { // reverse direction tensor_iterator->set_sliced_input(body_inputs[in_idx], node_inputs[in_idx + in_offset], -1, -1, 1, 0, axis); } else { // forward direction @@ -103,10 +101,9 @@ ov::OutputVector scan_to_tensor_iterator(const ov::OutputVector& node_inputs, } for (size_t i = 0; i < num_scan_outputs; ++i) { const auto out_idx = num_initial_values + i; - OPENVINO_SUPPRESS_DEPRECATED_START - const auto axis = - ov::normalize_axis(node_description, scan_output_axes[i], body_outputs[out_idx].get_partial_shape().rank()); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto axis = ov::util::normalize_axis(node_description, + scan_output_axes[i], + body_outputs[out_idx].get_partial_shape().rank()); if (scan_output_directions[i]) { // reverse direction outputs.push_back(tensor_iterator->get_concatenated_slices(body_outputs[out_idx], -1, -1, 1, 0, axis)); } else { // forward direction @@ -117,11 +114,11 @@ ov::OutputVector scan_to_tensor_iterator(const ov::OutputVector& node_inputs, return outputs; } -ov::OutputVector import_onnx_scan(const Node& node, +ov::OutputVector import_onnx_scan(const ov::frontend::onnx::Node& node, int64_t default_axis, int64_t in_offset, std::string&& in_directions_attr_name) { - const auto& node_inputs = node.get_ng_inputs(); + const auto& node_inputs = node.get_ov_inputs(); const auto& subgraphs = node.get_subgraphs(); auto body_graph = subgraphs.at("body"); @@ -161,10 +158,10 @@ ov::OutputVector import_onnx_scan(const Node& node, namespace set_1 { -ov::OutputVector scan(const Node& node) { +ov::OutputVector scan(const ov::frontend::onnx::Node& node) { // ONNX Scan-8 can have optional `sequence_lens` input, // and sequence scan_input axis is assumed to be always 1. - OPENVINO_ASSERT(ov::op::util::is_null(node.get_ng_inputs().at(0)), + OPENVINO_ASSERT(ov::op::util::is_null(node.get_ov_inputs().at(0)), node.get_description(), " ONNX Scan-8 `sequence_lens` input is not supported. "); return import_onnx_scan(node, 1, 1, "directions"); @@ -174,7 +171,7 @@ ov::OutputVector scan(const Node& node) { namespace set_9 { -ov::OutputVector scan(const Node& node) { +ov::OutputVector scan(const ov::frontend::onnx::Node& node) { // Since ONNX Scan-9 the optional `sequence_lens input` was removed, // new attributes to specify input/output axes and directions were added. return import_onnx_scan(node, 0, 0, "scan_input_directions"); @@ -182,6 +179,6 @@ ov::OutputVector scan(const Node& node) { } // namespace set_9 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/scan.hpp b/src/frontends/onnx/frontend/src/op/scan.hpp index 1ccbd35b22464b..41cb62fa51dcc6 100644 --- a/src/frontends/onnx/frontend/src/op/scan.hpp +++ b/src/frontends/onnx/frontend/src/op/scan.hpp @@ -4,13 +4,11 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { /// \brief Creates OpenVino node representing ONNX Scan operator. @@ -22,16 +20,13 @@ namespace set_1 { /// /// \return ov::OutputVector of resulting OpenVino nodes. /// -ov::OutputVector scan(const Node& node); +ov::OutputVector scan(const ov::frontend::onnx::Node& node); } // namespace set_1 namespace set_9 { -ov::OutputVector scan(const Node& node); +ov::OutputVector scan(const ov::frontend::onnx::Node& node); } // namespace set_9 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/scatter_elements.cpp b/src/frontends/onnx/frontend/src/op/scatter_elements.cpp index 971b38910214e0..b7704868049235 100644 --- a/src/frontends/onnx/frontend/src/op/scatter_elements.cpp +++ b/src/frontends/onnx/frontend/src/op/scatter_elements.cpp @@ -4,37 +4,35 @@ #include "op/scatter_elements.hpp" -#include - -#include "default_opset.hpp" #include "exceptions.hpp" -#include "openvino/opsets/opset12.hpp" +#include "openvino/op/scatter_elements_update.hpp" + +using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector scatter_elements(const Node& node) { - using namespace ov::opset12; - const auto data = node.get_ng_inputs().at(0); - const auto indices = node.get_ng_inputs().at(1); - const auto updates = node.get_ng_inputs().at(2); +ov::OutputVector scatter_elements(const ov::frontend::onnx::Node& node) { + const auto data = node.get_ov_inputs().at(0); + const auto indices = node.get_ov_inputs().at(1); + const auto updates = node.get_ov_inputs().at(2); const auto axis_node = node.get_attribute_as_constant("axis", 0); - ScatterElementsUpdate::Reduction reduction_ov; + v12::ScatterElementsUpdate::Reduction reduction_ov; if (node.has_attribute("reduction")) { std::string reduction_onnx = node.get_attribute_value("reduction", "none"); if (reduction_onnx == "none") { - reduction_ov = ScatterElementsUpdate::Reduction::NONE; + reduction_ov = v12::ScatterElementsUpdate::Reduction::NONE; } else if (reduction_onnx == "add") { - reduction_ov = ScatterElementsUpdate::Reduction::SUM; + reduction_ov = v12::ScatterElementsUpdate::Reduction::SUM; } else if (reduction_onnx == "mul") { - reduction_ov = ScatterElementsUpdate::Reduction::PROD; + reduction_ov = v12::ScatterElementsUpdate::Reduction::PROD; } else if (reduction_onnx == "min") { - reduction_ov = ScatterElementsUpdate::Reduction::MIN; + reduction_ov = v12::ScatterElementsUpdate::Reduction::MIN; } else if (reduction_onnx == "max") { - reduction_ov = ScatterElementsUpdate::Reduction::MAX; + reduction_ov = v12::ScatterElementsUpdate::Reduction::MAX; } else { CHECK_VALID_NODE(node, false, @@ -43,16 +41,13 @@ ov::OutputVector scatter_elements(const Node& node) { reduction_onnx); } } else { - reduction_ov = ScatterElementsUpdate::Reduction::NONE; + reduction_ov = v12::ScatterElementsUpdate::Reduction::NONE; } - return {std::make_shared(data, indices, updates, axis_node, reduction_ov)}; + return {std::make_shared(data, indices, updates, axis_node, reduction_ov)}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/scatter_elements.hpp b/src/frontends/onnx/frontend/src/op/scatter_elements.hpp index f0f97e2ac7bc89..4b7e0e608a9a7d 100644 --- a/src/frontends/onnx/frontend/src/op/scatter_elements.hpp +++ b/src/frontends/onnx/frontend/src/op/scatter_elements.hpp @@ -4,22 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector scatter_elements(const Node& node); +ov::OutputVector scatter_elements(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/scatter_nd.cpp b/src/frontends/onnx/frontend/src/op/scatter_nd.cpp index 444d37b36ce256..2718ea391d7ed6 100644 --- a/src/frontends/onnx/frontend/src/op/scatter_nd.cpp +++ b/src/frontends/onnx/frontend/src/op/scatter_nd.cpp @@ -7,21 +7,21 @@ #include "op/scatter_nd.hpp" -#include - -#include "default_opset.hpp" #include "exceptions.hpp" +#include "openvino/op/scatter_nd_update.hpp" + +using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector scatter_nd(const Node& node) { - ov::OutputVector ng_inputs{node.get_ng_inputs()}; - auto data = ng_inputs.at(0); - auto indices = ng_inputs.at(1); - auto updates = ng_inputs.at(2); +ov::OutputVector scatter_nd(const ov::frontend::onnx::Node& node) { + ov::OutputVector ov_inputs{node.get_ov_inputs()}; + auto data = ov_inputs.at(0); + auto indices = ov_inputs.at(1); + auto updates = ov_inputs.at(2); if (node.has_attribute("reduction")) { const auto reduction = node.get_attribute_value("reduction", "none"); CHECK_VALID_NODE(node, @@ -30,14 +30,11 @@ ov::OutputVector scatter_nd(const Node& node) { reduction); } - return {std::make_shared(data, indices, updates)}; + return {std::make_shared(data, indices, updates)}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/scatter_nd.hpp b/src/frontends/onnx/frontend/src/op/scatter_nd.hpp index 771153b46db9f3..4ba3e2a8c7df00 100644 --- a/src/frontends/onnx/frontend/src/op/scatter_nd.hpp +++ b/src/frontends/onnx/frontend/src/op/scatter_nd.hpp @@ -7,22 +7,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector scatter_nd(const Node& node); +ov::OutputVector scatter_nd(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/selu.cpp b/src/frontends/onnx/frontend/src/op/selu.cpp index 316c30d26ff905..3345c7e8c9bcd6 100644 --- a/src/frontends/onnx/frontend/src/op/selu.cpp +++ b/src/frontends/onnx/frontend/src/op/selu.cpp @@ -1,36 +1,33 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include "op/selu.hpp" -#include -#include +#include "openvino/op/constant.hpp" +#include "openvino/op/selu.hpp" -#include "default_opset.hpp" +using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector selu(const Node& node) { - auto data = node.get_ng_inputs().at(0); +ov::OutputVector selu(const ov::frontend::onnx::Node& node) { + auto data = node.get_ov_inputs().at(0); auto alpha = node.get_attribute_value("alpha", 1.67326319217681884765625); auto gamma = node.get_attribute_value("gamma", 1.05070102214813232421875); - auto alpha_node = default_opset::Constant::create(data.get_element_type(), Shape{}, {alpha}); + auto alpha_node = v0::Constant::create(data.get_element_type(), ov::Shape{}, {alpha}); - auto gamma_node = default_opset::Constant::create(data.get_element_type(), Shape{}, {gamma}); + auto gamma_node = v0::Constant::create(data.get_element_type(), ov::Shape{}, {gamma}); - return {std::make_shared(data, alpha_node, gamma_node)}; + return {std::make_shared(data, alpha_node, gamma_node)}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/selu.hpp b/src/frontends/onnx/frontend/src/op/selu.hpp index fa360f1d0f6c01..82ed712ce69bac 100644 --- a/src/frontends/onnx/frontend/src/op/selu.hpp +++ b/src/frontends/onnx/frontend/src/op/selu.hpp @@ -4,22 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector selu(const Node& node); +ov::OutputVector selu(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/shape.cpp b/src/frontends/onnx/frontend/src/op/shape.cpp index 58f3e0caa49ac0..e9d87145697b99 100644 --- a/src/frontends/onnx/frontend/src/op/shape.cpp +++ b/src/frontends/onnx/frontend/src/op/shape.cpp @@ -2,27 +2,25 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "ngraph/shape.hpp" +#include "op/shape.hpp" -#include +#include "openvino/op/shape_of.hpp" -#include "default_opset.hpp" -#include "op/shape.hpp" -#include "openvino/core/type/element_type.hpp" +using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector shape(const Node& node) { - const auto data = node.get_ng_inputs().at(0); - return {std::make_shared(data)}; +ov::OutputVector shape(const ov::frontend::onnx::Node& node) { + const auto data = node.get_ov_inputs().at(0); + return {std::make_shared(data)}; } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/shape.hpp b/src/frontends/onnx/frontend/src/op/shape.hpp index a2dc019dd05f02..51ba245c1efb39 100644 --- a/src/frontends/onnx/frontend/src/op/shape.hpp +++ b/src/frontends/onnx/frontend/src/op/shape.hpp @@ -4,20 +4,18 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector shape(const Node& node); +ov::OutputVector shape(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/shrink.cpp b/src/frontends/onnx/frontend/src/op/shrink.cpp index 0a3ff14412a069..61bbd031f41562 100644 --- a/src/frontends/onnx/frontend/src/op/shrink.cpp +++ b/src/frontends/onnx/frontend/src/op/shrink.cpp @@ -1,68 +1,71 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include "op/shrink.hpp" -#include - -#include "default_opset.hpp" #include "exceptions.hpp" - -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +#include "openvino/op/add.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/convert.hpp" +#include "openvino/op/greater.hpp" +#include "openvino/op/less.hpp" +#include "openvino/op/multiply.hpp" +#include "openvino/op/subtract.hpp" + +using namespace ov::op; + +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector shrink(const Node& node) { - const auto input = node.get_ng_inputs().at(0); +ov::OutputVector shrink(const ov::frontend::onnx::Node& node) { + const auto input = node.get_ov_inputs().at(0); const float bias = node.get_attribute_value("bias", 0.0f); const float lambd = node.get_attribute_value("lambd", 0.5f); CHECK_VALID_NODE(node, !(lambd < 0.0f), " The provided 'lambd' value: ", lambd, " must not be negative."); - std::shared_ptr negative_lambd; + std::shared_ptr negative_lambd; const auto input_element_type = input.get_element_type(); if (input_element_type.is_signed()) { - negative_lambd = default_opset::Constant::create(input_element_type, Shape{}, {-lambd}); + negative_lambd = v0::Constant::create(input_element_type, ov::Shape{}, {-lambd}); } else { // Passing -lambd to unsigned type constant will cause an overflow. // For unsigned types the lowest possible value is 0. - negative_lambd = default_opset::Constant::create(input_element_type, Shape{}, {0}); + negative_lambd = v0::Constant::create(input_element_type, ov::Shape{}, {0}); } - const auto positive_lambd = default_opset::Constant::create(input_element_type, Shape{}, {lambd}); + const auto positive_lambd = v0::Constant::create(input_element_type, ov::Shape{}, {lambd}); - const auto bias_tensor = default_opset::Constant::create(input_element_type, Shape{}, {bias}); + const auto bias_tensor = v0::Constant::create(input_element_type, ov::Shape{}, {bias}); // Create a mask indicating locations of values that need to be adjusted // by adding and subtracting bias // All other values indicated by 'false' in the masks need to be zeroed out - std::shared_ptr values_below_neg_lambd = std::make_shared(input, negative_lambd); - std::shared_ptr values_above_pos_lambd = std::make_shared(input, positive_lambd); + std::shared_ptr values_below_neg_lambd = std::make_shared(input, negative_lambd); + std::shared_ptr values_above_pos_lambd = std::make_shared(input, positive_lambd); // Convert from bool to the input type to be able to multiply adjusted inputs // by the created masks - values_below_neg_lambd = std::make_shared(values_below_neg_lambd, input_element_type); - values_above_pos_lambd = std::make_shared(values_above_pos_lambd, input_element_type); + values_below_neg_lambd = std::make_shared(values_below_neg_lambd, input_element_type); + values_above_pos_lambd = std::make_shared(values_above_pos_lambd, input_element_type); - std::shared_ptr input_minus_bias = std::make_shared(input, bias_tensor); - std::shared_ptr input_plus_bias = std::make_shared(input, bias_tensor); + std::shared_ptr input_minus_bias = std::make_shared(input, bias_tensor); + std::shared_ptr input_plus_bias = std::make_shared(input, bias_tensor); // multiply by the corresponding mask to zero-out the values within // the <-lambd;lambd> range and keep the bias-adjusted values from outside of it - input_minus_bias = std::make_shared(values_above_pos_lambd, input_minus_bias); + input_minus_bias = std::make_shared(values_above_pos_lambd, input_minus_bias); - input_plus_bias = std::make_shared(values_below_neg_lambd, input_plus_bias); + input_plus_bias = std::make_shared(values_below_neg_lambd, input_plus_bias); - return {std::make_shared(input_plus_bias, input_minus_bias)}; + return {std::make_shared(input_plus_bias, input_minus_bias)}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/shrink.hpp b/src/frontends/onnx/frontend/src/op/shrink.hpp index 1705505d6b1e4b..8e04c0f4fbab15 100644 --- a/src/frontends/onnx/frontend/src/op/shrink.hpp +++ b/src/frontends/onnx/frontend/src/op/shrink.hpp @@ -4,13 +4,11 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { /// \brief ONNX Shrink operator @@ -19,12 +17,9 @@ namespace set_1 { /// Input values greater or equal to '-lambd' and less or equal to 'lambd' are /// zeroed-out. 'Bias' is added to the values that are less than '-lambd' /// and subtracted from values greater than 'lambd'. -ov::OutputVector shrink(const Node& node); +ov::OutputVector shrink(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/sigmoid.hpp b/src/frontends/onnx/frontend/src/op/sigmoid.hpp index 63a0ee202939b0..4cc334c6034e66 100644 --- a/src/frontends/onnx/frontend/src/op/sigmoid.hpp +++ b/src/frontends/onnx/frontend/src/op/sigmoid.hpp @@ -4,27 +4,20 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" +#include "openvino/op/sigmoid.hpp" -#include - -#include "default_opset.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector sigmoid(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0))}; +inline ov::OutputVector sigmoid(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0))}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/sign.hpp b/src/frontends/onnx/frontend/src/op/sign.hpp index 4c25db7fe8834f..4a8ae114b7a30e 100644 --- a/src/frontends/onnx/frontend/src/op/sign.hpp +++ b/src/frontends/onnx/frontend/src/op/sign.hpp @@ -4,26 +4,19 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" +#include "openvino/op/sign.hpp" -#include - -#include "default_opset.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector sign(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0))}; +inline ov::OutputVector sign(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0))}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/sin.hpp b/src/frontends/onnx/frontend/src/op/sin.hpp index 9b92ec68f2a2c7..741f8a5295018d 100644 --- a/src/frontends/onnx/frontend/src/op/sin.hpp +++ b/src/frontends/onnx/frontend/src/op/sin.hpp @@ -4,26 +4,19 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" +#include "openvino/op/sin.hpp" -#include - -#include "default_opset.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector sin(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0))}; +inline ov::OutputVector sin(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0))}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/sinh.hpp b/src/frontends/onnx/frontend/src/op/sinh.hpp index 90895abd09abf1..58c17e38a3021b 100644 --- a/src/frontends/onnx/frontend/src/op/sinh.hpp +++ b/src/frontends/onnx/frontend/src/op/sinh.hpp @@ -4,26 +4,19 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" +#include "openvino/op/sinh.hpp" -#include - -#include "default_opset.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector sinh(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0))}; +inline ov::OutputVector sinh(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0))}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/size.cpp b/src/frontends/onnx/frontend/src/op/size.cpp index 02de44c6e340bd..759e7041baa40c 100644 --- a/src/frontends/onnx/frontend/src/op/size.cpp +++ b/src/frontends/onnx/frontend/src/op/size.cpp @@ -1,34 +1,30 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include "op/size.hpp" -#include -#include -#include +#include "openvino/core/shape.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/reduce_prod.hpp" +#include "openvino/op/shape_of.hpp" -#include "default_opset.hpp" -#include "ngraph/shape.hpp" -#include "openvino/core/type/element_type.hpp" +using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector size(const Node& node) { - auto data = node.get_ng_inputs().at(0); - auto axes = default_opset::Constant::create(ov::element::i32, Shape{}, {0}); - auto input_shape = std::make_shared(data); - return {std::make_shared(input_shape, axes)}; +ov::OutputVector size(const ov::frontend::onnx::Node& node) { + auto data = node.get_ov_inputs().at(0); + auto axes = v0::Constant::create(ov::element::i32, ov::Shape{}, {0}); + auto input_shape = std::make_shared(data); + return {std::make_shared(input_shape, axes)}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/size.hpp b/src/frontends/onnx/frontend/src/op/size.hpp index 6bce2d6f816e27..8511b705f298fc 100644 --- a/src/frontends/onnx/frontend/src/op/size.hpp +++ b/src/frontends/onnx/frontend/src/op/size.hpp @@ -4,22 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector size(const Node& node); +ov::OutputVector size(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/slice.cpp b/src/frontends/onnx/frontend/src/op/slice.cpp index ecfce8472220a4..aba0f14b41cbbb 100644 --- a/src/frontends/onnx/frontend/src/op/slice.cpp +++ b/src/frontends/onnx/frontend/src/op/slice.cpp @@ -1,25 +1,27 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include "op/slice.hpp" -#include -#include +#include "core/null_node.hpp" +#include "openvino/op/broadcast.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/shape_of.hpp" +#include "openvino/op/slice.hpp" -#include "default_opset.hpp" -#include "onnx_import/core/null_node.hpp" -#include "openvino/opsets/opset8.hpp" +using namespace ov::op; +using ov::Shape; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_10 { -ov::OutputVector slice(const Node& node) { +ov::OutputVector slice(const ov::frontend::onnx::Node& node) { using ov::op::util::is_null; - ov::OutputVector inputs{node.get_ng_inputs()}; + ov::OutputVector inputs{node.get_ov_inputs()}; const auto& data = inputs.at(0); const auto& starts = inputs.at(1); const auto& ends = inputs.at(2); @@ -31,45 +33,41 @@ ov::OutputVector slice(const Node& node) { if (steps_input_provided) { steps = inputs.at(4); } else { - const auto& default_step = default_opset::Constant::create(starts.get_element_type(), {1}, {1}); - steps = std::make_shared( - default_step, - std::make_shared(starts, ov::element::i64)); + const auto& default_step = v0::Constant::create(starts.get_element_type(), {1}, {1}); + steps = std::make_shared(default_step, std::make_shared(starts, ov::element::i64)); } if (axes_input_provided) { const auto axes = inputs.at(3); - return {std::make_shared(data, starts, ends, steps, axes)}; + return {std::make_shared(data, starts, ends, steps, axes)}; } else { - return {std::make_shared(data, starts, ends, steps)}; + return {std::make_shared(data, starts, ends, steps)}; } } } // namespace set_10 namespace set_1 { -ov::OutputVector slice(const Node& node) { - ov::Output data = node.get_ng_inputs().at(0); +ov::OutputVector slice(const ov::frontend::onnx::Node& node) { + ov::Output data = node.get_ov_inputs().at(0); const auto starts_atr = node.get_attribute_value>("starts"); const auto ends = node.get_attribute_as_constant>("ends"); - const auto starts = - std::make_shared(ov::element::i64, Shape{starts_atr.size()}, starts_atr); + const auto starts = std::make_shared(ov::element::i64, ov::Shape{starts_atr.size()}, starts_atr); auto axes_atr = node.get_attribute_value>("axes", std::vector()); - const auto steps = default_opset::Constant::create(ov::element::i64, - Shape{starts_atr.size()}, - std::vector(starts_atr.size(), 1)); + const auto steps = v0::Constant::create(ov::element::i64, + ov::Shape{starts_atr.size()}, + std::vector(starts_atr.size(), 1)); if (axes_atr.empty()) { - return {std::make_shared(data, starts, ends, steps)}; + return {std::make_shared(data, starts, ends, steps)}; } else { - const auto& axes = - std::make_shared(ov::element::i64, Shape{axes_atr.size()}, axes_atr); - return {std::make_shared(data, starts, ends, steps, axes)}; + const auto& axes = std::make_shared(ov::element::i64, ov::Shape{axes_atr.size()}, axes_atr); + return {std::make_shared(data, starts, ends, steps, axes)}; } } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/slice.hpp b/src/frontends/onnx/frontend/src/op/slice.hpp index 6dc4d7d388debb..7f9e7aae4f097b 100644 --- a/src/frontends/onnx/frontend/src/op/slice.hpp +++ b/src/frontends/onnx/frontend/src/op/slice.hpp @@ -4,27 +4,22 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_10 { -ov::OutputVector slice(const Node& node); +ov::OutputVector slice(const ov::frontend::onnx::Node& node); } // namespace set_10 namespace set_1 { -ov::OutputVector slice(const Node& node); +ov::OutputVector slice(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/softmax.cpp b/src/frontends/onnx/frontend/src/op/softmax.cpp index 0bd1ef0c0c962f..eb13ca9af0e72e 100644 --- a/src/frontends/onnx/frontend/src/op/softmax.cpp +++ b/src/frontends/onnx/frontend/src/op/softmax.cpp @@ -1,32 +1,35 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include "op/softmax.hpp" -#include - -#include "default_opset.hpp" #include "openvino/frontend/exception.hpp" -#include "ov_models/ov_builders/reshape.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/reshape.hpp" +#include "openvino/op/shape_of.hpp" +#include "openvino/op/softmax.hpp" +#include "utils/reshape.hpp" + +using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace { std::shared_ptr onnx_softmax(const ov::Output data, const int64_t axis) { const auto coerced_data = ov::op::util::flatten(data, static_cast(axis)); - const auto result = std::make_shared(coerced_data, 1); - const auto data_shape = std::make_shared(data); + const auto result = std::make_shared(coerced_data, 1); + const auto data_shape = std::make_shared(data); const bool special_zero = false; - return std::make_shared(result, data_shape, special_zero); + return std::make_shared(result, data_shape, special_zero); } } // namespace namespace op { namespace set_1 { -ov::OutputVector softmax(const Node& node) { - const auto data = node.get_ng_inputs().at(0); +ov::OutputVector softmax(const ov::frontend::onnx::Node& node) { + const auto data = node.get_ov_inputs().at(0); const auto data_rank = data.get_partial_shape().rank(); FRONT_END_GENERAL_CHECK(data_rank.is_static(), "ONNX Softmax data rank needs to be known (static)"); @@ -35,7 +38,7 @@ ov::OutputVector softmax(const Node& node) { std::shared_ptr result; switch (data_rank.get_length()) { case 0: { - result = default_opset::Constant::create(data.get_element_type(), Shape{}, {1}); + result = v0::Constant::create(data.get_element_type(), ov::Shape{}, {1}); break; } default: { @@ -48,8 +51,8 @@ ov::OutputVector softmax(const Node& node) { } } // namespace set_1 namespace set_11 { -ov::OutputVector softmax(const Node& node) { - const auto data = node.get_ng_inputs().at(0); +ov::OutputVector softmax(const ov::frontend::onnx::Node& node) { + const auto data = node.get_ov_inputs().at(0); const auto data_rank = data.get_partial_shape().rank(); FRONT_END_GENERAL_CHECK(data_rank.is_static(), "ONNX Softmax data rank needs to be known (static)"); @@ -58,11 +61,11 @@ ov::OutputVector softmax(const Node& node) { std::shared_ptr result; switch (data_rank.get_length()) { case 0: { - result = default_opset::Constant::create(data.get_element_type(), Shape{}, {1}); + result = v0::Constant::create(data.get_element_type(), ov::Shape{}, {1}); break; } default: { - result = std::make_shared(data, axis); + result = std::make_shared(data, axis); break; } } @@ -71,15 +74,15 @@ ov::OutputVector softmax(const Node& node) { } } // namespace set_11 namespace set_13 { -ov::OutputVector softmax(const Node& node) { - const auto data = node.get_ng_inputs().at(0); +ov::OutputVector softmax(const ov::frontend::onnx::Node& node) { + const auto data = node.get_ov_inputs().at(0); const auto axis = node.get_attribute_value("axis", -1); - return {std::make_shared(data, axis)}; + return {std::make_shared(data, axis)}; } } // namespace set_13 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/softmax.hpp b/src/frontends/onnx/frontend/src/op/softmax.hpp index b87bda13aac05e..cded80d80ec19c 100644 --- a/src/frontends/onnx/frontend/src/op/softmax.hpp +++ b/src/frontends/onnx/frontend/src/op/softmax.hpp @@ -4,31 +4,27 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector softmax(const Node& node); +ov::OutputVector softmax(const ov::frontend::onnx::Node& node); } // namespace set_1 namespace set_11 { -ov::OutputVector softmax(const Node& node); +ov::OutputVector softmax(const ov::frontend::onnx::Node& node); } // namespace set_11 namespace set_13 { -ov::OutputVector softmax(const Node& node); +ov::OutputVector softmax(const ov::frontend::onnx::Node& node); } // namespace set_13 } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/softplus.cpp b/src/frontends/onnx/frontend/src/op/softplus.cpp index 1e05b69285e8dd..3b5d246e6995e7 100644 --- a/src/frontends/onnx/frontend/src/op/softplus.cpp +++ b/src/frontends/onnx/frontend/src/op/softplus.cpp @@ -4,25 +4,22 @@ #include "op/softplus.hpp" -#include +#include "openvino/op/softplus.hpp" -#include "default_opset.hpp" +using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector softplus(const Node& node) { - const auto data = node.get_ng_inputs().at(0); - return {std::make_shared(data)}; +ov::OutputVector softplus(const ov::frontend::onnx::Node& node) { + const auto data = node.get_ov_inputs().at(0); + return {std::make_shared(data)}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/softplus.hpp b/src/frontends/onnx/frontend/src/op/softplus.hpp index 25ac0bef0cb692..911dcf6b9e2d83 100644 --- a/src/frontends/onnx/frontend/src/op/softplus.hpp +++ b/src/frontends/onnx/frontend/src/op/softplus.hpp @@ -4,22 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector softplus(const Node& node); +ov::OutputVector softplus(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/softsign.cpp b/src/frontends/onnx/frontend/src/op/softsign.cpp index d0b1a2fc4296d1..8b7bf672c0daaa 100644 --- a/src/frontends/onnx/frontend/src/op/softsign.cpp +++ b/src/frontends/onnx/frontend/src/op/softsign.cpp @@ -4,23 +4,20 @@ #include "op/softsign.hpp" -#include -#include +#include "openvino/op/softsign.hpp" -#include "default_opset.hpp" -#include "ngraph/shape.hpp" -#include "openvino/opsets/opset9.hpp" +using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector softsign(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0))}; +ov::OutputVector softsign(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0))}; } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/softsign.hpp b/src/frontends/onnx/frontend/src/op/softsign.hpp index a6f997950b6f97..931dbda573fd23 100644 --- a/src/frontends/onnx/frontend/src/op/softsign.hpp +++ b/src/frontends/onnx/frontend/src/op/softsign.hpp @@ -4,19 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector softsign(const Node& node); +ov::OutputVector softsign(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/space_to_depth.cpp b/src/frontends/onnx/frontend/src/op/space_to_depth.cpp index 5afea41b681085..a286e26355d134 100644 --- a/src/frontends/onnx/frontend/src/op/space_to_depth.cpp +++ b/src/frontends/onnx/frontend/src/op/space_to_depth.cpp @@ -4,27 +4,26 @@ #include "op/space_to_depth.hpp" -#include "default_opset.hpp" #include "openvino/frontend/exception.hpp" +#include "openvino/op/space_to_depth.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +using namespace ov::op; + +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector space_to_depth(const Node& node) { - auto data = node.get_ng_inputs().at(0); +ov::OutputVector space_to_depth(const ov::frontend::onnx::Node& node) { + auto data = node.get_ov_inputs().at(0); const auto& shape = data.get_partial_shape(); FRONT_END_GENERAL_CHECK(shape.rank().is_static() && shape.rank().get_length() == 4, "Input must be 4-dimensional"); std::size_t block_size = node.get_attribute_value("blocksize"); - const auto mode = default_opset::SpaceToDepth::SpaceToDepthMode::BLOCKS_FIRST; - return ov::OutputVector{std::make_shared(data, mode, block_size)}; + const auto mode = v0::SpaceToDepth::SpaceToDepthMode::BLOCKS_FIRST; + return {std::make_shared(data, mode, block_size)}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/space_to_depth.hpp b/src/frontends/onnx/frontend/src/op/space_to_depth.hpp index 491d698d5f9a5b..f39b6261778135 100644 --- a/src/frontends/onnx/frontend/src/op/space_to_depth.hpp +++ b/src/frontends/onnx/frontend/src/op/space_to_depth.hpp @@ -4,13 +4,11 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { /// \brief Permutes input tensor blocks of spatial data into depth. @@ -19,12 +17,9 @@ namespace set_1 { /// /// \return ov::OutputVector containing Tensor with shape: /// [N, C * blocksize * blocksize, H / blocksize, W / blocksize] -ov::OutputVector space_to_depth(const Node& node); +ov::OutputVector space_to_depth(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/split.cpp b/src/frontends/onnx/frontend/src/op/split.cpp index 8f6677d4d7946c..e62607bec2c24a 100644 --- a/src/frontends/onnx/frontend/src/op/split.cpp +++ b/src/frontends/onnx/frontend/src/op/split.cpp @@ -1,52 +1,51 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include "op/split.hpp" -#include +#include "openvino/op/constant.hpp" +#include "openvino/op/variadic_split.hpp" +#include "utils/split.hpp" -#include "default_opset.hpp" -#include "ov_models/ov_builders/split.hpp" +using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector split(const Node& node) { - const auto input = node.get_ng_inputs().at(0); +ov::OutputVector split(const ov::frontend::onnx::Node& node) { + const auto input = node.get_ov_inputs().at(0); const auto axis = node.get_attribute_value("axis", 0); if (node.has_attribute("split")) { const auto splits = node.get_attribute_value>("split"); - return ov::op::util::split(input, splits, axis); + return ov::op::util::make_split(input, splits, axis); } else { const auto outputs_number = node.get_output_names().size(); - return ov::op::util::split(input, outputs_number, axis); + return ov::op::util::make_split(input, outputs_number, axis); } } } // namespace set_1 namespace set_13 { -ov::OutputVector split(const Node& node) { - const auto inputs = node.get_ng_inputs(); +ov::OutputVector split(const ov::frontend::onnx::Node& node) { + const auto inputs = node.get_ov_inputs(); const auto axis = node.get_attribute_value("axis", 0); if (inputs.size() < 2) { const auto outputs_number = node.get_output_names().size(); - return ov::op::util::split(inputs.at(0), outputs_number, axis); + return ov::op::util::make_split(inputs.at(0), outputs_number, axis); } else { - const auto axis_node = default_opset::Constant::create(ov::element::Type_t::i64, Shape{}, {axis}); - return {std::make_shared(inputs.at(0), axis_node, inputs.at(1))->outputs()}; + const auto axis_node = v0::Constant::create(ov::element::Type_t::i64, ov::Shape{}, {axis}); + return {std::make_shared(inputs.at(0), axis_node, inputs.at(1))->outputs()}; } } } // namespace set_13 } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/split.hpp b/src/frontends/onnx/frontend/src/op/split.hpp index c85fcbae5aef97..e618f0de65bf1b 100644 --- a/src/frontends/onnx/frontend/src/op/split.hpp +++ b/src/frontends/onnx/frontend/src/op/split.hpp @@ -4,27 +4,22 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector split(const Node& node); +ov::OutputVector split(const ov::frontend::onnx::Node& node); } // namespace set_1 namespace set_13 { -ov::OutputVector split(const Node& node); +ov::OutputVector split(const ov::frontend::onnx::Node& node); } // namespace set_13 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/sqrt.hpp b/src/frontends/onnx/frontend/src/op/sqrt.hpp index d958095baee793..bad982c34059c0 100644 --- a/src/frontends/onnx/frontend/src/op/sqrt.hpp +++ b/src/frontends/onnx/frontend/src/op/sqrt.hpp @@ -4,27 +4,20 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" +#include "openvino/op/sqrt.hpp" -#include - -#include "default_opset.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector sqrt(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0))}; +inline ov::OutputVector sqrt(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0))}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/squeeze.cpp b/src/frontends/onnx/frontend/src/op/squeeze.cpp index c8abf904cf7214..a922c8a98a6596 100644 --- a/src/frontends/onnx/frontend/src/op/squeeze.cpp +++ b/src/frontends/onnx/frontend/src/op/squeeze.cpp @@ -1,42 +1,45 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include "op/squeeze.hpp" -#include "default_opset.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/squeeze.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +using namespace ov::op; + +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector squeeze(const Node& node) { - auto data = node.get_ng_inputs().at(0); +ov::OutputVector squeeze(const ov::frontend::onnx::Node& node) { + auto data = node.get_ov_inputs().at(0); const auto axes = node.get_attribute_value>("axes", {}); if (axes.empty()) { - return {std::make_shared(data)}; + return {std::make_shared(data)}; } else { - const auto axes_const = std::make_shared(ov::element::i64, Shape{axes.size()}, axes); - return {std::make_shared(data, axes_const)}; + const auto axes_const = std::make_shared(ov::element::i64, ov::Shape{axes.size()}, axes); + return {std::make_shared(data, axes_const)}; } } } // namespace set_1 namespace set_13 { -ov::OutputVector squeeze(const Node& node) { - const auto inputs = node.get_ng_inputs(); +ov::OutputVector squeeze(const ov::frontend::onnx::Node& node) { + const auto inputs = node.get_ov_inputs(); if (inputs.size() < 2) { - return {std::make_shared(inputs.at(0))}; + return {std::make_shared(inputs.at(0))}; } else { - return {std::make_shared(inputs.at(0), inputs.at(1))}; + return {std::make_shared(inputs.at(0), inputs.at(1))}; } } } // namespace set_13 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/squeeze.hpp b/src/frontends/onnx/frontend/src/op/squeeze.hpp index ef1005081d90a2..d50b33e158b695 100644 --- a/src/frontends/onnx/frontend/src/op/squeeze.hpp +++ b/src/frontends/onnx/frontend/src/op/squeeze.hpp @@ -4,27 +4,22 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector squeeze(const Node& node); +ov::OutputVector squeeze(const ov::frontend::onnx::Node& node); } // namespace set_1 namespace set_13 { -ov::OutputVector squeeze(const Node& node); +ov::OutputVector squeeze(const ov::frontend::onnx::Node& node); } // namespace set_13 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/stft.cpp b/src/frontends/onnx/frontend/src/op/stft.cpp index 1a35a4b0e441fd..e83feec56c4492 100644 --- a/src/frontends/onnx/frontend/src/op/stft.cpp +++ b/src/frontends/onnx/frontend/src/op/stft.cpp @@ -1,36 +1,46 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include "op/stft.hpp" -#include "default_opset.hpp" +#include "core/null_node.hpp" #include "exceptions.hpp" -#include "onnx_import/core/null_node.hpp" +#include "openvino/op/broadcast.hpp" +#include "openvino/op/concat.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/multiply.hpp" +#include "openvino/op/reshape.hpp" +#include "openvino/op/shape_of.hpp" +#include "openvino/op/slice.hpp" +#include "openvino/op/unsqueeze.hpp" #include "openvino/op/util/op_types.hpp" #include "utils/common.hpp" #include "utils/dft.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +using namespace ov::op; +using ov::Shape; + +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_17 { -ov::OutputVector stft(const Node& node) { - const ov::OutputVector ng_inputs{node.get_ng_inputs()}; - auto signal = ng_inputs.at(0); - const auto dft_length_provided = ng_inputs.size() > 3 && !ov::op::util::is_null(ng_inputs[3]); +ov::OutputVector stft(const ov::frontend::onnx::Node& node) { + const ov::OutputVector ov_inputs{node.get_ov_inputs()}; + auto signal = ov_inputs.at(0); + const auto dft_length_provided = ov_inputs.size() > 3 && !ov::op::util::is_null(ov_inputs[3]); const auto onesided = node.get_attribute_value("onesided", 1); const int64_t axis = 1; - const auto& frame_step_node = ng_inputs.at(1); + const auto& frame_step_node = ov_inputs.at(1); CHECK_VALID_NODE(node, ov::op::util::is_constant(frame_step_node.get_node_shared_ptr()) && ov::shape_size(frame_step_node.get_shape()) <= 1, "frame_step input must be a scalar or Shape{1} constant."); const auto frame_step = - ov::as_type_ptr(frame_step_node.get_node_shared_ptr())->cast_vector()[0]; + ov::as_type_ptr(frame_step_node.get_node_shared_ptr())->cast_vector()[0]; const auto signal_param_shape = signal.get_partial_shape(); CHECK_VALID_NODE(node, signal_param_shape.is_static() && signal_param_shape.size() == 3, @@ -38,24 +48,24 @@ ov::OutputVector stft(const Node& node) { int64_t frame_length = signal_param_shape[axis].get_length() / frame_step; // default value if (dft_length_provided) { - const auto& frame_length_node = ng_inputs[3]; + const auto& frame_length_node = ov_inputs[3]; CHECK_VALID_NODE(node, ov::op::util::is_constant(frame_length_node.get_node_shared_ptr()) && ov::shape_size(frame_length_node.get_shape()) <= 1, "frame_length input must be a scalar or Shape{1} constant."); - frame_length = ov::as_type_ptr(frame_length_node.get_node_shared_ptr()) - ->cast_vector()[0]; + frame_length = + ov::as_type_ptr(frame_length_node.get_node_shared_ptr())->cast_vector()[0]; } - const auto window_node_provided = ng_inputs.size() > 2 && !ov::op::util::is_null(ng_inputs[2]); + const auto window_node_provided = ov_inputs.size() > 2 && !ov::op::util::is_null(ov_inputs[2]); if (window_node_provided) { // window input provided - if (ng_inputs[2].get_partial_shape().rank().is_static()) { + if (ov_inputs[2].get_partial_shape().rank().is_static()) { CHECK_VALID_NODE(node, - ng_inputs[2].get_partial_shape().rank().get_length() == 1, + ov_inputs[2].get_partial_shape().rank().get_length() == 1, "The rank of window input must be 1D."); - if (ng_inputs[2].get_partial_shape()[0].is_static()) { + if (ov_inputs[2].get_partial_shape()[0].is_static()) { CHECK_VALID_NODE(node, - ng_inputs[2].get_partial_shape()[0].get_length() == frame_length, + ov_inputs[2].get_partial_shape()[0].get_length() == frame_length, "The length of window input must be equal to frame_length."); } } @@ -69,59 +79,52 @@ ov::OutputVector stft(const Node& node) { } const int64_t batch_size = signal_param_shape[0].get_length(); const auto nstfts = static_cast((signal_param_shape[axis].get_length() - frame_length) / frame_step) + 1; - const auto axis_const = default_opset::Constant::create(ov::element::i64, {}, {axis}); - const auto zero_const = default_opset::Constant::create(ov::element::i64, {}, {0}); - const auto step = default_opset::Constant::create(ov::element::i64, Shape{2}, {1, 1}); + const auto axis_const = v0::Constant::create(ov::element::i64, {}, {axis}); + const auto zero_const = v0::Constant::create(ov::element::i64, {}, {0}); + const auto step = v0::Constant::create(ov::element::i64, ov::Shape{2}, {1, 1}); ov::OutputVector all_signals; for (int64_t batch = 0; batch < batch_size; ++batch) { ov::OutputVector signals_in_batch; for (int64_t sig_idx = 0; sig_idx < nstfts; ++sig_idx) { - const auto start = default_opset::Constant::create(ov::element::i64, - Shape{2}, - std::vector{batch, sig_idx * frame_step}); + const auto start = + v0::Constant::create(ov::element::i64, ov::Shape{2}, std::vector{batch, sig_idx * frame_step}); const auto stop = - default_opset::Constant::create(ov::element::i64, - Shape{2}, - std::vector{batch + 1, sig_idx * frame_step + frame_length}); - const auto slice_axes = - default_opset::Constant::create(ov::element::i64, Shape{2}, std::vector{0, axis}); - const auto slice = std::make_shared(signal, start, stop, step, slice_axes); - const ov::Output flatten_slice = std::make_shared( + v0::Constant::create(ov::element::i64, + ov::Shape{2}, + std::vector{batch + 1, sig_idx * frame_step + frame_length}); + const auto slice_axes = v0::Constant::create(ov::element::i64, ov::Shape{2}, std::vector{0, axis}); + const auto slice = std::make_shared(signal, start, stop, step, slice_axes); + const ov::Output flatten_slice = std::make_shared( slice, - is_complex(slice) ? default_opset::Constant::create(ov::element::i64, {2}, {-1, 2}) - : (onesided ? default_opset::Constant::create(ov::element::i64, {1}, {-1}) - : default_opset::Constant::create(ov::element::i64, {2}, {-1, 1})), + is_complex(slice) ? v0::Constant::create(ov::element::i64, {2}, {-1, 2}) + : (onesided ? v0::Constant::create(ov::element::i64, {1}, {-1}) + : v0::Constant::create(ov::element::i64, {2}, {-1, 1})), false); const auto dft = dft::make_dft( window_node_provided - ? std::make_shared( + ? std::make_shared( flatten_slice, is_complex(flatten_slice) - ? std::make_shared( // align window shape with signal shape - std::make_shared( - ng_inputs[2], - default_opset::Constant::create(ov::element::i64, {1}, {1})), - std::make_shared(flatten_slice)) - : ng_inputs[2]) + ? std::make_shared( // align window shape with signal shape + std::make_shared(ov_inputs[2], + v0::Constant::create(ov::element::i64, {1}, {1})), + std::make_shared(flatten_slice)) + : ov_inputs[2]) : flatten_slice, - dft_length_provided ? ng_inputs[3] : std::make_shared(), + dft_length_provided ? ov_inputs[3] : std::make_shared(), 0, false, onesided == 1); - signals_in_batch.push_back(std::make_shared(dft, zero_const)); + signals_in_batch.push_back(std::make_shared(dft, zero_const)); } all_signals.push_back( - std::make_shared(std::make_shared(signals_in_batch, 0), - zero_const)); + std::make_shared(std::make_shared(signals_in_batch, 0), zero_const)); } - return {std::make_shared(all_signals, 0)}; + return {std::make_shared(all_signals, 0)}; } } // namespace set_17 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/stft.hpp b/src/frontends/onnx/frontend/src/op/stft.hpp index 509751329658df..3cd7358de35087 100644 --- a/src/frontends/onnx/frontend/src/op/stft.hpp +++ b/src/frontends/onnx/frontend/src/op/stft.hpp @@ -4,22 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_17 { -ov::OutputVector stft(const Node& node); +ov::OutputVector stft(const ov::frontend::onnx::Node& node); } // namespace set_17 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/sub.hpp b/src/frontends/onnx/frontend/src/op/sub.hpp index 32467f94c7f72a..7118bc47e1e37f 100644 --- a/src/frontends/onnx/frontend/src/op/sub.hpp +++ b/src/frontends/onnx/frontend/src/op/sub.hpp @@ -4,32 +4,27 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" +#include "openvino/op/subtract.hpp" -#include "default_opset.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector sub(const Node& node) { - return common::handle_opset6_binary_op(node); +inline ov::OutputVector sub(const ov::frontend::onnx::Node& node) { + return common::handle_opset6_binary_op(node); } } // namespace set_1 namespace set_7 { -inline ov::OutputVector sub(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0), node.get_ng_inputs().at(1))}; +inline ov::OutputVector sub(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0), node.get_ov_inputs().at(1))}; } } // namespace set_7 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/sum.hpp b/src/frontends/onnx/frontend/src/op/sum.hpp index 7762469a9f2d46..2bd3c276709dc4 100644 --- a/src/frontends/onnx/frontend/src/op/sum.hpp +++ b/src/frontends/onnx/frontend/src/op/sum.hpp @@ -4,33 +4,28 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -#include "default_opset.hpp" -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" +#include "openvino/op/add.hpp" #include "utils/variadic.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector sum(const Node& node) { - return variadic::make_ng_variadic_op(node, ov::op::AutoBroadcastType::NONE); +inline ov::OutputVector sum(const ov::frontend::onnx::Node& node) { + return variadic::make_ng_variadic_op(node, ov::op::AutoBroadcastType::NONE); } } // namespace set_1 namespace set_8 { -inline ov::OutputVector sum(const Node& node) { - return variadic::make_ng_variadic_op(node); +inline ov::OutputVector sum(const ov::frontend::onnx::Node& node) { + return variadic::make_ng_variadic_op(node); } } // namespace set_8 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/tan.hpp b/src/frontends/onnx/frontend/src/op/tan.hpp index ba126bcaa056d2..88e1eceed8f025 100644 --- a/src/frontends/onnx/frontend/src/op/tan.hpp +++ b/src/frontends/onnx/frontend/src/op/tan.hpp @@ -4,26 +4,19 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" +#include "openvino/op/tan.hpp" -#include - -#include "default_opset.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector tan(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0))}; +inline ov::OutputVector tan(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0))}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/tanh.hpp b/src/frontends/onnx/frontend/src/op/tanh.hpp index bda87687748073..cf28e1baf8c590 100644 --- a/src/frontends/onnx/frontend/src/op/tanh.hpp +++ b/src/frontends/onnx/frontend/src/op/tanh.hpp @@ -4,27 +4,20 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" +#include "openvino/op/tanh.hpp" -#include - -#include "default_opset.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector tanh(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0))}; +inline ov::OutputVector tanh(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0))}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/thresholded_relu.cpp b/src/frontends/onnx/frontend/src/op/thresholded_relu.cpp index a13a166c66dcaa..f8e5b0aad60814 100644 --- a/src/frontends/onnx/frontend/src/op/thresholded_relu.cpp +++ b/src/frontends/onnx/frontend/src/op/thresholded_relu.cpp @@ -1,37 +1,35 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include "op/thresholded_relu.hpp" -#include -#include +#include "openvino/op/constant.hpp" +#include "openvino/op/convert.hpp" +#include "openvino/op/greater.hpp" +#include "openvino/op/multiply.hpp" -#include "default_opset.hpp" +using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector thresholded_relu(const Node& node) { - const auto data = node.get_ng_inputs().at(0); +ov::OutputVector thresholded_relu(const ov::frontend::onnx::Node& node) { + const auto data = node.get_ov_inputs().at(0); const double alpha = node.get_attribute_value("alpha", 1.0); - const auto alpha_node = default_opset::Constant::create(data.get_element_type(), Shape{}, {alpha}); + const auto alpha_node = v0::Constant::create(data.get_element_type(), ov::Shape{}, {alpha}); const auto data_map = - std::make_shared(std::make_shared(data, alpha_node), - data.get_element_type()); + std::make_shared(std::make_shared(data, alpha_node), data.get_element_type()); - return {std::make_shared(data, data_map)}; + return {std::make_shared(data, data_map)}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/thresholded_relu.hpp b/src/frontends/onnx/frontend/src/op/thresholded_relu.hpp index 07e7d5181d0d3b..297efcfa317f3e 100644 --- a/src/frontends/onnx/frontend/src/op/thresholded_relu.hpp +++ b/src/frontends/onnx/frontend/src/op/thresholded_relu.hpp @@ -4,22 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector thresholded_relu(const Node& node); +ov::OutputVector thresholded_relu(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/tile.cpp b/src/frontends/onnx/frontend/src/op/tile.cpp index 95a06581dc5117..0a36d01d862bc1 100644 --- a/src/frontends/onnx/frontend/src/op/tile.cpp +++ b/src/frontends/onnx/frontend/src/op/tile.cpp @@ -4,32 +4,30 @@ #include "op/tile.hpp" -#include +#include "core/node.hpp" +#include "openvino/op/convert.hpp" +#include "openvino/op/tile.hpp" -#include "default_opset.hpp" -#include "onnx_import/core/node.hpp" +using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector tile(const Node& node) { - auto input = node.get_ng_inputs().at(0); - auto repeats = node.get_ng_inputs().at(1); +ov::OutputVector tile(const ov::frontend::onnx::Node& node) { + auto input = node.get_ov_inputs().at(0); + auto repeats = node.get_ov_inputs().at(1); // Workaround for backends which require repeats to be i64. // Remove the following line when no longer needed. - repeats = std::make_shared(repeats, ov::element::i64); + repeats = std::make_shared(repeats, ov::element::i64); - return {std::make_shared(input, repeats)}; + return {std::make_shared(input, repeats)}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/tile.hpp b/src/frontends/onnx/frontend/src/op/tile.hpp index 87bddcca502a40..106f38970ab7f5 100644 --- a/src/frontends/onnx/frontend/src/op/tile.hpp +++ b/src/frontends/onnx/frontend/src/op/tile.hpp @@ -4,26 +4,21 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { /// \brief Performs ONNX Tile operation. /// /// \param node The ONNX node object representing this operation. -/// \return The vector containing nGraph a node producing the output of the Tile op. -ov::OutputVector tile(const Node& node); +/// \return The vector containing OV a node producing the output of the Tile op. +ov::OutputVector tile(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/topk.cpp b/src/frontends/onnx/frontend/src/op/topk.cpp index 631b3e3aefa1fa..cc220b49a04086 100644 --- a/src/frontends/onnx/frontend/src/op/topk.cpp +++ b/src/frontends/onnx/frontend/src/op/topk.cpp @@ -4,69 +4,68 @@ #include "op/topk.hpp" -#include -#include - -#include "default_opset.hpp" -#include "ngraph/shape.hpp" -#include "openvino/core/type/element_type.hpp" #include "openvino/frontend/exception.hpp" +#include "openvino/op/topk.hpp" #include "utils/reshape.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START namespace { /// \return Return the second input to the TopK node reshaped to a scalar. -ov::Output get_k(const ngraph::onnx_import::Node& node) { - auto k_node = node.get_ng_inputs().at(1); +ov::Output get_k(const ov::frontend::onnx::Node& node) { + auto k_node = node.get_ov_inputs().at(1); FRONT_END_GENERAL_CHECK(shape_size(k_node.get_shape()) == 1, "ONNX TopK operator: 'K' parameter must contain a single positive value.", node); - return ngraph::onnx_import::reshape::interpret_as_scalar(k_node); + return ov::frontend::onnx::reshape::interpret_as_scalar(k_node); } } // namespace -namespace ngraph { -namespace onnx_import { +using namespace ov::op; + +using namespace ov::op; + +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector topk(const Node& node) { - auto data = node.get_ng_inputs().at(0); +ov::OutputVector topk(const ov::frontend::onnx::Node& node) { + auto data = node.get_ov_inputs().at(0); const auto k_node = node.get_attribute_as_constant("k"); const std::int64_t axis{node.get_attribute_value("axis", -1)}; - std::shared_ptr top_k = std::make_shared(data, - k_node, - axis, - default_opset::TopK::Mode::MAX, - default_opset::TopK::SortType::SORT_VALUES, - ov::element::i64); + std::shared_ptr top_k = std::make_shared(data, + k_node, + axis, + v11::TopK::Mode::MAX, + v11::TopK::SortType::SORT_VALUES, + ov::element::i64); return {top_k->output(0), top_k->output(1)}; } } // namespace set_1 namespace set_10 { -ov::OutputVector topk(const Node& node) { - auto data = node.get_ng_inputs().at(0); +ov::OutputVector topk(const ov::frontend::onnx::Node& node) { + auto data = node.get_ov_inputs().at(0); auto k = get_k(node); const std::int64_t axis{node.get_attribute_value("axis", -1)}; - std::shared_ptr top_k = std::make_shared(data, - k, - axis, - default_opset::TopK::Mode::MAX, - default_opset::TopK::SortType::SORT_VALUES, - ov::element::i64); + std::shared_ptr top_k = std::make_shared(data, + k, + axis, + v11::TopK::Mode::MAX, + v11::TopK::SortType::SORT_VALUES, + ov::element::i64); return {top_k->output(0), top_k->output(1)}; } } // namespace set_10 namespace set_11 { -ov::OutputVector topk(const Node& node) { +ov::OutputVector topk(const ov::frontend::onnx::Node& node) { // Process inputs - auto data = node.get_ng_inputs().at(0); + auto data = node.get_ov_inputs().at(0); auto k = get_k(node); // Process attributes @@ -74,22 +73,18 @@ ov::OutputVector topk(const Node& node) { const auto largest = node.get_attribute_value("largest", 1); const auto sorted = node.get_attribute_value("sorted", 1); - // Map attribute values to nGraph enums - const auto sort_type = sorted ? default_opset::TopK::SortType::SORT_VALUES : default_opset::TopK::SortType::NONE; + // Map attribute values to OpenVINO enums + const auto sort_type = sorted ? v11::TopK::SortType::SORT_VALUES : v11::TopK::SortType::NONE; const auto compute_max = static_cast(largest); - const auto mode = compute_max ? default_opset::TopK::Mode::MAX : default_opset::TopK::Mode::MIN; + const auto mode = compute_max ? v11::TopK::Mode::MAX : v11::TopK::Mode::MIN; - std::shared_ptr top_k = - std::make_shared(data, k, axis, mode, sort_type, ov::element::i64); + std::shared_ptr top_k = std::make_shared(data, k, axis, mode, sort_type, ov::element::i64); return {top_k->output(0), top_k->output(1)}; } } // namespace set_11 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/topk.hpp b/src/frontends/onnx/frontend/src/op/topk.hpp index e05e3efacf8f15..f5968c60c1ac03 100644 --- a/src/frontends/onnx/frontend/src/op/topk.hpp +++ b/src/frontends/onnx/frontend/src/op/topk.hpp @@ -4,21 +4,19 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { /// \brief Performs ONNX TopK operation. /// /// \param node The ONNX node object representing this operation. -/// \return The vector containing Ngraph nodes producing output of ONNX TopK +/// \return The vector containing OV nodes producing output of ONNX TopK /// operation (both values and indices). -ov::OutputVector topk(const Node& node); +ov::OutputVector topk(const ov::frontend::onnx::Node& node); } // namespace set_1 /// \brief Performs TopK operation from ONNX version 1.5 @@ -26,19 +24,17 @@ ov::OutputVector topk(const Node& node); /// \details ONNX op set 10 added support for K as a dynamic input, not a static /// attribute. namespace set_10 { -ov::OutputVector topk(const Node& node); +ov::OutputVector topk(const ov::frontend::onnx::Node& node); } /// \brief Performs TopK operation from ONNX version 1.6 /// /// \details ONNX op set 11 added support for `largest` and `sorted` attributes. namespace set_11 { -ov::OutputVector topk(const Node& node); +ov::OutputVector topk(const ov::frontend::onnx::Node& node); } } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/transpose.cpp b/src/frontends/onnx/frontend/src/op/transpose.cpp index 56f73d0a263364..9ea28088f884ab 100644 --- a/src/frontends/onnx/frontend/src/op/transpose.cpp +++ b/src/frontends/onnx/frontend/src/op/transpose.cpp @@ -4,18 +4,17 @@ #include "op/transpose.hpp" -#include -#include +#include "utils/reshape.hpp" -#include "ov_models/ov_builders/reshape.hpp" +using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector transpose(const Node& node) { - ov::Output data = node.get_ng_inputs().at(0); +ov::OutputVector transpose(const ov::frontend::onnx::Node& node) { + ov::Output data = node.get_ov_inputs().at(0); auto permute_axes = node.get_attribute_value>("perm", {}); @@ -23,10 +22,7 @@ ov::OutputVector transpose(const Node& node) { } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/transpose.hpp b/src/frontends/onnx/frontend/src/op/transpose.hpp index ff28adf92ecb96..897437d1fda96f 100644 --- a/src/frontends/onnx/frontend/src/op/transpose.hpp +++ b/src/frontends/onnx/frontend/src/op/transpose.hpp @@ -4,22 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector transpose(const Node& node); +ov::OutputVector transpose(const ov::frontend::onnx::Node& node); } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/trilu.cpp b/src/frontends/onnx/frontend/src/op/trilu.cpp index 8033edfcf22af9..30849020945fe9 100644 --- a/src/frontends/onnx/frontend/src/op/trilu.cpp +++ b/src/frontends/onnx/frontend/src/op/trilu.cpp @@ -1,21 +1,33 @@ -// Copyright (C) 2022 Intel Corporation +// Copyright (C) 2022-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include "op/trilu.hpp" -#include "default_opset.hpp" +#include "core/null_node.hpp" #include "exceptions.hpp" -#include "onnx_import/core/null_node.hpp" +#include "openvino/op/add.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/gather.hpp" +#include "openvino/op/greater.hpp" +#include "openvino/op/greater_eq.hpp" +#include "openvino/op/less.hpp" +#include "openvino/op/less_eq.hpp" +#include "openvino/op/range.hpp" +#include "openvino/op/select.hpp" +#include "openvino/op/shape_of.hpp" +#include "openvino/op/unsqueeze.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +using namespace ov::op; + +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector trilu(const Node& node) { - const auto inputs = node.get_ng_inputs(); +ov::OutputVector trilu(const ov::frontend::onnx::Node& node) { + const auto inputs = node.get_ov_inputs(); const auto num_inputs = inputs.size(); CHECK_VALID_NODE(node, num_inputs > 0 && num_inputs <= 2, "Trilu expects <= 2 input tensors. Got: ", num_inputs); @@ -30,9 +42,9 @@ ov::OutputVector trilu(const Node& node) { CHECK_VALID_NODE(node, inputs[1].get_partial_shape().compatible({}), "Trilu second input must be a scalar"); } - const auto shape = std::make_shared(input); - const auto zero = default_opset::Constant::create(ov::element::i64, Shape{}, {0}); - const auto one = default_opset::Constant::create(ov::element::i64, Shape{}, {1}); + const auto shape = std::make_shared(input); + const auto zero = v0::Constant::create(ov::element::i64, ov::Shape{}, {0}); + const auto one = v0::Constant::create(ov::element::i64, ov::Shape{}, {1}); // The approach here is to create a mask, that later can be used in Select operator // to choose appropiate values from the input @@ -62,47 +74,36 @@ ov::OutputVector trilu(const Node& node) { // fetch last two dimensions of input shape // M = shape[-1] // N = shape[-2] - const auto M = - std::make_shared(shape, - default_opset::Constant::create(ov::element::i32, Shape{}, {-1}), - zero); - const auto N = - std::make_shared(shape, - default_opset::Constant::create(ov::element::i32, Shape{}, {-2}), - zero); + const auto M = std::make_shared(shape, v0::Constant::create(ov::element::i32, ov::Shape{}, {-1}), zero); + const auto N = std::make_shared(shape, v0::Constant::create(ov::element::i32, ov::Shape{}, {-2}), zero); // create 2D tensor with shape [1, M] and values [[0, 1, ..., M - 1]] - const auto horizontal_range = std::make_shared( - std::make_shared(zero, M, one, ov::element::i64), - zero); + const auto horizontal_range = + std::make_shared(std::make_shared(zero, M, one, ov::element::i64), zero); // create 2D tensor with shape [N, 1] and values [[k], [k + 1], ..., [N + k - 1]] std::shared_ptr vertical_range; if (is_k_available) { - vertical_range = std::make_shared(inputs[1], - std::make_shared(N, inputs[1]), - one, - ov::element::i64); + vertical_range = + std::make_shared(inputs[1], std::make_shared(N, inputs[1]), one, ov::element::i64); } else { - vertical_range = std::make_shared(zero, N, one, ov::element::i64); + vertical_range = std::make_shared(zero, N, one, ov::element::i64); } - vertical_range = std::make_shared(vertical_range, one); + vertical_range = std::make_shared(vertical_range, one); const bool upper = node.get_attribute_value("upper", 1) == 1; std::shared_ptr mask; if (upper) { - mask = std::make_shared(horizontal_range, vertical_range); + mask = std::make_shared(horizontal_range, vertical_range); } else { - mask = std::make_shared(horizontal_range, vertical_range); + mask = std::make_shared(horizontal_range, vertical_range); } - return {std::make_shared( - mask, - input, - default_opset::Constant::create(input.get_element_type(), Shape{}, {0}))}; + return { + std::make_shared(mask, input, v0::Constant::create(input.get_element_type(), ov::Shape{}, {0}))}; } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/trilu.hpp b/src/frontends/onnx/frontend/src/op/trilu.hpp index 3084b9d2d10763..abfe0f2522fbea 100644 --- a/src/frontends/onnx/frontend/src/op/trilu.hpp +++ b/src/frontends/onnx/frontend/src/op/trilu.hpp @@ -2,19 +2,17 @@ // SPDX-License-Identifier: Apache-2.0 // #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector trilu(const Node& node); +ov::OutputVector trilu(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/unique.cpp b/src/frontends/onnx/frontend/src/op/unique.cpp index b197c941f99bef..035e32940bc102 100644 --- a/src/frontends/onnx/frontend/src/op/unique.cpp +++ b/src/frontends/onnx/frontend/src/op/unique.cpp @@ -4,26 +4,28 @@ #include "op/unique.hpp" -#include "default_opset.hpp" +#include "openvino/op/unique.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +using namespace ov::op; + +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector unique(const Node& node) { - const auto data = node.get_ng_inputs().at(0); +ov::OutputVector unique(const ov::frontend::onnx::Node& node) { + const auto data = node.get_ov_inputs().at(0); const bool sorted = node.get_attribute_value("sorted", 1); if (node.has_attribute("axis")) { const auto axis = node.get_attribute_as_constant("axis"); - return std::make_shared(data, axis, sorted)->outputs(); + return std::make_shared(data, axis, sorted)->outputs(); } else { - return std::make_shared(data, sorted)->outputs(); + return std::make_shared(data, sorted)->outputs(); } } } // namespace set_1 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/unique.hpp b/src/frontends/onnx/frontend/src/op/unique.hpp index 358608a055ab8c..cc8f181e77e74b 100644 --- a/src/frontends/onnx/frontend/src/op/unique.hpp +++ b/src/frontends/onnx/frontend/src/op/unique.hpp @@ -4,21 +4,17 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector unique(const Node& node); +ov::OutputVector unique(const ov::frontend::onnx::Node& node); } // namespace set_1 } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/unsqueeze.cpp b/src/frontends/onnx/frontend/src/op/unsqueeze.cpp index ee48f2099cfebd..a2a2c53787d0bb 100644 --- a/src/frontends/onnx/frontend/src/op/unsqueeze.cpp +++ b/src/frontends/onnx/frontend/src/op/unsqueeze.cpp @@ -4,35 +4,32 @@ #include "op/unsqueeze.hpp" -#include - -#include "default_opset.hpp" #include "exceptions.hpp" -#include "ngraph/shape.hpp" +#include "openvino/op/unsqueeze.hpp" + +using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector unsqueeze(const Node& node) { - auto data = node.get_ng_inputs().at(0); +ov::OutputVector unsqueeze(const ov::frontend::onnx::Node& node) { + auto data = node.get_ov_inputs().at(0); auto axes_node = node.get_attribute_as_constant>("axes", {}); - return {std::make_shared(data, axes_node)}; + return {std::make_shared(data, axes_node)}; } } // namespace set_1 namespace set_13 { -ov::OutputVector unsqueeze(const Node& node) { - auto inputs = node.get_ng_inputs(); - return {std::make_shared(inputs.at(0), inputs.at(1))}; +ov::OutputVector unsqueeze(const ov::frontend::onnx::Node& node) { + auto inputs = node.get_ov_inputs(); + return {std::make_shared(inputs.at(0), inputs.at(1))}; } } // namespace set_13 } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/unsqueeze.hpp b/src/frontends/onnx/frontend/src/op/unsqueeze.hpp index c536691dcd701f..353424b1dc619a 100644 --- a/src/frontends/onnx/frontend/src/op/unsqueeze.hpp +++ b/src/frontends/onnx/frontend/src/op/unsqueeze.hpp @@ -4,26 +4,22 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector unsqueeze(const Node& node); +ov::OutputVector unsqueeze(const ov::frontend::onnx::Node& node); } // namespace set_1 namespace set_13 { -ov::OutputVector unsqueeze(const Node& node); +ov::OutputVector unsqueeze(const ov::frontend::onnx::Node& node); } // namespace set_13 } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/upsample.cpp b/src/frontends/onnx/frontend/src/op/upsample.cpp index 53f1cccd47ad6b..767d0872cfa859 100644 --- a/src/frontends/onnx/frontend/src/op/upsample.cpp +++ b/src/frontends/onnx/frontend/src/op/upsample.cpp @@ -1,25 +1,25 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include "op/upsample.hpp" -#include - -#include "default_opset.hpp" #include "exceptions.hpp" -#include "ngraph/op/util/op_types.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/interpolate.hpp" + +using namespace ov::op; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace { constexpr unsigned version_1{1}; constexpr unsigned version_7{7}; constexpr unsigned version_9{9}; -void check_mode_support(const onnx_import::Node& node, const std::string& mode, const unsigned op_version) { +void check_mode_support(const ov::frontend::onnx::Node& node, const std::string& mode, const unsigned op_version) { const std::unordered_set modes_v1 = {"nearest", "bilinear"}; const std::unordered_set modes_v7 = {"nearest", "linear"}; const auto& supported_modes = op_version < version_7 ? modes_v1 : modes_v7; @@ -38,18 +38,16 @@ void check_mode_support(const onnx_import::Node& node, const std::string& mode, } } -default_opset::Interpolate::InterpolateAttrs get_attributes(const std::string& mode) { +v11::Interpolate::InterpolateAttrs get_attributes(const std::string& mode) { const auto interpolate_mode = mode == "linear" || mode == "bilinear" - ? default_opset::Interpolate::InterpolateMode::LINEAR_ONNX - : default_opset::Interpolate::InterpolateMode::NEAREST; + ? v11::Interpolate::InterpolateMode::LINEAR_ONNX + : v11::Interpolate::InterpolateMode::NEAREST; - auto attrs = default_opset::Interpolate::InterpolateAttrs(interpolate_mode, - default_opset::Interpolate::ShapeCalcMode::SCALES, - {0}, - {0}); + auto attrs = + v11::Interpolate::InterpolateAttrs(interpolate_mode, v11::Interpolate::ShapeCalcMode::SCALES, {0}, {0}); - if (attrs.mode == default_opset::Interpolate::InterpolateMode::LINEAR_ONNX) { - attrs.coordinate_transformation_mode = default_opset::Interpolate::CoordinateTransformMode::ASYMMETRIC; + if (attrs.mode == v11::Interpolate::InterpolateMode::LINEAR_ONNX) { + attrs.coordinate_transformation_mode = v11::Interpolate::CoordinateTransformMode::ASYMMETRIC; } return attrs; @@ -57,13 +55,13 @@ default_opset::Interpolate::InterpolateAttrs get_attributes(const std::string& m } // namespace namespace set_1 { -ov::OutputVector upsample(const onnx_import::Node& node) { +ov::OutputVector upsample(const ov::frontend::onnx::Node& node) { const auto height_scale = node.get_attribute_value("height_scale"); const auto width_scale = node.get_attribute_value("width_scale"); const auto mode = node.get_attribute_value("mode", "nearest"); check_mode_support(node, mode, version_1); - const auto data = node.get_ng_inputs().at(0); + const auto data = node.get_ov_inputs().at(0); static const std::string expectation{"Input tensor is required to be 4D."}; const auto rank = data.get_partial_shape().rank(); @@ -75,20 +73,20 @@ ov::OutputVector upsample(const onnx_import::Node& node) { scales[rank_size - 1] = width_scale; scales[rank_size - 2] = height_scale; - const auto scales_const = default_opset::Constant::create(ov::element::f32, Shape({scales.size()}), scales); + const auto scales_const = v0::Constant::create(ov::element::f32, ov::Shape({scales.size()}), scales); - return std::make_shared(data, scales_const, get_attributes(mode))->outputs(); + return std::make_shared(data, scales_const, get_attributes(mode))->outputs(); } } // namespace set_1 namespace set_7 { -ov::OutputVector upsample(const onnx_import::Node& node) { +ov::OutputVector upsample(const ov::frontend::onnx::Node& node) { const auto scales = node.get_attribute_value>("scales"); const auto mode = node.get_attribute_value("mode", "nearest"); check_mode_support(node, mode, version_7); - const auto data = node.get_ng_inputs().at(0); + const auto data = node.get_ov_inputs().at(0); const auto rank = data.get_partial_shape().rank(); CHECK_VALID_NODE(node, @@ -96,24 +94,24 @@ ov::OutputVector upsample(const onnx_import::Node& node) { "Input tensor's rank is required to be the same as number of " "elements of 'scales' attribute."); - const auto scales_const = default_opset::Constant::create(ov::element::f32, Shape({scales.size()}), scales); + const auto scales_const = v0::Constant::create(ov::element::f32, ov::Shape({scales.size()}), scales); - return std::make_shared(data, scales_const, get_attributes(mode))->outputs(); + return std::make_shared(data, scales_const, get_attributes(mode))->outputs(); } } // namespace set_7 namespace set_9 { -ov::OutputVector upsample(const onnx_import::Node& node) { +ov::OutputVector upsample(const ov::frontend::onnx::Node& node) { const auto mode = node.get_attribute_value("mode", "nearest"); check_mode_support(node, mode, version_9); - const auto& inputs = node.get_ng_inputs(); - return std::make_shared(inputs.at(0), inputs.at(1), get_attributes(mode))->outputs(); + const auto& inputs = node.get_ov_inputs(); + return std::make_shared(inputs.at(0), inputs.at(1), get_attributes(mode))->outputs(); } } // namespace set_9 } // namespace op -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/upsample.hpp b/src/frontends/onnx/frontend/src/op/upsample.hpp index 49010f45d84f39..87d40de79d990d 100644 --- a/src/frontends/onnx/frontend/src/op/upsample.hpp +++ b/src/frontends/onnx/frontend/src/op/upsample.hpp @@ -4,32 +4,27 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -ov::OutputVector upsample(const Node& node); +ov::OutputVector upsample(const ov::frontend::onnx::Node& node); } // namespace set_1 namespace set_7 { -ov::OutputVector upsample(const Node& node); +ov::OutputVector upsample(const ov::frontend::onnx::Node& node); } // namespace set_7 namespace set_9 { -ov::OutputVector upsample(const Node& node); +ov::OutputVector upsample(const ov::frontend::onnx::Node& node); } // namespace set_9 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/where.hpp b/src/frontends/onnx/frontend/src/op/where.hpp index a80febd24dc61e..57b59f2f95e302 100644 --- a/src/frontends/onnx/frontend/src/op/where.hpp +++ b/src/frontends/onnx/frontend/src/op/where.hpp @@ -4,28 +4,21 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" +#include "openvino/op/select.hpp" -#include - -#include "default_opset.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector where(const Node& node) { - ov::OutputVector ng_inputs{node.get_ng_inputs()}; +inline ov::OutputVector where(const ov::frontend::onnx::Node& node) { + ov::OutputVector ov_inputs{node.get_ov_inputs()}; - return {std::make_shared(ng_inputs.at(0), ng_inputs.at(1), ng_inputs.at(2))}; + return {std::make_shared(ov_inputs.at(0), ov_inputs.at(1), ov_inputs.at(2))}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/op/xor.hpp b/src/frontends/onnx/frontend/src/op/xor.hpp index 502d90efd0eb7d..5d40e4e232e948 100644 --- a/src/frontends/onnx/frontend/src/op/xor.hpp +++ b/src/frontends/onnx/frontend/src/op/xor.hpp @@ -4,27 +4,22 @@ #pragma once -#include "openvino/core/deprecated.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +#include "core/node.hpp" +#include "openvino/op/logical_xor.hpp" -#include "default_opset.hpp" -#include "onnx_import/core/node.hpp" - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace op { namespace set_1 { -inline ov::OutputVector logical_xor(const Node& node) { - return {std::make_shared(node.get_ng_inputs().at(0), - node.get_ng_inputs().at(1), - ov::op::AutoBroadcastSpec(ov::op::AutoBroadcastType::NUMPY))}; +inline ov::OutputVector logical_xor(const ov::frontend::onnx::Node& node) { + return {std::make_shared(node.get_ov_inputs().at(0), + node.get_ov_inputs().at(1), + ov::op::AutoBroadcastSpec(ov::op::AutoBroadcastType::NUMPY))}; } } // namespace set_1 - } // namespace op - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/ops_bridge.cpp b/src/frontends/onnx/frontend/src/ops_bridge.cpp index b522d6c733fd30..334eae33837371 100644 --- a/src/frontends/onnx/frontend/src/ops_bridge.cpp +++ b/src/frontends/onnx/frontend/src/ops_bridge.cpp @@ -94,6 +94,7 @@ #include "op/is_finite.hpp" #include "op/is_inf.hpp" #include "op/is_nan.hpp" +#include "op/layer_normalization.hpp" #include "op/leaky_relu.hpp" #include "op/less.hpp" #include "op/less_or_equal.hpp" @@ -192,8 +193,9 @@ using namespace ov::frontend::onnx; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { const char* OPENVINO_ONNX_DOMAIN = "org.openvinotoolkit"; @@ -426,6 +428,7 @@ OperatorsBridge::OperatorsBridge() { REGISTER_OPERATOR("IsFinite", 1, is_finite); REGISTER_OPERATOR("IsInf", 1, is_inf); REGISTER_OPERATOR("IsNaN", 1, is_nan) + REGISTER_OPERATOR("LayerNormalization", 1, layer_normalization); REGISTER_OPERATOR("LeakyRelu", 1, leaky_relu); REGISTER_OPERATOR("Less", 1, less); REGISTER_OPERATOR("LessOrEqual", 1, less_or_equal); @@ -604,6 +607,6 @@ OperatorsBridge::OperatorsBridge() { #undef REGISTER_OPERATOR #undef REGISTER_OPERATOR_WITH_DOMAIN -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/ops_bridge.hpp b/src/frontends/onnx/frontend/src/ops_bridge.hpp index 2618260bf9129e..7f0fe96785bd03 100644 --- a/src/frontends/onnx/frontend/src/ops_bridge.hpp +++ b/src/frontends/onnx/frontend/src/ops_bridge.hpp @@ -11,12 +11,12 @@ #include #include -#include "onnx_import/core/operator_set.hpp" -#include "openvino/core/deprecated.hpp" +#include "core/operator_set.hpp" #include "version_range.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { class OperatorsBridge { public: @@ -89,6 +89,6 @@ class OperatorsBridge { extern const char* OPENVINO_ONNX_DOMAIN; -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/place.cpp b/src/frontends/onnx/frontend/src/place.cpp index 3430bf4e6b56cb..f08221d3d3cbff 100644 --- a/src/frontends/onnx/frontend/src/place.cpp +++ b/src/frontends/onnx/frontend/src/place.cpp @@ -9,12 +9,12 @@ using namespace ov; using namespace ov::frontend::onnx; -PlaceInputEdge::PlaceInputEdge(const onnx_editor::InputEdge& edge, std::shared_ptr editor) +PlaceInputEdge::PlaceInputEdge(const InputEdge& edge, std::shared_ptr editor) : m_edge{edge}, m_editor{std::move(editor)}, m_initial_source_tensor_name{m_editor->get_source_tensor_name(m_edge)} {} -PlaceInputEdge::PlaceInputEdge(onnx_editor::InputEdge&& edge, std::shared_ptr editor) +PlaceInputEdge::PlaceInputEdge(InputEdge&& edge, std::shared_ptr editor) : m_edge{std::move(edge)}, m_editor{std::move(editor)}, m_initial_source_tensor_name{m_editor->get_source_tensor_name(m_edge)} {} @@ -26,7 +26,7 @@ void PlaceInputEdge::check_if_valid() const { " is outdated since the topology of the model has been changed."); } -onnx_editor::InputEdge PlaceInputEdge::get_input_edge() const { +InputEdge PlaceInputEdge::get_input_edge() const { return m_edge; } @@ -65,7 +65,7 @@ ov::frontend::Place::Ptr PlaceInputEdge::get_source_tensor() const { std::vector PlaceInputEdge::get_consuming_operations() const { check_if_valid(); - return {std::make_shared(onnx_editor::EditorNode{m_edge.m_node_idx}, m_editor)}; + return {std::make_shared(EditorNode{m_edge.m_node_idx}, m_editor)}; } ov::frontend::Place::Ptr PlaceInputEdge::get_producing_operation() const { @@ -76,13 +76,12 @@ ov::frontend::Place::Ptr PlaceInputEdge::get_producing_port() const { return get_source_tensor()->get_producing_port(); } -PlaceOutputEdge::PlaceOutputEdge(const onnx_editor::OutputEdge& edge, - std::shared_ptr editor) +PlaceOutputEdge::PlaceOutputEdge(const OutputEdge& edge, std::shared_ptr editor) : m_edge{edge}, m_editor{std::move(editor)}, m_initial_target_tensor_name{m_editor->get_target_tensor_name(edge)} {} -PlaceOutputEdge::PlaceOutputEdge(onnx_editor::OutputEdge&& edge, std::shared_ptr editor) +PlaceOutputEdge::PlaceOutputEdge(OutputEdge&& edge, std::shared_ptr editor) : m_edge{std::move(edge)}, m_editor{std::move(editor)}, m_initial_target_tensor_name{m_editor->get_target_tensor_name(m_edge)} {} @@ -95,7 +94,7 @@ void PlaceOutputEdge::check_if_valid() const { " is outdated since the topology of the model has been changed."); } -onnx_editor::OutputEdge PlaceOutputEdge::get_output_edge() const { +OutputEdge PlaceOutputEdge::get_output_edge() const { return m_edge; } @@ -138,18 +137,18 @@ std::vector PlaceOutputEdge::get_consuming_ports() con ov::frontend::Place::Ptr PlaceOutputEdge::get_producing_operation() const { check_if_valid(); - return std::make_shared(onnx_editor::EditorNode{m_edge.m_node_idx}, m_editor); + return std::make_shared(EditorNode{m_edge.m_node_idx}, m_editor); } std::vector PlaceOutputEdge::get_consuming_operations() const { return get_target_tensor()->get_consuming_operations(); } -PlaceTensor::PlaceTensor(const std::string& name, std::shared_ptr editor) +PlaceTensor::PlaceTensor(const std::string& name, std::shared_ptr editor) : m_name{name}, m_editor{std::move(editor)} {} -PlaceTensor::PlaceTensor(std::string&& name, std::shared_ptr editor) +PlaceTensor::PlaceTensor(std::string&& name, std::shared_ptr editor) : m_name{std::move(name)}, m_editor{std::move(editor)} {} @@ -166,7 +165,7 @@ ov::frontend::Place::Ptr PlaceTensor::get_producing_port() const { std::vector PlaceTensor::get_consuming_ports() const { std::vector ret; auto edges = m_editor->find_output_consumers(m_name); - std::transform(edges.begin(), edges.end(), std::back_inserter(ret), [this](const onnx_editor::InputEdge& edge) { + std::transform(edges.begin(), edges.end(), std::back_inserter(ret), [this](const InputEdge& edge) { return std::make_shared(edge, this->m_editor); }); return ret; @@ -228,12 +227,12 @@ void PlaceTensor::set_name_for_dimension(size_t shape_dim_index, const std::stri m_editor->set_name_for_dimension(m_name, shape_dim_index, dim_name); } -PlaceOp::PlaceOp(const onnx_editor::EditorNode& node, std::shared_ptr editor) +PlaceOp::PlaceOp(const EditorNode& node, std::shared_ptr editor) : m_node{node}, m_editor{std::move(editor)}, m_initial_first_output{m_editor->get_output_ports(m_node).at(0)} {} -PlaceOp::PlaceOp(onnx_editor::EditorNode&& node, std::shared_ptr editor) +PlaceOp::PlaceOp(EditorNode&& node, std::shared_ptr editor) : m_node{std::move(node)}, m_editor{std::move(editor)}, m_initial_first_output{m_editor->get_output_ports(m_node).at(0)} {} @@ -254,7 +253,7 @@ std::vector PlaceOp::get_names() const { } } -const onnx_editor::EditorNode& PlaceOp::get_editor_node() const { +const EditorNode& PlaceOp::get_editor_node() const { return m_node; } @@ -269,9 +268,8 @@ ov::frontend::Place::Ptr PlaceOp::get_output_port(int output_port_index) const { check_if_valid(); const int out_ports_number = static_cast(m_editor->get_output_ports(m_node).size()); if (output_port_index < out_ports_number) { - return std::make_shared( - m_editor->find_output_edge(m_node, onnx_editor::EditorOutput{output_port_index}), - m_editor); + return std::make_shared(m_editor->find_output_edge(m_node, EditorOutput{output_port_index}), + m_editor); } return nullptr; } @@ -280,9 +278,8 @@ ov::frontend::Place::Ptr PlaceOp::get_output_port(const std::string& output_port check_if_valid(); const auto output_ports = m_editor->get_output_ports(m_node); if (std::count(std::begin(output_ports), std::end(output_ports), output_port_name) == 1) { - return std::make_shared( - m_editor->find_output_edge(m_node, onnx_editor::EditorOutput{output_port_name}), - m_editor); + return std::make_shared(m_editor->find_output_edge(m_node, EditorOutput{output_port_name}), + m_editor); } return nullptr; } @@ -298,9 +295,8 @@ ov::frontend::Place::Ptr PlaceOp::get_input_port(int input_port_index) const { check_if_valid(); const int in_ports_number = static_cast(m_editor->get_input_ports(m_node).size()); if (input_port_index < in_ports_number) { - return std::make_shared( - m_editor->find_input_edge(m_node, onnx_editor::EditorInput{input_port_index}), - m_editor); + return std::make_shared(m_editor->find_input_edge(m_node, EditorInput{input_port_index}), + m_editor); } return nullptr; } @@ -309,8 +305,7 @@ ov::frontend::Place::Ptr PlaceOp::get_input_port(const std::string& input_name) check_if_valid(); const auto input_ports = m_editor->get_input_ports(m_node); if (std::count(std::begin(input_ports), std::end(input_ports), input_name) == 1) { - return std::make_shared(m_editor->find_input_edge(m_node, onnx_editor::EditorInput{input_name}), - m_editor); + return std::make_shared(m_editor->find_input_edge(m_node, EditorInput{input_name}), m_editor); } return nullptr; } diff --git a/src/frontends/onnx/frontend/src/place.hpp b/src/frontends/onnx/frontend/src/place.hpp index 8e70b4db8ce16f..0a3d95855e98a7 100644 --- a/src/frontends/onnx/frontend/src/place.hpp +++ b/src/frontends/onnx/frontend/src/place.hpp @@ -15,11 +15,11 @@ namespace onnx { class PlaceInputEdge : public Place { public: - PlaceInputEdge(const onnx_editor::InputEdge& edge, std::shared_ptr editor); - PlaceInputEdge(onnx_editor::InputEdge&& edge, std::shared_ptr editor); + PlaceInputEdge(const InputEdge& edge, std::shared_ptr editor); + PlaceInputEdge(InputEdge&& edge, std::shared_ptr editor); // internal usage - onnx_editor::InputEdge get_input_edge() const; + InputEdge get_input_edge() const; void check_if_valid() const; // external usage @@ -34,18 +34,18 @@ class PlaceInputEdge : public Place { Place::Ptr get_producing_port() const override; private: - onnx_editor::InputEdge m_edge; - const std::shared_ptr m_editor; + InputEdge m_edge; + const std::shared_ptr m_editor; std::string m_initial_source_tensor_name; }; class PlaceOutputEdge : public Place { public: - PlaceOutputEdge(const onnx_editor::OutputEdge& edge, std::shared_ptr editor); - PlaceOutputEdge(onnx_editor::OutputEdge&& edge, std::shared_ptr editor); + PlaceOutputEdge(const OutputEdge& edge, std::shared_ptr editor); + PlaceOutputEdge(OutputEdge&& edge, std::shared_ptr editor); // internal usage - onnx_editor::OutputEdge get_output_edge() const; + OutputEdge get_output_edge() const; void check_if_valid() const; // external usage @@ -60,15 +60,15 @@ class PlaceOutputEdge : public Place { std::vector get_consuming_operations() const override; private: - onnx_editor::OutputEdge m_edge; - std::shared_ptr m_editor; + OutputEdge m_edge; + std::shared_ptr m_editor; std::string m_initial_target_tensor_name; }; class PlaceTensor : public Place { public: - PlaceTensor(const std::string& name, std::shared_ptr editor); - PlaceTensor(std::string&& name, std::shared_ptr editor); + PlaceTensor(const std::string& name, std::shared_ptr editor); + PlaceTensor(std::string&& name, std::shared_ptr editor); // external usage std::vector get_names() const override; @@ -86,17 +86,17 @@ class PlaceTensor : public Place { private: std::string m_name; - std::shared_ptr m_editor; + std::shared_ptr m_editor; }; class PlaceOp : public Place { public: - PlaceOp(const onnx_editor::EditorNode& node, std::shared_ptr editor); - PlaceOp(onnx_editor::EditorNode&& node, std::shared_ptr editor); + PlaceOp(const EditorNode& node, std::shared_ptr editor); + PlaceOp(EditorNode&& node, std::shared_ptr editor); std::vector get_names() const override; // internal usage - const onnx_editor::EditorNode& get_editor_node() const; + const EditorNode& get_editor_node() const; void set_name(const std::string& new_name); void check_if_valid() const; @@ -131,8 +131,8 @@ class PlaceOp : public Place { bool is_output() const override; private: - onnx_editor::EditorNode m_node; - std::shared_ptr m_editor; + EditorNode m_node; + std::shared_ptr m_editor; std::string m_initial_first_output; }; diff --git a/src/frontends/onnx/frontend/src/utils/arg_min_max_factory.cpp b/src/frontends/onnx/frontend/src/utils/arg_min_max_factory.cpp index c75b3a4f337cee..0359e32e02cf59 100644 --- a/src/frontends/onnx/frontend/src/utils/arg_min_max_factory.cpp +++ b/src/frontends/onnx/frontend/src/utils/arg_min_max_factory.cpp @@ -4,7 +4,6 @@ #include "utils/arg_min_max_factory.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/convert.hpp" #include "openvino/op/gather.hpp" @@ -13,20 +12,21 @@ #include "openvino/op/squeeze.hpp" #include "openvino/op/subtract.hpp" #include "openvino/op/topk.hpp" +#include "validation_util.hpp" using namespace ov; using namespace ov::op; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace utils { -OPENVINO_SUPPRESS_DEPRECATED_START + ArgMinMaxFactory::ArgMinMaxFactory(const Node& node) : m_keep_dims{node.get_attribute_value("keepdims", 1)}, - m_input_node{node.get_ng_inputs().at(0)}, + m_input_node{node.get_ov_inputs().at(0)}, m_axis{node.get_attribute_value("axis", 0)}, m_select_last_index{node.get_attribute_value("select_last_index", 0)} {} -OPENVINO_SUPPRESS_DEPRECATED_END std::shared_ptr ArgMinMaxFactory::make_arg_max() const { return make_topk_subgraph(v11::TopK::Mode::MAX); @@ -37,7 +37,7 @@ std::shared_ptr ArgMinMaxFactory::make_arg_min() const { } std::shared_ptr ArgMinMaxFactory::make_topk_subgraph(v11::TopK::Mode mode) const { - const auto k_node = v0::Constant::create(ov::element::i64, Shape{}, {1}); + const auto k_node = v0::Constant::create(ov::element::i64, ov::Shape{}, {1}); if (m_select_last_index == 1) { // Example (ArgMin): @@ -64,28 +64,28 @@ std::shared_ptr ArgMinMaxFactory::make_topk_subgraph(v11::TopK::Mode m // res_index = dims_on_axis - topk->output(1) = 6 - 3 = 3 // result = res_index - 1 = 3 - 1 = 2 - OPENVINO_SUPPRESS_DEPRECATED_START const int64_t normalized_axis = - ov::normalize_axis(m_input_node.get_node(), m_axis, m_input_node.get_partial_shape().rank()); - OPENVINO_SUPPRESS_DEPRECATED_END + ov::util::normalize_axis(m_input_node.get_node(), m_axis, m_input_node.get_partial_shape().rank()); - const auto axis_node = v0::Constant::create(ov::element::i64, Shape{1}, {normalized_axis}); + const auto axis_node = v0::Constant::create(ov::element::i64, ov::Shape{1}, {normalized_axis}); const auto reverse = std::make_shared(m_input_node, axis_node, v1::Reverse::Mode::INDEX); const auto topk = std::make_shared(reverse, k_node, normalized_axis, mode, v1::TopK::SortType::NONE); const auto data_shape = std::make_shared(m_input_node); const auto dims_on_axis = - std::make_shared(data_shape, axis_node, v0::Constant::create(ov::element::i64, Shape{}, {0})); + std::make_shared(data_shape, + axis_node, + v0::Constant::create(ov::element::i64, ov::Shape{}, {0})); const auto res_index = std::make_shared(dims_on_axis, std::make_shared(topk->output(1), ov::element::i64)); const auto result = - std::make_shared(res_index, v0::Constant::create(ov::element::i64, Shape{1}, {1})); + std::make_shared(res_index, v0::Constant::create(ov::element::i64, ov::Shape{1}, {1})); if (m_keep_dims == 0) { - const auto axis_to_remove = v0::Constant::create(ov::element::u64, Shape{}, {topk->get_axis()}); + const auto axis_to_remove = v0::Constant::create(ov::element::u64, ov::Shape{}, {topk->get_axis()}); return std::make_shared(result, axis_to_remove); } @@ -98,7 +98,7 @@ std::shared_ptr ArgMinMaxFactory::make_topk_subgraph(v11::TopK::Mode m const auto result = std::make_shared(topk->output(1), ov::element::i64); if (m_keep_dims == 0) { - const auto axis_to_remove = v0::Constant::create(ov::element::u64, Shape{}, {topk->get_axis()}); + const auto axis_to_remove = v0::Constant::create(ov::element::u64, ov::Shape{}, {topk->get_axis()}); return std::make_shared(result, axis_to_remove); } @@ -106,5 +106,6 @@ std::shared_ptr ArgMinMaxFactory::make_topk_subgraph(v11::TopK::Mode m return result; } } // namespace utils -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/utils/arg_min_max_factory.hpp b/src/frontends/onnx/frontend/src/utils/arg_min_max_factory.hpp index 08d4da34147353..213aee65fb23e5 100644 --- a/src/frontends/onnx/frontend/src/utils/arg_min_max_factory.hpp +++ b/src/frontends/onnx/frontend/src/utils/arg_min_max_factory.hpp @@ -7,20 +7,19 @@ #include #include -#include "onnx_import/core/node.hpp" -#include "openvino/core/deprecated.hpp" +#include "core/node.hpp" #include "openvino/core/node.hpp" #include "openvino/op/topk.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace utils { /// \brief Factory class which generates sub-graphs for ONNX ArgMin, ArgMax ops. class ArgMinMaxFactory { public: - OPENVINO_SUPPRESS_DEPRECATED_START explicit ArgMinMaxFactory(const Node& node); - OPENVINO_SUPPRESS_DEPRECATED_END + virtual ~ArgMinMaxFactory() = default; /// \brief Creates ArgMax ONNX operation. @@ -41,5 +40,6 @@ class ArgMinMaxFactory { }; } // namespace utils -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/utils/common.cpp b/src/frontends/onnx/frontend/src/utils/common.cpp index 73e982df4c0cc0..de997ff168c1cd 100644 --- a/src/frontends/onnx/frontend/src/utils/common.cpp +++ b/src/frontends/onnx/frontend/src/utils/common.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -7,7 +7,6 @@ #include // onnx types #include "onnx_framework_node.hpp" -#include "openvino/core/deprecated.hpp" #include "openvino/frontend/exception.hpp" #include "openvino/op/add.hpp" #include "openvino/op/broadcast.hpp" @@ -21,40 +20,42 @@ #include "openvino/op/subtract.hpp" using namespace ov::op; +using ::ONNX_NAMESPACE::TensorProto_DataType; +using ov::Shape; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace common { const ov::element::Type& get_ov_element_type(int64_t onnx_type) { switch (onnx_type) { - case ONNX_NAMESPACE::TensorProto_DataType_BOOL: + case TensorProto_DataType::TensorProto_DataType_BOOL: return ov::element::boolean; - case ONNX_NAMESPACE::TensorProto_DataType_DOUBLE: + case TensorProto_DataType::TensorProto_DataType_DOUBLE: return ov::element::f64; - case ONNX_NAMESPACE::TensorProto_DataType_FLOAT16: + case TensorProto_DataType::TensorProto_DataType_FLOAT16: return ov::element::f16; - case ONNX_NAMESPACE::TensorProto_DataType_FLOAT: + case TensorProto_DataType::TensorProto_DataType_FLOAT: return ov::element::f32; - case ONNX_NAMESPACE::TensorProto_DataType_INT8: + case TensorProto_DataType::TensorProto_DataType_INT8: return ov::element::i8; - case ONNX_NAMESPACE::TensorProto_DataType_INT16: + case TensorProto_DataType::TensorProto_DataType_INT16: return ov::element::i16; - case ONNX_NAMESPACE::TensorProto_DataType_INT32: + case TensorProto_DataType::TensorProto_DataType_INT32: return ov::element::i32; - case ONNX_NAMESPACE::TensorProto_DataType_INT64: + case TensorProto_DataType::TensorProto_DataType_INT64: return ov::element::i64; - case ONNX_NAMESPACE::TensorProto_DataType_UINT8: + case TensorProto_DataType::TensorProto_DataType_UINT8: return ov::element::u8; - case ONNX_NAMESPACE::TensorProto_DataType_UINT16: + case TensorProto_DataType::TensorProto_DataType_UINT16: return ov::element::u16; - case ONNX_NAMESPACE::TensorProto_DataType_UINT32: + case TensorProto_DataType::TensorProto_DataType_UINT32: return ov::element::u32; - case ONNX_NAMESPACE::TensorProto_DataType_UINT64: + case TensorProto_DataType::TensorProto_DataType_UINT64: return ov::element::u64; - case ONNX_NAMESPACE::TensorProto_DataType_UNDEFINED: + case TensorProto_DataType::TensorProto_DataType_UNDEFINED: return ov::element::dynamic; - case ONNX_NAMESPACE::TensorProto_DataType_BFLOAT16: + case TensorProto_DataType::TensorProto_DataType_BFLOAT16: return ov::element::bf16; } OPENVINO_THROW("unsupported element type"); @@ -98,9 +99,9 @@ void validate_scalar_input(const char* input_name, } template -ov::OutputVector handle_opset6_binary_op(const Node& node) { - const ov::Output lhs_node = node.get_ng_inputs().at(0); - ov::Output rhs_node = node.get_ng_inputs().at(1); +ov::OutputVector handle_opset6_binary_op(const ov::frontend::onnx::Node& node) { + const ov::Output lhs_node = node.get_ov_inputs().at(0); + ov::Output rhs_node = node.get_ov_inputs().at(1); const bool broadcast = node.get_attribute_value("broadcast", 0); if (broadcast) { if (node.has_attribute("axis")) { @@ -114,7 +115,7 @@ ov::OutputVector handle_opset6_binary_op(const Node& node) { axis += lhs_rank; if (lhs_rank > axis + rhs_rank) { auto ones = v0::Constant::create(ov::element::i64, - Shape{static_cast(lhs_rank - axis - rhs_rank)}, + ov::Shape{static_cast(lhs_rank - axis - rhs_rank)}, std::vector(lhs_rank - axis - rhs_rank, 1)); auto rhs_shape = std::make_shared(rhs_node); auto new_shape = std::make_shared(ov::OutputVector{rhs_shape, ones}, 0); @@ -136,7 +137,7 @@ template ov::OutputVector handle_opset6_binary_op(const Node& no const std::string FAILSAFE_NODE = "ONNX_FAILSAFE_NODE"; std::shared_ptr make_failsafe_constant(const ov::element::Type& dtype) { - const auto failsafe_constant = v0::Constant::create(dtype, Shape{}, {0}); + const auto failsafe_constant = v0::Constant::create(dtype, ov::Shape{}, {0}); auto& rt_info = failsafe_constant->get_rt_info(); rt_info[FAILSAFE_NODE] = true; return failsafe_constant; @@ -166,7 +167,7 @@ std::string collect_translation_exceptions(const std::shared_ptr& par bool unsupported_found = false; bool additional_error_found = false; for (const auto& op : partially_converted->get_ops()) { - if (const auto unsupported = std::dynamic_pointer_cast(op)) { + if (const auto unsupported = std::dynamic_pointer_cast(op)) { if (unsupported->additional_error_message().empty()) { fully_unsupported_ops += (unsupported->get_attrs().get_opset_name().empty() ? "" @@ -197,6 +198,6 @@ std::string collect_translation_exceptions(const std::shared_ptr& par } } // namespace common -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/utils/common.hpp b/src/frontends/onnx/frontend/src/utils/common.hpp index 08df9160fdd1cd..0bfee5c8dce3a5 100644 --- a/src/frontends/onnx/frontend/src/utils/common.hpp +++ b/src/frontends/onnx/frontend/src/utils/common.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -13,15 +13,15 @@ #include // std::enable_if #include -#include "onnx_import/core/node.hpp" -#include "openvino/core/deprecated.hpp" +#include "core/node.hpp" #include "openvino/core/node.hpp" #include "openvino/core/shape.hpp" #include "openvino/core/type/element_type.hpp" #include "openvino/op/constant.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace common { const ov::element::Type& get_ov_element_type(std::int64_t onnx_type); @@ -75,7 +75,7 @@ std::shared_ptr get_monotonic_range_along_node_rank(const ov::Output -std::shared_ptr shifted_square_identity(const Shape output_shape, +std::shared_ptr shifted_square_identity(const ov::Shape output_shape, const ov::element::Type& output_type, const std::int64_t shift) { std::vector identity_matrix(shape_size(output_shape), T{0}); @@ -101,7 +101,7 @@ std::shared_ptr shifted_square_identity(const Shape output /// \return A Constant node representing identity matrix with shape (n, n). template std::shared_ptr square_identity(const size_t n, const ov::element::Type& type) { - return shifted_square_identity(Shape{n, n}, type, 0); + return shifted_square_identity(ov::Shape{n, n}, type, 0); } /// \brief Performs validation of an input that is expected to be a scalar. @@ -131,10 +131,9 @@ std::unique_ptr make_unique(Args&&... args) { /// \param node ONNX node /// /// \return ov::OutputVector with binary op -OPENVINO_SUPPRESS_DEPRECATED_START + template -ov::OutputVector handle_opset6_binary_op(const Node& node); -OPENVINO_SUPPRESS_DEPRECATED_END +ov::OutputVector handle_opset6_binary_op(const ov::frontend::onnx::Node& node); /// \brief Creates a "dummy" constant to be used in place of an invalid initializer /// encountered in the original model. @@ -157,5 +156,6 @@ bool is_optimized_out(const ov::Output& node_output); /// \brief Collect unsupported operators after convert_partially and all exceptions from translation process. std::string collect_translation_exceptions(const std::shared_ptr& partially_converted); } // namespace common -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/utils/conv_factory.cpp b/src/frontends/onnx/frontend/src/utils/conv_factory.cpp index 730cf1fe8f0d3d..782924439a7e05 100644 --- a/src/frontends/onnx/frontend/src/utils/conv_factory.cpp +++ b/src/frontends/onnx/frontend/src/utils/conv_factory.cpp @@ -4,17 +4,17 @@ #include "utils/conv_factory.hpp" +#include "core/null_node.hpp" #include "exceptions.hpp" -#include "onnx_import/core/null_node.hpp" #include "openvino/op/group_conv.hpp" #include "openvino/op/util/attr_types.hpp" -#include "ov_models/ov_builders/reshape.hpp" #include "utils/conv_factory.hpp" #include "utils/convpool.hpp" #include "utils/reshape.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace conv_factory { std::shared_ptr make_ng_convolution(const ov::Output& data, const ov::Output& filters, @@ -45,5 +45,6 @@ std::shared_ptr make_ng_convolution(const ov::Output& data } } } // namespace conv_factory -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/utils/conv_factory.hpp b/src/frontends/onnx/frontend/src/utils/conv_factory.hpp index 849d90f7988bb1..bf3020d4256f1b 100644 --- a/src/frontends/onnx/frontend/src/utils/conv_factory.hpp +++ b/src/frontends/onnx/frontend/src/utils/conv_factory.hpp @@ -4,12 +4,13 @@ #pragma once -#include "onnx_import/core/node.hpp" +#include "core/node.hpp" #include "openvino/core/node.hpp" #include "openvino/op/op.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace conv_factory { std::shared_ptr make_ng_convolution(const ov::Output& data, const ov::Output& filters, @@ -20,5 +21,6 @@ std::shared_ptr make_ng_convolution(const ov::Output& data int64_t groups, const ov::op::PadType& auto_pad); } // namespace conv_factory -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/utils/convpool.cpp b/src/frontends/onnx/frontend/src/utils/convpool.cpp index 80e68dc2975530..b59fed54385e4f 100644 --- a/src/frontends/onnx/frontend/src/utils/convpool.cpp +++ b/src/frontends/onnx/frontend/src/utils/convpool.cpp @@ -17,14 +17,14 @@ using namespace ov; using namespace ov::op; +using ov::CoordinateDiff; -OPENVINO_SUPPRESS_DEPRECATED_START - -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace convpool { -Shape get_kernel_shape(const Node& node) { - const auto& data_shape = node.get_ng_inputs().at(0).get_partial_shape(); +ov::Shape get_kernel_shape(const Node& node) { + const auto& data_shape = node.get_ov_inputs().at(0).get_partial_shape(); const size_t input_spatial_dims = data_shape.rank().get_length() - 2; return node.get_attribute_value>("kernel_shape", std::vector(input_spatial_dims, 1UL)); } @@ -38,7 +38,7 @@ namespace { /// \return The attribute default value. /// std::vector get_attr_default_value(const Node& node, const std::string& attr_name) { - const auto data_rank = node.get_ng_inputs().at(0).get_partial_shape().rank(); + const auto data_rank = node.get_ov_inputs().at(0).get_partial_shape().rank(); CHECK_VALID_NODE(node, data_rank.is_static(), "If '", attr_name, "' is not provided data rank must be static."); const auto data_spatial_dims = data_rank.get_length() - 2; @@ -69,11 +69,11 @@ std::vector get_attribute_value(const Node& node, } } // namespace -Strides get_strides(const Node& node, const std::size_t kernel_rank) { +ov::Strides get_strides(const Node& node, const std::size_t kernel_rank) { return get_attribute_value(node, "strides", kernel_rank); } -Strides get_dilations(const Node& node, const std::size_t kernel_rank) { +ov::Strides get_dilations(const Node& node, const std::size_t kernel_rank) { return get_attribute_value(node, "dilations", kernel_rank); } @@ -126,17 +126,17 @@ std::pair get_pads(const Node& node, const size_ } std::pair get_pads(const Node& node) { - const auto data_rank = node.get_ng_inputs().at(0).get_partial_shape().rank(); + const auto data_rank = node.get_ov_inputs().at(0).get_partial_shape().rank(); CHECK_VALID_NODE(node, data_rank.is_static(), "The rank of node must be static in order to calculate pads"); const auto data_spatial_dims = data_rank.get_length() - 2; return get_pads(node, data_spatial_dims); } -void calculate_auto_pads(const Shape& data_shape, - const Shape& filter_shape, - const Strides& strides, - const Strides& dilations, +void calculate_auto_pads(const ov::Shape& data_shape, + const ov::Shape& filter_shape, + const ov::Strides& strides, + const ov::Strides& dilations, const ov::op::PadType& pad_type, CoordinateDiff& padding_below, CoordinateDiff& padding_above) { @@ -164,9 +164,9 @@ void calculate_auto_pads(const Shape& data_shape, } Output get_reshaped_filters(const Output& filters, int64_t groups) { - const auto zero_node = v0::Constant::create(ov::element::i64, Shape(), {0}); - const auto split_lengths = v0::Constant::create(ov::element::i64, Shape{2}, {1, -1}); - const auto groups_node = v0::Constant::create(ov::element::i64, Shape{1}, {groups}); + const auto zero_node = v0::Constant::create(ov::element::i64, ov::Shape(), {0}); + const auto split_lengths = v0::Constant::create(ov::element::i64, ov::Shape{2}, {1, -1}); + const auto groups_node = v0::Constant::create(ov::element::i64, ov::Shape{1}, {groups}); const auto filters_shape = std::make_shared(filters); const auto splitted_shape = std::make_shared(filters_shape, zero_node, split_lengths); @@ -180,7 +180,6 @@ Output get_reshaped_filters(const Output& filters, int64_t g return reshaped_filters; } } // namespace convpool -} // namespace onnx_import -} // namespace ngraph - -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/utils/convpool.hpp b/src/frontends/onnx/frontend/src/utils/convpool.hpp index 91ddad14c00fc6..052e63e7d15993 100644 --- a/src/frontends/onnx/frontend/src/utils/convpool.hpp +++ b/src/frontends/onnx/frontend/src/utils/convpool.hpp @@ -1,23 +1,22 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #pragma once -#include "onnx_import/core/node.hpp" -#include "openvino/core/deprecated.hpp" +#include "core/node.hpp" #include "openvino/core/shape.hpp" #include "openvino/core/strides.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace convpool { /// \brief Get shape of kernel (filter) in pixels. /// /// \param node The Node ptr representing Conv or Pool operation. /// \return The kernel Shape object representing its dimensions (height, width, depth). -Shape get_kernel_shape(const Node& node); +ov::Shape get_kernel_shape(const ov::frontend::onnx::Node& node); /// /// \brief Get number of pixels to stride operation by in each direction. @@ -27,7 +26,7 @@ Shape get_kernel_shape(const Node& node); /// /// \return The kernel Shape object representing its dimensions (height, width, /// depth). -Strides get_strides(const Node& node, const std::size_t kernel_rank = 0UL); +ov::Strides get_strides(const ov::frontend::onnx::Node& node, const std::size_t kernel_rank = 0UL); /// /// \brief Get number of pixels for filter dilation in each direction. @@ -35,16 +34,16 @@ Strides get_strides(const Node& node, const std::size_t kernel_rank = 0UL); /// \param[in] node The Node ptr representing ONNX operation. /// \param[in] kernel_rank The operator'skernel rank. /// -/// \return The Strides object containing number of pixels for filter dilation +/// \return The ov::Strides object containing number of pixels for filter dilation /// (height, width, depth). -Strides get_dilations(const Node& node, const std::size_t kernel_rank = 0UL); +ov::Strides get_dilations(const ov::frontend::onnx::Node& node, const std::size_t kernel_rank = 0UL); /// \brief Gets the 'ceil_mode' (rounding type) attribute value. /// /// \param[in] node The ONNX node we query for attribute. /// /// \return The OV RoundingType object representing 'ceil_mode' attribute value. -ov::op::RoundingType get_rounding_type(const Node& node); +ov::op::RoundingType get_rounding_type(const ov::frontend::onnx::Node& node); /// \brief Get padding values for the operation described by an ONNX node. /// \details Values are taken from the `pads` attribute. @@ -56,7 +55,8 @@ ov::op::RoundingType get_rounding_type(const Node& node); /// /// \return A pair of (padding_above, padding_below), which elements contains number of /// pixels to pad in respective dimensions (height, width, depth). -std::pair get_pads(const Node& node, const size_t kernel_rank); +std::pair get_pads(const ov::frontend::onnx::Node& node, + const size_t kernel_rank); /// \brief Get padding values for the operation described by an ONNX node. /// \details Values are taken from the `pads` attribute. @@ -67,7 +67,7 @@ std::pair get_pads(const Node& node, con /// /// \return A pair of (padding_above, padding_below), which elements contains number of /// pixels to pad in respective dimensions (height, width, depth). -std::pair get_pads(const Node& node); +std::pair get_pads(const ov::frontend::onnx::Node& node); /// /// \brief Calculate paddings with respect to auto_pad value. @@ -81,10 +81,10 @@ std::pair get_pads(const Node& node); /// \param[in,out] padding_above The paddings above axis. /// /// \see ov::op::PadType -void calculate_auto_pads(const Shape& data_shape, - const Shape& filter_shape, - const Strides& strides, - const Strides& dilations, +void calculate_auto_pads(const ov::Shape& data_shape, + const ov::Shape& filter_shape, + const ov::Strides& strides, + const ov::Strides& dilations, const ov::op::PadType& pad_type, ov::CoordinateDiff& padding_below, ov::CoordinateDiff& padding_above); @@ -95,7 +95,7 @@ void calculate_auto_pads(const Shape& data_shape, /// /// \return The OV PadType object representing 'auto_pad' attribute value. /// -ov::op::PadType get_auto_pad(const Node& node); +ov::op::PadType get_auto_pad(const ov::frontend::onnx::Node& node); /// \brief Reshape group convolution filters to match desired shape: /// from [C_INPUT x C_OUTPUT/groups x k1 x k2 x ... x kn] @@ -107,8 +107,6 @@ ov::op::PadType get_auto_pad(const Node& node); /// \return Reshaped filters input. ov::Output get_reshaped_filters(const ov::Output& filters, int64_t groups); } // namespace convpool - -} // namespace onnx_import - -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/utils/dft.cpp b/src/frontends/onnx/frontend/src/utils/dft.cpp index 24dae417e3ed1e..4b9702f54ba0b4 100644 --- a/src/frontends/onnx/frontend/src/utils/dft.cpp +++ b/src/frontends/onnx/frontend/src/utils/dft.cpp @@ -4,8 +4,7 @@ #include "dft.hpp" -#include "onnx_import/core/null_node.hpp" -#include "openvino/core/deprecated.hpp" +#include "core/null_node.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/constant.hpp" @@ -18,8 +17,9 @@ using namespace ov::op; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace dft { namespace { @@ -54,9 +54,8 @@ ov::Output make_dft(const ov::Output& signal, if (is_inversed || !is_onesided) { // skip for RDFT case conversion_to_complex_applied = try_convert_real_to_complex(processed_signal); } - OPENVINO_SUPPRESS_DEPRECATED_START + bool dft_length_provided = !ov::op::util::is_null(length); - OPENVINO_SUPPRESS_DEPRECATED_END ov::Output result; if (is_inversed) { @@ -83,5 +82,6 @@ ov::Output make_dft(const ov::Output& signal, return {result}; } } // namespace dft -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/utils/dft.hpp b/src/frontends/onnx/frontend/src/utils/dft.hpp index 6ab0b01580df43..4052b250635e6d 100644 --- a/src/frontends/onnx/frontend/src/utils/dft.hpp +++ b/src/frontends/onnx/frontend/src/utils/dft.hpp @@ -6,8 +6,9 @@ #include "openvino/core/node.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace dft { ov::Output make_dft(const ov::Output& signal, @@ -16,5 +17,6 @@ ov::Output make_dft(const ov::Output& signal, bool is_inversed, bool is_one_sided); } // namespace dft -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/utils/legacy_conversion_extension.hpp b/src/frontends/onnx/frontend/src/utils/legacy_conversion_extension.hpp deleted file mode 100644 index 75df0dffc933dd..00000000000000 --- a/src/frontends/onnx/frontend/src/utils/legacy_conversion_extension.hpp +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once -#include - -#include "openvino/frontend/extension/conversion.hpp" -#include "openvino/frontend/node_context.hpp" -#include "openvino/frontend/onnx/node_context.hpp" -#include "openvino/frontend/onnx/visibility.hpp" -#include "ops_bridge.hpp" - -namespace ngraph { -namespace onnx_import { -/// An extension holding its own copy of the OperatorsBridge which should only be used with legacy ONNX importer API -/// Having it here keeps the legacy API operational without interfering with the frontends API -class LegacyConversionExtension : public ov::frontend::ConversionExtensionBase { -public: - using Ptr = std::shared_ptr; - - LegacyConversionExtension() : ov::frontend::ConversionExtensionBase("") {} - - OperatorsBridge& ops_bridge() { - return m_legacy_ops_bridge; - } - - /// The legacy API entry point for registering custom operations globally (does not affect ONNX FE) - void register_operator(const std::string& name, int64_t version, const std::string& domain, Operator fn) { - std::lock_guard lock{m_mutex}; - m_legacy_ops_bridge.register_operator(name, version, domain, std::move(fn)); - } - - void unregister_operator(const std::string& name, int64_t version, const std::string& domain) { - std::lock_guard lock{m_mutex}; - m_legacy_ops_bridge.unregister_operator(name, version, domain); - } - -private: - std::mutex m_mutex; - OperatorsBridge m_legacy_ops_bridge; -}; -} // namespace onnx_import -} // namespace ngraph diff --git a/src/tests/ov_helpers/ov_models/ov_builders/src/norm.cpp b/src/frontends/onnx/frontend/src/utils/norm.cpp similarity index 60% rename from src/tests/ov_helpers/ov_models/ov_builders/src/norm.cpp rename to src/frontends/onnx/frontend/src/utils/norm.cpp index 7719443e4a8570..5de81d55fdb31e 100644 --- a/src/tests/ov_helpers/ov_models/ov_builders/src/norm.cpp +++ b/src/frontends/onnx/frontend/src/utils/norm.cpp @@ -1,8 +1,8 @@ -// Copyright (C) 2018-2022 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // -#include "ov_models/ov_builders/norm.hpp" +#include "utils/norm.hpp" #include "openvino/op/abs.hpp" #include "openvino/op/add.hpp" @@ -27,30 +27,30 @@ enum class BiasMode { MAX }; -std::shared_ptr lp_norm(const Output& value, - size_t p_norm, - const Output& reduction_axes, - float bias, - bool keep_dims) { +std::shared_ptr lp_norm(const Output& value, + size_t p_norm, + const Output& reduction_axes, + float bias, + bool keep_dims) { // In general "entrywise" lp-norm for matrix `A` is defined as following double // sum: // ||A||_p = ||vec(A)||_p = [sum_{i=1}^m sum_{j=1}^n abs(a_{i,j})^p]^{1/p} - std::shared_ptr abs_values{std::make_shared(value)}; - std::shared_ptr p_node = ov::op::v0::Constant::create(value.get_element_type(), Shape{}, {p_norm}); + std::shared_ptr abs_values{std::make_shared(value)}; + std::shared_ptr p_node = ov::op::v0::Constant::create(value.get_element_type(), Shape{}, {p_norm}); // Get inner part of equation: abs_values^p_node, then sum over reduction_axes. - std::shared_ptr values{std::make_shared(abs_values, p_node)}; + std::shared_ptr values{std::make_shared(abs_values, p_node)}; values = std::make_shared(values, reduction_axes, keep_dims); - std::shared_ptr bias_node{ov::op::v0::Constant::create(values->get_element_type(), Shape{}, {bias})}; + std::shared_ptr bias_node{ov::op::v0::Constant::create(values->get_element_type(), Shape{}, {bias})}; values = std::make_shared(values, bias_node); // Get outer part of equation: raise values to 1/p_norm exponent. - std::shared_ptr inv_p_node = + std::shared_ptr inv_p_node = ov::op::v0::Constant::create(values->get_element_type(), Shape{}, {1.f / p_norm}); - return {std::make_shared(values, inv_p_node)}; + return std::make_shared(values, inv_p_node); } /// \brief Calculates L-0 norm of input tensor. @@ -64,12 +64,14 @@ std::shared_ptr lp_norm(const Output& value, /// /// \return L-0 norm of value. The output sub-graph is composed of v1 ops. /// -std::shared_ptr l0_norm(const Output& value, const Output& reduction_axes, bool keep_dims) { +std::shared_ptr l0_norm(const Output& value, + const Output& reduction_axes, + bool keep_dims) { // L0 norm returns number of elements different from zero. - const std::shared_ptr zero_node{ov::op::v0::Constant::create(value.get_element_type(), Shape{}, {0.f})}; + const std::shared_ptr zero_node{ov::op::v0::Constant::create(value.get_element_type(), Shape{}, {0.f})}; // Convert bool values to input node data type. - const std::shared_ptr non_zero_values = + const std::shared_ptr non_zero_values = std::make_shared(std::make_shared(value, zero_node), value.get_element_type()); @@ -87,14 +89,15 @@ std::shared_ptr l0_norm(const Output& value, const Output& red /// /// \return L-1 norm of value. The output sub-graph is composed of v1 ops. /// -std::shared_ptr l1_norm(const Output& value, - const Output& reduction_axes, - float bias, - bool keep_dims) { - const std::shared_ptr values{ +std::shared_ptr l1_norm(const Output& value, + const Output& reduction_axes, + float bias, + bool keep_dims) { + const std::shared_ptr values{ std::make_shared(std::make_shared(value), reduction_axes, keep_dims)}; - const std::shared_ptr bias_node{ov::op::v0::Constant::create(values->get_element_type(), Shape{}, {bias})}; + const std::shared_ptr bias_node{ + ov::op::v0::Constant::create(values->get_element_type(), Shape{}, {bias})}; return std::make_shared(values, bias_node); } @@ -112,36 +115,33 @@ std::shared_ptr l1_norm(const Output& value, /// /// \return L-2 norm of value. The output sub-graph is composed of v1 ops. /// -std::shared_ptr l2_norm(const Output& value, - const Output& reduction_axes, - float bias, - BiasMode bias_mode, - bool keep_dims) { - std::shared_ptr pow = std::make_shared( +std::shared_ptr l2_norm(const Output& value, + const Output& reduction_axes, + float bias, + BiasMode bias_mode, + bool keep_dims) { + std::shared_ptr pow = std::make_shared( value, std::make_shared(value.get_element_type(), Shape{}, 2)); - std::shared_ptr values{std::make_shared(pow, reduction_axes, keep_dims)}; + std::shared_ptr values{std::make_shared(pow, reduction_axes, keep_dims)}; - std::shared_ptr bias_node{ov::op::v0::Constant::create(values->get_element_type(), Shape{}, {bias})}; - std::shared_ptr result; + std::shared_ptr bias_node{ov::op::v0::Constant::create(values->get_element_type(), Shape{}, {bias})}; switch (bias_mode) { case BiasMode::MAX: { - result = std::make_shared(std::make_shared(values, bias_node)); - break; + return std::make_shared(std::make_shared(values, bias_node)); } case BiasMode::ADD: default: - result = std::make_shared(std::make_shared(values, bias_node)); + return std::make_shared(std::make_shared(values, bias_node)); } - return result; } } // namespace -std::shared_ptr lp_norm(const Output& value, - const Output& reduction_axes, - size_t p_norm, - float bias, - bool keep_dims) { +std::shared_ptr lp_norm(const Output& value, + const Output& reduction_axes, + size_t p_norm, + float bias, + bool keep_dims) { // The number of non-zero elements if (p_norm == 0) { return l0_norm(value, reduction_axes, keep_dims); diff --git a/src/tests/ov_helpers/ov_models/ov_builders/include/ov_models/ov_builders/norm.hpp b/src/frontends/onnx/frontend/src/utils/norm.hpp similarity index 100% rename from src/tests/ov_helpers/ov_models/ov_builders/include/ov_models/ov_builders/norm.hpp rename to src/frontends/onnx/frontend/src/utils/norm.hpp diff --git a/src/frontends/onnx/frontend/src/utils/onnx_internal.cpp b/src/frontends/onnx/frontend/src/utils/onnx_internal.cpp index a478eef9f92f49..11c55e2251b7d6 100644 --- a/src/frontends/onnx/frontend/src/utils/onnx_internal.cpp +++ b/src/frontends/onnx/frontend/src/utils/onnx_internal.cpp @@ -7,16 +7,17 @@ #include #include "core/graph.hpp" +#include "core/null_node.hpp" #include "core/transform.hpp" #include "onnx_framework_node.hpp" -#include "onnx_import/core/null_node.hpp" #include "openvino/core/model.hpp" #include "openvino/util/file_util.hpp" using namespace ov; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace detail { namespace { void remove_dangling_parameters(std::shared_ptr& model) { @@ -30,7 +31,7 @@ void remove_dangling_parameters(std::shared_ptr& model) { std::all_of(parameter_users.begin(), parameter_users.end(), [](const std::shared_ptr& node) -> bool { - return std::dynamic_pointer_cast(node) != nullptr; + return std::dynamic_pointer_cast(node) != nullptr; }); if (is_dangling_parameter) { model->remove_parameter(parameter); @@ -46,9 +47,7 @@ void remove_dangling_results(std::shared_ptr& model) { const auto result_inputs = result->input_values(); const bool is_dangling_result = std::all_of(result_inputs.begin(), result_inputs.end(), [](const Output& node) -> bool { - OPENVINO_SUPPRESS_DEPRECATED_START return ov::op::util::is_null(node); - OPENVINO_SUPPRESS_DEPRECATED_END }); if (is_dangling_result) { model->remove_result(result); @@ -56,7 +55,7 @@ void remove_dangling_results(std::shared_ptr& model) { } } -void apply_transformations(ONNX_NAMESPACE::ModelProto& model_proto) { +void apply_transformations(ModelProto& model_proto) { transform::fixup_legacy_operators(model_proto); } @@ -68,10 +67,10 @@ void convert_decoded_model(std::shared_ptr model) { OPENVINO_ASSERT(it != rt_info.end(), "Could not find '" + std::string(ONNX_GRAPH_RT_ATTRIBUTE) + "' attribute in decoded model. Model probably wasn't created by FrontEnd::decode function."); - auto onnx_graph = it->second.as>(); + auto onnx_graph = it->second.as>(); for (const auto& node : model->get_ordered_ops()) { - if (auto raw_node = std::dynamic_pointer_cast(node)) { - if (auto subgraph_node = std::dynamic_pointer_cast(node)) { + if (auto raw_node = std::dynamic_pointer_cast(node)) { + if (auto subgraph_node = std::dynamic_pointer_cast(node)) { subgraph_node->infer_inputs_from_parent(); for (auto& model : subgraph_node->get_subgraph_models()) { convert_decoded_model(model); @@ -90,7 +89,7 @@ void convert_decoded_model(std::shared_ptr model) { detail::remove_dangling_results(model); } -std::shared_ptr import_onnx_model(std::shared_ptr model_proto, +std::shared_ptr import_onnx_model(std::shared_ptr model_proto, const std::string& model_path, detail::MappedMemoryHandles mmap_cache, ov::frontend::ExtensionHolder extensions) { @@ -102,7 +101,7 @@ std::shared_ptr import_onnx_model(std::shared_ptr decode_to_framework_nodes(std::shared_ptr model_proto, +std::shared_ptr decode_to_framework_nodes(std::shared_ptr model_proto, const std::string& model_path, detail::MappedMemoryHandles mmap_cache, ov::frontend::ExtensionHolder extensions) { @@ -114,5 +113,6 @@ std::shared_ptr decode_to_framework_nodes(std::shared_ptrdecode(); } } // namespace detail -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/utils/onnx_internal.hpp b/src/frontends/onnx/frontend/src/utils/onnx_internal.hpp index 8348313ca3f112..e6afa4b582cecc 100644 --- a/src/frontends/onnx/frontend/src/utils/onnx_internal.hpp +++ b/src/frontends/onnx/frontend/src/utils/onnx_internal.hpp @@ -9,16 +9,19 @@ #include "openvino/core/model.hpp" #include "openvino/frontend/extension/holder.hpp" -#include "utils/legacy_conversion_extension.hpp" #include "utils/tensor_external_data.hpp" namespace ONNX_NAMESPACE { class ModelProto; } -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace detail { + +using ::ONNX_NAMESPACE::ModelProto; + /// \brief Imports and converts an serialized ONNX model from a ModelProto /// to an ov::Model representation. /// @@ -34,7 +37,7 @@ namespace detail { /// \param extensions An object containing a collection of frontend extensions to use during the import process /// \return An ov::Model that represents a single output from the created /// graph. -std::shared_ptr import_onnx_model(std::shared_ptr model_proto, +std::shared_ptr import_onnx_model(std::shared_ptr model_proto, const std::string& model_path, detail::MappedMemoryHandles mmap_cache, ov::frontend::ExtensionHolder extensions = {}); @@ -47,7 +50,7 @@ std::shared_ptr import_onnx_model(std::shared_ptr decode_to_framework_nodes(std::shared_ptr model_proto, +std::shared_ptr decode_to_framework_nodes(std::shared_ptr model_proto, const std::string& model_path, detail::MappedMemoryHandles mmap_cache, ov::frontend::ExtensionHolder extensions = {}); @@ -56,10 +59,7 @@ std::shared_ptr decode_to_framework_nodes(std::shared_ptr model); -/// \brief Get the legacy conversion extension. -/// -/// \return const LegacyConversionExtension::Ptr -const LegacyConversionExtension::Ptr get_legacy_conversion_extension(); } // namespace detail -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/utils/pooling_factory.cpp b/src/frontends/onnx/frontend/src/utils/pooling_factory.cpp index 32a4ba1f1cbdb3..4a0afb5dce8e62 100644 --- a/src/frontends/onnx/frontend/src/utils/pooling_factory.cpp +++ b/src/frontends/onnx/frontend/src/utils/pooling_factory.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -6,6 +6,7 @@ #include +#include "openvino/core/coordinate_diff.hpp" #include "openvino/frontend/exception.hpp" #include "openvino/op/avg_pool.hpp" #include "openvino/op/constant.hpp" @@ -14,9 +15,11 @@ #include "utils/convpool.hpp" using namespace ov::op; +using ov::Shape; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace pooling { namespace { @@ -30,14 +33,13 @@ std::shared_ptr transposition_axis_order(const ov::Rank& input_ran std::iota(axes.begin(), axes.end(), 0); std::reverse(axes.begin() + 2, axes.end()); - return std::make_shared(ov::element::i32, Shape{rank}, axes); + return std::make_shared(ov::element::i32, ov::Shape{rank}, axes); } } // namespace -OPENVINO_SUPPRESS_DEPRECATED_START PoolingFactory::PoolingFactory(const Node& node) : m_onnx_node{node}, - m_inputs{node.get_ng_inputs()}, + m_inputs{node.get_ov_inputs()}, m_kernel_shape(node.get_attribute_value>("kernel_shape")), m_strides{convpool::get_strides(node, m_kernel_shape.size())}, m_dilations{convpool::get_dilations(node, m_kernel_shape.size())}, @@ -46,8 +48,8 @@ PoolingFactory::PoolingFactory(const Node& node) const auto paddings = convpool::get_pads(node, m_kernel_shape.size()); const ov::CoordinateDiff& padding_above{paddings.second}; const ov::CoordinateDiff& padding_below{paddings.first}; - m_padding_below = Shape{std::begin(padding_below), std::end(padding_below)}; - m_padding_above = Shape{std::begin(padding_above), std::end(padding_above)}; + m_padding_below = ov::Shape{std::begin(padding_below), std::end(padding_below)}; + m_padding_above = ov::Shape{std::begin(padding_above), std::end(padding_above)}; m_storage_order = static_cast(node.get_attribute_value("storage_order", 0)); } @@ -62,7 +64,6 @@ ov::OutputVector PoolingFactory::make_avg_pool() const { m_rounding_type, m_auto_pad)}; } -OPENVINO_SUPPRESS_DEPRECATED_END ov::OutputVector PoolingFactory::make_max_pool() const { return {std::make_shared(m_inputs.at(0), @@ -93,5 +94,6 @@ ov::OutputVector PoolingFactory::make_max_pool_with_indices() const { } } } // namespace pooling -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/utils/pooling_factory.hpp b/src/frontends/onnx/frontend/src/utils/pooling_factory.hpp index 6a2dc85553d6fe..452af29e6c159e 100644 --- a/src/frontends/onnx/frontend/src/utils/pooling_factory.hpp +++ b/src/frontends/onnx/frontend/src/utils/pooling_factory.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -7,16 +7,16 @@ #include #include -#include "onnx_import/core/node.hpp" -#include "openvino/core/deprecated.hpp" +#include "core/node.hpp" #include "openvino/core/node.hpp" #include "openvino/core/shape.hpp" #include "openvino/core/strides.hpp" #include "openvino/op/op.hpp" #include "openvino/op/util/attr_types.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace pooling { /// /// \brief Factory class which generates sub-graphs for ONNX 'regular' pooling @@ -30,10 +30,8 @@ namespace pooling { /// paddings, kernel shape and auto_pad type. class PoolingFactory { public: - OPENVINO_SUPPRESS_DEPRECATED_START explicit PoolingFactory(const Node& node); virtual ~PoolingFactory() = default; - OPENVINO_SUPPRESS_DEPRECATED_END /// /// \brief Creates average pooling ONNX operation. @@ -51,15 +49,14 @@ class PoolingFactory { ov::OutputVector make_max_pool_with_indices() const; protected: - OPENVINO_SUPPRESS_DEPRECATED_START Node m_onnx_node; - OPENVINO_SUPPRESS_DEPRECATED_END + const ov::OutputVector m_inputs; - Shape m_kernel_shape; - Strides m_strides; - Strides m_dilations; - Shape m_padding_below; - Shape m_padding_above; + ov::Shape m_kernel_shape; + ov::Strides m_strides; + ov::Strides m_dilations; + ov::Shape m_padding_below; + ov::Shape m_padding_above; ov::op::PadType m_auto_pad; ov::op::RoundingType m_rounding_type; @@ -68,5 +65,6 @@ class PoolingFactory { StorageOrder m_storage_order; }; } // namespace pooling -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/utils/recurrent.cpp b/src/frontends/onnx/frontend/src/utils/recurrent.cpp index ef2de919091876..f5c2b6d8098f3b 100644 --- a/src/frontends/onnx/frontend/src/utils/recurrent.cpp +++ b/src/frontends/onnx/frontend/src/utils/recurrent.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -8,7 +8,7 @@ #include #include -#include "onnx_import/core/null_node.hpp" +#include "core/null_node.hpp" #include "openvino/core/enum_names.hpp" #include "openvino/op/add.hpp" #include "openvino/op/broadcast.hpp" @@ -18,17 +18,18 @@ #include "openvino/op/multiply.hpp" #include "openvino/op/shape_of.hpp" #include "openvino/util/common_util.hpp" -#include "ov_models/ov_builders/reshape.hpp" -#include "ov_models/ov_builders/split.hpp" +#include "utils/reshape.hpp" +#include "utils/split.hpp" using namespace ov::op; +using ov::Shape; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace recurrent { -OpInputMap::OpInputMap(const onnx_import::Node& node, std::size_t gates_count) { - const auto& ng_inputs = node.get_ng_inputs(); +OpInputMap::OpInputMap(const ov::frontend::onnx::Node& node, std::size_t gates_count) { + const auto& ng_inputs = node.get_ov_inputs(); m_map[OpInput::X] = ov::op::util::reorder_axes(ng_inputs.at(0), {1, 0, 2}); m_map[OpInput::W] = ng_inputs.at(1); @@ -40,33 +41,33 @@ OpInputMap::OpInputMap(const onnx_import::Node& node, std::size_t gates_count) { // Get dimensions needed for default inputs creation auto shape_of_x = std::make_shared(m_map[OpInput::X]); - auto axes = v0::Constant::create(ov::element::i32, Shape{1}, {0}); + auto axes = v0::Constant::create(ov::element::i32, ov::Shape{1}, {0}); auto batch_size_node = - std::make_shared(shape_of_x, v0::Constant::create(ov::element::i32, Shape{1}, {0}), axes); + std::make_shared(shape_of_x, v0::Constant::create(ov::element::i32, ov::Shape{1}, {0}), axes); auto seq_length_node = - std::make_shared(shape_of_x, v0::Constant::create(ov::element::i32, Shape{1}, {1}), axes); + std::make_shared(shape_of_x, v0::Constant::create(ov::element::i32, ov::Shape{1}, {1}), axes); auto shape_of_r = std::make_shared(m_map[OpInput::R]); auto num_directions_node = - std::make_shared(shape_of_r, v0::Constant::create(ov::element::i32, Shape{1}, {0}), axes); + std::make_shared(shape_of_r, v0::Constant::create(ov::element::i32, ov::Shape{1}, {0}), axes); auto hidden_size_node = - std::make_shared(shape_of_r, v0::Constant::create(ov::element::i32, Shape{1}, {2}), axes); + std::make_shared(shape_of_r, v0::Constant::create(ov::element::i32, ov::Shape{1}, {2}), axes); // ------ Optional inputs ------ if (ng_inputs.size() > 3 && !ov::op::util::is_null(ng_inputs.at(3))) { auto bias = ng_inputs.at(3); - auto split_bias = ov::op::util::split(bias, 2, 1); + auto split_bias = ov::op::util::make_split(bias, 2, 1); m_map[OpInput::B] = std::make_shared(split_bias.at(0), split_bias.at(1)); } else { auto b_shape = std::make_shared( - ov::OutputVector{ - num_directions_node, - std::make_shared(v0::Constant::create(ov::element::Type_t::i64, Shape{1}, {gates_count}), - hidden_size_node)}, + ov::OutputVector{num_directions_node, + std::make_shared( + v0::Constant::create(ov::element::Type_t::i64, ov::Shape{1}, {gates_count}), + hidden_size_node)}, 0); - m_map[OpInput::B] = - std::make_shared(v0::Constant::create(m_map[OpInput::X].get_element_type(), Shape{}, {0}), - b_shape); + m_map[OpInput::B] = std::make_shared( + v0::Constant::create(m_map[OpInput::X].get_element_type(), ov::Shape{}, {0}), + b_shape); } if (ng_inputs.size() > 4 && !ov::op::util::is_null(ng_inputs.at(4))) { m_map[OpInput::SEQ_LENGTHS] = ng_inputs.at(4); @@ -79,9 +80,9 @@ OpInputMap::OpInputMap(const onnx_import::Node& node, std::size_t gates_count) { } else { auto init_h_shape = std::make_shared(ov::OutputVector{batch_size_node, num_directions_node, hidden_size_node}, 0); - m_map[OpInput::INIT_H] = - std::make_shared(v0::Constant::create(m_map[OpInput::X].get_element_type(), Shape{}, {0}), - init_h_shape); + m_map[OpInput::INIT_H] = std::make_shared( + v0::Constant::create(m_map[OpInput::X].get_element_type(), ov::Shape{}, {0}), + init_h_shape); } } @@ -114,6 +115,6 @@ OpAttributes::OpAttributes(const Node& node) } } // namespace recurrent -} // namespace onnx_import -} // namespace ngraph -OPENVINO_SUPPRESS_DEPRECATED_END +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/utils/recurrent.hpp b/src/frontends/onnx/frontend/src/utils/recurrent.hpp index f57399bf22f6dc..a40a75a7e5100d 100644 --- a/src/frontends/onnx/frontend/src/utils/recurrent.hpp +++ b/src/frontends/onnx/frontend/src/utils/recurrent.hpp @@ -8,13 +8,13 @@ #include #include -#include "onnx_import/core/node.hpp" -#include "openvino/core/deprecated.hpp" +#include "core/node.hpp" #include "openvino/core/node.hpp" #include "openvino/op/util/attr_types.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace recurrent { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ INPUT NODES PARSING ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -41,9 +41,8 @@ enum class OpInput { struct OpInputMap { using container_type = std::map>; - OPENVINO_SUPPRESS_DEPRECATED_START - explicit OpInputMap(const onnx_import::Node& node, std::size_t gates_count); - OPENVINO_SUPPRESS_DEPRECATED_END + explicit OpInputMap(const ov::frontend::onnx::Node& node, std::size_t gates_count); + OpInputMap(container_type&& map); virtual ~OpInputMap() = default; @@ -59,9 +58,8 @@ struct OpInputMap { /// \brief This structure aggregates operator's attributes. /// struct OpAttributes { - OPENVINO_SUPPRESS_DEPRECATED_START explicit OpAttributes(const Node& node); - OPENVINO_SUPPRESS_DEPRECATED_END + virtual ~OpAttributes() = default; ov::op::RecurrentSequenceDirection m_direction; @@ -73,5 +71,6 @@ struct OpAttributes { }; } // namespace recurrent -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/utils/reshape.cpp b/src/frontends/onnx/frontend/src/utils/reshape.cpp index 36f051cc399e13..35c8efbbf941c5 100644 --- a/src/frontends/onnx/frontend/src/utils/reshape.cpp +++ b/src/frontends/onnx/frontend/src/utils/reshape.cpp @@ -1,8 +1,8 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // -#include "ov_models/ov_builders/reshape.hpp" +#include "utils/reshape.hpp" #include #include @@ -10,19 +10,28 @@ #include #include "openvino/frontend/exception.hpp" +#include "openvino/op/add.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/constant.hpp" +#include "openvino/op/convert.hpp" +#include "openvino/op/range.hpp" +#include "openvino/op/reduce_prod.hpp" #include "openvino/op/reshape.hpp" #include "openvino/op/shape_of.hpp" +#include "openvino/op/squeeze.hpp" +#include "openvino/op/strided_slice.hpp" #include "openvino/op/subtract.hpp" +#include "openvino/op/transpose.hpp" #include "openvino/op/util/op_types.hpp" -#include "utils/reshape.hpp" +#include "openvino/op/variadic_split.hpp" using namespace ov::op; +using ov::Shape; -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace reshape { std::vector infer_dimensions(const std::string& node_name, const std::vector& input_shape, @@ -71,7 +80,7 @@ std::vector infer_dimensions(const std::string& node_name, } ov::Output interpret_as_scalar(const ov::Output& node) { - Shape node_shape = node.get_shape(); + ov::Shape node_shape = node.get_shape(); // If node is already a scalar, return original if (is_scalar(node_shape)) { @@ -82,20 +91,20 @@ ov::Output interpret_as_scalar(const ov::Output& node) { "Scalar value can't be derived from a node with ", node_shape); - // If node is a Constant, recreate as Constant with Shape{} + // If node is a Constant, recreate as Constant with ov::Shape{} if (ov::op::util::is_constant(node.get_node())) { const auto value = ov::as_type_ptr(node.get_node_shared_ptr())->get_data_ptr(); return std::make_shared(node.get_element_type(), ov::Shape{}, value); } - return ov::op::util::reshape(node, Shape{}); + return ov::op::util::reshape(node, ov::Shape{}); } ov::Output reshape_channel_shaped_node_to_nchw(const ov::Output& node, const ov::Output& expected_rank) { // Prepare tail shape (rank = conv.rank - 2): [1, 1, 1, 1, ... ] - const auto one_const = v0::Constant::create(ov::element::i64, Shape{1}, {1}); - const auto two_const = v0::Constant::create(ov::element::i64, Shape{1}, {2}); + const auto one_const = v0::Constant::create(ov::element::i64, ov::Shape{1}, {1}); + const auto two_const = v0::Constant::create(ov::element::i64, ov::Shape{1}, {2}); const auto tail_shape_rank = std::make_shared(expected_rank, two_const); const auto tail_shape = std::make_shared(one_const, tail_shape_rank); @@ -107,5 +116,110 @@ ov::Output reshape_channel_shaped_node_to_nchw(const ov::Output reshape(const Output& value, const Shape& shape) { + if (value.get_partial_shape().same_scheme(shape)) { + return value.get_node_shared_ptr(); + } else if (is_scalar(shape)) { + auto value_rank = value.get_shape().size(); + AxisVector axes_vector(value_rank); + std::iota(axes_vector.begin(), axes_vector.end(), 0); + auto axes = ov::op::v0::Constant::create(ov::element::i64, Shape{value_rank}, axes_vector); + return std::make_shared(value, axes); + } else { + auto out_pattern = ov::op::v0::Constant::create(ov::element::i64, + Shape{shape.size()}, + std::vector(shape.begin(), shape.end())); + + return std::make_shared(value, out_pattern, false); + } +} + +std::shared_ptr reorder_axes(const Output& value, std::vector axes_order) { + const auto axes_order_const = + ov::op::v0::Constant::create(ov::element::i64, + Shape{axes_order.size()}, + std::vector(axes_order.begin(), axes_order.end())); + return std::make_shared(value, axes_order_const); +} + +std::shared_ptr transpose(const Output& value) { + // This part is left to preserve backward compatibility and ensure passing ONNX tests. + if (value.get_partial_shape().is_static()) { + std::vector axes_order(value.get_shape().size()); + std::iota(begin(axes_order), end(axes_order), 0); + std::reverse(begin(axes_order), end(axes_order)); + return reorder_axes(value, axes_order); + } + + const auto input_rank = std::make_shared(std::make_shared(value)); + const auto neg_one = ov::op::v0::Constant::create(ov::element::i64, Shape{}, {-1}); + const auto start_node = std::make_shared(input_rank, neg_one); + const auto reverse_axes_order = std::make_shared(reshape(start_node, Shape{}), // start + neg_one, // stop (exclusive) + neg_one); // step + return std::make_shared(value, reverse_axes_order); +} + +namespace { +/// +/// \brief Return the node representing normalized axis with respect to +/// provided rank. +/// +/// \param[in] node_rank The node representing rank used for normalization. +/// \param[in] axis The axis value to be normalized. +/// +/// \return The new Constant node representing normalized axis value. +/// +std::shared_ptr get_normalized_axis_node(const std::shared_ptr node_rank, int64_t axis) { + auto axis_node = ov::op::v0::Constant::create(ov::element::i64, Shape{1}, {axis}); + // shortcut for already positive value + if (axis >= 0) { + return axis_node; + } + + // TODO: What if axis value is beyond acceptable values? [-node_rank, + // node_rank-1] + return std::make_shared(node_rank, axis_node); +} +} // namespace + +std::shared_ptr flatten(const Output& value, int axis) { + // First dimension of output tensor is the product of [d_0, ... d_{axis-1}] dimensions of + // input tensor. The last dimension is the product of the rest of input tensor dimensions: + // [d_{axis}, ..., d_n] + std::shared_ptr output_shape; + if (axis == 0) { + output_shape = ov::op::v0::Constant::create(ov::element::i64, Shape{2}, {1, -1}); + } else if (axis == 1) { + output_shape = ov::op::v0::Constant::create(ov::element::i64, Shape{2}, {0, -1}); + } else { + const auto value_shape = std::make_shared(value); + const auto value_rank = std::make_shared(value_shape); + const auto axis_node = get_normalized_axis_node(value_rank, axis); + + const auto first_part_dims = + std::make_shared(value_shape, + ov::op::v0::Constant::create(ov::element::i64, {1}, {0}), + axis_node, + std::vector{0}, + std::vector{0}); + const auto first_part_dims_length = + std::make_shared(first_part_dims, + ov::op::v0::Constant::create(ov::element::i64, {}, {0}), + true); + + const auto remaining_part_length = ov::op::v0::Constant::create(ov::element::i64, {1}, {-1}); + + output_shape = + std::make_shared(ov::OutputVector{first_part_dims_length, remaining_part_length}, 0); + } + return std::make_shared(value, output_shape, true); +} +} // namespace util +} // namespace op +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/utils/reshape.hpp b/src/frontends/onnx/frontend/src/utils/reshape.hpp index 198696310cb72c..1000f52c4e4d7d 100644 --- a/src/frontends/onnx/frontend/src/utils/reshape.hpp +++ b/src/frontends/onnx/frontend/src/utils/reshape.hpp @@ -11,8 +11,9 @@ #include "openvino/core/node.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace reshape { /// \brief Infer `output_shape` dimension values. /// @@ -61,5 +62,42 @@ ov::Output reshape_channel_shaped_node_to_nchw(const ov::Output& expected_rank); } // namespace reshape -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend + +namespace op { +namespace util { +/// \brief Change shape of a value +/// +/// \param[in] value The value to be reshaped. +/// \param[in] shape The new shape. +/// +/// \return Reshape:v1 op. +std::shared_ptr reshape(const Output& value, const Shape& shape); + +/// \brief Permute axes according to specified axes_order parameter. +/// +/// \param The vlaue whose axes we want to permute. +/// \param axes_order The permutation of axes. +/// +/// \return Transpose:v1 op. +std::shared_ptr reorder_axes(const Output& value, std::vector axes_order = {}); + +/// \brief Return transposed value (with axes in reversed order). +/// +/// \param Value to transpose. +/// +/// \return Transpose:v1 op. +std::shared_ptr transpose(const Output& value); + +/// \brief Flatten a value into a 2D matrix, with a static dividing axis. +/// +/// \param The tensor to be flattened. +/// \param The axis dividing shape. +/// +/// \return The new value will be a 2D matrix representing the flattened input +/// node. +std::shared_ptr flatten(const Output& value, int axis); +} // namespace util +} // namespace op +} // namespace ov diff --git a/src/tests/ov_helpers/ov_models/ov_builders/src/split.cpp b/src/frontends/onnx/frontend/src/utils/split.cpp similarity index 75% rename from src/tests/ov_helpers/ov_models/ov_builders/src/split.cpp rename to src/frontends/onnx/frontend/src/utils/split.cpp index 3a154ecb4f55ca..eab597930eaaa8 100644 --- a/src/tests/ov_helpers/ov_models/ov_builders/src/split.cpp +++ b/src/frontends/onnx/frontend/src/utils/split.cpp @@ -1,8 +1,8 @@ -// Copyright (C) 2018-2022 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // -#include "ov_models/ov_builders/split.hpp" +#include "utils/split.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/split.hpp" @@ -11,7 +11,7 @@ namespace ov { namespace op { namespace util { -OutputVector split(const Output& value, const std::vector& split_lengths, int64_t axis) { +OutputVector make_split(const Output& value, const std::vector& split_lengths, int64_t axis) { const auto axis_node = ov::op::v0::Constant::create(ov::element::i64, Shape{}, {axis}); const auto split_lengths_node = ov::op::v0::Constant::create(ov::element::i64, Shape{split_lengths.size()}, split_lengths); @@ -20,7 +20,7 @@ OutputVector split(const Output& value, const std::vector& split_ return variadic_split->outputs(); } -OutputVector split(const Output& value, int64_t num_splits, int64_t axis) { +OutputVector make_split(const Output& value, int64_t num_splits, int64_t axis) { const auto axis_node = ov::op::v0::Constant::create(ov::element::i64, Shape{}, {axis}); const auto split = std::make_shared(value, axis_node, num_splits); diff --git a/src/tests/ov_helpers/ov_models/ov_builders/include/ov_models/ov_builders/split.hpp b/src/frontends/onnx/frontend/src/utils/split.hpp similarity index 89% rename from src/tests/ov_helpers/ov_models/ov_builders/include/ov_models/ov_builders/split.hpp rename to src/frontends/onnx/frontend/src/utils/split.hpp index d08b1da3aaf4a5..5cdbaf287eb90b 100644 --- a/src/tests/ov_helpers/ov_models/ov_builders/include/ov_models/ov_builders/split.hpp +++ b/src/frontends/onnx/frontend/src/utils/split.hpp @@ -21,7 +21,7 @@ namespace util { /// \return The vector containing multiple outputs we split input node into. /// The vector is output of Split:v1 op /// -ov::OutputVector split(const Output& value, const std::vector& split_lengths, int64_t axis = 0); +ov::OutputVector make_split(const Output& value, const std::vector& split_lengths, int64_t axis = 0); /// \brief Split value on specified axis into multiple parts. /// @@ -39,7 +39,7 @@ ov::OutputVector split(const Output& value, const std::vector& sp /// \return The vector containing multiple nodes we split input node into. /// The vector is output of VariadicSplit:v1 op /// -ov::OutputVector split(const Output& value, int64_t num_splits, int64_t axis = 0); +ov::OutputVector make_split(const Output& value, int64_t num_splits, int64_t axis = 0); } // namespace util } // namespace op } // namespace ov diff --git a/src/frontends/onnx/frontend/src/utils/tensor_external_data.cpp b/src/frontends/onnx/frontend/src/utils/tensor_external_data.cpp index d96f354c65e1c5..677b2d63fb9342 100644 --- a/src/frontends/onnx/frontend/src/utils/tensor_external_data.cpp +++ b/src/frontends/onnx/frontend/src/utils/tensor_external_data.cpp @@ -11,10 +11,11 @@ #include "openvino/util/file_util.hpp" #include "openvino/util/log.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace detail { -TensorExternalData::TensorExternalData(const ONNX_NAMESPACE::TensorProto& tensor) { +TensorExternalData::TensorExternalData(const TensorProto& tensor) { for (const auto& entry : tensor.external_data()) { if (entry.key() == "location") { m_data_location = ov::util::sanitize_path(entry.value()); @@ -103,5 +104,6 @@ std::string TensorExternalData::to_string() const { return s.str(); } } // namespace detail -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/utils/tensor_external_data.hpp b/src/frontends/onnx/frontend/src/utils/tensor_external_data.hpp index eb04e001e7ed4c..28a8860007d0c3 100644 --- a/src/frontends/onnx/frontend/src/utils/tensor_external_data.hpp +++ b/src/frontends/onnx/frontend/src/utils/tensor_external_data.hpp @@ -10,16 +10,18 @@ #include "openvino/runtime/shared_buffer.hpp" #include "openvino/util/mmap_object.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace detail { +using ::ONNX_NAMESPACE::TensorProto; template using Buffer = std::shared_ptr>>; using MappedMemoryHandles = std::shared_ptr>>; /// \brief Helper class used to load tensor data from external files class TensorExternalData { public: - TensorExternalData(const ONNX_NAMESPACE::TensorProto& tensor); + TensorExternalData(const TensorProto& tensor); /// \brief Load external data from tensor passed to constructor /// @@ -51,5 +53,6 @@ class TensorExternalData { std::string m_sha1_digest{}; }; } // namespace detail -} // namespace onnx_import -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/src/utils/variadic.hpp b/src/frontends/onnx/frontend/src/utils/variadic.hpp index 751c4c3cffb550..5f5dd373615b52 100644 --- a/src/frontends/onnx/frontend/src/utils/variadic.hpp +++ b/src/frontends/onnx/frontend/src/utils/variadic.hpp @@ -6,12 +6,12 @@ #include -#include "onnx_import/core/node.hpp" -#include "openvino/core/deprecated.hpp" +#include "core/node.hpp" #include "utils/common.hpp" -namespace ngraph { -namespace onnx_import { +namespace ov { +namespace frontend { +namespace onnx { namespace variadic { /// \brief Create an OpenVINO version of an ONNX variadic operation. /// This creates a subgraph with a series of binary operations. @@ -21,12 +21,12 @@ namespace variadic { /// \tparam T Class of an OpenVINO binary operation (e.g. Add, Minimum, Maximum) /// /// \return OpenVINO node equivalent of the ONNX operation -OPENVINO_SUPPRESS_DEPRECATED_START + template inline ov::OutputVector make_ng_variadic_op( const Node& node, const ov::op::AutoBroadcastSpec& auto_broadcast = ov::op::AutoBroadcastType::NUMPY) { - const ov::OutputVector ng_inputs{node.get_ng_inputs()}; + const ov::OutputVector ng_inputs{node.get_ov_inputs()}; // Templated binary operation - Creates Add, Minimum, Maximum, etc. const auto binary_operation = [&auto_broadcast](const ov::Output& arg0, @@ -46,10 +46,8 @@ inline ov::OutputVector make_ng_variadic_op( return {result}; } -OPENVINO_SUPPRESS_DEPRECATED_END } // namespace variadic - -} // namespace onnx_import - -} // namespace ngraph +} // namespace onnx +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/onnx_common/include/onnx_common/utils.hpp b/src/frontends/onnx/onnx_common/include/onnx_common/utils.hpp index 62df90c9e7a05b..a26346945dd24b 100644 --- a/src/frontends/onnx/onnx_common/include/onnx_common/utils.hpp +++ b/src/frontends/onnx/onnx_common/include/onnx_common/utils.hpp @@ -10,7 +10,9 @@ namespace ov { namespace frontend { namespace onnx { namespace common { -using namespace ::ONNX_NAMESPACE; +using ::ONNX_NAMESPACE::TensorProto_DataType; +using ::ONNX_NAMESPACE::TensorShapeProto; + /// \brief Retuns size of an ONNX data type in bytes. /// /// \param onnx_type Number assigned to an ONNX data type in the TensorProto_DataType enum. diff --git a/src/frontends/onnx/onnx_common/src/utils.cpp b/src/frontends/onnx/onnx_common/src/utils.cpp index 725826ba95a23b..9b7977fccdadd5 100644 --- a/src/frontends/onnx/onnx_common/src/utils.cpp +++ b/src/frontends/onnx/onnx_common/src/utils.cpp @@ -4,12 +4,10 @@ #include "onnx_common/utils.hpp" -#include - -#include - #include "openvino/core/except.hpp" +using namespace ::ONNX_NAMESPACE; + namespace ov { namespace frontend { namespace onnx { @@ -49,8 +47,6 @@ size_t get_onnx_data_size(int32_t onnx_type) { } OPENVINO_THROW("unsupported element type"); } -namespace { -using namespace ONNX_NAMESPACE; const std::map OV_2_ONNX_TYPES = { {ov::element::Type_t::bf16, TensorProto_DataType::TensorProto_DataType_BFLOAT16}, {ov::element::Type_t::f16, TensorProto_DataType::TensorProto_DataType_FLOAT16}, @@ -65,7 +61,6 @@ const std::map OV_2_ONNX_TYPES = { {ov::element::Type_t::u32, TensorProto_DataType::TensorProto_DataType_UINT32}, {ov::element::Type_t::u64, TensorProto_DataType::TensorProto_DataType_UINT64}, {ov::element::Type_t::boolean, TensorProto_DataType::TensorProto_DataType_BOOL}}; -} // namespace ov::element::Type_t onnx_to_ov_data_type(const TensorProto_DataType& onnx_type) { const auto result = std::find_if(OV_2_ONNX_TYPES.begin(), diff --git a/src/frontends/onnx/tests/onnx_editor.cpp b/src/frontends/onnx/tests/onnx_editor.cpp index 2dad30685b3f19..17bd717ce4cd58 100644 --- a/src/frontends/onnx/tests/onnx_editor.cpp +++ b/src/frontends/onnx/tests/onnx_editor.cpp @@ -29,9 +29,9 @@ InputTypePred element_type_is(const ov::element::Type et) { }; } -std::shared_ptr find_input(const ParameterVector& inputs, const std::string& name) { +std::shared_ptr find_input(const ov::ParameterVector& inputs, const std::string& name) { const auto input_pos = - std::find_if(std::begin(inputs), std::end(inputs), [&name](const ParameterVector::value_type i) { + std::find_if(std::begin(inputs), std::end(inputs), [&name](const ov::ParameterVector::value_type i) { return i->get_friendly_name() == name; }); diff --git a/src/frontends/onnx/tests/onnx_import_org_openvino.in.cpp b/src/frontends/onnx/tests/onnx_import_org_openvino.in.cpp index 28814dd17b3efa..cba2f57bcc535d 100644 --- a/src/frontends/onnx/tests/onnx_import_org_openvino.in.cpp +++ b/src/frontends/onnx/tests/onnx_import_org_openvino.in.cpp @@ -30,8 +30,6 @@ #include "common_test_utils/test_tools.hpp" #include "common_test_utils/type_prop.hpp" #include "gtest/gtest.h" -#include "onnx_import/core/null_node.hpp" -#include "onnx_import/onnx_utils.hpp" #include "onnx_utils.hpp" using namespace ov; diff --git a/src/frontends/onnx/tests/onnx_reader_external_data.cpp b/src/frontends/onnx/tests/onnx_reader_external_data.cpp index 6a501a38a93d88..128dc1a86ba1f7 100644 --- a/src/frontends/onnx/tests/onnx_reader_external_data.cpp +++ b/src/frontends/onnx/tests/onnx_reader_external_data.cpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // -#include #include #include diff --git a/src/frontends/onnx/tests/onnx_tensor_names.cpp b/src/frontends/onnx/tests/onnx_tensor_names.cpp index fcfef4c386f1bf..e64e8b57129a59 100644 --- a/src/frontends/onnx/tests/onnx_tensor_names.cpp +++ b/src/frontends/onnx/tests/onnx_tensor_names.cpp @@ -6,7 +6,6 @@ #include "common_test_utils/test_case.hpp" #include "common_test_utils/test_control.hpp" #include "gtest/gtest.h" -#include "onnx_import/onnx_utils.hpp" #include "onnx_utils.hpp" #include "openvino/op/abs.hpp" #include "openvino/op/convolution.hpp" diff --git a/src/frontends/onnx/tests/op_extension.cpp b/src/frontends/onnx/tests/op_extension.cpp index fa9f8dce7a0860..7f06fdfc534439 100644 --- a/src/frontends/onnx/tests/op_extension.cpp +++ b/src/frontends/onnx/tests/op_extension.cpp @@ -5,7 +5,6 @@ #include "op_extension.hpp" #include "common_test_utils/file_utils.hpp" -#include "onnx_import/onnx_utils.hpp" #include "onnx_utils.hpp" #include "openvino/core/so_extension.hpp" #include "openvino/frontend/extension/op.hpp" diff --git a/src/frontends/onnx/tests/tests_python/model_zoo_preprocess.ps1 b/src/frontends/onnx/tests/tests_python/model_zoo_preprocess.ps1 index d9f85a67f2e202..c57d9f309f0e96 100644 --- a/src/frontends/onnx/tests/tests_python/model_zoo_preprocess.ps1 +++ b/src/frontends/onnx/tests/tests_python/model_zoo_preprocess.ps1 @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 # default ONNX Model Zoo commit hash ID: -$ONNX_SHA="d58213534f2a4d1c4b19ba62b3bb5f544353256e".Substring(0, 8) +$ONNX_SHA="5faef4c33eba0395177850e1e31c4a6a9e634c82".Substring(0, 8) $MODELS_DIR="." $ENABLE_ONNX_MODELS_ZOO=$false $ENABLE_MSFT_MODELS=$false diff --git a/src/frontends/onnx/tests/tests_python/model_zoo_preprocess.sh b/src/frontends/onnx/tests/tests_python/model_zoo_preprocess.sh index 19e0dec1577aa1..b101a4c86f4524 100755 --- a/src/frontends/onnx/tests/tests_python/model_zoo_preprocess.sh +++ b/src/frontends/onnx/tests/tests_python/model_zoo_preprocess.sh @@ -6,7 +6,7 @@ set -e # default ONNX Model Zoo commit hash ID: -ONNX_SHA=d58213534f2a4d1c4b19ba62b3bb5f544353256e +ONNX_SHA=5faef4c33eba0395177850e1e31c4a6a9e634c82 MODELS_DIR="$HOME/.onnx/model_zoo" ENABLE_ONNX_MODELS_ZOO=false diff --git a/src/frontends/onnx/tests/tests_python/test_backend.py b/src/frontends/onnx/tests/tests_python/test_backend.py index 3f59e94c3f3bd1..381e8ce547c7a3 100644 --- a/src/frontends/onnx/tests/tests_python/test_backend.py +++ b/src/frontends/onnx/tests/tests_python/test_backend.py @@ -363,25 +363,6 @@ def expect_fail(test_case_path, xfail): # type: (str) -> None "OnnxBackendNodeModelTest.test_sce_NCd1d2d3d4d5_mean_weight_log_prob_cpu", # ticket: 81976 "OnnxBackendNodeModelTest.test_sce_NCd1d2d3d4d5_none_no_weight_cpu", # ticket: 81976 "OnnxBackendNodeModelTest.test_sce_NCd1d2d3d4d5_none_no_weight_log_prob_cpu", # ticket: 81976 - "OnnxBackendNodeModelTest.test_layer_normalization_2d_axis0_cpu", # ticket: 90649 - "OnnxBackendNodeModelTest.test_layer_normalization_2d_axis1_cpu", # ticket: 90649 - "OnnxBackendNodeModelTest.test_layer_normalization_2d_axis_negative_1_cpu", # ticket: 90649 - "OnnxBackendNodeModelTest.test_layer_normalization_2d_axis_negative_2_cpu", # ticket: 90649 - "OnnxBackendNodeModelTest.test_layer_normalization_3d_axis0_epsilon_cpu", # ticket: 90649 - "OnnxBackendNodeModelTest.test_layer_normalization_3d_axis1_epsilon_cpu", # ticket: 90649 - "OnnxBackendNodeModelTest.test_layer_normalization_3d_axis2_epsilon_cpu", # ticket: 90649 - "OnnxBackendNodeModelTest.test_layer_normalization_3d_axis_negative_1_epsilon_cpu", # ticket: 90649 - "OnnxBackendNodeModelTest.test_layer_normalization_3d_axis_negative_2_epsilon_cpu", # ticket: 90649 - "OnnxBackendNodeModelTest.test_layer_normalization_3d_axis_negative_3_epsilon_cpu", # ticket: 90649 - "OnnxBackendNodeModelTest.test_layer_normalization_4d_axis0_cpu", # ticket: 90649 - "OnnxBackendNodeModelTest.test_layer_normalization_4d_axis1_cpu", # ticket: 90649 - "OnnxBackendNodeModelTest.test_layer_normalization_4d_axis2_cpu", # ticket: 90649 - "OnnxBackendNodeModelTest.test_layer_normalization_4d_axis3_cpu", # ticket: 90649 - "OnnxBackendNodeModelTest.test_layer_normalization_4d_axis_negative_1_cpu", # ticket: 90649 - "OnnxBackendNodeModelTest.test_layer_normalization_4d_axis_negative_2_cpu", # ticket: 90649 - "OnnxBackendNodeModelTest.test_layer_normalization_4d_axis_negative_3_cpu", # ticket: 90649 - "OnnxBackendNodeModelTest.test_layer_normalization_4d_axis_negative_4_cpu", # ticket: 90649 - "OnnxBackendNodeModelTest.test_layer_normalization_default_axis_cpu", # ticket: 90649 ), ( xfail_issue_81976, # SoftmaxCrossEntropyLoss operator diff --git a/src/frontends/paddle/src/input_model.cpp b/src/frontends/paddle/src/input_model.cpp index 1cba2924d81873..ef361aa683e07a 100644 --- a/src/frontends/paddle/src/input_model.cpp +++ b/src/frontends/paddle/src/input_model.cpp @@ -48,8 +48,8 @@ class InputModel::InputModelImpl { void set_partial_shape(Place::Ptr place, const ov::PartialShape&); ov::PartialShape get_partial_shape(Place::Ptr place) const; void set_element_type(Place::Ptr place, const ov::element::Type&); + ov::element::Type get_element_type(const Place::Ptr& place) const; void set_tensor_value(Place::Ptr place, const void* value); - std::vector> get_op_places(const int32_t blck_idx) const; std::map> get_var_places() const { return m_var_places; @@ -558,6 +558,10 @@ void InputModel::InputModelImpl::set_element_type(Place::Ptr place, const ov::el castToTensorPlace(place)->set_element_type(type); } +ov::element::Type InputModel::InputModelImpl::get_element_type(const Place::Ptr& place) const { + return castToTensorPlace(place)->get_element_type(); +} + void InputModel::InputModelImpl::set_tensor_value(Place::Ptr place, const void* value) { m_graph_changed = true; auto tensor_place = castToTensorPlace(place); @@ -632,6 +636,10 @@ void InputModel::set_element_type(const Place::Ptr& place, const ov::element::Ty _impl->set_element_type(place, type); } +ov::element::Type InputModel::get_element_type(const Place::Ptr& place) const { + return castToTensorPlace(place)->get_element_type(); +} + void InputModel::set_tensor_value(const Place::Ptr& place, const void* value) { _impl->set_tensor_value(place, value); } diff --git a/src/frontends/paddle/src/input_model.hpp b/src/frontends/paddle/src/input_model.hpp index 8607cf30134129..11b4e230eb4a38 100644 --- a/src/frontends/paddle/src/input_model.hpp +++ b/src/frontends/paddle/src/input_model.hpp @@ -31,6 +31,7 @@ class InputModel : public ov::frontend::InputModel { void set_partial_shape(const Place::Ptr& place, const ov::PartialShape&) override; ov::PartialShape get_partial_shape(const Place::Ptr& place) const override; void set_element_type(const Place::Ptr& place, const ov::element::Type&) override; + ov::element::Type get_element_type(const Place::Ptr& place) const override; void set_tensor_value(const Place::Ptr& place, const void* value) override; int64_t get_version() const; diff --git a/src/frontends/paddle/src/internal/op/conditional_block.cpp b/src/frontends/paddle/src/internal/op/conditional_block.cpp index 4173e45f56d384..b5d3dea9dd4dfb 100644 --- a/src/frontends/paddle/src/internal/op/conditional_block.cpp +++ b/src/frontends/paddle/src/internal/op/conditional_block.cpp @@ -6,7 +6,6 @@ #include -#include "openvino/core/validation_util.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/util/precision_sensitive_attribute.hpp" diff --git a/src/frontends/paddle/src/internal/op/tensorarray_write.cpp b/src/frontends/paddle/src/internal/op/tensorarray_write.cpp index 78d9315affdf13..efbb29323b37cd 100644 --- a/src/frontends/paddle/src/internal/op/tensorarray_write.cpp +++ b/src/frontends/paddle/src/internal/op/tensorarray_write.cpp @@ -6,7 +6,6 @@ #include -#include "openvino/core/validation_util.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/util/precision_sensitive_attribute.hpp" diff --git a/src/frontends/paddle/src/op/quantize_linear.cpp b/src/frontends/paddle/src/op/quantize_linear.cpp index 794325dd35f308..99e12cd4d0efb4 100644 --- a/src/frontends/paddle/src/op/quantize_linear.cpp +++ b/src/frontends/paddle/src/op/quantize_linear.cpp @@ -3,7 +3,6 @@ // #include "default_opset.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/frontend/paddle/node_context.hpp" #include "openvino/opsets/opset6.hpp" diff --git a/src/frontends/paddle/tests/CMakeLists.txt b/src/frontends/paddle/tests/CMakeLists.txt index 078a133138aa45..1604103638d5a4 100644 --- a/src/frontends/paddle/tests/CMakeLists.txt +++ b/src/frontends/paddle/tests/CMakeLists.txt @@ -33,7 +33,7 @@ ov_add_test_target( openvino_paddle_frontend paddle_fe_standalone_build_test LINK_LIBRARIES - cnpy + openvino::cnpy frontend_shared_test_classes openvino_paddle_frontend openvino::runtime diff --git a/src/frontends/paddle/tests/read_paddle_model_test.cpp b/src/frontends/paddle/tests/read_paddle_model_test.cpp index 08beac86b67f24..d321e1e0e820c3 100644 --- a/src/frontends/paddle/tests/read_paddle_model_test.cpp +++ b/src/frontends/paddle/tests/read_paddle_model_test.cpp @@ -2,12 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // -#include #include -#include #include -#include +#include #include #include diff --git a/src/frontends/pytorch/include/openvino/frontend/pytorch/decoder.hpp b/src/frontends/pytorch/include/openvino/frontend/pytorch/decoder.hpp index d5878783c314af..43243ab6c647b4 100644 --- a/src/frontends/pytorch/include/openvino/frontend/pytorch/decoder.hpp +++ b/src/frontends/pytorch/include/openvino/frontend/pytorch/decoder.hpp @@ -19,7 +19,7 @@ class TorchDecoder : public IDecoder { // fundamental types like int, float etc. virtual Any const_input(size_t index) const = 0; - // Using size_t for input/output unuque ids are in sync with torch code, see def in + // Using size_t for input/output unique ids are in sync with torch code, see def in // torch/include/torch/csrc/jit/ir/ir.h, Value::unique_ // TODO: set of input and output methods are not aligned; also they are not aligned with the rest of FEs @@ -89,7 +89,7 @@ class TorchDecoder : public IDecoder { virtual size_t output(size_t index) const = 0; // Embed mapping to/from the original node representation from/to node passed as a parameter - // the representation of this mapping is specific for particular decored type and may be NOP + // the representation of this mapping is specific for particular decorated type and may be NOP // returns the same node as syntactically convenient way to make nested sentences in code virtual std::shared_ptr mark_node(std::shared_ptr ov_node) const = 0; @@ -109,9 +109,19 @@ class TorchDecoder : public IDecoder { /// Returns new nodes for inputs inlined in the op itself // Used in Torch.FX decoder - virtual OutputVector inlined_inputs(size_t start_index) const = 0; + virtual OutputVector inlined_input(size_t index) const = 0; - /// Returns the id of the deccoder type (0: TorchFX, 1: TorchScript) + /// Returns if input is inlined + // Used in Torch.FX decoder + virtual bool is_input_inlined(size_t index) const = 0; + + /// Returns named attribute as Any. For example kwargs input for FX graph + virtual ov::Any get_attribute(const std::string& name) const = 0; + + /// Returns index of named input. For example kwargs input for FX graph + virtual size_t get_named_input(const std::string& name) const = 0; + + /// Returns the id of the decoder type ("fx": TorchFX, "ts": TorchScript) virtual const std::string& decoder_type_name() const = 0; }; diff --git a/src/frontends/pytorch/include/openvino/frontend/pytorch/node_context.hpp b/src/frontends/pytorch/include/openvino/frontend/pytorch/node_context.hpp index ae8f0b34a86895..307f04391d4e79 100644 --- a/src/frontends/pytorch/include/openvino/frontend/pytorch/node_context.hpp +++ b/src/frontends/pytorch/include/openvino/frontend/pytorch/node_context.hpp @@ -51,12 +51,36 @@ class NodeContext : public frontend::NodeContext { // Search for input in tensor map and return an output port for already converted op // TODO: int due to base class uses it, but naturally it should be size_t for PT Output get_input(int index) const override { - FRONT_END_GENERAL_CHECK(!input_is_none(index), "Input is none with index: ", index); + size_t index_ = static_cast(index); + FRONT_END_GENERAL_CHECK(!input_is_none(index_), "Input doesn't exist with index: ", index); auto input = m_decoder_inputs.at(index); + if (input == 0) { + // Case when input can be inlined (possible only for fx decoder) + if (m_decoder->is_input_inlined(index_)) { + auto inlined_input = m_decoder->inlined_input(index_); + FRONT_END_GENERAL_CHECK(inlined_input.size() == 1, "Incorrect inlined input with index:", index); + return inlined_input[0]; + } + } FRONT_END_GENERAL_CHECK(m_tensor_map->count(input), "No tensor corresponding input: ", input, " exist."); return m_tensor_map->at(input); } + Output get_input(const std::string& name) const override { + FRONT_END_GENERAL_CHECK(has_attribute(name), "Input with name ", name, " doesn't exist"); + auto attr = get_attribute_as_any(name); + if (attr.is>()) { + // Case when input is constant value + return attr.as>(); + } else if (attr.is()) { + // None means input is unknown type, most likely a Node + auto input = m_decoder->get_named_input(name); + FRONT_END_GENERAL_CHECK(m_tensor_map->count(input), "No tensor corresponding input: ", input, " exist."); + return m_tensor_map->at(input); + } + FRONT_END_GENERAL_CHECK(false, "Input has type which can't be converted to ov::Node."); + } + Any get_values_from_const_input(int index) const override; // TODO: upstream to base class @@ -112,9 +136,8 @@ class NodeContext : public frontend::NodeContext { return ov_output; } - Any get_attribute_as_any(const std::string&) const override { - throw std::runtime_error( - "There is no any named attributes in PyTorch node, query by attribute name is not implemented"); + Any get_attribute_as_any(const std::string& name) const override { + return m_decoder->get_attribute(name); } void mutate_input(size_t index, Output ov_output) const; diff --git a/src/frontends/pytorch/src/frontend.cpp b/src/frontends/pytorch/src/frontend.cpp index ee9a9919045f72..03835b72935327 100644 --- a/src/frontends/pytorch/src/frontend.cpp +++ b/src/frontends/pytorch/src/frontend.cpp @@ -39,6 +39,7 @@ #include "transforms/prim_list_unpack_replacer.hpp" #include "transforms/prim_unpack_parameter_replacer.hpp" #include "transforms/quantized_node_remover.hpp" +#include "transforms/remove_packing_ops.hpp" #include "transforms/reverseprop_resolver.hpp" #include "transforms/rfftn_complex_replacer.hpp" #include "transforms/softmax_reshape_elimination.hpp" @@ -194,6 +195,7 @@ void FrontEnd::normalize(const std::shared_ptr& model) const { manager.register_pass(); manager.register_pass(); manager.register_pass(); + // TODO: remove AtenIndexToSelect when problem with dynamic input rank is gone. manager.register_pass(); manager.register_pass(); manager.register_pass(); @@ -212,6 +214,8 @@ void FrontEnd::normalize(const std::shared_ptr& model) const { manager.register_pass(); manager.register_pass(); manager.register_pass(); + manager.register_pass(); + manager.register_pass(); manager.register_pass(); manager.register_pass(); // Second pass of AlignTypesRemoval after all converting transformations diff --git a/src/frontends/pytorch/src/helper_ops/packed_sequence.hpp b/src/frontends/pytorch/src/helper_ops/packed_sequence.hpp new file mode 100644 index 00000000000000..30e1a37c9d1d96 --- /dev/null +++ b/src/frontends/pytorch/src/helper_ops/packed_sequence.hpp @@ -0,0 +1,43 @@ +// Copyright (C) 2018-2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "internal_op.hpp" +#include "utils.hpp" + +namespace ov { +namespace frontend { +namespace pytorch { + +class PackPadded : public InternalOperation { +public: + OPENVINO_OP("PackPadded", "util", ov::op::util::FrameworkNode); + PackPadded(const Output& input, const Output& lengths) + : InternalOperation("prim::PackPadded", {input, lengths}, 2, "This is PackedSequence pack operation.") { + validate_and_infer_types(); + } + + void validate_and_infer_types() override { + set_output_type(0, get_input_element_type(0), PartialShape({-1, -1, -1})); + set_output_type(1, get_input_element_type(1), PartialShape::dynamic()); + } +}; + +class PadPacked : public InternalOperation { +public: + OPENVINO_OP("PadPacked", "util", ov::op::util::FrameworkNode); + PadPacked(const Output& input, const Output& lengths) + : InternalOperation("prim::PadPacked", {input, lengths}, 2, "This is PackedSequence unpack operation.") { + validate_and_infer_types(); + } + + void validate_and_infer_types() override { + set_output_type(0, get_input_element_type(0), PartialShape({-1, -1, -1})); + set_output_type(1, get_input_element_type(1), get_input_partial_shape(1)); + } +}; +} // namespace pytorch +} // namespace frontend +} // namespace ov diff --git a/src/frontends/pytorch/src/node_context.cpp b/src/frontends/pytorch/src/node_context.cpp index 0ebd26d3b8e901..4d0fd1acfeba47 100644 --- a/src/frontends/pytorch/src/node_context.cpp +++ b/src/frontends/pytorch/src/node_context.cpp @@ -4,7 +4,6 @@ #include "openvino/frontend/pytorch/node_context.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/frontend/exception.hpp" #include "openvino/frontend/pytorch/decoder.hpp" #include "openvino/op/constant.hpp" @@ -12,6 +11,7 @@ #include "openvino/util/log.hpp" #include "pt_framework_node.hpp" #include "translate_session.hpp" +#include "validation_util.hpp" namespace ov { namespace frontend { @@ -109,7 +109,7 @@ Output NodeContext::get_tensor_from_model_or_create_input(size_t index) co } Output NodeContext::get_input_from_visible_context(size_t index) const { - FRONT_END_GENERAL_CHECK(index < get_input_size(), "Index is lower then number of inputs."); + FRONT_END_GENERAL_CHECK(index < get_input_size(), "Index ", index, " is lower then number of inputs."); auto input_tensor = get_input(static_cast(index)); auto input_node = input_tensor.get_node_shared_ptr(); if (std::dynamic_pointer_cast(input_node)) { @@ -156,9 +156,7 @@ std::shared_ptr get_constant_at_input(const NodeContext& ctx, size return {}; input_val = concat_list_construct(input_val); } - OPENVINO_SUPPRESS_DEPRECATED_START - auto constant = get_constant_from_source(input_val); - OPENVINO_SUPPRESS_DEPRECATED_END + auto constant = ov::util::get_constant_from_source(input_val); FRONT_END_GENERAL_CHECK(constant, "Input with index ", index, " cannot be interpreted as Constant: ", input_val); return constant; } diff --git a/src/frontends/pytorch/src/op/adaptive_poolnd.cpp b/src/frontends/pytorch/src/op/adaptive_poolnd.cpp index 9c349e50c8ed86..bc6b17cbed093d 100644 --- a/src/frontends/pytorch/src/op/adaptive_poolnd.cpp +++ b/src/frontends/pytorch/src/op/adaptive_poolnd.cpp @@ -117,6 +117,21 @@ OutputVector translate_adaptive_max_pool1d(const NodeContext& context) { return translate_adaptive_max_pool_base(context, const_tile_params, const_neg_1); }; +OutputVector translate_adaptive_max_pool3d_fx(const NodeContext& context) { + auto outs = translate_adaptive_max_pool3d(context); + return {context.mark_node(make_list_construct(outs))}; +}; + +OutputVector translate_adaptive_max_pool2d_fx(const NodeContext& context) { + auto outs = translate_adaptive_max_pool2d(context); + return {context.mark_node(make_list_construct(outs))}; +}; + +OutputVector translate_adaptive_max_pool1d_fx(const NodeContext& context) { + auto outs = translate_adaptive_max_pool1d(context); + return {context.mark_node(make_list_construct(outs))}; +}; + } // namespace op } // namespace pytorch } // namespace frontend diff --git a/src/frontends/pytorch/src/op/add.cpp b/src/frontends/pytorch/src/op/add.cpp index 33699ad90fa39c..ab2933bd6f7910 100644 --- a/src/frontends/pytorch/src/op/add.cpp +++ b/src/frontends/pytorch/src/op/add.cpp @@ -34,8 +34,14 @@ OutputVector translate_add_common(const NodeContext& context, bool inplace) { } else { align_eltwise_input_types(context, lhs, rhs, true); } + Output alpha; if (!context.input_is_none(2)) { - auto converted_alpha = context.mark_node(std::make_shared(context.get_input(2), rhs)); + alpha = context.get_input(2); + } else if (context.has_attribute("alpha")) { + alpha = context.get_attribute>("alpha"); + } + if (alpha.get_node_shared_ptr()) { + auto converted_alpha = context.mark_node(std::make_shared(alpha, rhs)); rhs = context.mark_node(std::make_shared(converted_alpha, rhs)); } auto add = context.mark_node(std::make_shared(lhs, rhs)); diff --git a/src/frontends/pytorch/src/op/addcmul.cpp b/src/frontends/pytorch/src/op/addcmul.cpp index 7933acfde1d176..9ebe2a24875f25 100644 --- a/src/frontends/pytorch/src/op/addcmul.cpp +++ b/src/frontends/pytorch/src/op/addcmul.cpp @@ -17,15 +17,30 @@ namespace op { using namespace ov::op; -OutputVector translate_addcmul(const NodeContext& context) { - num_inputs_check(context, 4, 4); +namespace { +OutputVector addcmul_common(const NodeContext& context, const Output& value) { const auto eltwise_mult = std::make_shared(context.get_input(1), context.get_input(2)); - const auto value = context.get_input(3); const auto converted_value = std::make_shared(value, context.get_input(1)); const auto scalar_mult = std::make_shared(eltwise_mult, converted_value); context.mark_nodes({eltwise_mult, converted_value, scalar_mult}); return {context.mark_node(std::make_shared(context.get_input(0), scalar_mult))}; }; +} // namespace + +OutputVector translate_addcmul(const NodeContext& context) { + num_inputs_check(context, 4, 4); + const auto value = context.get_input(3); + return addcmul_common(context, value); +}; + +OutputVector translate_addcmul_fx(const NodeContext& context) { + num_inputs_check(context, 3, 3); + Output value = context.mark_node(v0::Constant::create(element::f32, Shape{}, {1})); + if (context.has_attribute("value")) { + value = context.get_input("value"); + } + return addcmul_common(context, value); +}; } // namespace op } // namespace pytorch diff --git a/src/frontends/pytorch/src/op/addmm.cpp b/src/frontends/pytorch/src/op/addmm.cpp index 731014c6c27c5c..097737ec93ecf1 100644 --- a/src/frontends/pytorch/src/op/addmm.cpp +++ b/src/frontends/pytorch/src/op/addmm.cpp @@ -16,12 +16,22 @@ namespace op { using namespace ov::op; -OutputVector translate_addmm(const NodeContext& context) { - num_inputs_check(context, 3, 5); +namespace { +OutputVector translate_addmm_common(const NodeContext& context, const Output beta, const Output alpha) { auto input = context.get_input(0); auto m1 = context.get_input(1); auto m2 = context.get_input(2); auto mm = context.mark_node(std::make_shared(m1, m2)); + auto beta_converted = context.mark_node(std::make_shared(beta, input)); + auto alpha_converted = context.mark_node(std::make_shared(alpha, mm)); + auto input_beta = context.mark_node(std::make_shared(input, beta_converted)); + auto mm_alpha = context.mark_node(std::make_shared(mm, alpha_converted)); + return {context.mark_node(std::make_shared(input_beta, mm_alpha))}; +}; +} // namespace + +OutputVector translate_addmm(const NodeContext& context) { + num_inputs_check(context, 3, 5); auto one = context.mark_node(v0::Constant::create(element::f32, Shape{}, {1})); ov::Output alpha = one; ov::Output beta = one; @@ -31,11 +41,21 @@ OutputVector translate_addmm(const NodeContext& context) { if (!context.input_is_none(4)) { alpha = context.get_input(4); } - auto beta_converted = context.mark_node(std::make_shared(beta, input)); - auto alpha_converted = context.mark_node(std::make_shared(alpha, mm)); - auto input_beta = context.mark_node(std::make_shared(input, beta_converted)); - auto mm_alpha = context.mark_node(std::make_shared(mm, alpha_converted)); - return {context.mark_node(std::make_shared(input_beta, mm_alpha))}; + return {translate_addmm_common(context, beta, alpha)}; +}; + +OutputVector translate_addmm_fx(const NodeContext& context) { + num_inputs_check(context, 3, 3); + auto one = context.mark_node(v0::Constant::create(element::f32, Shape{}, {1})); + ov::Output alpha = one; + ov::Output beta = one; + if (context.has_attribute("beta")) { + beta = context.get_input("beta"); + } + if (context.has_attribute("alpha")) { + alpha = context.get_input("alpha"); + } + return {translate_addmm_common(context, beta, alpha)}; }; } // namespace op diff --git a/src/frontends/pytorch/src/op/batch_norm.cpp b/src/frontends/pytorch/src/op/batch_norm.cpp index 126588eb952a6b..5d10222eceb890 100644 --- a/src/frontends/pytorch/src/op/batch_norm.cpp +++ b/src/frontends/pytorch/src/op/batch_norm.cpp @@ -17,6 +17,7 @@ #include "openvino/op/subtract.hpp" #include "openvino/op/unsqueeze.hpp" #include "openvino/op/util/framework_node.hpp" +#include "openvino/pass/graph_rewrite.hpp" #include "utils.hpp" namespace ov { @@ -37,91 +38,112 @@ Output broadcast_const_to_channel_dim(const NodeContext& context, auto channel_dim_exp = context.mark_node(std::make_shared(channel_dim, zero_i)); return context.mark_node(std::make_shared(value, channel_dim_exp)); } + +OutputVector make_batch_norm(const NodeContext& context, + const Output& input, + const Output& weight, + const Output& bias, + const Output& running_mean, + const Output& running_var, + float epsilon) { + Output w = weight; + Output b = bias; + Output mean = running_mean; + Output var = running_var; + if (!w.get_node_shared_ptr()) { + auto one_f = context.mark_node(v0::Constant::create(element::f32, Shape{}, {1})); + w = broadcast_const_to_channel_dim(context, input, one_f); + } + if (!b.get_node_shared_ptr()) { + auto zero_f = context.mark_node(v0::Constant::create(element::f32, Shape{}, {0})); + b = broadcast_const_to_channel_dim(context, input, zero_f); + } + auto zero = context.mark_node(v0::Constant::create(element::i32, Shape{}, {0})); + auto zero_1d = context.mark_node(v0::Constant::create(element::i32, Shape{1}, {0})); + auto one = context.mark_node(v0::Constant::create(element::i32, Shape{}, {1})); + auto two = context.mark_node(v0::Constant::create(element::i32, Shape{}, {2})); + Output rank = std::get<1>(get_shape_rank(context, input, true)); + auto after_channel_dims = context.mark_node(std::make_shared(two, rank, one)); + auto axes = context.mark_node(std::make_shared(OutputVector{zero_1d, after_channel_dims}, 0)); + if (!mean.get_node_shared_ptr()) { + mean = context.mark_node(std::make_shared(input, axes, false)); + } + if (!var.get_node_shared_ptr()) { + auto current_mean = context.mark_node(std::make_shared(input, axes, true)); + auto sub_v = context.mark_node(std::make_shared(input, current_mean)); + auto sqr_sub = context.mark_node(std::make_shared(sub_v, sub_v)); + var = context.mark_node(std::make_shared(sqr_sub, axes, false)); + } + return {context.mark_node(std::make_shared(input, w, b, mean, var, epsilon))}; +} } // namespace -OutputVector translate_batch_norm_common(const NodeContext& context, bool training) { +OutputVector translate_batch_norm(const NodeContext& context) { // Schema: aten::batch_norm(Tensor input, Tensor? weight, Tensor? bias, Tensor? running_mean, Tensor? running_var, // bool training, float momentum, float eps, bool cudnn_enabled) -> Tensor - - // batch_norm_legit_no_training Schema: aten::batch_norm(Tensor input, Tensor? weight, Tensor? bias, Tensor? - // running_mean, Tensor? running_var, float momentum, float eps) -> Tensor - - auto input = context.get_input(0); + num_inputs_check(context, 7, 9); Output weight; Output bias; Output running_mean; Output running_var; - Output current_mean; - Output current_var; if (!context.input_is_none(1)) { weight = context.get_input(1); - } else { - auto one_f = context.mark_node(v0::Constant::create(element::f32, Shape{}, {1})); - weight = broadcast_const_to_channel_dim(context, input, one_f); } if (!context.input_is_none(2)) { bias = context.get_input(2); - } else { - auto zero_f = context.mark_node(v0::Constant::create(element::f32, Shape{}, {0})); - bias = broadcast_const_to_channel_dim(context, input, zero_f); } // index 3 running_mean and index 4 running_var can be none for training case only, check that not training before // if training for batch norm activated, but model in eval mode, it uses current statistics instead of running - if (training) { - auto zero = context.mark_node(v0::Constant::create(element::i32, Shape{}, {0})); - auto zero_1d = context.mark_node(v0::Constant::create(element::i32, Shape{1}, {0})); - auto one = context.mark_node(v0::Constant::create(element::i32, Shape{}, {1})); - auto two = context.mark_node(v0::Constant::create(element::i32, Shape{}, {2})); - auto input_shape = context.mark_node(std::make_shared(input, element::i32)); - auto rank_unsq = context.mark_node(std::make_shared(input_shape, element::i32)); - auto rank = context.mark_node(std::make_shared(rank_unsq, zero)); - auto after_channel_dims = context.mark_node(std::make_shared(two, rank, one)); - auto axes = context.mark_node(std::make_shared(OutputVector{zero_1d, after_channel_dims}, 0)); - current_mean = context.mark_node(std::make_shared(input, axes, false)); - auto mean = context.mark_node(std::make_shared(input, axes, true)); - auto sub_v = context.mark_node(std::make_shared(input, mean)); - auto sqr_sub = context.mark_node(std::make_shared(sub_v, sub_v)); - current_var = context.mark_node(std::make_shared(sqr_sub, axes, false)); - } + auto training = context.const_input(5); if (!training) { running_mean = context.get_input(3); - } else { - running_mean = current_mean; - } - if (!training) { running_var = context.get_input(4); - } else { - running_var = current_var; } // Input with index 6 is momentum, it is used only for updating running_mean accumulation during training - // In batch_norm_legit_no_training, momentum is index 5 and epsilon is 6 - float epsilon; - if (context.get_input_size() == 7) { - epsilon = context.const_input(6); - } else { - epsilon = context.const_input(7); - } + float epsilon = context.const_input(7); // Input with index 8 is flag "cudnn_enabled" we can ignore it - return {context.mark_node( - std::make_shared(input, weight, bias, running_mean, running_var, epsilon))}; -}; - -OutputVector translate_batch_norm(const NodeContext& context) { - num_inputs_check(context, 7, 9); - auto training = context.const_input(5); - return translate_batch_norm_common(context, training); + return make_batch_norm(context, context.get_input(0), weight, bias, running_mean, running_var, epsilon); } OutputVector translate_batch_norm_legit_fx(const NodeContext& context) { - num_inputs_check(context, 7, 9); - auto training = context.const_input(5); - auto output = translate_batch_norm_common(context, training); + auto output = translate_batch_norm(context); return {context.mark_node(make_list_construct(output))}; } OutputVector translate_batch_norm_legit_no_training_fx(const NodeContext& context) { num_inputs_check(context, 7, 9); - auto output = translate_batch_norm_common(context, false); + Output weight; + Output bias; + if (!context.input_is_none(1)) { + weight = context.get_input(1); + } + if (!context.input_is_none(2)) { + bias = context.get_input(2); + } + auto running_mean = context.get_input(3); + auto running_var = context.get_input(4); + float epsilon = context.const_input(6); + auto output = make_batch_norm(context, context.get_input(0), weight, bias, running_mean, running_var, epsilon); + return {context.mark_node(make_list_construct(output))}; +} + +OutputVector translate_batch_norm_legit_no_stats_fx(const NodeContext& context) { + num_inputs_check(context, 6, 6); + // torch.ops.aten._native_batch_norm_legit.no_stats(arg2_1, arg0_1, arg1_1, True, 0.1, 5e-05) + Output weight; + if (!context.input_is_none(1)) { + weight = context.get_input(1); + } + Output bias; + if (!context.input_is_none(2)) { + bias = context.get_input(2); + } + auto training = context.const_input(3); + FRONT_END_OP_CONVERSION_CHECK(training, + "aten._native_batch_norm_legit.no_stats can only be used when training=True."); + // index 4 momentum is used during training only + auto eps = context.const_input(5); + auto output = make_batch_norm(context, context.get_input(0), weight, bias, {}, {}, eps); return {context.mark_node(make_list_construct(output))}; } diff --git a/src/frontends/pytorch/src/op/div.cpp b/src/frontends/pytorch/src/op/div.cpp index dbbb6c89af7e6c..477c9ced2bb462 100644 --- a/src/frontends/pytorch/src/op/div.cpp +++ b/src/frontends/pytorch/src/op/div.cpp @@ -17,14 +17,13 @@ namespace frontend { namespace pytorch { namespace op { -OutputVector translate_div_common(const NodeContext& context, bool inplace) { - num_inputs_check(context, 2, 3); - auto x = context.get_input(0); - auto y = context.get_input(1); - std::string rounding_mode = ""; - if (!context.input_is_none(2)) { - rounding_mode = context.const_input(2); - } +OutputVector translate_div_common(const NodeContext& context, + const Output& lhs, + const Output& rhs, + const std::string& rounding_mode, + bool inplace) { + auto x = lhs; + auto y = rhs; if (rounding_mode.empty()) { // if no rounding mode and both inputs are ints cast BOTH to fp32 const auto x_dtype = x.get_element_type(); @@ -36,7 +35,7 @@ OutputVector translate_div_common(const NodeContext& context, bool inplace) { } if (inplace) { if (x.get_element_type().is_dynamic() || x.get_element_type() != y.get_element_type()) - y = context.mark_node(std::make_shared(x, y)); + y = context.mark_node(std::make_shared(y, x)); } else { align_eltwise_input_types(context, x, y, true); } @@ -55,11 +54,36 @@ OutputVector translate_div_common(const NodeContext& context, bool inplace) { }; OutputVector translate_div(const NodeContext& context) { - return translate_div_common(context, false); + num_inputs_check(context, 2, 3); + auto x = context.get_input(0); + auto y = context.get_input(1); + std::string rounding_mode = ""; + if (!context.input_is_none(2)) { + rounding_mode = context.const_input(2); + } + return translate_div_common(context, x, y, rounding_mode, false); }; OutputVector translate_div_(const NodeContext& context) { - return translate_div_common(context, true); + num_inputs_check(context, 2, 3); + auto x = context.get_input(0); + auto y = context.get_input(1); + std::string rounding_mode = ""; + if (!context.input_is_none(2)) { + rounding_mode = context.const_input(2); + } + return translate_div_common(context, x, y, rounding_mode, true); +}; + +OutputVector translate_div_fx(const NodeContext& context) { + num_inputs_check(context, 2, 2); + auto x = context.get_input(0); + auto y = context.get_input(1); + std::string rounding_mode = ""; + if (context.has_attribute("rounding_mode")) { + rounding_mode = context.get_attribute("rounding_mode"); + } + return translate_div_common(context, x, y, rounding_mode, false); }; } // namespace op diff --git a/src/frontends/pytorch/src/op/expand.cpp b/src/frontends/pytorch/src/op/expand.cpp index 0b0690404129c6..7fcb7a898a48bc 100644 --- a/src/frontends/pytorch/src/op/expand.cpp +++ b/src/frontends/pytorch/src/op/expand.cpp @@ -49,7 +49,7 @@ OutputVector translate_expand_fx(const NodeContext& context) { // output shapes are same. This should be removed after a proper optimization is // implemented. auto sizes_const = context.const_input(1); - if (x.get_shape() == sizes_const) { + if (x.get_partial_shape().is_static() && x.get_shape() == sizes_const) { return {x}; } auto sizes = context.get_input(1); diff --git a/src/frontends/pytorch/src/op/full.cpp b/src/frontends/pytorch/src/op/full.cpp index a86b5bf37251d8..defcbab7095089 100644 --- a/src/frontends/pytorch/src/op/full.cpp +++ b/src/frontends/pytorch/src/op/full.cpp @@ -71,6 +71,21 @@ OutputVector translate_full(const NodeContext& context) { return {base_translate_full_with_convert(context, sizes, value, dtype_id)}; }; +OutputVector translate_full_fx(const NodeContext& context) { + // aten.full.default([16, 16], 0, dtype = torch.float32, layout = torch.strided, device = device(type='cpu'), + // pin_memory = False) + num_inputs_check(context, 2, 2); + auto sizes = context.get_input(0); + auto value = context.get_input(1); + + auto filled_tensor = base_translate_full(context, sizes, value); + if (context.has_attribute("dtype")) { + auto dtype = context.get_attribute("dtype"); + filled_tensor = context.mark_node(std::make_shared(filled_tensor, dtype)); + } + return {filled_tensor}; +}; + OutputVector translate_full_like(const NodeContext& context) { num_inputs_check(context, 2, 7); auto input = context.get_input(0); @@ -220,7 +235,7 @@ OutputVector translate_empty_like(const NodeContext& context) { if (!context.input_is_none(dtype_id)) { empty = base_translate_full_with_convert(context, sizes, value, dtype_id); } else { - empty = base_translate_full(context, sizes, value); + empty = base_translate_full_with_convertlike(context, sizes, value, input); } } else if (context.get_input_size() == 4) { auto out = context.input_is_none(3) ? input : context.get_input(3); diff --git a/src/frontends/pytorch/src/op/gelu.cpp b/src/frontends/pytorch/src/op/gelu.cpp index 4f7fc810596b6c..64afb511b31dc3 100644 --- a/src/frontends/pytorch/src/op/gelu.cpp +++ b/src/frontends/pytorch/src/op/gelu.cpp @@ -12,13 +12,9 @@ namespace frontend { namespace pytorch { namespace op { -OutputVector translate_gelu(const NodeContext& context) { - num_inputs_check(context, 1, 2); +namespace { +OutputVector translate_gelu_common(const NodeContext& context, const std::string& approximate) { auto x = context.get_input(0); - std::string approximate = "none"; - if (!context.input_is_none(1)) { - approximate = context.const_input(1); - } if (approximate == "none") { return {context.mark_node(std::make_shared(x, ov::op::GeluApproximationMode::ERF))}; } @@ -27,6 +23,27 @@ OutputVector translate_gelu(const NodeContext& context) { } FRONT_END_OP_CONVERSION_CHECK(false, "Unsupported approximate for Gelu: ", approximate); }; +} // namespace + +OutputVector translate_gelu(const NodeContext& context) { + num_inputs_check(context, 1, 2); + auto x = context.get_input(0); + std::string approximate = "none"; + if (!context.input_is_none(1)) { + approximate = context.const_input(1); + } + return translate_gelu_common(context, approximate); +}; + +OutputVector translate_gelu_fx(const NodeContext& context) { + num_inputs_check(context, 1, 1); + auto x = context.get_input(0); + std::string approximate = "none"; + if (context.has_attribute("approximate")) { + approximate = context.get_attribute("approximate"); + } + return translate_gelu_common(context, approximate); +}; } // namespace op } // namespace pytorch diff --git a/src/frontends/pytorch/src/op/glu.cpp b/src/frontends/pytorch/src/op/glu.cpp index dbe979fb1f2870..779c81c4904f29 100644 --- a/src/frontends/pytorch/src/op/glu.cpp +++ b/src/frontends/pytorch/src/op/glu.cpp @@ -17,7 +17,7 @@ namespace op { using namespace ov::op; OutputVector translate_glu(const NodeContext& context) { - num_inputs_check(context, 2, 2); + num_inputs_check(context, 1, 2); auto x = context.get_input(0); auto dim = context.input_is_none(1) ? context.mark_node(v0::Constant::create(element::i32, Shape{}, {-1})) : context.get_input(1); diff --git a/src/frontends/pytorch/src/op/index.cpp b/src/frontends/pytorch/src/op/index.cpp index e739476619ff7f..a9aaf62257d71b 100644 --- a/src/frontends/pytorch/src/op/index.cpp +++ b/src/frontends/pytorch/src/op/index.cpp @@ -3,9 +3,20 @@ // #include "openvino/frontend/pytorch/node_context.hpp" +#include "openvino/op/add.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/convert.hpp" +#include "openvino/op/gather.hpp" #include "openvino/op/gather_nd.hpp" +#include "openvino/op/multiply.hpp" +#include "openvino/op/non_zero.hpp" +#include "openvino/op/reduce_prod.hpp" +#include "openvino/op/reshape.hpp" +#include "openvino/op/shape_of.hpp" +#include "openvino/op/slice.hpp" +#include "openvino/op/split.hpp" +#include "openvino/op/transpose.hpp" +#include "pt_framework_node.hpp" #include "utils.hpp" namespace ov { @@ -13,23 +24,252 @@ namespace frontend { namespace pytorch { namespace op { +using namespace ov::op; + +namespace { +Output flatten(ov::pass::NodeRegistry& rg, const Output& value, size_t axis) { + // First dimension of output tensor is the product of [d_0, ... d_{axis-1}] dimensions of + // input tensor. The last dimension is the product of the rest of input tensor dimensions: + // [d_{axis}, ..., d_n] + Output output_shape; + if (axis == 0) { + output_shape = v0::Constant::create(element::i32, Shape{2}, {1, -1}); + } else if (axis == 1) { + output_shape = v0::Constant::create(element::i32, Shape{2}, {0, -1}); + } else { + const auto value_shape = rg.make(value, element::i32); + const auto value_rank = rg.make(value_shape, element::i32); + const auto axis_node = v0::Constant::create(element::i32, Shape{1}, {axis}); + auto start = v0::Constant::create(element::i32, Shape{1}, {0}); + auto step = v0::Constant::create(element::i32, Shape{1}, {1}); + const auto first_part_dims = rg.make(value_shape, start, axis_node, step); + auto zero = v0::Constant::create(element::i32, {}, {0}); + auto first_part_dims_length = rg.make(first_part_dims, zero, true); + + auto remaining_part_length = v0::Constant::create(element::i32, {1}, {-1}); + + output_shape = rg.make(OutputVector{first_part_dims_length, remaining_part_length}, 0); + } + return rg.make(value, output_shape, true); +} + +OutputVector index_on_list(ov::pass::NodeRegistry& rg, + const Output& data, + std::deque> ids, + int64_t rank) { + // Multiple tensors as indices. Each tensor could either be + // 1. prim::Constant() + // representing ":" in python indexing. E.g. tensor[:, :] + // 2. prim::Constant[value=...] or tensor output + // representing advanced indexing. E.g. tensor[[0, 1], [2, 0]]. + // For more info on advanced indexing, + // check https://docs.scipy.org/doc/numpy/reference/arrays.indexing.html#advanced-indexing + + // Consider a general case of + // t: [x_1, y_1, y_2, ..., x_m, ..., y_n] + // where t is a tensor of rank m+n, {x_i} are axes where tensor index is provided, and {y_i} are axes for + // ":". Same results can be achieved through transposing t into + // t: [x_1, x_2, ..., x_m, y_1, y_2, ..., y_n] + // and use gather + // t: [x_1 * x_2 * ... * x_m, y_1 * y_2 * ... * y_n] + // tensor index = \sum_{i=1}^m (ind_i * \prod_{j=i+1}^m (x_j)) + // After gather, reshape and transpose back. + std::vector advanced_ids; + std::vector is_masked_bool; + OutputVector masked_indicies; + // for case when index is bool e.g. x[x>0], replace index with non_zero + for (size_t i = 0; i < ids.size(); i++) { + // skip dimensions where index is None + bool is_none = false; + if (!ids[i].get_node_shared_ptr()) { + is_none = true; + } + if (auto const_input = cast_fw_node(ids[i].get_node_shared_ptr(), "prim::Constant")) { + const auto& attrs = const_input->get_attrs(); + if (attrs.find("none_value") != attrs.end()) { + is_none = true; + } + } + if (is_none) { + masked_indicies.push_back(ids[i]); + is_masked_bool.push_back(false); + continue; + } + auto id_dtype = ids[i].get_element_type(); + if (id_dtype == element::boolean || id_dtype == element::u8) { + auto idx = rg.make(ids[i], element::u8); + auto nonzero = rg.make(idx, element::i32); + auto input_order = v0::Constant::create(element::i32, Shape{2}, {1, 0}); + auto masked_id = rg.make(nonzero, input_order); + masked_indicies.push_back(masked_id); + is_masked_bool.push_back(true); + } else { + masked_indicies.push_back(ids[i]); + is_masked_bool.push_back(false); + } + advanced_ids.push_back(i); + } + + // all indicies prim::Constant(None), return input as is + if (advanced_ids.size() == 0) { + return {data}; + } + // perform gather for single element case + if (advanced_ids.size() == 1) { + auto index = masked_indicies[advanced_ids[0]]; + if (is_masked_bool[advanced_ids[0]]) { + auto gather = rg.make(data, index); + return {gather}; + } + index = rg.make(index, element::i32); + auto dim = v0::Constant::create(element::i32, Shape{}, {advanced_ids[0]}); + auto gather = rg.make(data, index, dim); + return {gather}; + } + auto adv_idx_count = advanced_ids.size(); + auto input_shape = rg.make(data, element::i32); + auto zero = v0::Constant::create(element::i32, Shape{}, {0}); + auto input_dims = rg.make(input_shape, zero, rank); + std::vector non_used_dims; + for (auto i = 0; i < rank; i++) { + if (std::find(advanced_ids.begin(), advanced_ids.end(), i) == advanced_ids.end()) { + non_used_dims.push_back(i); + } + } + std::vector permutation_dims; + permutation_dims.insert(permutation_dims.end(), advanced_ids.begin(), advanced_ids.end()); + permutation_dims.insert(permutation_dims.end(), non_used_dims.begin(), non_used_dims.end()); + auto transpose_dims = v0::Constant::create(element::i32, Shape{permutation_dims.size()}, permutation_dims); + auto transposed_input = rg.make(data, transpose_dims); + auto flatten_input = flatten(rg, transposed_input, adv_idx_count); + auto cum_adv_index = masked_indicies[advanced_ids.back()]; + cum_adv_index = rg.make(cum_adv_index, element::i32); + auto multiplier = input_dims->output(advanced_ids.back()); + for (int i = static_cast(adv_idx_count) - 2; i > -1; i--) { + auto input_id = advanced_ids[i]; + auto m_idx = rg.make(masked_indicies[input_id], element::i32); + auto adv_index = rg.make(m_idx, multiplier); + cum_adv_index = rg.make(cum_adv_index, adv_index); + multiplier = rg.make(multiplier, input_dims->output(input_id)); + } + std::shared_ptr gather = rg.make(flatten_input, cum_adv_index, zero); + OutputVector concat_dims; + // check if all advanced indices are consecutive. + std::vector consequence_dims; + auto cum_adv_index_shape_tensor = rg.make(cum_adv_index, element::i32); + for (size_t i = advanced_ids[0]; i <= advanced_ids[advanced_ids.back()]; i++) { + consequence_dims.push_back(i); + } + // unfold regular index axes + if (advanced_ids == consequence_dims) { + OutputVector folded_adv_idx_shape_vector; + auto minus_one = v0::Constant::create(element::i32, Shape{1}, {-1}); + folded_adv_idx_shape_vector.push_back(minus_one); + for (auto i : non_used_dims) { + folded_adv_idx_shape_vector.push_back(input_dims->output(i)); + } + auto folded_adv_idx_shape = rg.make(folded_adv_idx_shape_vector, 0); + gather = rg.make(gather, folded_adv_idx_shape, false); + std::vector adv_idx_permute; + for (size_t i = 1; i < advanced_ids[0] + 1; i++) { + adv_idx_permute.push_back(i); + } + adv_idx_permute.push_back(0); + for (size_t i = advanced_ids[0] + 1; i < (rank - adv_idx_count + 1); i++) { + adv_idx_permute.push_back(i); + } + // Transpose folded advanced indexed axis to its original location. + auto permute_indicies = v0::Constant::create(element::i32, Shape{adv_idx_permute.size()}, adv_idx_permute); + gather = rg.make(gather, permute_indicies); + // unfold advanced index axes + for (size_t i = 0; i < advanced_ids[0]; i++) { + concat_dims.push_back(input_dims->output(i)); + } + concat_dims.push_back(cum_adv_index_shape_tensor); + for (auto i : non_used_dims) { + if (i < advanced_ids[0]) { + continue; + } + concat_dims.push_back(input_dims->output(i)); + } + + } else { + size_t i = 0; + auto one = v0::Constant::create(element::i32, Shape{1}, {1}); + while (i < non_used_dims.size() && non_used_dims[i] < advanced_ids[0]) { + concat_dims.push_back(one); + i++; + } + concat_dims.push_back(cum_adv_index_shape_tensor); + for (; i < non_used_dims.size(); i++) { + concat_dims.push_back(input_dims->output(non_used_dims[i])); + } + } + auto final_shape = rg.make(concat_dims, 0); + gather = rg.make(gather, final_shape, false); + return {gather}; +} +} // namespace + +OutputVector translate_index(const NodeContext& context) { + num_inputs_check(context, 2, 2); + auto x = context.get_input(0); + if (context.input_is_none(1)) { + return {x}; + } + auto indices = context.get_input(1); + auto index_dtype = context.get_input_type(1); + if (index_dtype.is()) { + auto list_elems = get_list_as_outputs(indices); + ov::pass::NodeRegistry rg; + auto rank = x.get_partial_shape().rank(); + // index transformation supports only tensors with static rank + FRONT_END_OP_CONVERSION_CHECK(rank.is_static(), "Dynamic rank for aten::index input is not supported."); + auto res = index_on_list(rg, x, list_elems, rank.get_length()); + context.mark_nodes(rg.get()); + return res; + } + auto index_ov_type = indices.get_element_type(); + if (index_ov_type.is_dynamic()) { + if (simplified_type_interpret(index_dtype).is()) { + index_ov_type = index_dtype.as(); + } + } + if (index_ov_type == element::boolean || index_ov_type == element::u8) { + auto nonzero = context.mark_node(std::make_shared(indices, element::i32)); + auto input_order = context.mark_node(v0::Constant::create(element::i32, Shape{2}, {1, 0})); + auto masked_id = context.mark_node(std::make_shared(nonzero, input_order)); + auto gather = context.mark_node(std::make_shared(x, masked_id)); + return {gather}; + } + if (index_ov_type != element::i32) { + indices = context.mark_node(std::make_shared(indices, element::i32)); + } + auto dim = context.mark_node(v0::Constant::create(element::i32, Shape{}, {0})); + return {context.mark_node(std::make_shared(x, indices, dim))}; +}; + OutputVector translate_index_fx(const NodeContext& context) { num_inputs_check(context, 2, context.get_input_size()); auto x = context.get_input(0); std::deque> list_elems; for (size_t i = 1; i < context.get_input_size(); i++) { - auto index = context.get_input(static_cast(i)); - if (index.get_element_type() == element::i64) { - auto converted = context.mark_node(std::make_shared(index, element::i32)); - list_elems.push_back(converted); - } else { - list_elems.push_back(index); + Output index; + if (!context.input_is_none(i)) { + index = context.get_input(static_cast(i)); } + list_elems.push_back(index); } - auto concat = - context.mark_node(std::make_shared(OutputVector(list_elems.begin(), list_elems.end()), 0)); - auto gather = std::make_shared(x, concat); - return {gather}; + ov::pass::NodeRegistry rg; + auto rank = x.get_partial_shape().rank(); + if (rank.is_dynamic()) { + rank = context.get_decoder()->get_input_shape(0).rank(); + } + // index transformation supports only tensors with static rank + FRONT_END_OP_CONVERSION_CHECK(rank.is_static(), "Dynamic rank for aten::index input is not supported."); + auto res = index_on_list(rg, x, list_elems, rank.get_length()); + context.mark_nodes(rg.get()); + return res; }; } // namespace op diff --git a/src/frontends/pytorch/src/op/leaky_relu.cpp b/src/frontends/pytorch/src/op/leaky_relu.cpp new file mode 100644 index 00000000000000..edca96998a2084 --- /dev/null +++ b/src/frontends/pytorch/src/op/leaky_relu.cpp @@ -0,0 +1,32 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "openvino/frontend/pytorch/node_context.hpp" +#include "openvino/op/prelu.hpp" +#include "utils.hpp" + +namespace ov { +namespace frontend { +namespace pytorch { +namespace op { + +using namespace ov::op; + +OutputVector translate_leaky_relu_fx(const NodeContext& context) { + num_inputs_check(context, 1, 2); + auto x = context.get_input(0); + float default_negative_slope = 1e-2f; + Output negative_slope = ov::op::v0::Constant::create(element::f32, Shape{1}, {default_negative_slope}); + if (context.get_input_size() == 1) { + negative_slope = context.mark_node(std::make_shared(negative_slope, x)); + } else { + negative_slope = context.get_input(1); + } + return {context.mark_node(std::make_shared(x, negative_slope))}; +}; + +} // namespace op +} // namespace pytorch +} // namespace frontend +} // namespace ov diff --git a/src/frontends/pytorch/src/op/lstm.cpp b/src/frontends/pytorch/src/op/lstm.cpp index 0ea42e8bfa1799..1ec859e5e7b8c5 100644 --- a/src/frontends/pytorch/src/op/lstm.cpp +++ b/src/frontends/pytorch/src/op/lstm.cpp @@ -1,6 +1,7 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // +#include "helper_ops/packed_sequence.hpp" #include "openvino/frontend/pytorch/node_context.hpp" #include "openvino/op/add.hpp" #include "openvino/op/broadcast.hpp" @@ -248,12 +249,23 @@ OutputVector generic_rnn(ov::pass::NodeRegistry& rg, } if (!batch_first) prev_output = rg.make(prev_output, order_102); - Output h_res = rg.make(h_outs, 1); + Output h_res; + if (h_outs.size() == 1) { + h_res = h_outs[0]; + } else { + h_res = rg.make(h_outs, 1); + } + h_res = rg.make(h_res, order_102); if (variant == RnnVariant::RNN || variant == RnnVariant::GRU) { return {prev_output, h_res}; } else if (variant == RnnVariant::LSTM) { - Output c_res = rg.make(c_outs, 1); + Output c_res; + if (c_outs.size() == 1) { + c_res = c_outs[0]; + } else { + c_res = rg.make(c_outs, 1); + } c_res = rg.make(c_res, order_102); return {prev_output, h_res, c_res}; } @@ -267,7 +279,33 @@ OutputVector translate_lstm(const NodeContext& context) { ov::pass::NodeRegistry rg; if (context.get_input_type(3).is()) { // lstm packed - FRONT_END_OP_CONVERSION_CHECK(false, "Unsupported lstm variant."); + // aten::lstm.data(Tensor data, Tensor batch_sizes, Tensor[] hx, Tensor[] params, bool has_biases, int + // num_layers, float dropout, bool train, bool bidirectional) -> (Tensor, Tensor, Tensor) + const auto data = context.get_input(0); + const auto batch_sizes = context.get_input(1); + const auto hx = context.get_input(2); + const auto params = context.get_input(3); + const auto has_bias = context.const_input(4); + const auto num_layers = context.const_input(5); + // const auto dropout = context.const_input(6); - skip + const auto train = context.const_input(7); + FRONT_END_OP_CONVERSION_CHECK(!train, "LSTM in train mode is not supported."); + const auto bidirectional = context.const_input(8); + + const auto initial_states = get_list_as_outputs(hx); + const auto all_weights = get_list_as_outputs(params); + const auto res = generic_rnn(rg, + RnnVariant::LSTM, + data, + initial_states, + all_weights, + has_bias, + num_layers, + bidirectional, + false, + batch_sizes); + context.mark_nodes(rg.get()); + return res; } else { // aten::lstm.input(Tensor input, Tensor[] hx, Tensor[] params, bool has_biases, int num_layers, float dropout, // bool train, bool bidirectional, bool batch_first) -> (Tensor, Tensor, Tensor) diff --git a/src/frontends/pytorch/src/op/mean.cpp b/src/frontends/pytorch/src/op/mean.cpp index 503b7a47f2951f..ef88c2922ac39d 100644 --- a/src/frontends/pytorch/src/op/mean.cpp +++ b/src/frontends/pytorch/src/op/mean.cpp @@ -20,7 +20,7 @@ OutputVector translate_mean(const NodeContext& context) { // aten::mean(Tensor self, *, ScalarType? dtype=None) -> Tensor if (num_inputs == 2) { if (!context.input_is_none(1)) { - x = apply_dtype(context, 3, x); + x = apply_dtype(context, 1, x); } axes = get_axes_range(context, 0); } else { @@ -42,6 +42,30 @@ OutputVector translate_mean(const NodeContext& context) { return {mean}; }; +OutputVector translate_mean_fx(const NodeContext& context) { + num_inputs_check(context, 2, 5); + auto x = context.get_input(0); + auto num_inputs = context.get_input_size(); + bool keep_dims = false; + Output axes; + if (num_inputs == 2) { + axes = context.get_input(1); + } else { + axes = context.get_input(1); + if (!context.input_is_none(2)) { + keep_dims = context.const_input(2); + } + if (!context.input_is_none(3)) { + x = apply_dtype(context, 3, x); + } + } + auto mean = context.mark_node(std::make_shared(x, axes, keep_dims)); + if (num_inputs == 5 && !context.input_is_none(4)) { + context.mutate_input(4, mean); + } + return {mean}; +}; + } // namespace op } // namespace pytorch } // namespace frontend diff --git a/src/frontends/pytorch/src/op/pack_sequence.cpp b/src/frontends/pytorch/src/op/pack_sequence.cpp new file mode 100644 index 00000000000000..2e0fd92b50c231 --- /dev/null +++ b/src/frontends/pytorch/src/op/pack_sequence.cpp @@ -0,0 +1,52 @@ +// Copyright (C) 2018-2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "helper_ops/packed_sequence.hpp" +#include "openvino/frontend/pytorch/node_context.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/convert.hpp" +#include "openvino/op/transpose.hpp" +#include "utils.hpp" + +namespace ov { +namespace frontend { +namespace pytorch { +namespace op { + +using namespace ov::op; + +OutputVector translate_pack_padded_sequence(const NodeContext& context) { + num_inputs_check(context, 3, 3); + auto seq = context.get_input(0); + auto lengths = context.get_input(1); + const auto batch_first = context.const_input(2); + + const auto order_102 = v0::Constant::create(element::i32, Shape{3}, {1, 0, 2}); + if (batch_first) + seq = context.mark_node(std::make_shared(seq, order_102)); + if (lengths.get_element_type() != element::i32) + lengths = context.mark_node(std::make_shared(lengths, element::i32)); + return context.mark_node(std::make_shared(seq, lengths))->outputs(); +}; + +OutputVector translate_pad_packed_sequence(const NodeContext& context) { + // aten::_pad_packed_sequence with schema aten::_pad_packed_sequence(Tensor data, Tensor batch_sizes, bool + // batch_first, Scalar padding_value, int total_length) -> (Tensor, Tensor) + num_inputs_check(context, 3, 5); + auto seq = context.get_input(0); + auto lengths = context.get_input(1); + const auto batch_first = context.const_input(2); + auto pad_packed = context.mark_node(std::make_shared(seq, lengths)); + seq = pad_packed->output(0); + lengths = pad_packed->output(1); + const auto order_102 = v0::Constant::create(element::i32, Shape{3}, {1, 0, 2}); + if (batch_first) + seq = context.mark_node(std::make_shared(seq, order_102)); + return {seq, lengths}; +}; + +} // namespace op +} // namespace pytorch +} // namespace frontend +} // namespace ov diff --git a/src/frontends/pytorch/src/op/pad.cpp b/src/frontends/pytorch/src/op/pad.cpp index ab853fec5f0e29..390277edcf5796 100644 --- a/src/frontends/pytorch/src/op/pad.cpp +++ b/src/frontends/pytorch/src/op/pad.cpp @@ -22,11 +22,12 @@ namespace op { using namespace ov::op; -OutputVector translate_pad(const NodeContext& context) { - num_inputs_check(context, 2, 4); - auto data = context.get_input(0); - auto paddings = context.const_input>(1); - std::string mode = "constant"; +namespace { +OutputVector translate_pad_common(const NodeContext& context, + const Output& data, + const std::vector& paddings, + const Output& pad_value, + const std::string& mode = "constant") { Output shape; Output rank; std::tie(shape, rank) = get_shape_rank(context, data); @@ -45,9 +46,6 @@ OutputVector translate_pad(const NodeContext& context) { auto pads_remaining = context.mark_node(std::make_shared(zero, pads_diff)); auto pads_begins = context.mark_node(std::make_shared(NodeVector{pads_remaining, pads_begin_short}, 0)); auto pads_ends = context.mark_node(std::make_shared(NodeVector{pads_remaining, pads_end_short}, 0)); - if (!context.input_is_none(2)) { - mode = context.const_input(2); - } if (mode == "circular") { int64_t pad_l; int64_t pad_r; @@ -86,24 +84,46 @@ OutputVector translate_pad(const NodeContext& context) { } return {cur}; } + auto pad_value_ = context.mark_node(std::make_shared(pad_value, data)); const std::map pt_to_ov_pad{ {"constant", PadMode::CONSTANT}, {"reflect", PadMode::REFLECT}, {"replicate", PadMode::EDGE}, }; + auto ov_mode = pt_to_ov_pad.find(mode); + FRONT_END_OP_CONVERSION_CHECK(ov_mode != pt_to_ov_pad.end(), + "aten::pad conversion doesn't support [ ", + mode, + " ] padding mode"); + return {context.mark_node(std::make_shared(data, pads_begins, pads_ends, pad_value_, ov_mode->second))}; +} +} // namespace + +OutputVector translate_pad(const NodeContext& context) { + num_inputs_check(context, 2, 4); + auto data = context.get_input(0); + auto paddings = context.const_input>(1); + std::string mode = "constant"; + + if (!context.input_is_none(2)) { + mode = context.const_input(2); + } + Output pad_value = context.mark_node(v0::Constant::create(element::f32, Shape{}, {0})); if (mode == "constant") { if (!context.input_is_none(3)) { pad_value = context.get_input(3); } - pad_value = context.mark_node(std::make_shared(pad_value, data)); } - auto ov_mode = pt_to_ov_pad.find(mode); - FRONT_END_OP_CONVERSION_CHECK(ov_mode != pt_to_ov_pad.end(), - "aten::pad conversion doesn't support [ ", - mode, - " ] padding mode"); - return {context.mark_node(std::make_shared(data, pads_begins, pads_ends, pad_value, ov_mode->second))}; + return translate_pad_common(context, data, paddings, pad_value, mode); +} + +OutputVector translate_constant_pad_nd_fx(const NodeContext& context) { + num_inputs_check(context, 3, 3); + auto data = context.get_input(0); + auto paddings = context.const_input>(1); + auto pad_value = context.get_input(2); + return translate_pad_common(context, data, paddings, pad_value); } } // namespace op diff --git a/src/frontends/pytorch/src/op/scalar_tensor.cpp b/src/frontends/pytorch/src/op/scalar_tensor.cpp new file mode 100644 index 00000000000000..64428486511adb --- /dev/null +++ b/src/frontends/pytorch/src/op/scalar_tensor.cpp @@ -0,0 +1,34 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "openvino/frontend/pytorch/node_context.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/convert.hpp" +#include "openvino/op/convert_like.hpp" +#include "pt_framework_node.hpp" +#include "utils.hpp" + +namespace ov { +namespace frontend { +namespace pytorch { +namespace op { + +using namespace ov::op; + +OutputVector translate_scalar_tensor_fx(const NodeContext& context) { + // aten.scalar_tensor.default(-100.0, dtype = torch.float32, layout = torch.strided, device = device(type='cpu')) + num_inputs_check(context, 1, 1); + auto data = context.get_input(0); + if (context.has_attribute("dtype")) { + auto dtype = context.get_attribute("dtype"); + data = context.mark_node(std::make_shared(context.get_input(0), dtype)); + } + // layout and device can be ignored + return {data}; +} + +} // namespace op +} // namespace pytorch +} // namespace frontend +} // namespace ov diff --git a/src/frontends/pytorch/src/op/scaled_dot_product_attention.cpp b/src/frontends/pytorch/src/op/scaled_dot_product_attention.cpp index 5a9e0d1f95cad7..c1e5fce3abc924 100644 --- a/src/frontends/pytorch/src/op/scaled_dot_product_attention.cpp +++ b/src/frontends/pytorch/src/op/scaled_dot_product_attention.cpp @@ -6,6 +6,7 @@ #include "openvino/frontend/pytorch/node_context.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/convert_like.hpp" +#include "openvino/op/unsqueeze.hpp" #include "openvino/op/util/framework_node.hpp" #include "utils.hpp" @@ -45,16 +46,35 @@ OutputVector translate_scaled_dot_product_attention(const NodeContext& context) }; OutputVector translate_scaled_dot_product_attention_fx(const NodeContext& context) { - // aten::scaled_dot_product_attention(Tensor query, Tensor key, Tensor value, Tensor? attn_mask=None, float - // dropout_p=0., bool is_causal=False) TODO: Scale parameter? - num_inputs_check(context, 3, 6); // TODO: Set 7 instead of 6 if `scale` argument supported in FX. - auto output = translate_scaled_dot_product_attention_common(context); - // TODO: scaled_dot_product_flash_attention has 9 outputs but for most cases only - // the first input is used. Rest of the outputs should be returned properly as - // needed. - ov::OutputVector out_vec; - out_vec.push_back(output); - return {context.mark_node(make_list_construct(out_vec))}; + // torch.ops.aten._scaled_dot_product_flash_attention_for_cpu.default(arg1_1, arg2_1, arg3_1, 0.0, True, attn_mask = + // arg0_1, scale = 5.0) + // aten._scaled_dot_product_flash_attention.default(arg0_1, arg1_1, arg2_1, 0.0, True, scale = 5.0) + num_inputs_check(context, 3, 5); + const auto query = context.get_input(0); + const auto key = context.get_input(1); + const auto value = context.get_input(2); + auto zero = context.mark_node(v0::Constant::create(element::i32, Shape{}, {0})); + OutputVector inputs{query, key, value}; + // Index 3 is dropout + auto causal = false; + if (context.has_attribute("is_causal")) { + causal = context.get_attribute("scale"); + } else if (!context.input_is_none(4)) { + causal = context.const_input(4); + } + if (context.has_attribute("attn_mask")) { + const auto attn_mask = context.get_input("attn_mask"); + inputs.push_back(attn_mask); + } else if (context.has_attribute("scale")) { + // if scale exist but attn_mask no, add zero input to fill in gap + inputs.push_back(context.mark_node(std::make_shared(zero, query))); + } + if (context.has_attribute("scale")) { + const auto scale = context.get_input("scale"); + inputs.push_back(context.mark_node(std::make_shared(scale, query))); + } + auto sdpa = context.mark_node(std::make_shared(inputs, causal)); + return {context.mark_node(make_list_construct({sdpa}))}; }; } // namespace op diff --git a/src/frontends/pytorch/src/op/slice_scatter.cpp b/src/frontends/pytorch/src/op/slice_scatter.cpp new file mode 100644 index 00000000000000..05bdc081a3e317 --- /dev/null +++ b/src/frontends/pytorch/src/op/slice_scatter.cpp @@ -0,0 +1,68 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "helper_ops/slice_assign.hpp" +#include "openvino/frontend/pytorch/node_context.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/slice.hpp" +#include "openvino/op/unsqueeze.hpp" +#include "utils.hpp" + +namespace ov { +namespace frontend { +namespace pytorch { +namespace op { + +using namespace ov::op; + +OutputVector translate_slice_scatter_fx(const NodeContext& context) { + num_inputs_check(context, 2, 6); + auto input = context.get_input(0); + auto src = context.get_input(1); + auto axis_0 = context.mark_node(v0::Constant::create(element::i32, Shape{}, {0})); + ov::Output dim; + if (!context.input_is_none(2)) { + dim = context.get_input(2); + if (dim.get_partial_shape().rank().is_dynamic() || dim.get_partial_shape().rank().get_length() == 0) { + dim = context.mark_node(std::make_shared(dim, axis_0)); + } + } else { + dim = context.mark_node(v0::Constant::create(element::i32, Shape{1}, {1})); + } + ov::Output start; + if (!context.input_is_none(3)) { + start = context.get_input(3); + if (start.get_partial_shape().rank().is_dynamic() || start.get_partial_shape().rank().get_length() == 0) { + start = context.mark_node(std::make_shared(start, axis_0)); + } + } else { + start = context.mark_node(v0::Constant::create(element::i32, Shape{1}, {0})); + } + ov::Output end; + if (!context.input_is_none(4)) { + end = context.get_input(4); + if (end.get_partial_shape().rank().is_dynamic() || end.get_partial_shape().rank().get_length() == 0) { + end = context.mark_node(std::make_shared(end, axis_0)); + } + } else { + end = context.mark_node(v0::Constant::create(element::i32, Shape{1}, {INT_MAX})); + } + ov::Output step; + if (!context.input_is_none(5)) { + step = context.get_input(5); + if (step.get_partial_shape().rank().is_dynamic() || step.get_partial_shape().rank().get_length() == 0) { + step = context.mark_node(std::make_shared(step, axis_0)); + } + } else { + step = context.mark_node(v0::Constant::create(element::i32, Shape{1}, {1})); + } + return {context.mark_node(std::make_shared(input, src, start, end, step, dim))}; +}; + +} // namespace op +} // namespace pytorch +} // namespace frontend +} // namespace ov \ No newline at end of file diff --git a/src/frontends/pytorch/src/op/split.cpp b/src/frontends/pytorch/src/op/split.cpp index db7d35075805b8..7b0241192cb667 100644 --- a/src/frontends/pytorch/src/op/split.cpp +++ b/src/frontends/pytorch/src/op/split.cpp @@ -4,10 +4,11 @@ #include "openvino/op/split.hpp" -#include +//#include #include "openvino/frontend/pytorch/node_context.hpp" #include "openvino/op/util/framework_node.hpp" +#include "openvino/op/variadic_split.hpp" #include "utils.hpp" namespace ov { @@ -18,7 +19,7 @@ namespace op { using namespace ov::op; OutputVector translate_chunk_fx(const NodeContext& context) { - num_inputs_check(context, 2, 3); + num_inputs_check(context, 3, 3); auto num_chunks = context.const_input(1); auto dim = context.get_input(2); @@ -35,6 +36,17 @@ OutputVector translate_chunk_fx(const NodeContext& context) { return {context.mark_node(make_list_construct(chunk->outputs()))}; } +OutputVector translate_split_with_sizes_fx(const NodeContext& context) { + num_inputs_check(context, 3, 3); + auto data = context.get_input(0); + auto split_lengths = context.get_input(1); + auto dim = context.get_input(2); + + auto split = std::make_shared(data, dim, split_lengths); + + return {context.mark_node(make_list_construct(split->outputs()))}; +} + } // namespace op } // namespace pytorch } // namespace frontend diff --git a/src/frontends/pytorch/src/op/sub.cpp b/src/frontends/pytorch/src/op/sub.cpp index 62534aee53864b..69148f23329d4d 100644 --- a/src/frontends/pytorch/src/op/sub.cpp +++ b/src/frontends/pytorch/src/op/sub.cpp @@ -21,7 +21,7 @@ OutputVector translate_sub_common(const NodeContext& context, bool inplace) { auto y = context.get_input(1); if (inplace) { if (x.get_element_type().is_dynamic() || x.get_element_type() != y.get_element_type()) - y = context.mark_node(std::make_shared(x, y)); + y = context.mark_node(std::make_shared(y, x)); } else { align_eltwise_input_types(context, x, y); } @@ -45,6 +45,20 @@ OutputVector translate_sub_(const NodeContext& context) { return translate_sub_common(context, true); }; +OutputVector translate_sub_fx(const NodeContext& context) { + num_inputs_check(context, 2, 2); + auto x = context.get_input(0); + auto y = context.get_input(1); + align_eltwise_input_types(context, x, y); + // default alpha is 1 so no need to multiply if alpha is not provided + if (context.has_attribute("alpha")) { + auto alpha = context.get_attribute>("alpha"); + auto casted_alpha = context.mark_node(std::make_shared(alpha, y)); + y = context.mark_node(std::make_shared(casted_alpha, y)); + } + return {context.mark_node(std::make_shared(x, y))}; +}; + } // namespace op } // namespace pytorch } // namespace frontend diff --git a/src/frontends/pytorch/src/op/to.cpp b/src/frontends/pytorch/src/op/to.cpp index 0267e0ed20c4d4..d902caeb8487bc 100644 --- a/src/frontends/pytorch/src/op/to.cpp +++ b/src/frontends/pytorch/src/op/to.cpp @@ -81,6 +81,16 @@ OutputVector translate_to(const NodeContext& context) { return {cast}; } +OutputVector translate_to_fx(const NodeContext& context) { + num_inputs_check(context, 1, 1); + auto data = context.get_input(0); + if (context.has_attribute("dtype")) { + auto dtype = context.get_attribute("dtype"); + data = context.mark_node(std::make_shared(context.get_input(0), dtype)); + } + return {data}; +} + } // namespace op } // namespace pytorch } // namespace frontend diff --git a/src/frontends/pytorch/src/op_table.cpp b/src/frontends/pytorch/src/op_table.cpp index 9bc3083fbfdf0e..7eb8875787ef01 100644 --- a/src/frontends/pytorch/src/op_table.cpp +++ b/src/frontends/pytorch/src/op_table.cpp @@ -95,6 +95,7 @@ OP_CONVERTER(translate_gru); OP_CONVERTER(translate_hardtanh); OP_CONVERTER(translate_if); OP_CONVERTER(translate_im2col); +OP_CONVERTER(translate_index); OP_CONVERTER(translate_index_add); OP_CONVERTER(translate_index_put_); OP_CONVERTER(translate_index_select); @@ -148,7 +149,9 @@ OP_CONVERTER(translate_ones_like); OP_CONVERTER(translate_or); OP_CONVERTER(translate_bitwise_xor); OP_CONVERTER(translate_outer); +OP_CONVERTER(translate_pack_padded_sequence); OP_CONVERTER(translate_pad); +OP_CONVERTER(translate_pad_packed_sequence); OP_CONVERTER(translate_pairwise_distance); OP_CONVERTER(translate_pixel_shuffle); OP_CONVERTER(translate_pixel_unshuffle); @@ -230,19 +233,36 @@ OP_CONVERTER(translate_quantized_convnd_relu); OP_CONVERTER(translate_quantized_linear); OP_CONVERTER(translate_xor); // Torch FX Translations +OP_CONVERTER(translate_adaptive_max_pool1d_fx); +OP_CONVERTER(translate_adaptive_max_pool2d_fx); +OP_CONVERTER(translate_adaptive_max_pool3d_fx); +OP_CONVERTER(translate_addcmul_fx); +OP_CONVERTER(translate_addmm_fx); OP_CONVERTER(translate_arange_fx); OP_CONVERTER(translate_batch_norm_legit_fx); OP_CONVERTER(translate_batch_norm_legit_no_training_fx); +OP_CONVERTER(translate_batch_norm_legit_no_stats_fx); OP_CONVERTER(translate_cat_fx); +OP_CONVERTER(translate_constant_pad_nd_fx); OP_CONVERTER(translate_chunk_fx); +OP_CONVERTER(translate_div_fx); OP_CONVERTER(translate_expand_fx); +OP_CONVERTER(translate_full_fx); +OP_CONVERTER(translate_gelu_fx); OP_CONVERTER(translate_group_norm_fx); OP_CONVERTER(translate_index_fx); OP_CONVERTER(translate_layer_norm_fx); +OP_CONVERTER(translate_leaky_relu_fx); OP_CONVERTER(translate_max_poolnd_fx); +OP_CONVERTER(translate_mean_fx); +OP_CONVERTER(translate_split_with_sizes_fx); +OP_CONVERTER(translate_scalar_tensor_fx); OP_CONVERTER(translate_scaled_dot_product_attention_fx); OP_CONVERTER(translate_slice_fx); +OP_CONVERTER(translate_slice_scatter_fx); OP_CONVERTER(translate_softmax_fx); +OP_CONVERTER(translate_sub_fx); +OP_CONVERTER(translate_to_fx); OP_CONVERTER(translate_transpose_fx); } // namespace op @@ -260,6 +280,8 @@ const std::map get_supported_ops_ts() { {"aten::_convolution", op::translate_convolution}, {"aten::_convolution_mode", op::translate_convolution_mode}, {"aten::_native_multi_head_attention", op::translate_native_multi_head_attention}, + {"aten::_pack_padded_sequence", op::translate_pack_padded_sequence}, + {"aten::_pad_packed_sequence", op::translate_pad_packed_sequence}, {"aten::_set_item", op::translate_set_item}, {"aten::_shape_as_tensor", op::translate_shape_as_tensor}, {"aten::_upsample_bicubic2d_aa", op::translate_upsample_bicubic2d_aa}, @@ -631,81 +653,123 @@ const std::map get_supported_ops_ts() { const std::map get_supported_ops_fx() { return { - {"aten._adaptive_avg_pool2d.default", op::translate_1to1_match_2_inputs}, + {"aten.abs.default", op::translate_1to1_match_1_inputs}, + {"aten._adaptive_avg_pool1d.default", op::translate_adaptive_avg_pool1d}, + {"aten._adaptive_avg_pool2d.default", op::translate_adaptive_avg_pool2d}, + {"aten._adaptive_avg_pool3d.default", op::translate_adaptive_avg_pool3d}, + {"aten.adaptive_max_pool1d.default", op::translate_adaptive_max_pool1d_fx}, + {"aten.adaptive_max_pool2d.default", op::translate_adaptive_max_pool2d_fx}, + {"aten.adaptive_max_pool3d.default", op::translate_adaptive_max_pool3d_fx}, + {"aten._local_scalar_dense.default", op::skip_node}, {"aten._softmax.default", op::translate_softmax_fx}, - {"aten._to_copy.default", op::skip_node}, + {"aten._to_copy.default", op::translate_to_fx}, {"aten._unsafe_view.default", op::translate_reshape}, {"aten.add.Tensor", op::translate_add}, {"aten.add_.Tensor", op::translate_add}, - {"aten.addmm.default", op::translate_addmm}, + {"aten.addcmul.default", op::translate_addcmul_fx}, + {"aten.addmm.default", op::translate_addmm_fx}, + {"aten.alias.default", op::skip_node}, {"aten.arange.start", op::translate_arange_fx}, + {"aten.arange.start_step", op::translate_arange_fx}, {"aten.arange.default", op::translate_arange_fx}, {"aten.argmax.default", op::translate_argmax}, + {"aten.as_strided.default", op::translate_as_strided}, {"aten.avg_pool2d.default", op::translate_avg_poolnd}, - {"aten.baddbmm.default", op::translate_addmm}, + {"aten.avg_pool3d.default", op::translate_avg_poolnd}, + {"aten.baddbmm.default", op::translate_addmm_fx}, {"aten.bitwise_and.Tensor", op::translate_bitwise_and}, {"aten.bmm.default", op::translate_1to1_match_2_inputs_align_types}, {"aten.cat.default", op::translate_cat_fx}, + {"aten.ceil.default", op::translate_1to1_match_1_inputs}, + {"aten.clamp.default", op::translate_clamp}, {"aten.clamp_min.default", op::translate_1to1_match_2_inputs}, + {"aten.constant_pad_nd.default", op::translate_constant_pad_nd_fx}, {"aten.clone.default", op::skip_node}, // ignore clone operators that are inserted by PyTorch autograd {"aten.convolution.default", op::translate_convolution}, - {"aten.copy_.default", op::skip_node}, + {"aten._convolution.default", op::translate_convolution}, + {"aten.copy.default", op::skip_node}, + {"aten.copy_.default", op::translate_copy_}, {"aten.cos.default", op::translate_1to1_match_1_inputs}, {"aten.cumsum.default", op::translate_cumsum}, {"aten.detach.default", op::skip_node}, - {"aten.div.Scalar", op::translate_div}, - {"aten.div.Tensor", op::translate_div}, + {"aten.div.Scalar", op::translate_div_fx}, + {"aten.div.Tensor", op::translate_div_fx}, + {"aten.div.Tensor_mode", op::translate_div_fx}, {"aten.embedding.default", op::translate_embedding}, {"aten.empty.memory_format", op::translate_empty}, {"aten.eq.Scalar", op::translate_1to1_match_2_inputs_align_types}, {"aten.eq.Tensor", op::translate_1to1_match_2_inputs_align_types}, {"aten.exp.default", op::translate_1to1_match_1_inputs}, {"aten.expand.default", op::translate_expand_fx}, - {"aten.full.default", op::translate_full}, + {"aten.floor.default", op::translate_1to1_match_1_inputs}, + {"aten.floor_divide.default", op::translate_floor_divide}, + {"aten.full.default", op::translate_full_fx}, + {"aten.full.names", op::translate_full_fx}, + {"aten.full_like.default", op::translate_full_like}, {"aten.gather.default", op::translate_gather}, - {"aten.gelu.default", op::translate_gelu}, + {"aten.gelu.default", op::translate_gelu_fx}, + {"aten.glu.default", op::translate_glu}, {"aten.gt.Scalar", op::translate_1to1_match_2_inputs_align_types}, {"aten.hardsigmoid.default", op::translate_1to1_match_1_inputs}, + {"aten.hardswish.default", op::translate_1to1_match_1_inputs}, {"aten.hardswish_.default", op::inplace_op>}, + {"aten.hardtanh.default", op::translate_hardtanh}, {"aten.hardtanh_.default", op::inplace_op}, {"aten.index.Tensor", op::translate_index_fx}, - {"aten.leaky_relu_.default", op::inplace_op>}, + {"aten.leaky_relu.default", op::translate_leaky_relu_fx}, + {"aten.leaky_relu_.default", op::inplace_op}, {"aten.lift_fresh_copy.default", op::skip_node}, {"aten.linalg_vector_norm.default", op::translate_linalg_vector_norm}, {"aten.log.default", op::translate_log}, {"aten.logsumexp.default", op::translate_logsumexp}, + {"aten.lt.Scalar", op::translate_1to1_match_2_inputs_align_types}, {"aten.lt.Tensor", op::translate_1to1_match_2_inputs_align_types}, {"aten.masked_fill_.Scalar", op::inplace_op}, {"aten.masked_fill.Tensor", op::translate_masked_fill}, {"aten.max_pool2d_with_indices.default", op::translate_max_poolnd_fx}, - {"aten.mean.dim", op::translate_mean}, + {"aten.max_pool3d_with_indices.default", op::translate_max_poolnd_fx}, + {"aten.mean.dim", op::translate_mean_fx}, {"aten.mm.default", op::translate_1to1_match_2_inputs}, {"aten.mul.Tensor", op::translate_1to1_match_2_inputs_align_types}, {"aten.mul.Scalar", op::translate_1to1_match_2_inputs_align_types}, {"aten.native_batch_norm.default", op::translate_batch_norm_legit_fx}, {"aten._native_batch_norm_legit.default", op::translate_batch_norm_legit_fx}, + {"aten._native_batch_norm_legit.no_stats", op::translate_batch_norm_legit_no_stats_fx}, {"aten._native_batch_norm_legit_no_training.default", op::translate_batch_norm_legit_no_training_fx}, + {"aten._native_batch_norm_legit_functional.default", op::translate_batch_norm_legit_fx}, + {"aten.native_dropout.default", op::skip_node}, {"aten.native_group_norm.default", op::translate_group_norm_fx}, {"aten.native_layer_norm.default", op::translate_layer_norm_fx}, + {"aten.ne.Scalar", op::translate_1to1_match_2_inputs_align_types}, {"aten.neg.default", op::translate_neg}, {"aten.new_ones.default", op::translate_new_ones}, {"aten.permute.default", op::translate_1to1_match_2_inputs}, {"aten.pow.Tensor_Scalar", op::translate_pow}, {"aten.relu.default", op::translate_1to1_match_1_inputs}, {"aten.relu_.default", op::inplace_op>}, + {"aten.repeat.default", op::translate_1to1_match_2_inputs}, {"aten.rsub.Scalar", op::translate_rsub}, + {"aten.roll.default", op::translate_roll}, {"aten._scaled_dot_product_flash_attention.default", op::translate_scaled_dot_product_attention_fx}, + {"aten._scaled_dot_product_flash_attention_for_cpu.default", op::translate_scaled_dot_product_attention_fx}, + {"aten.scalar_tensor.default", op::translate_scalar_tensor_fx}, {"aten.select.int", op::translate_select}, {"aten.sigmoid.default", op::translate_1to1_match_1_inputs}, {"aten.silu.default", op::translate_1to1_match_1_inputs}, {"aten.silu_.default", op::inplace_op>}, {"aten.sin.default", op::translate_1to1_match_1_inputs}, {"aten.slice.Tensor", op::translate_slice_fx}, + {"aten.slice_scatter.default", op::translate_slice_scatter_fx}, {"aten.split.Tensor", op::translate_chunk_fx}, - {"aten.sub.default", op::translate_sub}, - {"aten.sub.Tensor", op::translate_sub}, + {"aten.split_with_sizes.default", op::translate_split_with_sizes_fx}, + {"aten.squeeze.dim", op::translate_squeeze}, + {"aten.squeeze.dims", op::translate_squeeze}, + {"aten.sub.default", op::translate_sub_fx}, + {"aten.sub.Tensor", op::translate_sub_fx}, + {"aten.sum.dim_IntList", op::translate_sum}, {"aten.t.default", op::translate_t}, {"aten.tanh.default", op::translate_1to1_match_1_inputs}, + {"aten.unfold.default", op::translate_unfold}, {"aten.transpose.int", op::translate_transpose}, {"aten.unsqueeze.default", op::translate_1to1_match_2_inputs}, {"aten.upsample_nearest2d.default", op::translate_upsample_nearest2d}, diff --git a/src/frontends/pytorch/src/transforms/remove_packing_ops.cpp b/src/frontends/pytorch/src/transforms/remove_packing_ops.cpp new file mode 100644 index 00000000000000..d5e13c6d31a21d --- /dev/null +++ b/src/frontends/pytorch/src/transforms/remove_packing_ops.cpp @@ -0,0 +1,135 @@ +// Copyright (C) 2018-2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "remove_packing_ops.hpp" + +#include "helper_ops/packed_sequence.hpp" +#include "openvino/op/gather.hpp" +#include "openvino/op/gru_sequence.hpp" +#include "openvino/op/lstm_sequence.hpp" +#include "openvino/op/reshape.hpp" +#include "openvino/op/rnn_sequence.hpp" +#include "openvino/op/shape_of.hpp" +#include "openvino/op/squeeze.hpp" +#include "openvino/op/transpose.hpp" +#include "openvino/pass/pattern/matcher.hpp" +#include "openvino/pass/pattern/op/wrap_type.hpp" +#include "utils.hpp" + +namespace ov { +namespace frontend { +namespace pytorch { +namespace pass { + +using namespace ov::pass; +using namespace ov::op; + +namespace { +bool is_rnn(std::shared_ptr node) { + if (as_type_ptr(node) || as_type_ptr(node) || + as_type_ptr(node)) { + return true; + } + return false; +} +} // namespace + +MovePackThroughLstm::MovePackThroughLstm() { + auto pack_op = pattern::wrap_type(); + + ov::matcher_pass_callback callback = [=](pattern::Matcher& m) { + auto pack = m.get_match_root(); + + auto targets = pack->output(0).get_target_inputs(); + if (targets.size() != 1) + return false; + auto rnn = targets.begin()->get_node()->shared_from_this(); + // Input to rnn may be transposed, skipping Transpose + if (as_type_ptr(rnn)) + rnn = rnn->output(0).get_target_inputs().begin()->get_node()->shared_from_this(); + if (!is_rnn(rnn)) + return false; + targets = rnn->output(0).get_target_inputs(); + if (targets.size() != 1) + return false; + + // The rnn is followed by a transpose and a reshape (if bidirectional), or by a squeeze (if unidirectional). + auto next = targets.begin()->get_node()->shared_from_this(); + if (as_type_ptr(next)) { + next = next->output(0).get_target_inputs().begin()->get_node()->shared_from_this(); + if (!as_type_ptr(next)) { + return false; + } + } else if (!as_type_ptr(next)) { + return false; + } + + // remove PackPadded from in front of the RNN + pack->output(0).replace(pack->input_value(0)); + + auto batch_sizes = pack->output(1); + for (auto node_input : batch_sizes.get_target_inputs()) { + auto user = node_input.get_node()->shared_from_this(); + // Make calculation of max_batch_size not depend on batch_sizes. + // This looks for a pattern generated by code such as + // https://github.com/pytorch/pytorch/blob/febff45/torch/nn/modules/rnn.py#L815-L815. + // + // Replace Gather[axis=0](batch_sizes, 0) + // with Gather[axis=0](ShapeOf(rnn_input), 0) + if (const auto gather = as_type_ptr(user)) { + if (gather->get_axis() != 0) + continue; + auto rnn_shape = std::make_shared(rnn->input_value(0), element::i32); + auto indx_1 = v0::Constant::create(element::i32, Shape{}, {0}); + auto new_gather = std::make_shared(rnn_shape, indx_1, gather->input_value(2)); + copy_runtime_info_and_name(gather, {new_gather, rnn_shape, indx_1}); + replace_node(gather, new_gather); + } else if (user == rnn) { + node_input.replace_source_output(pack->input_value(1)); + } + } + // and insert new PackPadded after the RNN + auto next_target_inputs = next->output(0).get_target_inputs(); + auto newPackPadded = std::make_shared(next->output(0), pack->input_value(1)); + register_new_node(newPackPadded); + + // make things consume from the new PackPadded + for (auto& input : next_target_inputs) + input.replace_source_output(newPackPadded->output(0)); + pack->output(1).replace(newPackPadded->output(1)); + + return true; + }; + + auto m = std::make_shared(pack_op, "ov::frontend::pytorch::pass::MovePackThroughLstm"); + this->register_matcher(m, callback); +}; + +RemovePackingOps::RemovePackingOps() { + auto unpack_op = pattern::wrap_type(); + + ov::matcher_pass_callback callback = [](pattern::Matcher& m) { + const auto& unpack = m.get_match_root(); + auto pack_node = unpack->input_value(0).get_node_shared_ptr(); + if (as_type_ptr(pack_node)) + pack_node = std::dynamic_pointer_cast(pack_node->input_value(0).get_node_shared_ptr()); + if (!pack_node) + return false; + + pack_node->output(0).replace(pack_node->input_value(0)); + pack_node->output(1).replace(pack_node->input_value(1)); + unpack->output(0).replace(unpack->input_value(0)); + unpack->output(1).replace(unpack->input_value(1)); + + return true; + }; + + auto m = std::make_shared(unpack_op, "ov::frontend::pytorch::pass::RemovePackingOps"); + this->register_matcher(m, callback); +}; + +} // namespace pass +} // namespace pytorch +} // namespace frontend +} // namespace ov diff --git a/src/frontends/pytorch/src/transforms/remove_packing_ops.hpp b/src/frontends/pytorch/src/transforms/remove_packing_ops.hpp new file mode 100644 index 00000000000000..773100dfc35af9 --- /dev/null +++ b/src/frontends/pytorch/src/transforms/remove_packing_ops.hpp @@ -0,0 +1,36 @@ +// Copyright (C) 2018-2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "openvino/pass/graph_rewrite.hpp" +#include "openvino/pass/pass.hpp" + +namespace ov { +namespace frontend { +namespace pytorch { +namespace pass { + +/** + * Move PackPadded through RNN ops, because RNN(PackPadded(x)) == PackPadded(RNN(x)). + */ +class MovePackThroughLstm : public ov::pass::MatcherPass { +public: + OPENVINO_RTTI("ov::frontend::pytorch::pass::MovePackThroughLstm"); + MovePackThroughLstm(); +}; + +/** + * Remove PackPadded -> PadPacked ops. + */ +class RemovePackingOps : public ov::pass::MatcherPass { +public: + OPENVINO_RTTI("ov::frontend::pytorch::pass::RemovePackingOps"); + RemovePackingOps(); +}; + +} // namespace pass +} // namespace pytorch +} // namespace frontend +} // namespace ov diff --git a/src/frontends/pytorch/src/transforms/softmax_reshape_elimination.cpp b/src/frontends/pytorch/src/transforms/softmax_reshape_elimination.cpp index 927097023bcdbf..65a059778924fa 100644 --- a/src/frontends/pytorch/src/transforms/softmax_reshape_elimination.cpp +++ b/src/frontends/pytorch/src/transforms/softmax_reshape_elimination.cpp @@ -5,10 +5,10 @@ #include "softmax_reshape_elimination.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/reshape.hpp" #include "openvino/op/softmax.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" +#include "validation_util.hpp" namespace ov { namespace frontend { @@ -39,9 +39,7 @@ SoftmaxReshapeElimination::SoftmaxReshapeElimination() { const auto softmax_rank = softmax->get_input_partial_shape(0).rank(); int64_t axis = 0; if (const auto softmax_v8 = ov::as_type_ptr(softmax)) { - OPENVINO_SUPPRESS_DEPRECATED_START - axis = ov::normalize_axis(softmax->get_friendly_name(), softmax_v8->get_axis(), softmax_rank); - OPENVINO_SUPPRESS_DEPRECATED_END + axis = ov::util::normalize_axis(softmax->get_friendly_name(), softmax_v8->get_axis(), softmax_rank); } else if (const auto softmax_v1 = ov::as_type_ptr(softmax)) { axis = softmax_v1->get_axis(); } else { diff --git a/src/frontends/pytorch/src/translate_session.cpp b/src/frontends/pytorch/src/translate_session.cpp index 1beed272f43c48..1791326f41a57b 100644 --- a/src/frontends/pytorch/src/translate_session.cpp +++ b/src/frontends/pytorch/src/translate_session.cpp @@ -74,10 +74,6 @@ std::shared_ptr TranslateSession::convert_pytorch_model( std::shared_ptr pytorch_model, const TensorMap& external_tensor_map, const std::shared_ptr& input_model) { - // FIXME: don't use global variable to count inlined inputs, no we should use global counter because ID should be - // unique for all new inlined inputs - static size_t inlined_nodes_counter = 100000000; // Suppose there are not graph with more than 10M nodes - std::shared_ptr resulting_model; // define here to make a conversion in a nested scope { auto parameters = std::make_shared(); @@ -128,18 +124,6 @@ std::shared_ptr TranslateSession::convert_pytorch_model( // But this value can be found in the outer scope, for this purpose we create new input for the model to // link with external scope on a higher level. - auto inlined_inputs = node->inlined_inputs(inlined_nodes_counter); - for (size_t i = 0; i < inlined_inputs.size(); ++i) { - size_t fw_tensor_id = inlined_nodes_counter; - ++inlined_nodes_counter; // TODO: Make sure that Decoder side use the same increment for producing ids - if (tensor_map->find(fw_tensor_id) != tensor_map->end()) { - throw std::runtime_error("Duplicated producer for PT value with unique ID: " + - std::to_string(fw_tensor_id) + " produced by inlined_inputs"); - } - - (*tensor_map)[fw_tensor_id] = inlined_inputs[i]; - } - auto raw_inputs = node->inputs(); for (size_t i = 0; i < raw_inputs.size(); ++i) { auto input = raw_inputs.at(i); @@ -286,11 +270,13 @@ OutputVector TranslateSession::convert_node(const NodeContext& context) { if (it != m_translator_map.end()) { return it->second(context); } + OPENVINO_DEBUG << "No translator found for: " << context.get_op_type() << "\n"; } catch (std::exception& e) { exception = e.what(); } catch (...) { exception = "Unknown exception type."; } + OPENVINO_DEBUG << exception << "\n"; try { // Create PtFrameworkNode for everything that wasn't able to be converted normally return make_framework_node(context, exception); @@ -299,6 +285,7 @@ OutputVector TranslateSession::convert_node(const NodeContext& context) { } catch (...) { exception += " Unknown exception happened while creating FrameworkNode with subgraphs"; } + OPENVINO_DEBUG << exception << "\n"; return make_framework_node_ignore_bodies(context, exception); } diff --git a/src/frontends/pytorch/src/utils.cpp b/src/frontends/pytorch/src/utils.cpp index 20f56b9d421187..86c6d11e1d65e7 100644 --- a/src/frontends/pytorch/src/utils.cpp +++ b/src/frontends/pytorch/src/utils.cpp @@ -346,7 +346,7 @@ std::shared_ptr cast_fw_node(std::shared_ptr return fw_node; } -std::shared_ptr make_list_construct(const ov::OutputVector& inputs) { +std::shared_ptr make_list_construct(const ov::OutputVector& inputs) { auto list_construct = std::make_shared<::ov::op::util::FrameworkNode>(inputs, inputs.size()); ov::op::util::FrameworkNodeAttrs attrs; attrs.set_type_name("PTFrameworkNode"); diff --git a/src/frontends/pytorch/src/utils.hpp b/src/frontends/pytorch/src/utils.hpp index 93dc956124ae76..3cb5798af9f65c 100644 --- a/src/frontends/pytorch/src/utils.hpp +++ b/src/frontends/pytorch/src/utils.hpp @@ -64,7 +64,7 @@ OutputVector make_framework_node(const NodeContext& context, const std::string& std::shared_ptr cast_fw_node(std::shared_ptr node, const std::string& type); -std::shared_ptr make_list_construct(const ov::OutputVector& inputs); +std::shared_ptr make_list_construct(const ov::OutputVector& inputs); bool is_none_node(const Output& node); @@ -248,8 +248,17 @@ class DummyDecoder : public TorchDecoder { virtual bool may_produce_alias(size_t in_index, size_t out_index) const override { FRONT_END_NOT_IMPLEMENTED(may_produce_alias); } - virtual OutputVector inlined_inputs(size_t start_index) const override { - FRONT_END_NOT_IMPLEMENTED(inlined_inputs); + bool is_input_inlined(size_t index) const override { + FRONT_END_NOT_IMPLEMENTED(is_input_inlined); + } + virtual OutputVector inlined_input(size_t index) const override { + FRONT_END_NOT_IMPLEMENTED(inlined_input); + } + virtual ov::Any get_attribute(const std::string& name) const override { + FRONT_END_NOT_IMPLEMENTED(get_attribute); + } + virtual size_t get_named_input(const std::string& name) const override { + FRONT_END_NOT_IMPLEMENTED(get_named_input); } private: diff --git a/src/frontends/tensorflow/docs/supported_ops.md b/src/frontends/tensorflow/docs/supported_ops.md index 27d61a8bf7ad69..374c7ef88ee3de 100644 --- a/src/frontends/tensorflow/docs/supported_ops.md +++ b/src/frontends/tensorflow/docs/supported_ops.md @@ -1,4 +1,4 @@ -# TensorFlow Operations Supported by OpenVINO TensorFlow Frontend +# TensorFlow Operations Supported by OpenVINO TensorFlow Frontend Here is a table of operations supported by the TensorFlow Frontend from [tf.raw_ops](https://www.tensorflow.org/api_docs/python/tf/raw_ops). A "supported operation" is one that TensorFlow Frontend can convert to the OpenVINO representation. @@ -232,7 +232,7 @@ A "supported operation" is one that TensorFlow Frontend can convert to the OpenV | ConditionalAccumulator | NO | | | ConfigureDistributedTPU | NO | | | ConfigureTPUEmbedding | NO | | -| Conj | NO | | +| Conj | YES | | | ConjugateTranspose | YES | | | Const | YES | | | ConsumeMutexLock | NO | | @@ -594,10 +594,10 @@ A "supported operation" is one that TensorFlow Frontend can convert to the OpenV | LogicalOr | YES | | | LookupTableExport | NO | | | LookupTableExportV2 | NO | | -| LookupTableFind | NO | | -| LookupTableFindV2 | NO | | -| LookupTableImport | NO | | -| LookupTableImportV2 | NO | | +| LookupTableFind | YES | | +| LookupTableFindV2 | YES | | +| LookupTableImport | YES | | +| LookupTableImportV2 | YES | | | LookupTableInsert | YES | | | LookupTableInsertV2 | YES | | | LookupTableRemoveV2 | NO | | diff --git a/src/frontends/tensorflow/include/openvino/frontend/tensorflow/variable.hpp b/src/frontends/tensorflow/include/openvino/frontend/tensorflow/variable.hpp index e8f783c994f153..88f4ca551a2fb2 100644 --- a/src/frontends/tensorflow/include/openvino/frontend/tensorflow/variable.hpp +++ b/src/frontends/tensorflow/include/openvino/frontend/tensorflow/variable.hpp @@ -4,6 +4,7 @@ #pragma once +#include "openvino/frontend/tensorflow/decoder.hpp" #include "openvino/op/util/framework_node.hpp" namespace ov { @@ -15,6 +16,17 @@ class Variable : public ov::op::util::FrameworkNode { using Ptr = std::shared_ptr; OPENVINO_OP("TFVariable", "ov::frontend::tensorflow", ::ov::op::util::FrameworkNode); + Variable(const std::string& name, const std::shared_ptr& decoder) + : ov::op::util::FrameworkNode(ov::OutputVector{}, 1), + m_name(name), + m_shape(ov::Shape{}), + m_type(ov::element::dynamic), + m_decoder(decoder), + m_is_initialized(false), + m_init_counter(0) { + validate_and_infer_types(); + } + Variable(const std::string& name, const ov::Shape& shape, const ov::element::Type& type, @@ -60,7 +72,7 @@ class Variable : public ov::op::util::FrameworkNode { return m_is_initialized; } - ov::Output get_value() const { + virtual ov::Output get_value() { FRONT_END_GENERAL_CHECK( m_is_initialized, "[TensorFlow Frontend] internal error: get_value() is called for uninitialized variable"); @@ -75,7 +87,7 @@ class Variable : public ov::op::util::FrameworkNode { return m_init_counter; } -private: +protected: std::string m_name; ov::Shape m_shape; ov::element::Type m_type; diff --git a/src/frontends/tensorflow/src/hash_table.hpp b/src/frontends/tensorflow/src/hash_table.hpp new file mode 100644 index 00000000000000..74407e6e323548 --- /dev/null +++ b/src/frontends/tensorflow/src/hash_table.hpp @@ -0,0 +1,113 @@ +// Copyright (C) 2018-2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "openvino/core/node_output.hpp" +#include "openvino/core/type/element_type.hpp" +#include "openvino/frontend/tensorflow/variable.hpp" + +namespace ov { +namespace frontend { +namespace tensorflow { + +// this class describes TensorFlow table produced by operations tf.raw_ops.HashTable, tf.raw_ops.HashTableV2, +// tf.raw_ops.MutableHashTable and stores a dictionary of keys mapped to values +// Objects of this class is fed to Lookup* operations for initialization and searching values by keys +// Types of keys and values can be different +class HashTable : public Variable { +public: + using Ptr = std::shared_ptr; + OPENVINO_OP("TFHashTable", "ov::frontend::tensorflow", Variable); + + HashTable(const std::string& name, + const ov::element::Type& key_type, + const ov::element::Type& value_type, + const std::shared_ptr& decoder = nullptr) + : Variable(name, decoder), + m_key_type(key_type), + m_value_type(value_type) { + validate_and_infer_types(); + } + + HashTable(const HashTable& other, const ov::Output& keys, const ov::Output& values) + : HashTable(other) { + m_keys = keys; + m_values = values; + // reset names of tensor corresponding to variable value + // that is because variable can have multiple values during inference + m_keys.set_names({}); + m_values.set_names({}); + m_is_initialized = true; + ++m_init_counter; + } + + // it must be used only for cloning + // other ways are illegal + HashTable(const std::string& name, + const ov::element::Type& key_type, + const ov::element::Type& value_type, + const ov::Output& keys, + const ov::Output& values, + bool is_initialized, + uint64_t init_counter, + const std::shared_ptr& decoder = nullptr) + : Variable(name, decoder), + m_key_type(key_type), + m_value_type(value_type), + m_keys(keys), + m_values(values) { + m_init_counter = init_counter; + m_is_initialized = is_initialized; + validate_and_infer_types(); + } + + void validate_and_infer_types() override { + // this is a type of resource so its shape and type is not applicable + set_output_type(0, ov::element::dynamic, ov::PartialShape::dynamic()); + } + + std::shared_ptr clone_with_new_inputs(const OutputVector& inputs) const override { + auto hash_table_node = std::make_shared(m_name, + m_key_type, + m_value_type, + m_keys, + m_values, + m_is_initialized, + m_init_counter, + m_decoder); + hash_table_node->set_attrs(get_attrs()); + return hash_table_node; + } + + ov::Output get_values() const { + FRONT_END_GENERAL_CHECK(m_is_initialized, + "[TensorFlow Frontend] internal error: get_values() is called for uninitialized table"); + return m_values; + } + + ov::Output get_keys() const { + FRONT_END_GENERAL_CHECK(m_is_initialized, + "[TensorFlow Frontend] internal error: get_values() is called for uninitialized table"); + return m_keys; + } + + ov::Output get_value() override { + return output(0); + } + + ov::element::Type get_key_type() const { + return m_key_type; + } + +private: + ov::element::Type m_key_type; + ov::element::Type m_value_type; + ov::Output m_keys; + ov::Output m_values; +}; + +} // namespace tensorflow +} // namespace frontend +} // namespace ov diff --git a/src/frontends/tensorflow/src/op/block_lstm.cpp b/src/frontends/tensorflow/src/op/block_lstm.cpp index c9e9929fbc7ef3..6f4700b41c19cd 100644 --- a/src/frontends/tensorflow/src/op/block_lstm.cpp +++ b/src/frontends/tensorflow/src/op/block_lstm.cpp @@ -5,7 +5,6 @@ #include "helper_ops/block_lstm.hpp" #include "common_op_table.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/frontend/tensorflow/node_context.hpp" using namespace std; diff --git a/src/frontends/tensorflow/src/op/hash_table.cpp b/src/frontends/tensorflow/src/op/hash_table.cpp index cf68ccb287ee33..6d5d023ad627e0 100644 --- a/src/frontends/tensorflow/src/op/hash_table.cpp +++ b/src/frontends/tensorflow/src/op/hash_table.cpp @@ -2,12 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "helper_ops/hash_table.hpp" +#include "hash_table.hpp" #include "common_op_table.hpp" #include "openvino/frontend/tensorflow/node_context.hpp" #include "utils.hpp" +using namespace ov; using namespace std; namespace ov { @@ -17,9 +18,11 @@ namespace op { OutputVector translate_hash_table_op(const ov::frontend::tensorflow::NodeContext& node) { default_op_checks(node, 0, {"MutableHashTable", "MutableHashTableV2", "HashTable", "HashTableV2"}); + auto node_name = node.get_name(); + auto key_dtype = node.get_attribute("key_dtype"); + auto value_dtype = node.get_attribute("value_dtype"); - auto hash_table = make_shared(node.get_decoder()); - set_node_name(node.get_name(), hash_table); + auto hash_table = make_shared(node_name, key_dtype, value_dtype, node.get_decoder()); return {hash_table}; } diff --git a/src/frontends/tensorflow/src/op/lookup_table_find.cpp b/src/frontends/tensorflow/src/op/lookup_table_find.cpp new file mode 100644 index 00000000000000..b9c9647469062e --- /dev/null +++ b/src/frontends/tensorflow/src/op/lookup_table_find.cpp @@ -0,0 +1,103 @@ +// Copyright (C) 2018-2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "common_op_table.hpp" +#include "hash_table.hpp" +#include "openvino/frontend/tensorflow/node_context.hpp" +#include "openvino/frontend/tensorflow/variable.hpp" +#include "openvino/op/concat.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/convert.hpp" +#include "openvino/op/equal.hpp" +#include "openvino/op/gather.hpp" +#include "openvino/op/multiply.hpp" +#include "openvino/op/range.hpp" +#include "openvino/op/reduce_logical_or.hpp" +#include "openvino/op/reduce_max.hpp" +#include "openvino/op/reshape.hpp" +#include "openvino/op/select.hpp" +#include "openvino/op/shape_of.hpp" +#include "openvino/op/unsqueeze.hpp" + +using namespace std; +using namespace ov; +using namespace ov::op; +using namespace ov::frontend::tensorflow; + +namespace ov { +namespace frontend { +namespace tensorflow { +namespace op { +OutputVector translate_lookup_table_find_op(const NodeContext& node) { + default_op_checks(node, 3, {"LookupTableFind", "LookupTableFindV2"}); + auto table_handle = as_type_ptr(node.get_input_by_reference(0).get_node_shared_ptr()); + TENSORFLOW_OP_VALIDATION( + node, + table_handle, + "[TensorFlow Frontend] internal error: LookupTableFind operation expects table_handle by the first input"); + TENSORFLOW_OP_VALIDATION( + node, + table_handle->is_initialized(), + "[TensorFlow Frontend] internal error: LookupTableFind operation expects initialized table_handle"); + auto keys = node.get_input(1); + auto default_value = node.get_input(2); + + auto key_type = table_handle->get_key_type(); + TENSORFLOW_OP_VALIDATION( + node, + key_type.is_integral_number(), + "[TensorFlow Frontend] internal error: LookupTableFind is only supported for integer keys"); + + auto all_keys = table_handle->get_keys(); + auto all_values = table_handle->get_values(); + + // reshape both all values and keys to 1D tensor to work it further + auto target_shape = make_shared(element::i32, Shape{1}, vector{-1}); + all_keys = make_shared(all_keys, target_shape, false); + all_values = make_shared(all_values, target_shape, false); + + // update all values with default value and all keys + auto default_value_shape = make_shared(element::i32, Shape{1}, vector{1}); + default_value = make_shared(default_value, default_value_shape, false); + all_values = make_shared(OutputVector{all_values, default_value}, 0); + auto num_keys = make_shared(all_keys, element::i64)->output(0); + auto scalar_shape = make_shared(element::i32, Shape{0}, vector{}); + num_keys = make_shared(num_keys, scalar_shape, false); + num_keys = make_shared(num_keys, key_type); + + // compute mask which keys are not valid and for which default value must be used + auto unsqueeze_axis = make_shared(element::i32, Shape{1}, vector{-1}); + auto unsqueeze_keys = make_shared(keys, unsqueeze_axis); + auto equal_mask = make_shared(all_keys, unsqueeze_keys)->output(0); + auto reduce_equal_mask = make_shared(equal_mask, unsqueeze_axis, false); + + // map keys to new keys from range [0, n], n index will be for out-of-range keys + // 1. generate mask-01 of shape [keys_shape, len(all_keys)], + // where 0 - not found key, 1 - found key + auto const_zero = make_shared(key_type, Shape{}, 0); + auto const_one = make_shared(key_type, Shape{}, 1); + auto mask01 = make_shared(equal_mask, const_one, const_zero); + // 2. generate a range [0, n-1] that will be multiplied to mask for computation of new keys + auto new_all_keys = make_shared(const_zero, num_keys, const_one, key_type); + // 3. compute new keys + auto reduce_axis = make_shared(element::i32, Shape{1}, vector{-1}); + auto new_keys = make_shared(mask01, new_all_keys)->output(0); + new_keys = make_shared(new_keys, reduce_axis, false); + + // replace invalid keys with key_for_default_value + new_keys = make_shared(reduce_equal_mask, new_keys, num_keys); + + // at this point all keys are sorted and are from the range [0, n] + // and keys are also mapped to this range + auto gather_axis = make_shared(element::i32, Shape{1}, vector{0}); + auto lookup_values = make_shared(all_values, new_keys, gather_axis); + set_node_name(node.get_name(), lookup_values); + + return {lookup_values}; +} + +} // namespace op +} // namespace tensorflow +} // namespace frontend +} // namespace ov diff --git a/src/frontends/tensorflow/src/op/lookup_table_import.cpp b/src/frontends/tensorflow/src/op/lookup_table_import.cpp new file mode 100644 index 00000000000000..421fe81be18f5f --- /dev/null +++ b/src/frontends/tensorflow/src/op/lookup_table_import.cpp @@ -0,0 +1,42 @@ +// Copyright (C) 2018-2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "common_op_table.hpp" +#include "hash_table.hpp" +#include "openvino/frontend/tensorflow/node_context.hpp" +#include "openvino/frontend/tensorflow/variable.hpp" + +using namespace std; +using namespace ov; +using namespace ov::op; +using namespace ov::frontend::tensorflow; + +namespace ov { +namespace frontend { +namespace tensorflow { +namespace op { +OutputVector translate_lookup_table_import_op(const NodeContext& node) { + default_op_checks(node, 3, {"LookupTableImport", "LookupTableImportV2"}); + auto table_handle = node.get_input_by_reference(0); + auto keys = node.get_input(1); + auto values = node.get_input(2); + if (auto ref = as_type_ptr(table_handle.get_node_shared_ptr())) { + auto new_table = make_shared(*ref, keys, values); + + // since this operation produces new state of the variable + // it needs to update variables map + auto variables_state_map = node.get_variable_state_map(); + TENSORFLOW_OP_VALIDATION(node, + variables_state_map, + "[TensorFlow Frontend] internal error: variable state map is nullptr"); + variables_state_map->update_variable_state_map_for_node(node.get_name(), new_table); + } + + return {}; +} + +} // namespace op +} // namespace tensorflow +} // namespace frontend +} // namespace ov diff --git a/src/frontends/tensorflow/src/op/queue_dequeue.cpp b/src/frontends/tensorflow/src/op/queue_dequeue.cpp index b377680f183488..d021087296358a 100644 --- a/src/frontends/tensorflow/src/op/queue_dequeue.cpp +++ b/src/frontends/tensorflow/src/op/queue_dequeue.cpp @@ -84,9 +84,7 @@ OutputVector translate_queue_dequeue_many_op(const ov::frontend::tensorflow::Nod // compute batch dimension for outputs // this is a number of batch objects emitted from QueueDequeue Dimension batch_dim = Dimension::dynamic(); - OPENVINO_SUPPRESS_DEPRECATED_START - if (auto n_const = get_constant_from_source(n)) { - OPENVINO_SUPPRESS_DEPRECATED_END + if (auto n_const = ov::util::get_constant_from_source(n)) { auto n_value = n_const->cast_vector(); if (n_value.size() > 0 && n_value[0] > 0) { batch_dim = n_value[0]; diff --git a/src/frontends/tensorflow/src/op/sparse_reshape.cpp b/src/frontends/tensorflow/src/op/sparse_reshape.cpp index 9af84044d0f3db..ac5832d4728a2d 100644 --- a/src/frontends/tensorflow/src/op/sparse_reshape.cpp +++ b/src/frontends/tensorflow/src/op/sparse_reshape.cpp @@ -5,7 +5,6 @@ #include "common_op_table.hpp" #include "helper_ops/sparse_fill_empty_rows.hpp" #include "helper_ops/sparse_segment_ops.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/frontend/tensorflow/node_context.hpp" using namespace std; diff --git a/src/frontends/tensorflow/src/op/xla_conv_v2.cpp b/src/frontends/tensorflow/src/op/xla_conv_v2.cpp index 2d6ecdfa7bfb73..66bf6beb988628 100644 --- a/src/frontends/tensorflow/src/op/xla_conv_v2.cpp +++ b/src/frontends/tensorflow/src/op/xla_conv_v2.cpp @@ -29,10 +29,8 @@ namespace op { namespace { vector get_const_vector(const NodeContext& node, const Output& input, const string& input_name) { - OPENVINO_SUPPRESS_DEPRECATED_START - auto input_const = get_constant_from_source(input); + auto input_const = ov::util::get_constant_from_source(input); TENSORFLOW_OP_VALIDATION(node, input_const, "XlaConvV2 is supported only with constant " + input_name + "."); - OPENVINO_SUPPRESS_DEPRECATED_END return input_const->cast_vector(); } diff --git a/src/frontends/tensorflow/src/op_table.cpp b/src/frontends/tensorflow/src/op_table.cpp index fd9b6f848aea7a..034861ba6030a5 100644 --- a/src/frontends/tensorflow/src/op_table.cpp +++ b/src/frontends/tensorflow/src/op_table.cpp @@ -95,6 +95,8 @@ TF_OP_CONVERTER(translate_hash_table_op); TF_OP_CONVERTER(translate_if_op); TF_OP_CONVERTER(translate_iterator_get_next_op); TF_OP_CONVERTER(translate_iterator_op); +TF_OP_CONVERTER(translate_lookup_table_import_op); +TF_OP_CONVERTER(translate_lookup_table_find_op); TF_OP_CONVERTER(translate_loop_cond_op); TF_OP_CONVERTER(translate_merge_op); TF_OP_CONVERTER(translate_mergev2checkpoint_op); @@ -222,6 +224,7 @@ const std::map get_supported_ops() { {"ClipByValue", CreatorFunction(translate_clip_by_value_op)}, {"Complex", CreatorFunction(translate_complex_op)}, {"ComplexAbs", CreatorFunction(translate_complex_abs_op)}, + {"Conj", CreatorFunction(translate_conj_op)}, {"ConjugateTranspose", CreatorFunction(translate_conj_transpose_op)}, {"Concat", CreatorFunction(translate_concat_op)}, {"ConcatV2", CreatorFunction(translate_concat_op)}, @@ -287,6 +290,10 @@ const std::map get_supported_ops() { {"ListDiff", CreatorFunction(translate_list_diff_op)}, {"LogSoftmax", CreatorFunction(translate_log_softmax_op)}, {"Log1p", CreatorFunction(translate_log_1p_op)}, + {"LookupTableFind", CreatorFunction(translate_lookup_table_find_op)}, + {"LookupTableFindV2", CreatorFunction(translate_lookup_table_find_op)}, + {"LookupTableImport", CreatorFunction(translate_lookup_table_import_op)}, + {"LookupTableImportV2", CreatorFunction(translate_lookup_table_import_op)}, {"LookupTableInsert", CreatorFunction(translate_no_op)}, {"LookupTableInsertV2", CreatorFunction(translate_no_op)}, {"LRN", CreatorFunction(translate_lrn_op)}, diff --git a/src/frontends/tensorflow_common/include/common_op_table.hpp b/src/frontends/tensorflow_common/include/common_op_table.hpp index 0b83ad0ca5680b..9a4376951c14cf 100644 --- a/src/frontends/tensorflow_common/include/common_op_table.hpp +++ b/src/frontends/tensorflow_common/include/common_op_table.hpp @@ -50,6 +50,7 @@ OP_CONVERTER(translate_clip_by_value_op); OP_CONVERTER(translate_complex_op); OP_CONVERTER(translate_complex_abs_op); OP_CONVERTER(translate_concat_op); +OP_CONVERTER(translate_conj_op); OP_CONVERTER(translate_conj_transpose_op); OP_CONVERTER(translate_const_op); OP_CONVERTER(translate_conv_2d_op); diff --git a/src/frontends/tensorflow_common/include/helper_ops/hash_table.hpp b/src/frontends/tensorflow_common/include/helper_ops/hash_table.hpp deleted file mode 100644 index 6f517c97750d32..00000000000000 --- a/src/frontends/tensorflow_common/include/helper_ops/hash_table.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "helper_ops/internal_operation.hpp" - -namespace ov { -namespace frontend { -namespace tensorflow { - -class HashTable : public InternalOperation { -public: - OPENVINO_OP("HashTable", "ov::frontend::tensorflow", InternalOperation); - - HashTable(const std::shared_ptr& decoder = nullptr) - : InternalOperation(decoder, OutputVector{}, 1, "HashTable") { - validate_and_infer_types(); - } - - void validate_and_infer_types() override { - set_output_type(0, ov::element::dynamic, ov::PartialShape::dynamic()); - } - - std::shared_ptr clone_with_new_inputs(const OutputVector& inputs) const override { - auto hash_table_node = std::make_shared(m_decoder); - hash_table_node->set_attrs(get_attrs()); - return hash_table_node; - } -}; - -} // namespace tensorflow -} // namespace frontend -} // namespace ov diff --git a/src/frontends/tensorflow_common/include/utils.hpp b/src/frontends/tensorflow_common/include/utils.hpp index 3d013f87a814c2..ec0d789a5a7703 100644 --- a/src/frontends/tensorflow_common/include/utils.hpp +++ b/src/frontends/tensorflow_common/include/utils.hpp @@ -4,13 +4,13 @@ #pragma once -#include "openvino/core/validation_util.hpp" #include "openvino/frontend/node_context.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/convert_like.hpp" #include "openvino/op/reshape.hpp" #include "openvino/op/transpose.hpp" #include "openvino/pass/graph_rewrite.hpp" +#include "validation_util.hpp" namespace ov { namespace frontend { @@ -64,9 +64,7 @@ void get_const_input(const NodeContext& node, int input_index, std::vector* v std::to_string(input_size) + " inputs, but requested input port index to be " + std::to_string(input_size)); auto ov_input = node.get_input(input_index); - OPENVINO_SUPPRESS_DEPRECATED_START - if (auto constant = get_constant_from_source(ov_input)) { - OPENVINO_SUPPRESS_DEPRECATED_END + if (auto constant = ov::util::get_constant_from_source(ov_input)) { *vector = constant->cast_vector(); return; } diff --git a/src/frontends/tensorflow_common/src/op/conj_transpose.cpp b/src/frontends/tensorflow_common/src/op/conj_transpose.cpp index 8b4a51bdcbc828..068b095d97d28d 100644 --- a/src/frontends/tensorflow_common/src/op/conj_transpose.cpp +++ b/src/frontends/tensorflow_common/src/op/conj_transpose.cpp @@ -14,33 +14,59 @@ using namespace std; using namespace ov::op; +std::shared_ptr get_conj_ptr(const ov::Output& node) { + auto real_index = make_shared(ov::element::i32, ov::Shape{1}, 0); + auto imag_index = make_shared(ov::element::i32, ov::Shape{1}, 1); + + auto gather_axis = make_shared(ov::element::i32, ov::Shape{1}, -1); + + auto real = make_shared(node, real_index, gather_axis)->output(0); + auto imag = make_shared(node, imag_index, gather_axis)->output(0); + + imag = make_shared(imag); + + auto conj = make_shared(ov::OutputVector{real, imag}, -1); + return conj; +} + namespace ov { namespace frontend { namespace tensorflow { namespace op { -OutputVector translate_conj_transpose_op(const NodeContext& node) { - default_op_checks(node, 2, {"ConjugateTranspose"}, true); +OutputVector translate_conj_op(const NodeContext& node) { + default_op_checks(node, 1, {"Conj"}, true); auto x = node.get_input(0); - auto perm = node.get_input(1); auto complex_type_mark = as_type_ptr(x.get_node_shared_ptr()); + + std::shared_ptr conj{x.get_node_shared_ptr()}; if (complex_type_mark) { element::Type complex_part_type = complex_type_mark->get_complex_part_type(); auto x = complex_type_mark->input_value(0); + auto conj = get_conj_ptr(x); - auto real_index = make_shared(element::i32, Shape{1}, 0); - auto imag_index = make_shared(element::i32, Shape{1}, 1); + set_node_name(node.get_name(), conj); + auto complex_conj = make_shared(conj, complex_part_type); + return {complex_conj->output(0)}; + } - auto gather_axis = make_shared(element::i32, Shape{1}, -1); + set_node_name(node.get_name(), conj); + return {conj}; +} - auto real = make_shared(x, real_index, gather_axis)->output(0); - auto imag = make_shared(x, imag_index, gather_axis)->output(0); +OutputVector translate_conj_transpose_op(const NodeContext& node) { + default_op_checks(node, 2, {"ConjugateTranspose"}, true); - imag = make_shared(imag); + auto x = node.get_input(0); + auto perm = node.get_input(1); - auto conj_tensor = make_shared(OutputVector{real, imag}, -1)->output(0); + auto complex_type_mark = as_type_ptr(x.get_node_shared_ptr()); + if (complex_type_mark) { + element::Type complex_part_type = complex_type_mark->get_complex_part_type(); + auto x = complex_type_mark->input_value(0); + auto conj_tensor = get_conj_ptr(x); OutputVector concat_inputs; concat_inputs.push_back(perm); diff --git a/src/frontends/tensorflow_common/src/op/max_pool.cpp b/src/frontends/tensorflow_common/src/op/max_pool.cpp index c693f1e7533554..07892e6fb8272f 100644 --- a/src/frontends/tensorflow_common/src/op/max_pool.cpp +++ b/src/frontends/tensorflow_common/src/op/max_pool.cpp @@ -115,12 +115,10 @@ OutputVector translate_max_pool_v2(const NodeContext& node) { auto ksize = node.get_input(1); auto strides = node.get_input(2); - OPENVINO_SUPPRESS_DEPRECATED_START - auto ksize_constant = get_constant_from_source(ksize); + auto ksize_constant = ov::util::get_constant_from_source(ksize); TENSORFLOW_OP_VALIDATION(node, ksize_constant, "MaxPoolV2 is supported only with constant ksize."); - auto strides_constant = get_constant_from_source(strides); + auto strides_constant = ov::util::get_constant_from_source(strides); TENSORFLOW_OP_VALIDATION(node, ksize_constant, "MaxPoolV2 is supported only with constant strides."); - OPENVINO_SUPPRESS_DEPRECATED_END auto ksize_vector = ksize_constant->cast_vector(); auto strides_vector = strides_constant->cast_vector(); diff --git a/src/frontends/tensorflow_lite/src/tflite_transformations/tflite_quantize_resolver.cpp b/src/frontends/tensorflow_lite/src/tflite_transformations/tflite_quantize_resolver.cpp index e1aff2366c8fc4..93a16f36856514 100644 --- a/src/frontends/tensorflow_lite/src/tflite_transformations/tflite_quantize_resolver.cpp +++ b/src/frontends/tensorflow_lite/src/tflite_transformations/tflite_quantize_resolver.cpp @@ -81,9 +81,7 @@ void fuse_zp_to_weights(ov::Output& output, std::vector& zero if (rank == 0) { constant = ov::as_type_ptr(output.get_node_shared_ptr()); } else { - OPENVINO_SUPPRESS_DEPRECATED_START - constant = ov::get_constant_from_source(value); - OPENVINO_SUPPRESS_DEPRECATED_END + constant = ov::util::get_constant_from_source(value); } if (!constant) return false; @@ -99,9 +97,7 @@ void fuse_zp_to_weights(ov::Output& output, std::vector& zero auto zp_node = ov::opset10::Constant::create(ov::element::i32, zp_shape, zero_point); output = std::make_shared(output, zp_node); output = std::make_shared(output, ov::element::i8); - OPENVINO_SUPPRESS_DEPRECATED_START - output = ov::get_constant_from_source(output); // TODO: Check Me - OPENVINO_SUPPRESS_DEPRECATED_END + output = ov::util::get_constant_from_source(output); // TODO: Check Me zero_point = {0}; } @@ -181,12 +177,10 @@ pass::TFLQuantizeReplacer::TFLQuantizeReplacer() { output_low = ov::opset10::Constant::create(element::f32, {}, {low}); output_high = ov::opset10::Constant::create(element::f32, {}, {high}); } - OPENVINO_SUPPRESS_DEPRECATED_START - input_low = get_constant_from_source(input_low); - input_high = get_constant_from_source(input_high); - output_low = get_constant_from_source(output_low); - output_high = get_constant_from_source(output_high); - OPENVINO_SUPPRESS_DEPRECATED_END + input_low = ov::util::get_constant_from_source(input_low); + input_high = ov::util::get_constant_from_source(input_high); + output_low = ov::util::get_constant_from_source(output_low); + output_high = ov::util::get_constant_from_source(output_high); output = std::make_shared(output, input_low, input_high, output_low, output_high, levels); if (out_type != element::f32) { diff --git a/src/frontends/tests/frontend/shared/CMakeLists.txt b/src/frontends/tests/frontend/shared/CMakeLists.txt index f413e359afb738..5f4328d24ac486 100644 --- a/src/frontends/tests/frontend/shared/CMakeLists.txt +++ b/src/frontends/tests/frontend/shared/CMakeLists.txt @@ -23,7 +23,7 @@ target_link_libraries(${TARGET_NAME} openvino::util openvino::runtime PRIVATE - cnpy) + openvino::cnpy) add_dependencies(${TARGET_NAME} test_builtin_extensions) diff --git a/src/frontends/tests/frontend/shared/include/utils.hpp b/src/frontends/tests/frontend/shared/include/utils.hpp index 8d4cce4e5196f1..6a771c98f0e7e9 100644 --- a/src/frontends/tests/frontend/shared/include/utils.hpp +++ b/src/frontends/tests/frontend/shared/include/utils.hpp @@ -9,7 +9,6 @@ #include #include "common_test_utils/file_utils.hpp" -#include "file_utils.h" #include "openvino/util/env_util.hpp" #include "openvino/util/file_util.hpp" diff --git a/src/inference/CMakeLists.txt b/src/inference/CMakeLists.txt index cc7422a456101f..25e4c590b68799 100644 --- a/src/inference/CMakeLists.txt +++ b/src/inference/CMakeLists.txt @@ -20,9 +20,6 @@ file (GLOB LIBRARY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/cpp_interfaces/interface/*.cpp ) -set(OV_STATIC_DEPENDENT_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/file_utils.cpp) -list(REMOVE_ITEM LIBRARY_SRC ${OV_STATIC_DEPENDENT_FILES}) - file (GLOB LIBRARY_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.h ${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp @@ -51,22 +48,6 @@ elseif(NOT EMSCRIPTEN) ${CMAKE_CURRENT_SOURCE_DIR}/src/os/lin/*.hpp) endif() -if(ENABLE_SSE42) - file(GLOB SSE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/cpu_x86_sse42/*.cpp) - file(GLOB SSE_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/cpu_x86_sse42/*.hpp) - - list(APPEND LIBRARY_HEADERS ${SSE_HEADERS}) - list(APPEND LIBRARY_SRC ${SSE_SRC}) - - ov_sse42_optimization_flags(sse4_2_flags) - set_source_files_properties(${SSE_SRC} PROPERTIES COMPILE_OPTIONS "${sse4_2_flags}") - add_definitions(-DHAVE_SSE=1) - - if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.16") - set_source_files_properties(${SSE_SRC} PROPERTIES SKIP_PRECOMPILE_HEADERS ON) - endif() -endif() - set (PUBLIC_HEADERS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include") file (GLOB_RECURSE PUBLIC_HEADERS @@ -83,12 +64,10 @@ source_group("include" FILES ${LIBRARY_HEADERS} ${PUBLIC_HEADERS}) # Create object library add_library(${TARGET_NAME}_obj OBJECT - ${OV_STATIC_DEPENDENT_FILES} ${LIBRARY_SRC} ${LIBRARY_HEADERS} ${PUBLIC_HEADERS}) -ov_add_version_defines(src/ie_version.cpp ${TARGET_NAME}_obj) if(NOT BUILD_SHARED_LIBS) target_compile_definitions(${TARGET_NAME}_obj PUBLIC OPENVINO_STATIC_LIBRARY) @@ -132,7 +111,7 @@ target_link_libraries(${TARGET_NAME} INTERFACE openvino::runtime) target_include_directories(${TARGET_NAME} INTERFACE $ $) -ov_add_clang_format_target(${TARGET_NAME}_clang FOR_SOURCES ${OV_STATIC_DEPENDENT_FILES} ${LIBRARY_SRC} ${LIBRARY_HEADERS} ${PUBLIC_HEADERS}) +ov_add_clang_format_target(${TARGET_NAME}_clang FOR_SOURCES ${LIBRARY_SRC} ${LIBRARY_HEADERS} ${PUBLIC_HEADERS}) ov_ncc_naming_style(FOR_TARGET ${TARGET_NAME}_obj SOURCE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/include/openvino" diff --git a/src/inference/dev_api/blob_factory.hpp b/src/inference/dev_api/blob_factory.hpp index f37f813604c62f..1c5a6801d654f6 100644 --- a/src/inference/dev_api/blob_factory.hpp +++ b/src/inference/dev_api/blob_factory.hpp @@ -15,7 +15,6 @@ #include "ie_blob.h" #include "ie_data.h" -#include "ie_memcpy.h" #include "openvino/runtime/itensor.hpp" #include "openvino/runtime/so_ptr.hpp" @@ -124,22 +123,6 @@ InferenceEngine::Blob::Ptr make_blob_with_precision(InferenceEngine::Precision p #undef USE_FACTORY } -/** - * @brief Copy data from std::vector to Blob - * @ingroup ie_dev_api_memory - * @tparam T type of data in std::vector - * @param outputBlob An output blob to copy to - * @param inputVector An input std::vector to copy from - */ -template -void CopyVectorToBlob(const InferenceEngine::Blob::Ptr outputBlob, const std::vector& inputVector) { - if (outputBlob->size() != inputVector.size()) - IE_THROW() << "Size mismatch between dims and vector"; - if (outputBlob->element_size() != sizeof(T)) - IE_THROW() << "Element size mismatch between blob and vector"; - ie_memcpy(outputBlob->buffer().as(), outputBlob->byteSize(), &inputVector[0], inputVector.size() * sizeof(T)); -} - namespace ov { ov::SoPtr make_tensor(const std::shared_ptr& tensor, bool unwrap = false); diff --git a/src/inference/dev_api/blob_transform.hpp b/src/inference/dev_api/blob_transform.hpp deleted file mode 100644 index 244939280288c3..00000000000000 --- a/src/inference/dev_api/blob_transform.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/** - * @brief A file containing function copying Blob's in different layouts - * @file blob_transform.hpp - */ - -#pragma once - -#include "ie_api.h" -#include "ie_blob.h" - -IE_SUPPRESS_DEPRECATED_START -namespace InferenceEngine { - -/** - * @brief Copies data with taking into account layout and precision params - * @ingroup ie_dev_api_memory - * - * @param[in] src The source Blob::Ptr - * @param[in] dst The destination Blob::Ptr - */ -INFERENCE_ENGINE_API_CPP(void) blob_copy(Blob::Ptr src, Blob::Ptr dst); - -} // namespace InferenceEngine -IE_SUPPRESS_DEPRECATED_END diff --git a/src/inference/dev_api/cpp_interfaces/interface/ie_iexecutable_network_internal.hpp b/src/inference/dev_api/cpp_interfaces/interface/ie_iexecutable_network_internal.hpp index 8d2c8c831f361e..4341677a3bd4ea 100644 --- a/src/inference/dev_api/cpp_interfaces/interface/ie_iexecutable_network_internal.hpp +++ b/src/inference/dev_api/cpp_interfaces/interface/ie_iexecutable_network_internal.hpp @@ -11,7 +11,6 @@ #include "cpp/ie_cnn_network.h" #include "cpp_interfaces/interface/ie_ivariable_state_internal.hpp" -#include "ie_parameter.hpp" #include "openvino/runtime/so_ptr.hpp" namespace ov { @@ -132,23 +131,23 @@ class INFERENCE_ENGINE_1_0_DEPRECATED INFERENCE_ENGINE_API_CLASS(IExecutableNetw /** * @brief Sets configuration for current executable network - * @param config Map of pairs: (config parameter name, config parameter value) + * @param config Map of pairs: (config name, config ov::Any value) */ - virtual void SetConfig(const std::map& config); + virtual void SetConfig(const ov::AnyMap& config); /** * @brief Gets configuration dedicated to plugin behaviour - * @param name A config key, can be found in ie_plugin_config.hpp + * @param name A config key, can be found in properties.hpp * @return A value of config corresponding to config key */ - virtual Parameter GetConfig(const std::string& name) const; + virtual ov::Any GetConfig(const std::string& name) const; /** * @brief Gets general runtime metric for dedicated hardware * @param name A metric name to request * @return A metric value corresponding to metric key */ - virtual Parameter GetMetric(const std::string& name) const; + virtual ov::Any GetMetric(const std::string& name) const; /** * @brief Raises the flag that model was loaded from cache diff --git a/src/inference/dev_api/cpp_interfaces/interface/ie_internal_plugin_config.hpp b/src/inference/dev_api/cpp_interfaces/interface/ie_internal_plugin_config.hpp deleted file mode 100644 index eeac793acc7dcc..00000000000000 --- a/src/inference/dev_api/cpp_interfaces/interface/ie_internal_plugin_config.hpp +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/** - * @brief A header for properties that are passed from IE to plguinsor from one plugin to another - * @file ie_internal_plugin_config.hpp - */ - -#pragma once - -#include "ie_plugin_config.hpp" -#include "openvino/runtime/internal_properties.hpp" - -namespace InferenceEngine { - -/** - * @brief A namespace with internal plugin configuration keys - * @ingroup ie_dev_api_plugin_api - */ -namespace PluginConfigInternalParams { - -/** - * @def CONFIG_KEY_INTERNAL(name) - * @ingroup ie_dev_api_plugin_api - * @brief Shortcut for defining internal configuration keys - */ -#define CONFIG_KEY_INTERNAL(name) ::InferenceEngine::PluginConfigInternalParams::_CONFIG_KEY(name) - -/** - * @def CONFIG_VALUE_INTERNAL(name) - * @ingroup ie_dev_api_plugin_api - * @brief Shortcut for defining internal configuration values - */ -#define CONFIG_VALUE_INTERNAL(name) ::InferenceEngine::PluginConfigInternalParams::name - -/** - * @brief Defines a low precision mode key - * @ingroup ie_dev_api_plugin_api - */ -INFERENCE_ENGINE_1_0_DEPRECATED DECLARE_CONFIG_KEY(LP_TRANSFORMS_MODE); - -/** - * @brief Limit \#threads that are used by CPU Executor Streams to execute `parallel_for` calls - * @ingroup ie_dev_api_plugin_api - */ -INFERENCE_ENGINE_1_0_DEPRECATED DECLARE_CONFIG_KEY(CPU_THREADS_PER_STREAM); - -/** - * @brief Number of streams in Performance-core(big core) - * @ingroup ie_dev_api_plugin_api - * @brief Shortcut for defining internal configuration values - */ -INFERENCE_ENGINE_1_0_DEPRECATED DECLARE_CONFIG_KEY(BIG_CORE_STREAMS); - -/** - * @brief Number of streams in Efficient-core(small core) on hybrid cores machine - * @ingroup ie_dev_api_plugin_api - * @brief Shortcut for defining internal configuration values - */ -INFERENCE_ENGINE_1_0_DEPRECATED DECLARE_CONFIG_KEY(SMALL_CORE_STREAMS); - -/** - * @brief Number of threads per stream in big cores - * @ingroup ie_dev_api_plugin_api - * @brief Shortcut for defining internal configuration values - */ -INFERENCE_ENGINE_1_0_DEPRECATED DECLARE_CONFIG_KEY(THREADS_PER_STREAM_BIG); - -/** - * @brief Number of threads per stream in small cores on hybrid cores machine - * @ingroup ie_dev_api_plugin_api - * @brief Shortcut for defining internal configuration values - */ -INFERENCE_ENGINE_1_0_DEPRECATED DECLARE_CONFIG_KEY(THREADS_PER_STREAM_SMALL); - -/** - * @brief Small core start offset when binding cpu cores - * @ingroup ie_dev_api_plugin_api - * @brief Shortcut for defining internal configuration values - */ -INFERENCE_ENGINE_1_0_DEPRECATED DECLARE_CONFIG_KEY(SMALL_CORE_OFFSET); - -/** - * @brief Defines how many records can be stored in the CPU runtime parameters cache per CPU runtime parameter type per - * stream - * @ingroup ie_dev_api_plugin_api - */ -INFERENCE_ENGINE_1_0_DEPRECATED DECLARE_CONFIG_KEY(CPU_RUNTIME_CACHE_CAPACITY); - -/** - * @brief Internal device id for particular device (like GPU.0, GPU.1 etc) - */ -INFERENCE_ENGINE_1_0_DEPRECATED DECLARE_CONFIG_KEY(CONFIG_DEVICE_ID); - -/** - * @brief enable hyper thread - */ -INFERENCE_ENGINE_1_0_DEPRECATED DECLARE_CONFIG_KEY(ENABLE_HYPER_THREAD); - -/** - * @brief Defines Snippets tokenization mode - * @param ENABLE - default pipeline - * @param IGNORE_CALLBACK - disable the Snippets markup transformation and tokenization callback - * @param DISABLE - turn off the Snippets - * @ingroup ie_dev_api_plugin_api - */ -INFERENCE_ENGINE_1_0_DEPRECATED DECLARE_CONFIG_KEY(SNIPPETS_MODE); -INFERENCE_ENGINE_1_0_DEPRECATED DECLARE_CONFIG_VALUE(ENABLE); -INFERENCE_ENGINE_1_0_DEPRECATED DECLARE_CONFIG_VALUE(IGNORE_CALLBACK); -INFERENCE_ENGINE_1_0_DEPRECATED DECLARE_CONFIG_VALUE(DISABLE); - -} // namespace PluginConfigInternalParams - -} // namespace InferenceEngine diff --git a/src/inference/dev_api/cpp_interfaces/interface/ie_iplugin_internal.hpp b/src/inference/dev_api/cpp_interfaces/interface/ie_iplugin_internal.hpp index cafff6d53bc905..8480eef310b5be 100644 --- a/src/inference/dev_api/cpp_interfaces/interface/ie_iplugin_internal.hpp +++ b/src/inference/dev_api/cpp_interfaces/interface/ie_iplugin_internal.hpp @@ -17,12 +17,10 @@ #include "blob_factory.hpp" #include "cpp/ie_cnn_network.h" #include "ie_input_info.hpp" -#include "ie_parameter.hpp" #include "openvino/core/extension.hpp" #include "openvino/runtime/iplugin.hpp" #include "openvino/runtime/so_ptr.hpp" #include "openvino/util/pp.hpp" -#include "ie_version.hpp" using namespace ov::threading; @@ -120,7 +118,7 @@ GetSupportedNodes(const std::shared_ptr& model, */ class INFERENCE_ENGINE_1_0_DEPRECATED INFERENCE_ENGINE_API_CLASS(IInferencePlugin) : public std::enable_shared_from_this { - class VersionStore : public Version { + class VersionStore : public ov::Version { void copyFrom(const Version& v); public: @@ -141,13 +139,13 @@ class INFERENCE_ENGINE_1_0_DEPRECATED INFERENCE_ENGINE_API_CLASS(IInferencePlugi * @brief Sets a plugin version * @param version A version to set */ - void SetVersion(const Version& version); + void SetVersion(const ov::Version& version); /** * @brief Gets a plugin version - * @return A const InferenceEngine::Version object + * @return A const ov::Version object */ - const Version& GetVersion() const; + const ov::Version& GetVersion() const; /** * @brief Provides a name of a plugin @@ -187,7 +185,7 @@ class INFERENCE_ENGINE_1_0_DEPRECATED INFERENCE_ENGINE_API_CLASS(IInferencePlugi virtual void AddExtension(const std::shared_ptr& extension); /** - * @brief Sets configuration for plugin, acceptable keys can be found in ie_plugin_config.hpp + * @brief Sets configuration for plugin, acceptable keys can be found in properties.hpp * @param config string-string map of config parameters */ virtual void SetConfig(const std::map& config); @@ -204,7 +202,7 @@ class INFERENCE_ENGINE_1_0_DEPRECATED INFERENCE_ENGINE_API_CLASS(IInferencePlugi * @param options - configuration details for config * @return Value of config corresponding to config key */ - virtual Parameter GetConfig(const std::string& name, const std::map& options) const; + virtual ov::Any GetConfig(const std::string& name, const ov::AnyMap& options) const; /** * @brief Gets general runtime metric for dedicated hardware @@ -212,7 +210,7 @@ class INFERENCE_ENGINE_1_0_DEPRECATED INFERENCE_ENGINE_API_CLASS(IInferencePlugi * @param options - configuration details for metric * @return Metric value corresponding to metric key */ - virtual Parameter GetMetric(const std::string& name, const std::map& options) const; + virtual ov::Any GetMetric(const std::string& name, const ov::AnyMap& options) const; /** * @deprecated Use ImportNetwork(std::istream& networkModel, const std::map& config) diff --git a/src/inference/dev_api/file_utils.h b/src/inference/dev_api/file_utils.h deleted file mode 100644 index 870cc91a1fdff3..00000000000000 --- a/src/inference/dev_api/file_utils.h +++ /dev/null @@ -1,182 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/** - * @brief Basic function to work with file system and UNICODE symbols - * @file file_utils.h - */ - -#pragma once - -// clang-format off -#include -#include - -#include "ie_api.h" -#include "openvino/util/file_util.hpp" - -/// @ingroup ie_dev_api_file_utils -namespace FileUtils { - -/** - * @brief Enables only `char` or `wchar_t` template specializations - * @tparam C A char type - */ -template -using enableIfSupportedChar = - typename std::enable_if<(std::is_same::value || std::is_same::value)>::type; - -/** - * @brief Interface function to get absolute path of file - * @ingroup ie_dev_api_file_utils - * @param filePath - path to file, can be relative to current working directory - * @return Absolute path of file - * @throw InferenceEngine::Exception if any error occurred - */ -INFERENCE_ENGINE_API_CPP(std::string) absoluteFilePath(const std::string& filePath); - -/** - * @brief Interface function to create directorty recursively by given path - * @ingroup ie_dev_api_file_utils - * @param dirPath - path to file, can be relative to current working directory - * @throw InferenceEngine::Exception if any error occurred - */ -INFERENCE_ENGINE_API_CPP(void) createDirectoryRecursive(const std::string& dirPath); - -/** - * @brief Interface function to check if directory exists for given path - * @ingroup ie_dev_api_file_utils - * @param path - path to directory - * @return true if directory exists, false otherwise - */ -INFERENCE_ENGINE_API_CPP(bool) directoryExists(const std::string& path); - -/** - * @brief Interface function to get the size of a file. The function supports UNICODE path - * @ingroup ie_dev_api_file_utils - * @param fileName - name of the file - * @return size of the file - */ -INFERENCE_ENGINE_API(long long) fileSize(const char *fileName); - -#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT - -/** - * @brief Returns file size for file with UNICODE path name - * @ingroup ie_dev_api_file_utils - * - * @param[in] fileName The file name - * - * @return { description_of_the_return_value } - */ -inline long long fileSize(const wchar_t* fileName) { - return fileSize(::ov::util::wstring_to_string(fileName).c_str()); -} - -#endif // OPENVINO_ENABLE_UNICODE_PATH_SUPPORT - -/** - * @brief Function to get the size of a file. The function supports UNICODE path - * @ingroup ie_dev_api_file_utils - * @param f - string name of the file - * @return size of the file - */ -template > -inline long long fileSize(const std::basic_string &f) { - return fileSize(f.c_str()); -} - -/** - * @brief check if file with a given filename exists. The function supports UNICODE path - * @ingroup ie_dev_api_file_utils - * @param fileName - given filename - * @return true is exists - */ -template > -inline bool fileExist(const C * fileName) { - return fileSize(fileName) >= 0; -} - -/** - * @brief check if file with a given filename exists. The function supports UNICODE path - * @ingroup ie_dev_api_file_utils - * @param fileName - string with a given filename - * @return true is exists - */ -template > -inline bool fileExist(const std::basic_string &fileName) { - return fileExist(fileName.c_str()); -} - -/** - * @brief CPP Interface function to combint path with filename. The function supports UNICODE path - * @ingroup ie_dev_api_file_utils - * @param folder - path to add filename to - * @param file - filename to add to path - * @return string with combination of the path and the filename divided by file separator - */ - -template > -inline std::basic_string makePath(const std::basic_string &folder, const std::basic_string &file) { - if (folder.empty()) - return file; - return folder + ov::util::FileTraits::file_separator + file; -} - -/** - * @brief CPP Interface function to extract extension from filename - * @ingroup ie_dev_api_file_utils - * @param filename - string with the name of the file which extension should be extracted - * @return string with extracted file extension - */ -template > -inline std::basic_string fileExt(const std::basic_string &filename) { - auto pos = filename.rfind(ov::util::FileTraits::dot_symbol); - if (pos == std::string::npos) - return {}; - return filename.substr(pos + 1); -} - -template > -inline std::basic_string makePluginLibraryName(const std::basic_string &path, const std::basic_string &input) { - std::basic_string separator(1, ov::util::FileTraits::file_separator); - if (path.empty()) - separator = {}; - return path + separator + ov::util::FileTraits::library_prefix() + input + ov::util::FileTraits::dot_symbol + ov::util::FileTraits::library_ext(); -} - -} // namespace FileUtils -// clang-format on - -namespace InferenceEngine { - -/** - * @brief Returns a path to Inference Engine library - * @ingroup ie_dev_api_file_utils - * @return A `std::string` path to Inference Engine library - */ -INFERENCE_ENGINE_API_CPP(std::string) getIELibraryPath(); - -#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT - -/** - * @brief Returns a unicode path to Inference Engine library - * @ingroup ie_dev_api_file_utils - * @return A `std::wstring` path to Inference Engine library - */ -INFERENCE_ENGINE_API_CPP(std::wstring) getIELibraryPathW(); - -inline ::ov::util::FilePath getInferenceEngineLibraryPath() { - return getIELibraryPathW(); -} - -#else - -inline ::ov::util::FilePath getInferenceEngineLibraryPath() { - return getIELibraryPath(); -} - -#endif // OPENVINO_ENABLE_UNICODE_PATH_SUPPORT - -} // namespace InferenceEngine diff --git a/src/inference/dev_api/ie_icore.hpp b/src/inference/dev_api/ie_icore.hpp index be2b85118de466..4461c580a4515d 100644 --- a/src/inference/dev_api/ie_icore.hpp +++ b/src/inference/dev_api/ie_icore.hpp @@ -15,7 +15,6 @@ #include "cpp/ie_cnn_network.h" #include "cpp_interfaces/interface/ie_iexecutable_network_internal.hpp" -#include "ie_parameter.hpp" #include "openvino/runtime/icore.hpp" #include "openvino/runtime/properties.hpp" @@ -51,7 +50,7 @@ class ICore : public ov::ICore { * * @param network CNNNetwork object acquired from Core::ReadNetwork * @param deviceName Name of device to load network to - * @param config Optional map of pairs: (config parameter name, config parameter value) relevant only for this load + * @param config Optional map of pairs: (config name, config value) relevant only for this load * operation * @return An executable network reference */ @@ -68,7 +67,7 @@ class ICore : public ov::ICore { * @param modelStr String data of model * @param weights Model's weights * @param deviceName Name of device to load network to - * @param config Optional map of pairs: (config parameter name, config parameter value) relevant only for this load + * @param config Optional map of pairs: (config name, config value) relevant only for this load * operation * @param val Optional callback to perform validation of loaded CNNNetwork, if ReadNetwork is triggered * @return An executable network reference @@ -88,7 +87,7 @@ class ICore : public ov::ICore { * * @param modelPath Path to model * @param deviceName Name of device to load network to - * @param config Optional map of pairs: (config parameter name, config parameter value) relevant only for this load + * @param config Optional map of pairs: (config name, config value) relevant only for this load * operation * @param val Optional callback to perform validation of loaded CNNNetwork, if ReadNetwork is triggered * @return An executable network reference @@ -102,7 +101,7 @@ class ICore : public ov::ICore { * @brief Creates an executable network from a previously exported network * @param networkModel network model stream * @param deviceName Name of device load executable network on - * @param config Optional map of pairs: (config parameter name, config parameter value) relevant only for this load + * @param config Optional map of pairs: (config name, config value) relevant only for this load * operation* * @return An executable network reference */ @@ -115,7 +114,7 @@ class ICore : public ov::ICore { * * @param deviceName A name of a device to query * @param network Network object to query - * @param config Optional map of pairs: (config parameter name, config parameter value) + * @param config Optional map of pairs: (config name, config value) * @return An object containing a map of pairs a layer name -> a device name supporting this layer. */ virtual QueryNetworkResult QueryNetwork(const CNNNetwork& network, @@ -159,7 +158,7 @@ class ICore : public ov::ICore { * @brief Checks whether device supports model caching feature * * @param deviceName - A name of a device to get a metric value. - * @return True if device has IMPORT_EXPORT_SUPPORT and CACHING_PROPERTIES metric in SUPPORTED_METRICS and + * @return True if device has IMPORT_EXPORT_SUPPORT and CACHING_PROPERTIES metric in SUPPORTED_PROPERTIES and * this metric returns 'true', False otherwise. */ virtual bool DeviceSupportsModelCaching(const std::string& deviceName) const = 0; diff --git a/src/inference/dev_api/ie_memcpy.h b/src/inference/dev_api/ie_memcpy.h deleted file mode 100644 index af8e521efb4b53..00000000000000 --- a/src/inference/dev_api/ie_memcpy.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/** - * @brief Defines a ie_memcpy to safely (SDL-friendly) copy arrays - * @file ie_memcpy.h - */ - -#pragma once - -#include - -#include "ie_api.h" - -/** - * @brief Copies bytes between buffers with security enhancements - * Copies count bytes from src to dest. If the source and destination - * overlap, the behavior is undefined. - * @ingroup ie_dev_api_memory - * - * @param dest A Pointer to the object to copy to - * @param destsz A max number of bytes to modify in the destination (typically the size - * of the destination object) - * @param src A pointer to the object to copy from - * @param count A number of bytes to copy - * - * @return zero on success and non-zero value on error. - */ - -INFERENCE_ENGINE_API_CPP(int) ie_memcpy(void* dest, size_t destsz, void const* src, size_t count); diff --git a/src/inference/dev_api/openvino/runtime/icore.hpp b/src/inference/dev_api/openvino/runtime/icore.hpp index de2ca2ebf07c57..bf4da34721d152 100644 --- a/src/inference/dev_api/openvino/runtime/icore.hpp +++ b/src/inference/dev_api/openvino/runtime/icore.hpp @@ -225,9 +225,10 @@ class OPENVINO_RUNTIME_API ICore { * @brief Get only properties that are supported by specified device * @param full_device_name Name of a device (can be either virtual or hardware) * @param properties Properties that can contains configs that are not supported by device + * @param keep_core_property Whether to return core-level properties * @return map of properties that are supported by device */ - virtual AnyMap get_supported_property(const std::string& full_device_name, const AnyMap& properties) const = 0; + virtual AnyMap get_supported_property(const std::string& full_device_name, const AnyMap& properties, const bool keep_core_property = true) const = 0; virtual bool device_supports_model_caching(const std::string& device_name) const = 0; diff --git a/src/inference/dev_api/openvino/runtime/internal_properties.hpp b/src/inference/dev_api/openvino/runtime/internal_properties.hpp index 5250609306a523..a9e42e03fa54e7 100644 --- a/src/inference/dev_api/openvino/runtime/internal_properties.hpp +++ b/src/inference/dev_api/openvino/runtime/internal_properties.hpp @@ -43,29 +43,11 @@ static constexpr Property exclusive_async_requests */ static constexpr Property config_device_id{"CONFIG_DEVICE_ID"}; -/** - * @brief The name for setting CPU affinity per thread option. - * - * It is passed to Core::get_property() - * - * The following options are implemented only for the TBB as a threading option - * ov::threading::IStreamsExecutor::ThreadBindingType::NUMA (pinning threads to NUMA nodes, best for real-life, - * contented cases) on the Windows and MacOS* this option behaves as YES - * ov::threading::IStreamsExecutor::ThreadBindingType::HYBRID_AWARE (let the runtime to do pinning to the cores types, - * e.g. prefer the "big" cores for latency tasks) on the hybrid CPUs this option is default - * - * Also, the settings are ignored, if the OpenVINO compiled with OpenMP and any affinity-related OpenMP's - * environment variable is set (as affinity is configured explicitly) - * @ingroup ov_dev_api_plugin_api - */ -static constexpr Property cpu_bind_thread{ - "CPU_BIND_THREAD"}; - /** * @brief Limit \#threads that are used by IStreamsExecutor to execute `parallel_for` calls * @ingroup ov_dev_api_plugin_api */ -static constexpr Property threads_per_stream{"THREADS_PER_STREAM"}; +static constexpr Property threads_per_stream{"THREADS_PER_STREAM"}; /** * @brief It contains compiled_model_runtime_properties information to make plugin runtime can check whether it is diff --git a/src/inference/dev_api/openvino/runtime/system_conf.hpp b/src/inference/dev_api/openvino/runtime/system_conf.hpp index c3648a69118e6b..f2ccef5a9c8ad9 100644 --- a/src/inference/dev_api/openvino/runtime/system_conf.hpp +++ b/src/inference/dev_api/openvino/runtime/system_conf.hpp @@ -191,6 +191,13 @@ OPENVINO_RUNTIME_API int get_num_sockets(); */ OPENVINO_RUNTIME_API std::vector> get_proc_type_table(); +/** + * @brief Returns the socket ID in cpu mapping table of the currently running thread. + * @ingroup ie_dev_api_system_conf + * @return socket ID in cpu mapping + */ +OPENVINO_RUNTIME_API int get_current_socket_id(); + /** * @brief Returns a table of original number of processor types without filtering other plugins occupying CPU * resources. The difference from get_proc_type_table: This is used to get the configuration of current machine. For diff --git a/src/inference/dev_api/openvino/runtime/threading/istreams_executor.hpp b/src/inference/dev_api/openvino/runtime/threading/istreams_executor.hpp index 363b7a912b15f0..43708c94794ae8 100644 --- a/src/inference/dev_api/openvino/runtime/threading/istreams_executor.hpp +++ b/src/inference/dev_api/openvino/runtime/threading/istreams_executor.hpp @@ -21,31 +21,6 @@ namespace ov { namespace threading { -/** - * @brief Number of streams in Performance-core(big core) - */ -static constexpr Property big_core_streams{"BIG_CORE_STREAMS"}; - -/** - * @brief Number of streams in Efficient-core(small core) on hybrid cores machine - */ -static constexpr Property small_core_streams{"SMALL_CORE_STREAMS"}; - -/** - * @brief Number of threads per stream in big cores - */ -static constexpr Property threads_per_stream_big{"THREADS_PER_STREAM_BIG"}; - -/** - * @brief Number of threads per stream in small cores on hybrid cores machine - */ -static constexpr Property threads_per_stream_small{"THREADS_PER_STREAM_SMALL"}; - -/** - * @brief Small core start offset when binding cpu cores - */ -static constexpr Property small_core_offset{"SMALL_CORE_OFFSET"}; - /** * @interface IStreamsExecutor * @ingroup ov_dev_api_threading @@ -80,86 +55,65 @@ class OPENVINO_RUNTIME_API IStreamsExecutor : virtual public ITaskExecutor { * @brief Defines IStreamsExecutor configuration */ struct OPENVINO_RUNTIME_API Config { - /** - * @brief Sets configuration - * @param properties map of properties - */ - void set_property(const ov::AnyMap& properties); - - /** - * @brief Sets configuration - * @param key property name - * @param value property value - */ - void set_property(const std::string& key, const ov::Any& value); - - /** - * @brief Return configuration value - * @param key configuration key - * @return configuration value wrapped into ov::Any - */ - ov::Any get_property(const std::string& key) const; - - /** - * @brief Create appropriate multithreaded configuration - * filing unconfigured values from initial configuration using hardware properties - * @param initial Inital configuration - * @param fp_intesive additional hint for the the (Hybrid) core-types selection logic - * whether the executor should be configured for floating point intensive work (as opposite to int8 - * intensive) - * @return configured values - */ - static Config make_default_multi_threaded(const Config& initial, const bool fp_intesive = true); - static int get_default_num_streams( - const bool enable_hyper_thread = true); // no network specifics considered (only CPU's caps); - static int get_hybrid_num_streams(std::map& config, const int stream_mode); - static void update_hybrid_custom_threads(Config& config); - static Config reserve_cpu_threads(const Config& initial); - - std::string _name; //!< Used by `ITT` to name executor threads - int _streams = 1; //!< Number of streams. - int _threadsPerStream = 0; //!< Number of threads per stream that executes `ov_parallel` calls - ThreadBindingType _threadBindingType = ThreadBindingType::NONE; //!< Thread binding to hardware resource type. - //!< No binding by default - int _threadBindingStep = 1; //!< In case of @ref CORES binding offset type - //!< thread binded to cores with defined step - int _threadBindingOffset = 0; //!< In case of @ref CORES binding offset type thread binded to cores - //!< starting from offset - int _threads = 0; //!< Number of threads distributed between streams. - //!< Reserved. Should not be used. - int _big_core_streams = 0; //!< Number of streams in Performance-core(big core) - int _small_core_streams = 0; //!< Number of streams in Efficient-core(small core) - int _threads_per_stream_big = 0; //!< Threads per stream in big cores - int _threads_per_stream_small = 0; //!< Threads per stream in small cores - int _small_core_offset = 0; //!< Calculate small core start offset when binding cpu cores - bool _enable_hyper_thread = true; //!< enable hyper thread - int _plugin_task = NOT_USED; - enum StreamMode { DEFAULT, AGGRESSIVE, LESSAGGRESSIVE }; + public: enum PreferredCoreType { ANY, LITTLE, BIG, ROUND_ROBIN // used w/multiple streams to populate the Big cores first, then the Little, then wrap around // (for large #streams) - } _threadPreferredCoreType = - PreferredCoreType::ANY; //!< In case of @ref HYBRID_AWARE hints the TBB to affinitize + }; + private: + std::string _name; //!< Used by `ITT` to name executor threads + int _streams = 1; //!< Number of streams. + int _threads_per_stream = 0; //!< Number of threads per stream that executes `ov_parallel` calls + ThreadBindingType _threadBindingType = ThreadBindingType::NONE; //!< Thread binding to hardware resource type. + //!< No binding by default + int _threadBindingStep = 1; //!< In case of @ref CORES binding offset type + //!< thread binded to cores with defined step + int _threadBindingOffset = 0; //!< In case of @ref CORES binding offset type thread binded to cores + //!< starting from offset + int _threads = 0; //!< Number of threads distributed between streams. + //!< Reserved. Should not be used. + PreferredCoreType _thread_preferred_core_type = + PreferredCoreType::ANY; //!< LITTLE and BIG are valid in hybrid core machine, ANY is valid in all machines. + //!< Core type priority: physical PCore, ECore, logical PCore std::vector> _streams_info_table = {}; std::vector> _stream_processor_ids; bool _cpu_reservation = false; - bool _streams_changed = false; + /** + * @brief Get and reserve cpu ids based on configuration and hardware information, + * streams_info_table must be present in the configuration + */ + void reserve_cpu_threads(); + + /** + * @brief Modify _streams_info_table and related configuration according to configuration + */ + void update_executor_config(); + + /** + * @brief Set _streams_info_table and _cpu_reservation in cpu streams executor config when nstreams = 0, + * that is, only create one thread with TBB + */ + void set_config_zero_stream(); + + public: /** * @brief A constructor with arguments * - * @param[in] name The executor name - * @param[in] streams @copybrief Config::_streams - * @param[in] threadsPerStream @copybrief Config::_threadsPerStream - * @param[in] threadBindingType @copybrief Config::_threadBindingType - * @param[in] threadBindingStep @copybrief Config::_threadBindingStep - * @param[in] threadBindingOffset @copybrief Config::_threadBindingOffset - * @param[in] threads @copybrief Config::_threads - * @param[in] threadPreferBigCores @copybrief Config::_threadPreferBigCores + * @param[in] name The executor name + * @param[in] streams @copybrief Config::_streams + * @param[in] threadsPerStream @copybrief Config::_threads_per_stream + * @param[in] threadBindingType @copybrief Config::_threadBindingType + * @param[in] threadBindingStep @copybrief Config::_threadBindingStep + * @param[in] threadBindingOffset @copybrief Config::_threadBindingOffset + * @param[in] threads @copybrief Config::_threads + * @param[in] threadPreferredCoreType @copybrief Config::_thread_preferred_core_type + * @param[in] streamsInfoTable @copybrief Config::_streams_info_table + * @param[in] cpuReservation @copybrief Config::_cpu_reservation */ Config(std::string name = "StreamsExecutor", int streams = 1, @@ -173,32 +127,103 @@ class OPENVINO_RUNTIME_API IStreamsExecutor : virtual public ITaskExecutor { bool cpuReservation = false) : _name{name}, _streams{streams}, - _threadsPerStream{threadsPerStream}, + _threads_per_stream{threadsPerStream}, _threadBindingType{threadBindingType}, _threadBindingStep{threadBindingStep}, _threadBindingOffset{threadBindingOffset}, _threads{threads}, - _threadPreferredCoreType(threadPreferredCoreType), + _thread_preferred_core_type(threadPreferredCoreType), _streams_info_table{streamsInfoTable}, - _cpu_reservation{cpuReservation} {} + _cpu_reservation{cpuReservation} { + update_executor_config(); + } + // These APIs which includes set_property and get_property can not be removed until they will never be called by + // other plugins such as NV plugin. /** - * @brief Modify _streams_info_table and related configuration according to user-specified parameters, bind - * threads to cpu cores if cpu_pinning is true. - * @param stream_nums Number of streams specified by user - * @param threads_per_stream Number of threads per stream specified by user - * @param core_type Cpu type (Big/Little/Any) specified by user - * @param cpu_pinning Whether to bind the threads to cpu cores + * @brief Sets configuration + * @param properties map of properties */ - void update_executor_config(int stream_nums, - int threads_per_stream, - PreferredCoreType core_type, - bool cpu_pinning); + void set_property(const ov::AnyMap& properties); + /** - * @brief Set _streams_info_table and _cpu_reservation in cpu streams executor config when nstreams = 0, - * that is, only create one thread with TBB + * @brief Sets configuration + * @param key property name + * @param value property value */ - void set_config_zero_stream(); + void set_property(const std::string& key, const ov::Any& value); + + /** + * @brief Return configuration value + * @param key configuration key + * @return configuration value wrapped into ov::Any + */ + ov::Any get_property(const std::string& key) const; + + std::string get_name() { + return _name; + } + int get_streams() { + return _streams; + } + int get_streams() const { + return _streams; + } + int get_threads() { + return _threads; + } + int get_threads() const { + return _threads; + } + int get_threads_per_stream() { + return _threads_per_stream; + } + bool get_cpu_reservation() { + return _cpu_reservation; + } + std::vector> get_streams_info_table() { + return _streams_info_table; + } + std::vector> get_stream_processor_ids() { + return _stream_processor_ids; + } + ThreadBindingType get_thread_binding_type() { + return _threadBindingType; + } + int get_thread_binding_step() { + return _threadBindingStep; + } + int get_thread_binding_offset() { + return _threadBindingOffset; + } + bool operator==(const Config& config){ + if (_name == config._name && _streams == config._streams && + _threads_per_stream == config._threads_per_stream && _threadBindingType == config._threadBindingType && + _thread_preferred_core_type == config._thread_preferred_core_type) { + return true; + } else { + return false; + } + } + + /** + * @brief Create appropriate multithreaded configuration + * filing unconfigured values from initial configuration using hardware properties + * @param initial Inital configuration + * @return configured values + */ + static Config make_default_multi_threaded(const Config& initial); + + static int get_default_num_streams(); // no network specifics considered (only CPU's caps); + + /** + * @brief Get and reserve cpu ids based on configuration and hardware information + * streams_info_table must be present in the configuration + * @param initial Inital configuration + * @return configured values + */ + // It will be removed when other plugins will no longer call it. + static Config reserve_cpu_threads(const Config& initial); }; /** diff --git a/src/inference/dev_api/precision_utils.h b/src/inference/dev_api/precision_utils.h deleted file mode 100644 index 221aead0c41e16..00000000000000 --- a/src/inference/dev_api/precision_utils.h +++ /dev/null @@ -1,180 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/** - * @brief Basic functions to convert from FP16 to FP32 and vice versa - * @file precision_utils.h - */ - -#pragma once - -#include -#include -#include -#include - -#include "ie_api.h" - -/** - * @brief Inference Engine Plugin API namespace - */ -namespace InferenceEngine { - -/** - * @brief A type difinition for FP16 data type. Defined as a singed short - * @ingroup ie_dev_api_precision - */ -using ie_fp16 = short; - -/** - * @brief Namespace for precision utilities - * @ingroup ie_dev_api_precision - */ -namespace PrecisionUtils { - -/** - * @brief Converts a single-precision floating point value to a half-precision floating poit value - * @ingroup ie_dev_api_precision - * - * @param[in] x A single-precision floating point value - * @return A half-precision floating point value - */ -INFERENCE_ENGINE_API_CPP(ie_fp16) f32tof16(float x); - -/** - * @brief Convers a half-precision floating point value to a single-precision floating point value - * @ingroup ie_dev_api_precision - * - * @param[in] x A half-precision floating point value - * @return A single-precision floating point value - */ -INFERENCE_ENGINE_API_CPP(float) f16tof32(ie_fp16 x); - -/** - * @brief Converts a half-precision floating point array to single-precision floating point array - * and applies `scale` and `bias` is needed - * @ingroup ie_dev_api_precision - * - * @param dst A destination array of single-precision floating point values - * @param[in] src A source array of half-precision floating point values - * @param[in] nelem A number of elements in arrays - * @param[in] scale An optional scale parameter - * @param[in] bias An optional bias parameter - */ -INFERENCE_ENGINE_API_CPP(void) -f16tof32Arrays(float* dst, const ie_fp16* src, size_t nelem, float scale = 1.f, float bias = 0.f); - -/** - * @brief Converts a single-precision floating point array to a half-precision floating point array - * and applies `scale` and `bias` if needed - * @ingroup ie_dev_api_precision - * - * @param dst A destination array of half-precision floating point values - * @param[in] src A sources array of single-precision floating point values - * @param[in] nelem A number of elements in arrays - * @param[in] scale An optional scale parameter - * @param[in] bias An optional bias parameter - */ -INFERENCE_ENGINE_API_CPP(void) -f32tof16Arrays(ie_fp16* dst, const float* src, size_t nelem, float scale = 1.f, float bias = 0.f); - -#if defined(_MSC_VER) -# pragma warning(push) -# pragma warning(disable : 4018) -#endif - -namespace details { - -// To overcame syntax parse error, when `>` comparison operator is threated as template closing bracket -constexpr inline bool Greater(size_t v1, size_t v2) { - return v1 > v2; -} - -} // namespace details - -/** - * @brief Converts one integral type to another saturating the result if the source value doesn't fit - * into destination type range - * @ingroup ie_dev_api_precision - * - * @param value Value to be converted - * @return A saturated value - */ -template ::value && std::is_integral::value && - std::is_signed::value && !std::is_same::value>::type* = nullptr> -inline OutT saturate_cast(const InT& value) { - using MaxT = typename std::conditional::type, - typename std::make_unsigned::type>::type; - using MinT = typename std::conditional::type, - typename std::make_signed::type>::type; - - static const MaxT OUT_MAX = static_cast(std::numeric_limits::max()); - static const MaxT IN_MAX = static_cast(std::numeric_limits::max()); - - static const MinT OUT_MIN = static_cast(std::numeric_limits::min()); - static const MinT IN_MIN = static_cast(std::numeric_limits::min()); - - if (OUT_MAX > IN_MAX && OUT_MIN < IN_MIN) { - return static_cast(value); - } - - const InT max = static_cast(OUT_MAX < IN_MAX ? OUT_MAX : IN_MAX); - const InT min = static_cast(OUT_MIN > IN_MIN ? OUT_MIN : IN_MIN); - - return static_cast(std::min(std::max(value, min), max)); -} - -/** - * @brief Converts one integral type to another saturating the result if the source value doesn't fit - * into destination type range - * @ingroup ie_dev_api_precision - * - * @param value Value to be converted - * @return A saturated value - */ -template ::value && std::is_integral::value && - std::is_unsigned::value && !std::is_same::value>::type* = nullptr> -inline OutT saturate_cast(const InT& value) { - using MaxT = typename std::conditional::type, - typename std::make_unsigned::type>::type; - - static const MaxT OUT_MAX = static_cast(std::numeric_limits::max()); - static const MaxT IN_MAX = static_cast(std::numeric_limits::max()); - - if (OUT_MAX > IN_MAX) { - return static_cast(value); - } - - const InT max = static_cast(OUT_MAX < IN_MAX ? OUT_MAX : IN_MAX); - - return static_cast(std::min(value, max)); -} - -#if defined(_MSC_VER) -# pragma warning(pop) -#endif - -/** - * @brief Converts one integral type to another saturating the result if the source value doesn't fit - * into destination type range - * @ingroup ie_dev_api_precision - * - * @param value Value to be converted - * @return A saturated value - */ -template -inline InT saturate_cast(const InT& value) { - return value; -} - -} // namespace PrecisionUtils - -} // namespace InferenceEngine diff --git a/src/inference/dev_api/remote_utils.hpp b/src/inference/dev_api/remote_utils.hpp deleted file mode 100644 index d37f5ec8612150..00000000000000 --- a/src/inference/dev_api/remote_utils.hpp +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "ie_ngraph_utils.hpp" -#include "openvino/runtime/iremote_context.hpp" - -namespace ov { -namespace legacy_convert { - -class INFERENCE_ENGINE_API_CLASS(TensorHolder) { -public: - TensorHolder(ov::SoPtr tensor) : _tensor(tensor) {} - - const ov::SoPtr& get_tensor() const { - return _tensor; - } - -private: - ov::SoPtr _tensor; -}; - -} // namespace legacy_convert -} // namespace ov diff --git a/src/inference/include/ie/cpp/ie_executable_network.hpp b/src/inference/include/ie/cpp/ie_executable_network.hpp index 80ee0cbab45338..10ab6a66c3d12e 100644 --- a/src/inference/include/ie/cpp/ie_executable_network.hpp +++ b/src/inference/include/ie/cpp/ie_executable_network.hpp @@ -29,7 +29,6 @@ #include "cpp/ie_cnn_network.h" #include "cpp/ie_infer_request.hpp" #include "ie_iexecutable_network.hpp" -#include "ie_parameter.hpp" namespace ov { class Core; @@ -142,9 +141,9 @@ class INFERENCE_ENGINE_1_0_DEPRECATED INFERENCE_ENGINE_API_CLASS(ExecutableNetwo /** * @brief Sets configuration for current executable network * - * @param config Map of pairs: (config parameter name, config parameter value) + * @param config Map of pairs: (config name, config value) */ - void SetConfig(const std::map& config); + void SetConfig(const ov::AnyMap& config); /** @brief Gets configuration for current executable network. * @@ -154,10 +153,10 @@ class INFERENCE_ENGINE_1_0_DEPRECATED INFERENCE_ENGINE_API_CLASS(ExecutableNetwo * dynamically, e.g. DEVICE_ID cannot changed if an executable network has already been compiled for particular * device. * - * @param name config key, can be found in ie_plugin_config.hpp - * @return Configuration parameter value + * @param name config key, can be found in properties.hpp + * @return Configuration ov::Any value */ - Parameter GetConfig(const std::string& name) const; + ov::Any GetConfig(const std::string& name) const; /** * @brief Gets general runtime metric for an executable network. @@ -166,9 +165,9 @@ class INFERENCE_ENGINE_1_0_DEPRECATED INFERENCE_ENGINE_API_CLASS(ExecutableNetwo * which executable network is running or all other properties which cannot be changed dynamically. * * @param name metric name to request - * @return Metric parameter value + * @return Metric ov::Any value */ - Parameter GetMetric(const std::string& name) const; + ov::Any GetMetric(const std::string& name) const; /** * @brief Checks if current ExecutableNetwork object is not initialized diff --git a/src/inference/include/ie/details/ie_exception.hpp b/src/inference/include/ie/details/ie_exception.hpp deleted file mode 100644 index fafa65173b0dc1..00000000000000 --- a/src/inference/include/ie/details/ie_exception.hpp +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(IE_LEGACY_HEADER_INCLUDED) -# define IE_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The Inference Engine API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The Inference Engine API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include "ie_common.h" diff --git a/src/inference/include/ie/hetero/hetero_plugin_config.hpp b/src/inference/include/ie/hetero/hetero_plugin_config.hpp deleted file mode 100644 index ada6b20ca84327..00000000000000 --- a/src/inference/include/ie/hetero/hetero_plugin_config.hpp +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/** - * @brief A header that defines advanced related properties for Heterogeneous plugins. - * These properties should be used in SetConfig() and LoadNetwork() methods of plugins - * - * @file hetero_plugin_config.hpp - */ - -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(IE_LEGACY_HEADER_INCLUDED) -# define IE_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The Inference Engine API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The Inference Engine API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include "ie_plugin_config.hpp" - -namespace InferenceEngine { - -/** - * @brief Heterogeneous plugin configuration - */ -namespace HeteroConfigParams { - -/** - * @def HETERO_CONFIG_KEY(name) - * @brief Shortcut for defining HETERO configuration keys - */ -#define HETERO_CONFIG_KEY(name) InferenceEngine::HeteroConfigParams::_CONFIG_KEY(HETERO_##name) -#define DECLARE_HETERO_CONFIG_KEY(name) DECLARE_CONFIG_KEY(HETERO_##name) - -/** - * @brief The key for enabling of dumping the topology with details of layers and details how - * this network would be executed on different devices to the disk in GraphViz format. - * This option should be used with values: CONFIG_VALUE(NO) (default) or CONFIG_VALUE(YES) - */ -INFERENCE_ENGINE_1_0_DEPRECATED DECLARE_HETERO_CONFIG_KEY(DUMP_GRAPH_DOT); - -} // namespace HeteroConfigParams -} // namespace InferenceEngine diff --git a/src/inference/include/ie/ie_core.hpp b/src/inference/include/ie/ie_core.hpp index d8d2242d9f2060..a18cba26cbca7f 100644 --- a/src/inference/include/ie/ie_core.hpp +++ b/src/inference/include/ie/ie_core.hpp @@ -26,8 +26,7 @@ #include #include "cpp/ie_executable_network.hpp" -#include "ie_plugin_config.hpp" -#include "ie_version.hpp" +#include "openvino/core/version.hpp" namespace InferenceEngine { @@ -62,7 +61,7 @@ class INFERENCE_ENGINE_1_0_DEPRECATED INFERENCE_ENGINE_API_CLASS(Core) { * @param deviceName Device name to identify plugin * @return A vector of versions */ - std::map GetVersions(const std::string& deviceName) const; + std::map GetVersions(const std::string& deviceName) const; #ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT /** @@ -217,7 +216,7 @@ class INFERENCE_ENGINE_1_0_DEPRECATED INFERENCE_ENGINE_API_CLASS(Core) { const std::map& config = {}) const; /** - * @brief Sets configuration for device, acceptable keys can be found in ie_plugin_config.hpp + * @brief Sets configuration for device, acceptable keys can be found in properties.hpp * * @param deviceName An optional name of a device. If device name is not specified, the config is set for all the * registered devices. @@ -235,7 +234,7 @@ class INFERENCE_ENGINE_1_0_DEPRECATED INFERENCE_ENGINE_API_CLASS(Core) { * @param name - config key. * @return Value of config corresponding to config key. */ - Parameter GetConfig(const std::string& deviceName, const std::string& name) const; + ov::Any GetConfig(const std::string& deviceName, const std::string& name) const; /** * @brief Gets general runtime metric for dedicated hardware. @@ -248,7 +247,7 @@ class INFERENCE_ENGINE_1_0_DEPRECATED INFERENCE_ENGINE_API_CLASS(Core) { * @param options - optional parameters to get a metric value * @return Metric value corresponding to metric key. */ - Parameter GetMetric(const std::string& deviceName, const std::string& name, const ParamMap& options = {}) const; + ov::Any GetMetric(const std::string& deviceName, const std::string& name, const ov::AnyMap& options = {}) const; /** * @brief Returns devices available for neural networks inference diff --git a/src/inference/include/ie/ie_iexecutable_network.hpp b/src/inference/include/ie/ie_iexecutable_network.hpp index 989167885c5d9d..c3ffc38cb5e26c 100644 --- a/src/inference/include/ie/ie_iexecutable_network.hpp +++ b/src/inference/include/ie/ie_iexecutable_network.hpp @@ -29,7 +29,6 @@ #include "ie_icnn_network.hpp" #include "ie_iinfer_request.hpp" #include "ie_input_info.hpp" -#include "ie_parameter.hpp" namespace InferenceEngine { @@ -123,11 +122,11 @@ class INFERENCE_ENGINE_1_0_DEPRECATED IExecutableNetwork : public std::enable_sh /** * @brief Sets configuration for current executable network * - * @param config Map of pairs: (config parameter name, config parameter value) + * @param config Map of pairs: (config name, config value) * @param resp Pointer to the response message that holds a description of an error if any occurred * @return code of the operation. InferenceEngine::OK if succeeded */ - virtual StatusCode SetConfig(const std::map& config, ResponseDesc* resp) noexcept = 0; + virtual StatusCode SetConfig(const ov::AnyMap& config, ResponseDesc* resp) noexcept = 0; /** @brief Gets configuration for current executable network. * @@ -137,12 +136,12 @@ class INFERENCE_ENGINE_1_0_DEPRECATED IExecutableNetwork : public std::enable_sh * dynamically, e.g. DEVICE_ID cannot changed if an executable network has already been compiled for particular * device. * - * @param name config key, can be found in ie_plugin_config.hpp + * @param name config key, can be found in properties.hpp * @param result value of config corresponding to config key * @param resp Pointer to the response message that holds a description of an error if any occurred * @return code of the operation. InferenceEngine::OK if succeeded */ - virtual StatusCode GetConfig(const std::string& name, Parameter& result, ResponseDesc* resp) const noexcept = 0; + virtual StatusCode GetConfig(const std::string& name, ov::Any& result, ResponseDesc* resp) const noexcept = 0; /** * @brief Gets general runtime metric for an executable network. @@ -155,7 +154,7 @@ class INFERENCE_ENGINE_1_0_DEPRECATED IExecutableNetwork : public std::enable_sh * @param resp Pointer to the response message that holds a description of an error if any occurred * @return code of the operation. InferenceEngine::OK if succeeded */ - virtual StatusCode GetMetric(const std::string& name, Parameter& result, ResponseDesc* resp) const noexcept = 0; + virtual StatusCode GetMetric(const std::string& name, ov::Any& result, ResponseDesc* resp) const noexcept = 0; protected: virtual ~IExecutableNetwork() = default; diff --git a/src/inference/include/ie/ie_parameter.hpp b/src/inference/include/ie/ie_parameter.hpp deleted file mode 100644 index 5141f5ab931d40..00000000000000 --- a/src/inference/include/ie/ie_parameter.hpp +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/** - * @brief A header file for the Parameter class - * @file ie_parameter.hpp - */ -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(IE_LEGACY_HEADER_INCLUDED) -# define IE_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The Inference Engine API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The Inference Engine API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ie_blob.h" -#include "openvino/core/any.hpp" -#include "openvino/core/except.hpp" - -namespace InferenceEngine { - -/** - * @brief Alias for type that can store any value - */ -using Parameter = ov::Any; -using ParamMap = ov::AnyMap; - -} // namespace InferenceEngine diff --git a/src/inference/include/ie/ie_plugin_config.hpp b/src/inference/include/ie/ie_plugin_config.hpp deleted file mode 100644 index 2d3bf9eafa1985..00000000000000 --- a/src/inference/include/ie/ie_plugin_config.hpp +++ /dev/null @@ -1,532 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/** - * @brief A header for advanced hardware related properties for Inference Engine plugins - * To use in SetConfig, LoadNetwork, ImportNetwork methods of plugins - * - * @file ie_plugin_config.hpp - */ -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(IE_LEGACY_HEADER_INCLUDED) -# define IE_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The Inference Engine API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The Inference Engine API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include -#include -#include -#include - -#include "ie_precision.hpp" - -namespace InferenceEngine { -IE_SUPPRESS_DEPRECATED_START - -/** - * @brief %Metrics - */ -namespace Metrics { - -/** - * @def METRIC_KEY(name) - * @brief shortcut for defining common Inference Engine metrics - */ -#define METRIC_KEY(name) InferenceEngine::Metrics::METRIC_##name - -/** - * @def EXEC_NETWORK_METRIC_KEY(name) - * @brief shortcut for defining common Inference Engine ExecutableNetwork metrics - */ -#define EXEC_NETWORK_METRIC_KEY(name) METRIC_KEY(name) - -#ifndef DECLARE_METRIC_KEY_IMPL -# define DECLARE_METRIC_KEY(name, ...) static constexpr auto METRIC_##name = # name -#else -# define DECLARE_METRIC_KEY(name, ...) \ - static constexpr auto METRIC_##name = #name; \ - DECLARE_METRIC_KEY_IMPL(name, __VA_ARGS__) -#endif - -#define DECLARE_EXEC_NETWORK_METRIC_KEY(name, ...) DECLARE_METRIC_KEY(name, __VA_ARGS__) - -/** - * @def METRIC_VALUE(name) - * @brief shortcut for defining metric values - */ -#define METRIC_VALUE(name) InferenceEngine::Metrics::name -#define DECLARE_METRIC_VALUE(name) static constexpr auto name = #name - -/** - * @brief Metric to get a std::vector of available device IDs. String value is "AVAILABLE_DEVICES" - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_METRIC_KEY(AVAILABLE_DEVICES, std::vector); - -/** - * @brief Metric to get a std::vector of supported metrics. String value is "SUPPORTED_METRICS" - * - * This can be used as an executable network metric as well. - * - * Each of the returned device metrics can be passed to Core::GetMetric, executable network metrics - * can be passed to ExecutableNetwork::GetMetric. - * - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_METRIC_KEY(SUPPORTED_METRICS, std::vector); - -/** - * @brief Metric to get a std::vector of supported config keys. String value is "SUPPORTED_CONFIG_KEYS" - * - * This can be used as an executable network metric as well. - * - * Each of the returned device configuration keys can be passed to Core::SetConfig, Core::GetConfig, and - * Core::LoadNetwork, configuration keys for executable networks can be passed to ExecutableNetwork::SetConfig and - * ExecutableNetwork::GetConfig. - * - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_METRIC_KEY(SUPPORTED_CONFIG_KEYS, std::vector); - -/** - * @brief Metric to get a std::string value representing a full device name. String value is "FULL_DEVICE_NAME" - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_METRIC_KEY(FULL_DEVICE_NAME, std::string); - -/** - * @brief Metric to get a std::vector of optimization options per device. String value is - * "OPTIMIZATION_CAPABILITIES" - * - * The possible values: - * - "FP32" - device can support FP32 models - * - "BF16" - device can support BF16 computations for models - * - "FP16" - device can support FP16 models - * - "INT8" - device can support models with INT8 layers - * - "BIN" - device can support models with BIN layers - * - "WINOGRAD" - device can support models where convolution implemented via Winograd transformations - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_METRIC_KEY(OPTIMIZATION_CAPABILITIES, std::vector); - -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_METRIC_VALUE(FP32); -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_METRIC_VALUE(BF16); -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_METRIC_VALUE(FP16); -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_METRIC_VALUE(INT8); -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_METRIC_VALUE(BIN); -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_METRIC_VALUE(WINOGRAD); - -/** - * @brief Metric to provide information about a range for streams on platforms where streams are supported. - * - * Metric returns a value of std::tuple type, where: - * - First value is bottom bound. - * - Second value is upper bound. - * String value for metric name is "RANGE_FOR_STREAMS". - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_METRIC_KEY(RANGE_FOR_STREAMS, std::tuple); -/** - * @brief Metric to query information optimal batch size for the given device and the network - * - * Metric returns a value of unsigned int type, - * Returns optimal batch size for a given network on the given device. The returned value is aligned to power of 2. - * Also, MODEL_PTR is the required option for this metric since the optimal batch size depends on the model, - * so if the MODEL_PTR is not given, the result of the metric is always 1. - * For the GPU the metric is queried automatically whenever the OpenVINO performance hint for the throughput is used, - * so that the result (>1) governs the automatic batching (transparently to the application). - * The automatic batching can be disabled with ALLOW_AUTO_BATCHING set to NO - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_METRIC_KEY(OPTIMAL_BATCH_SIZE, unsigned int); - -/** - * @brief Metric to get maximum batch size which does not cause performance degradation due to memory swap impact. - * - * Metric returns a value of unsigned int type, - * Note that the returned value may not aligned to power of 2. - * Also, MODEL_PTR is the required option for this metric since the available max batch size depends on the model size. - * If the MODEL_PTR is not given, it will return 1. - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_METRIC_KEY(MAX_BATCH_SIZE, unsigned int); - -/** - * @brief Metric to provide a hint for a range for number of async infer requests. If device supports streams, - * the metric provides range for number of IRs per stream. - * - * Metric returns a value of std::tuple type, where: - * - First value is bottom bound. - * - Second value is upper bound. - * - Third value is step inside this range. - * String value for metric name is "RANGE_FOR_ASYNC_INFER_REQUESTS". - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_METRIC_KEY(RANGE_FOR_ASYNC_INFER_REQUESTS, std::tuple); - -/** - * @brief Metric to get an unsigned int value of number of waiting infer request. - * - * String value is "NUMBER_OF_WAITNING_INFER_REQUESTS". This can be used as an executable network metric as well - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_METRIC_KEY(NUMBER_OF_WAITING_INFER_REQUESTS, unsigned int); - -/** - * @brief Metric to get an unsigned int value of number of infer request in execution stage. - * - * String value is "NUMBER_OF_EXEC_INFER_REQUESTS". This can be used as an executable network metric as well - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_METRIC_KEY(NUMBER_OF_EXEC_INFER_REQUESTS, unsigned int); - -/** - * @brief Metric which defines the device architecture. - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_METRIC_KEY(DEVICE_ARCHITECTURE, std::string); - -/** - * @brief Enum to define possible device types - */ -enum class INFERENCE_ENGINE_1_0_DEPRECATED DeviceType { - integrated = 0, - discrete = 1, -}; - -/** @cond INTERNAL */ -INFERENCE_ENGINE_1_0_DEPRECATED inline std::ostream& operator<<( - std::ostream& os, - const InferenceEngine::Metrics::DeviceType& deviceType) { - switch (deviceType) { - case InferenceEngine::Metrics::DeviceType::discrete: - os << "discrete"; - break; - case InferenceEngine::Metrics::DeviceType::integrated: - os << "integrated"; - break; - default: - os << "unknown"; - break; - } - - return os; -} -/** @endcond */ - -/** - * @brief Metric to get a type of device. See DeviceType enum definition for possible return values - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_METRIC_KEY(DEVICE_TYPE, DeviceType); - -/** - * @brief Metric which defines Giga OPS per second count (GFLOPS or GIOPS) for a set of precisions supported by - * specified device - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_METRIC_KEY(DEVICE_GOPS, std::map); - -/** - * @brief Metric which defines support of import/export functionality by plugin - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_METRIC_KEY(IMPORT_EXPORT_SUPPORT, bool); - -/** - * @brief Metric to get a name of network. String value is "NETWORK_NAME". - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_EXEC_NETWORK_METRIC_KEY(NETWORK_NAME, std::string); - -/** - * @brief Metric to get a float of device thermal. String value is "DEVICE_THERMAL" - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_METRIC_KEY(DEVICE_THERMAL, float); - -/** - * @brief Metric to get an unsigned integer value of optimal number of executable network infer requests. - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_EXEC_NETWORK_METRIC_KEY(OPTIMAL_NUMBER_OF_INFER_REQUESTS, unsigned int); - -} // namespace Metrics - -/** - * @brief Generic plugin configuration - */ -namespace PluginConfigParams { - -/** - * @def CONFIG_KEY(name) - * @brief shortcut for defining configuration keys - */ -#define CONFIG_KEY(name) InferenceEngine::PluginConfigParams::_CONFIG_KEY(name) -#define _CONFIG_KEY(name) KEY_##name -#define DECLARE_CONFIG_KEY(name) static constexpr auto _CONFIG_KEY(name) = #name - -/** - * @def CONFIG_VALUE(name) - * @brief shortcut for defining configuration values - */ -#define CONFIG_VALUE(name) InferenceEngine::PluginConfigParams::name -#define DECLARE_CONFIG_VALUE(name) static constexpr auto name = #name - -/** - * @brief (Optional) config key that defines what model should be provided with more performant bounded resource first - * It provides 3 types of levels: High, Medium and Low. The default value is Medium - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_KEY(MODEL_PRIORITY); -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_VALUE(MODEL_PRIORITY_HIGH); -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_VALUE(MODEL_PRIORITY_MED); -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_VALUE(MODEL_PRIORITY_LOW); - -/** - * @brief High-level OpenVINO Performance Hints - * unlike low-level config keys that are individual (per-device), the hints are smth that every device accepts - * and turns into device-specific settings - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_KEY(PERFORMANCE_HINT); -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_VALUE(LATENCY); -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_VALUE(THROUGHPUT); -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_VALUE(UNDEFINED); -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_VALUE(CUMULATIVE_THROUGHPUT); -/** - * @brief (Optional) config key that backs the (above) Performance Hints - * by giving additional information on how many inference requests the application will be keeping in flight - * usually this value comes from the actual use-case (e.g. number of video-cameras, or other sources of inputs) - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_KEY(PERFORMANCE_HINT_NUM_REQUESTS); -/** - * @brief (Optional) config key that governs Auto-Batching (with YES/NO values, below) - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_KEY(ALLOW_AUTO_BATCHING); - -/** - * @brief generic boolean values - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_VALUE(YES); -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_VALUE(NO); - -/** - * @brief Auto-batching configuration, string for the device + batch size, e.g. "GPU(4)" - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_KEY(AUTO_BATCH_DEVICE_CONFIG); -/** - * @brief Auto-batching configuration: string with timeout (in ms), e.g. "100" - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_KEY(AUTO_BATCH_TIMEOUT); - -/** - * @brief Limit `#threads` that are used by Inference Engine for inference on the CPU. - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_KEY(CPU_THREADS_NUM); - -/** - * @brief The name for setting CPU affinity per thread option. - * - * It is passed to Core::SetConfig(), this option should be used with values: - * PluginConfigParams::NO (no pinning for CPU inference threads) - * PluginConfigParams::YES, which is default on the conventional CPUs (pinning threads to cores, best for static - * benchmarks), - * - * the following options are implemented only for the TBB as a threading option - * PluginConfigParams::NUMA (pinning threads to NUMA nodes, best for real-life, contented cases) - * on the Windows and MacOS* this option behaves as YES - * PluginConfigParams::HYBRID_AWARE (let the runtime to do pinning to the cores types, e.g. prefer the "big" cores for - * latency tasks) on the hybrid CPUs this option is default - * - * Also, the settings are ignored, if the OpenVINO compiled with OpenMP and any affinity-related OpenMP's - * environment variable is set (as affinity is configured explicitly) - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_KEY(CPU_BIND_THREAD); -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_VALUE(NUMA); -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_VALUE(HYBRID_AWARE); - -/** - * @brief Optimize CPU execution to maximize throughput. - * - * It is passed to Core::SetConfig(), this option should be used with values: - * - KEY_CPU_THROUGHPUT_NUMA creates as many streams as needed to accommodate NUMA and avoid associated penalties - * - KEY_CPU_THROUGHPUT_AUTO creates bare minimum of streams to improve the performance, - * this is the most portable option if you have no insights into how many cores you target machine will have - * (and what is the optimal number of streams) - * - finally, specifying the positive integer value creates the requested number of streams - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_KEY(CPU_THROUGHPUT_STREAMS); -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_VALUE(CPU_THROUGHPUT_NUMA); -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_VALUE(CPU_THROUGHPUT_AUTO); - -/** - * @brief The name for setting performance counters option. - * - * It is passed to Core::SetConfig(), this option should be used with values: - * PluginConfigParams::YES or PluginConfigParams::NO - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_KEY(PERF_COUNT); - -/** - * @brief This key directs the plugin to load a configuration file. - * - * The value should be a file name with the plugin specific configuration - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_KEY(CONFIG_FILE); - -/** - * @brief the key for setting desirable log level. - * - * This option should be used with values: PluginConfigParams::LOG_NONE (default), - * PluginConfigParams::LOG_ERROR, PluginConfigParams::LOG_WARNING, - * PluginConfigParams::LOG_INFO, PluginConfigParams::LOG_DEBUG, PluginConfigParams::LOG_TRACE - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_KEY(LOG_LEVEL); - -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_VALUE(LOG_NONE); // turn off logging -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_VALUE(LOG_ERROR); // error events that might still allow the - // application to continue running -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_VALUE(LOG_WARNING); // potentially harmful situations which may - // further lead to ERROR -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_VALUE(LOG_INFO); // informational messages that display the progress of the - // application at coarse-grained level -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_VALUE(LOG_DEBUG); // fine-grained events that are most useful to - // debug an application. -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_VALUE(LOG_TRACE); // finer-grained informational events than the DEBUG - -/** - * @brief the key for setting of required device to execute on - * values: device id starts from "0" - first device, "1" - second device, etc - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_KEY(DEVICE_ID); - -/** - * @brief the key for enabling exclusive mode for async requests of different executable networks and the same plugin. - * - * Sometimes it is necessary to avoid oversubscription requests that are sharing the same device in parallel. - * E.g. There 2 task executors for CPU device: one - in the Hetero plugin, another - in pure CPU plugin. - * Parallel execution both of them might lead to oversubscription and not optimal CPU usage. More efficient - * to run the corresponding tasks one by one via single executor. - * By default, the option is set to YES for hetero cases, and to NO for conventional (single-plugin) cases - * Notice that setting YES disables the CPU streams feature (see another config key in this file) - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_KEY(EXCLUSIVE_ASYNC_REQUESTS); - -/** - * @deprecated Use InferenceEngine::ExecutableNetwork::GetExecGraphInfo::serialize method - * @brief This key enables dumping of the internal primitive graph. - * - * Should be passed into LoadNetwork method to enable dumping of internal graph of primitives and - * corresponding configuration information. Value is a name of output dot file without extension. - * Files `_init.dot` and `_perf.dot` will be produced. - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_KEY(DUMP_EXEC_GRAPH_AS_DOT); - -/** - * @brief The name for setting to execute in bfloat16 precision whenever it is possible - * - * This option let plugin know to downscale the precision where it see performance benefits from - * bfloat16 execution - * Such option do not guarantee accuracy of the network, the accuracy in this mode should be - * verified separately by the user and basing on performance and accuracy results it should be - * user's decision to use this option or not to use - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_KEY(ENFORCE_BF16); - -/** - * @brief This key defines the directory which will be used to store any data cached by plugins. - * - * The underlying cache structure is not defined and might differ between OpenVINO releases - * Cached data might be platform / device specific and might be invalid after OpenVINO version change - * If this key is not specified or value is empty string, then caching is disabled. - * The key might enable caching for the plugin using the following code: - * - * @code - * ie.SetConfig({{CONFIG_KEY(CACHE_DIR), "cache/"}}, "GPU"); // enables cache for GPU plugin - * @endcode - * - * The following code enables caching of compiled network blobs for devices where import/export is supported - * - * @code - * ie.SetConfig({{CONFIG_KEY(CACHE_DIR), "cache/"}}); // enables models cache - * @endcode - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_KEY(CACHE_DIR); - -/** - * @brief The key to decide whether terminate tbb threads when inference engine destructing. - * - * value type: boolean - * - True explicitly terminate tbb when inference engine destruction - * - False will not involve additional tbb operations when inference engine destruction - * - * @code - * ie.SetConfig({{CONFIG_KEY(FORCE_TBB_TERMINATE), CONFIG_VALUE(YES)}}); // enable - * @endcode - */ -INFERENCE_ENGINE_1_0_DEPRECATED -DECLARE_CONFIG_KEY(FORCE_TBB_TERMINATE); - -} // namespace PluginConfigParams - -/** - * @def AUTO_CONFIG_KEY(name) - * @brief A macro which provides an AUTO-mangled name for configuration key with name `name` - */ -#define AUTO_CONFIG_KEY(name) InferenceEngine::_CONFIG_KEY(AUTO_##name) - -#define DECLARE_AUTO_CONFIG_KEY(name) DECLARE_CONFIG_KEY(AUTO_##name) - -IE_SUPPRESS_DEPRECATED_END -} // namespace InferenceEngine - -#include "hetero/hetero_plugin_config.hpp" -#include "multi-device/multi_device_config.hpp" diff --git a/src/inference/include/ie/ie_version.hpp b/src/inference/include/ie/ie_version.hpp deleted file mode 100644 index 9363aa7d82be5f..00000000000000 --- a/src/inference/include/ie/ie_version.hpp +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/** - * @brief A header file that provides versioning information for the Inference Engine library - * - * @file ie_version.hpp - */ -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(IE_LEGACY_HEADER_INCLUDED) -# define IE_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The Inference Engine API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The Inference Engine API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -/** - * @def IE_VERSION_MAJOR - * @brief Defines Inference Engine major version - * - * @def IE_VERSION_MINOR - * @brief Defines Inference Engine minor version - * - * @def IE_VERSION_PATCH - * @brief Defines Inference Engine patch version - */ - -#define IE_VERSION_MAJOR 2024 -#define IE_VERSION_MINOR 0 -#define IE_VERSION_PATCH 0 - -#include "ie_api.h" - -/** - * @brief Inference Engine C++ API - */ -namespace InferenceEngine { -IE_SUPPRESS_DEPRECATED_START - -/** - * @struct Version - * @brief Represents version information that describes plugins and the inference engine runtime library - */ -#pragma pack(push, 1) -struct INFERENCE_ENGINE_1_0_DEPRECATED Version { - IE_SUPPRESS_DEPRECATED_START - /** - * @deprecated Use IE_VERSION_[MAJOR|MINOR|PATCH] definitions, buildNumber property - * @brief An API version reflects the set of supported features - */ - struct INFERENCE_ENGINE_1_0_DEPRECATED ApiVersion { - INFERENCE_ENGINE_DEPRECATED("Use IE_VERSION_[MAJOR|MINOR|PATCH] definitions, buildNumber property") - int major; //!< A major version - INFERENCE_ENGINE_DEPRECATED("Use IE_VERSION_[MAJOR|MINOR|PATCH] definitions, buildNumber property") - int minor; //!< A minor version - - /** - * @brief A default construtor - */ - ApiVersion() { - major = 0; - minor = 0; - } - - /** - * @brief A default construtor - * @param v A version to copy - */ - ApiVersion(const ApiVersion& v) { - major = v.major; - minor = v.minor; - } - - /** - * @brief A default construtor - * @param _major A major version to copy - * @param _minor A minor version to copy - */ - ApiVersion(int _major, int _minor) { - major = _major; - minor = _minor; - } - - /** - * @brief A copy operator - * @param other An object to copy - * @return A copy - */ - ApiVersion& operator=(const ApiVersion& other) { - major = other.major; - minor = other.minor; - return *this; - } - }; - - /** - * @brief An API version reflects the set of supported features - */ - ApiVersion apiVersion; - IE_SUPPRESS_DEPRECATED_END - - /** - * @brief A null terminated string with build number - */ - const char* buildNumber; - - /** - * @brief A null terminated description string - */ - const char* description; -}; -#pragma pack(pop) - -/** - * @brief Gets the current Inference Engine version - * - * @return The current Inference Engine version - */ -INFERENCE_ENGINE_API(const Version*) GetInferenceEngineVersion() noexcept; - -IE_SUPPRESS_DEPRECATED_END -} // namespace InferenceEngine diff --git a/src/inference/include/ie/multi-device/multi_device_config.hpp b/src/inference/include/ie/multi-device/multi_device_config.hpp deleted file mode 100644 index b51916f73d15dc..00000000000000 --- a/src/inference/include/ie/multi-device/multi_device_config.hpp +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/** - * @brief A header that defines advanced related properties for Multi_Device plugin. - * These properties should be used in SetConfig() and LoadNetwork() methods - * - * @file multi_device_config.hpp - */ - -#pragma once - -#if !defined(IN_OV_COMPONENT) && !defined(IE_LEGACY_HEADER_INCLUDED) -# define IE_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The Inference Engine API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The Inference Engine API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include "ie_plugin_config.hpp" - -namespace InferenceEngine { - -/** - * @brief Multi Device plugin configuration - */ -namespace MultiDeviceConfigParams { - -/** - * @def MULTI_CONFIG_KEY(name) - * @brief A macro which provides a MULTI-mangled name for configuration key with name `name` - */ -#define MULTI_CONFIG_KEY(name) InferenceEngine::MultiDeviceConfigParams::_CONFIG_KEY(MULTI_##name) - -#define DECLARE_MULTI_CONFIG_KEY(name) DECLARE_CONFIG_KEY(MULTI_##name) -#define DECLARE_MULTI_CONFIG_VALUE(name) DECLARE_CONFIG_VALUE(MULTI_##name) - -/** - * @brief Device Priorities config option, with comma-separated devices listed in the desired priority - */ -INFERENCE_ENGINE_1_0_DEPRECATED DECLARE_MULTI_CONFIG_KEY(DEVICE_PRIORITIES); - -} // namespace MultiDeviceConfigParams -} // namespace InferenceEngine diff --git a/src/inference/src/any_copy.cpp b/src/inference/src/any_copy.cpp index 16cbdd31882c40..d4cbb2b2450592 100644 --- a/src/inference/src/any_copy.cpp +++ b/src/inference/src/any_copy.cpp @@ -6,7 +6,6 @@ #include -#include "ie_plugin_config.hpp" #include "openvino/runtime/properties.hpp" namespace ov { diff --git a/src/inference/src/any_copy.hpp b/src/inference/src/any_copy.hpp index 9af954f25a048c..f9121035edd028 100644 --- a/src/inference/src/any_copy.hpp +++ b/src/inference/src/any_copy.hpp @@ -4,7 +4,6 @@ #pragma once -#include #include #include #include diff --git a/src/inference/src/blob_transform.cpp b/src/inference/src/blob_transform.cpp deleted file mode 100644 index 321bef03dc997b..00000000000000 --- a/src/inference/src/blob_transform.cpp +++ /dev/null @@ -1,379 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "blob_transform.hpp" - -#include "openvino/runtime/system_conf.hpp" -#ifdef HAVE_SSE -# include "cpu_x86_sse42/blob_transform_sse42.hpp" -#endif - -#include -#include - -//---------------------------------------------------------------------- - -IE_SUPPRESS_DEPRECATED_START - -namespace InferenceEngine { - -template -static void blob_copy_4d_t(Blob::Ptr src, Blob::Ptr dst) { - using data_t = typename InferenceEngine::PrecisionTrait::value_type; - - auto* src_ptr = src->buffer().as(); - auto* dst_ptr = dst->buffer().as(); - - SizeVector dims = src->getTensorDesc().getDims(); - - size_t N = dims[0]; - size_t C = dims[1]; - size_t H = dims[2]; - size_t W = dims[3]; - - const Layout src_l = src->getTensorDesc().getLayout(); - const auto& src_blk_dsc = src->getTensorDesc().getBlockingDesc(); - const auto& src_strides = src_blk_dsc.getStrides(); - const auto N_src_stride = src_strides[0]; - const auto C_src_stride = src_l == NHWC ? src_strides[3] : src_strides[1]; - const auto H_src_stride = src_l == NHWC ? src_strides[1] : src_strides[2]; - const auto W_src_stride = src_l == NHWC ? src_strides[2] : src_strides[3]; - src_ptr += src_blk_dsc.getOffsetPadding(); - - const Layout dst_l = dst->getTensorDesc().getLayout(); - const auto& dst_blk_desc = dst->getTensorDesc().getBlockingDesc(); - const auto& dst_strides = dst_blk_desc.getStrides(); - const auto N_dst_stride = dst_strides[0]; - const auto C_dst_stride = dst_l == NHWC ? dst_strides[3] : dst_strides[1]; - const auto H_dst_stride = dst_l == NHWC ? dst_strides[1] : dst_strides[2]; - const auto W_dst_stride = dst_l == NHWC ? dst_strides[2] : dst_strides[3]; - - dst_ptr += dst_blk_desc.getOffsetPadding(); - -#ifdef HAVE_SSE - if (src->getTensorDesc().getLayout() == NHWC && dst->getTensorDesc().getLayout() == NCHW && C == 3 && - C_src_stride == 1 && W_src_stride == 3 && W_dst_stride == 1 && ov::with_cpu_x86_sse42()) { - if (PRC == Precision::U8) { - blob_copy_4d_split_u8c3(reinterpret_cast(src_ptr), - reinterpret_cast(dst_ptr), - N_src_stride, - H_src_stride, - N_dst_stride, - H_dst_stride, - C_dst_stride, - static_cast(N), - static_cast(H), - static_cast(W)); - return; - } - - if (PRC == Precision::FP32) { - blob_copy_4d_split_f32c3(reinterpret_cast(src_ptr), - reinterpret_cast(dst_ptr), - N_src_stride, - H_src_stride, - N_dst_stride, - H_dst_stride, - C_dst_stride, - static_cast(N), - static_cast(H), - static_cast(W)); - return; - } - } - - if (src->getTensorDesc().getLayout() == NCHW && dst->getTensorDesc().getLayout() == NHWC && C == 3 && - C_dst_stride == 1 && W_dst_stride == 3 && W_src_stride == 1 && ov::with_cpu_x86_sse42()) { - if (PRC == Precision::U8) { - blob_copy_4d_merge_u8c3(reinterpret_cast(src_ptr), - reinterpret_cast(dst_ptr), - N_src_stride, - H_src_stride, - C_src_stride, - N_dst_stride, - H_dst_stride, - static_cast(N), - static_cast(H), - static_cast(W)); - return; - } - - if (PRC == Precision::FP32) { - blob_copy_4d_merge_f32c3(reinterpret_cast(src_ptr), - reinterpret_cast(dst_ptr), - N_src_stride, - H_src_stride, - C_src_stride, - N_dst_stride, - H_dst_stride, - static_cast(N), - static_cast(H), - static_cast(W)); - return; - } - } -#else - (void)H_dst_stride; -#endif // HAVE_SSE - - if (src->getTensorDesc().getLayout() == NHWC && dst->getTensorDesc().getLayout() == NCHW) { - for (size_t n = 0; n < N; n++) { - for (size_t c = 0; c < C; c++) { - data_t* dst_ptr_l = dst_ptr + n * N_dst_stride + c * C_dst_stride; - data_t* src_ptr_l = src_ptr + n * N_src_stride + c * C_src_stride; - for (size_t h = 0; h < H; h++) { - data_t* src_ptr_l_l = src_ptr_l + h * H_src_stride; - for (size_t w = 0; w < W; w++) { - *dst_ptr_l = *src_ptr_l_l; - src_ptr_l_l += W_src_stride; - dst_ptr_l++; - } - } - } - } - } else if (src->getTensorDesc().getLayout() == NCHW && dst->getTensorDesc().getLayout() == NHWC) { - for (size_t n = 0; n < N; n++) { - for (size_t c = 0; c < C; c++) { - data_t* src_ptr_l = src_ptr + n * N_src_stride + c * C_src_stride; - data_t* dst_ptr_l = dst_ptr + n * N_dst_stride + c; - for (size_t h = 0; h < H; h++) { - data_t* src_ptr_l_l = src_ptr_l + h * H_src_stride; - for (size_t w = 0; w < W; w++) { - *dst_ptr_l = *src_ptr_l_l; - dst_ptr_l += W_dst_stride; - src_ptr_l_l++; - } - } - } - } - } else { - for (size_t i = 0; i < N * C * H * W; i++) { - dst_ptr[i] = src_ptr[i]; - } - } -} - -static inline void blob_copy_4d(Blob::Ptr src, Blob::Ptr dst) { - switch (src->getTensorDesc().getPrecision()) { - case Precision::FP32: - case Precision::I32: - case Precision::U32: - blob_copy_4d_t(src, dst); - break; - - case Precision::FP16: - case Precision::U16: - case Precision::I16: - blob_copy_4d_t(src, dst); - break; - - case Precision::U8: - case Precision::I8: - blob_copy_4d_t(src, dst); - break; - - default: - IE_THROW() << "Unsupported blob transformation for precision " << src->getTensorDesc().getPrecision(); - } -} - -template -static void blob_copy_5d_t(Blob::Ptr src, Blob::Ptr dst) { - using data_t = typename InferenceEngine::PrecisionTrait::value_type; - - const auto& src_blk_desc = src->getTensorDesc().getBlockingDesc(); - const auto& dst_blk_desc = dst->getTensorDesc().getBlockingDesc(); - - data_t* src_ptr = src->buffer().as() + src_blk_desc.getOffsetPadding(); - data_t* dst_ptr = dst->buffer().as() + dst_blk_desc.getOffsetPadding(); - - SizeVector dims = src->getTensorDesc().getDims(); // == dst's dims - - const size_t N = dims[0]; - const size_t C = dims[1]; - const size_t D = dims[2]; - const size_t H = dims[3]; - const size_t W = dims[4]; - - const Layout src_l = src->getTensorDesc().getLayout(); - const auto& src_strides = src_blk_desc.getStrides(); - const auto N_src_stride = src_strides[0]; - const auto C_src_stride = src_l == NDHWC ? src_strides[4] : src_strides[1]; - const auto D_src_stride = src_l == NDHWC ? src_strides[1] : src_strides[2]; - const auto H_src_stride = src_l == NDHWC ? src_strides[2] : src_strides[3]; - const auto W_src_stride = src_l == NDHWC ? src_strides[3] : src_strides[4]; - - const Layout dst_l = dst->getTensorDesc().getLayout(); - const auto& dst_strides = dst_blk_desc.getStrides(); - const auto N_dst_stride = dst_strides[0]; - const auto C_dst_stride = dst_l == NDHWC ? dst_strides[4] : dst_strides[1]; - const auto D_dst_stride = dst_l == NDHWC ? dst_strides[1] : dst_strides[2]; - const auto H_dst_stride = dst_l == NDHWC ? dst_strides[2] : dst_strides[3]; - const auto W_dst_stride = dst_l == NDHWC ? dst_strides[3] : dst_strides[4]; - -#ifdef HAVE_SSE - if (src->getTensorDesc().getLayout() == NDHWC && dst->getTensorDesc().getLayout() == NCDHW && C == 3 && - C_src_stride == 1 && W_src_stride == 3 && W_dst_stride == 1 && ov::with_cpu_x86_sse42()) { - if (PRC == Precision::U8) { - blob_copy_5d_split_u8c3(reinterpret_cast(src_ptr), - reinterpret_cast(dst_ptr), - N_src_stride, - D_src_stride, - H_src_stride, - N_dst_stride, - D_dst_stride, - H_dst_stride, - C_dst_stride, - static_cast(N), - static_cast(D), - static_cast(H), - static_cast(W)); - return; - } - - if (PRC == Precision::FP32) { - blob_copy_5d_split_f32c3(reinterpret_cast(src_ptr), - reinterpret_cast(dst_ptr), - N_src_stride, - D_src_stride, - H_src_stride, - N_dst_stride, - D_dst_stride, - H_dst_stride, - C_dst_stride, - static_cast(N), - static_cast(D), - static_cast(H), - static_cast(W)); - return; - } - } - - if (src->getTensorDesc().getLayout() == NCDHW && dst->getTensorDesc().getLayout() == NDHWC && C == 3 && - C_dst_stride == 1 && W_dst_stride == 3 && W_src_stride == 1 && ov::with_cpu_x86_sse42()) { - if (PRC == Precision::U8) { - blob_copy_5d_merge_u8c3(reinterpret_cast(src_ptr), - reinterpret_cast(dst_ptr), - N_src_stride, - D_src_stride, - H_src_stride, - C_src_stride, - N_dst_stride, - D_dst_stride, - H_dst_stride, - static_cast(N), - static_cast(D), - static_cast(H), - static_cast(W)); - return; - } - - if (PRC == Precision::FP32) { - blob_copy_5d_merge_f32c3(reinterpret_cast(src_ptr), - reinterpret_cast(dst_ptr), - N_src_stride, - D_src_stride, - H_src_stride, - C_src_stride, - N_dst_stride, - D_dst_stride, - H_dst_stride, - static_cast(N), - static_cast(D), - static_cast(H), - static_cast(W)); - return; - } - } -#else - (void)H_dst_stride; -#endif // HAVE_SSE - if (src->getTensorDesc().getLayout() == NDHWC && dst->getTensorDesc().getLayout() == NCDHW) { - for (size_t n = 0; n < N; n++) { - for (size_t c = 0; c < C; c++) { - for (size_t d = 0; d < D; d++) { - data_t* dst_ptr_l = dst_ptr + n * N_dst_stride + c * C_dst_stride + d * D_dst_stride; - data_t* src_ptr_l = src_ptr + n * N_src_stride + c * C_src_stride + d * D_src_stride; - for (size_t h = 0; h < H; h++) { - data_t* src_ptr_l_l = src_ptr_l + h * H_src_stride; - for (size_t w = 0; w < W; w++) { - *dst_ptr_l = *src_ptr_l_l; - src_ptr_l_l += W_src_stride; - dst_ptr_l++; - } - } - } - } - } - } else if (src->getTensorDesc().getLayout() == NCDHW && dst->getTensorDesc().getLayout() == NDHWC) { - for (size_t n = 0; n < N; n++) { - for (size_t c = 0; c < C; c++) { - for (size_t d = 0; d < D; d++) { - data_t* src_ptr_l = src_ptr + n * N_src_stride + c * C_src_stride + d * D_src_stride; - data_t* dst_ptr_l = dst_ptr + n * N_dst_stride + c + d * D_dst_stride; - for (size_t h = 0; h < H; h++) { - data_t* src_ptr_l_l = src_ptr_l + h * H_src_stride; - for (size_t w = 0; w < W; w++) { - *dst_ptr_l = *src_ptr_l_l; - dst_ptr_l += W_dst_stride; - src_ptr_l_l++; - } - } - } - } - } - } else { - for (size_t i = 0; i < N * C * D * H * W; i++) { - dst_ptr[i] = src_ptr[i]; - } - } -} - -static inline void blob_copy_5d(Blob::Ptr src, Blob::Ptr dst) { - switch (src->getTensorDesc().getPrecision()) { - case Precision::FP32: - case Precision::I32: - case Precision::U32: - blob_copy_5d_t(src, dst); - break; - - case Precision::FP16: - case Precision::U16: - case Precision::I16: - blob_copy_5d_t(src, dst); - break; - - case Precision::U8: - case Precision::I8: - blob_copy_5d_t(src, dst); - break; - - default: - IE_THROW() << "Unsupported blob transformation for precision " << src->getTensorDesc().getPrecision(); - } -} - -void blob_copy(Blob::Ptr src, Blob::Ptr dst) { - if (src->buffer() == nullptr) - IE_THROW() << "Cannot copy blob data. Source is not allocated."; - - if (dst->buffer() == nullptr) - IE_THROW() << "Cannot copy blob data. Destination is not allocated."; - - if (src->getTensorDesc().getPrecision() != dst->getTensorDesc().getPrecision()) - IE_THROW() << "Unimplemented blob transformation from precision " << src->getTensorDesc().getPrecision() - << " to " << dst->getTensorDesc().getPrecision(); - - if (src->getTensorDesc().getDims() != dst->getTensorDesc().getDims()) - IE_THROW() << "Unimplemented blob transformation from different shapes "; - - if (src->getTensorDesc().getDims().size() == 4) - blob_copy_4d(src, dst); - else if (src->getTensorDesc().getDims().size() == 5) - blob_copy_5d(src, dst); - else - IE_THROW() << "Unimplemented blob transformation. Only 4d or 5d supported."; -} - -} // namespace InferenceEngine diff --git a/src/inference/src/cnn_network_ngraph_impl.cpp b/src/inference/src/cnn_network_ngraph_impl.cpp index 72607a8bf4eb95..433461f22d3dcc 100644 --- a/src/inference/src/cnn_network_ngraph_impl.cpp +++ b/src/inference/src/cnn_network_ngraph_impl.cpp @@ -500,10 +500,9 @@ StatusCode CNNNetworkNGraphImpl::serialize(const std::string& xmlPath, const std::string& binPath, ResponseDesc* resp) const noexcept { try { - std::map custom_opsets; ov::pass::Manager manager; using namespace ov::pass; - REGISTER_PASS(manager, Serialize, xmlPath, binPath, custom_opsets, ov::pass::Serialize::Version::IR_V10) + REGISTER_PASS(manager, Serialize, xmlPath, binPath, ov::pass::Serialize::Version::IR_V10) manager.run_passes(_ngraph_function); } catch (const Exception& e) { return DescriptionBuffer(GENERAL_ERROR, resp) << e.what(); @@ -518,10 +517,9 @@ StatusCode CNNNetworkNGraphImpl::serialize(const std::string& xmlPath, StatusCode CNNNetworkNGraphImpl::serialize(std::ostream& xmlBuf, std::ostream& binBuf, ResponseDesc* resp) const noexcept { try { - std::map custom_opsets; ov::pass::Manager manager; using namespace ov::pass; - REGISTER_PASS(manager, Serialize, xmlBuf, binBuf, custom_opsets, ov::pass::Serialize::Version::IR_V10) + REGISTER_PASS(manager, Serialize, xmlBuf, binBuf, ov::pass::Serialize::Version::IR_V10) manager.run_passes(_ngraph_function); } catch (const Exception& e) { return DescriptionBuffer(GENERAL_ERROR, resp) << e.what(); @@ -536,11 +534,10 @@ StatusCode CNNNetworkNGraphImpl::serialize(std::ostream& xmlBuf, std::ostream& b StatusCode CNNNetworkNGraphImpl::serialize(std::ostream& xmlBuf, Blob::Ptr& binBlob, ResponseDesc* resp) const noexcept { try { - std::map custom_opsets; std::stringstream binBuf; ov::pass::Manager manager; using namespace ov::pass; - REGISTER_PASS(manager, Serialize, xmlBuf, binBuf, custom_opsets, ov::pass::Serialize::Version::IR_V10) + REGISTER_PASS(manager, Serialize, xmlBuf, binBuf, ov::pass::Serialize::Version::IR_V10) manager.run_passes(_ngraph_function); std::streambuf* pbuf = binBuf.rdbuf(); diff --git a/src/inference/src/compilation_context.cpp b/src/inference/src/compilation_context.cpp index 9d9df1754eab08..8eaca40d5f09c8 100644 --- a/src/inference/src/compilation_context.cpp +++ b/src/inference/src/compilation_context.cpp @@ -12,10 +12,9 @@ #endif #include "cpp/ie_cnn_network.h" -#include "details/ie_exception.hpp" -#include "file_utils.h" #include "itt.hpp" #include "openvino/pass/manager.hpp" +#include "openvino/util/file_util.hpp" #include "openvino/util/xml_parse_utils.hpp" #include "transformations/hash.hpp" #include "transformations/rt_info/fused_names_attribute.hpp" @@ -59,7 +58,7 @@ std::string ModelCache::calculate_file_info(const std::string& filePath) { auto absPath = filePath; if (filePath.size() > 0) { try { - absPath = FileUtils::absoluteFilePath(filePath); + absPath = ov::util::get_absolute_file_path(filePath); } catch (std::runtime_error&) { // can't get absolute path, will use filePath for hash } @@ -127,7 +126,7 @@ std::string ModelCache::compute_hash(const std::string& modelName, const ov::Any OV_ITT_SCOPE(FIRST_INFERENCE, ov::itt::domains::ReadTime, "ModelCache::compute_hash - ModelName"); uint64_t seed = 0; try { - seed = hash_combine(seed, FileUtils::absoluteFilePath(modelName)); + seed = hash_combine(seed, ov::util::get_absolute_file_path(modelName)); } catch (...) { // can't get absolute path, use modelName for hash calculation seed = hash_combine(seed, modelName); diff --git a/src/inference/src/cpp/ie_executable_network.cpp b/src/inference/src/cpp/ie_executable_network.cpp index 63b74987546228..1b5ecdf5d7a2a1 100644 --- a/src/inference/src/cpp/ie_executable_network.cpp +++ b/src/inference/src/cpp/ie_executable_network.cpp @@ -9,7 +9,6 @@ #include "cpp_interfaces/interface/ie_iexecutable_network_internal.hpp" #include "ie_common.h" #include "ie_executable_network_base.hpp" -#include "ie_plugin_config.hpp" #include "openvino/core/except.hpp" #include "openvino/runtime/compiled_model.hpp" @@ -80,15 +79,15 @@ CNNNetwork ExecutableNetwork::GetExecGraphInfo() { EXEC_NET_CALL_STATEMENT(return CNNNetwork{_impl->GetExecGraphInfo()}); } -void ExecutableNetwork::SetConfig(const std::map& config) { +void ExecutableNetwork::SetConfig(const ov::AnyMap& config) { EXEC_NET_CALL_STATEMENT(_impl->SetConfig(config)); } -Parameter ExecutableNetwork::GetConfig(const std::string& name) const { +ov::Any ExecutableNetwork::GetConfig(const std::string& name) const { EXEC_NET_CALL_STATEMENT(return {_impl->GetConfig(name), {_so}}); } -Parameter ExecutableNetwork::GetMetric(const std::string& name) const { +ov::Any ExecutableNetwork::GetMetric(const std::string& name) const { EXEC_NET_CALL_STATEMENT(return {_impl->GetMetric(name), {_so}}); } diff --git a/src/inference/src/cpp/ie_executable_network_base.hpp b/src/inference/src/cpp/ie_executable_network_base.hpp index f1a5cffa38b0f6..d62e8fc3ee2eb9 100644 --- a/src/inference/src/cpp/ie_executable_network_base.hpp +++ b/src/inference/src/cpp/ie_executable_network_base.hpp @@ -68,15 +68,15 @@ class ExecutableNetworkBase : public IExecutableNetwork { TO_STATUS(graphPtr = CNNNetwork{_impl->GetExecGraphInfo()}); } - StatusCode SetConfig(const std::map& config, ResponseDesc* resp) noexcept override { + StatusCode SetConfig(const ov::AnyMap& config, ResponseDesc* resp) noexcept override { TO_STATUS(_impl->SetConfig(config)); } - StatusCode GetConfig(const std::string& name, Parameter& result, ResponseDesc* resp) const noexcept override { + StatusCode GetConfig(const std::string& name, ov::Any& result, ResponseDesc* resp) const noexcept override { TO_STATUS(result = _impl->GetConfig(name)); } - StatusCode GetMetric(const std::string& name, Parameter& result, ResponseDesc* resp) const noexcept override { + StatusCode GetMetric(const std::string& name, ov::Any& result, ResponseDesc* resp) const noexcept override { TO_STATUS(result = _impl->GetMetric(name)); } diff --git a/src/inference/src/cpp_interfaces/interface/ie_iexecutable_network_internal.cpp b/src/inference/src/cpp_interfaces/interface/ie_iexecutable_network_internal.cpp index 967765102002f7..33b85be225558a 100644 --- a/src/inference/src/cpp_interfaces/interface/ie_iexecutable_network_internal.cpp +++ b/src/inference/src/cpp_interfaces/interface/ie_iexecutable_network_internal.cpp @@ -15,7 +15,6 @@ #include "cpp_interfaces/interface/ie_iplugin_internal.hpp" #include "ie_icore.hpp" #include "ie_ngraph_utils.hpp" -#include "ie_parameter.hpp" #include "openvino/core/node.hpp" namespace InferenceEngine { @@ -96,15 +95,15 @@ std::shared_ptr IExecutableNetworkInternal::GetPointerToSo() { return _so; } -void IExecutableNetworkInternal::SetConfig(const std::map&) { +void IExecutableNetworkInternal::SetConfig(const ov::AnyMap&) { IE_THROW(NotImplemented); } -Parameter IExecutableNetworkInternal::GetConfig(const std::string&) const { +ov::Any IExecutableNetworkInternal::GetConfig(const std::string&) const { IE_THROW(NotImplemented); } -Parameter IExecutableNetworkInternal::GetMetric(const std::string&) const { +ov::Any IExecutableNetworkInternal::GetMetric(const std::string&) const { IE_THROW(NotImplemented); } diff --git a/src/inference/src/cpp_interfaces/interface/ie_iplugin_internal.cpp b/src/inference/src/cpp_interfaces/interface/ie_iplugin_internal.cpp index 08d22fd16ab2f8..8612b7b64f0a49 100644 --- a/src/inference/src/cpp_interfaces/interface/ie_iplugin_internal.cpp +++ b/src/inference/src/cpp_interfaces/interface/ie_iplugin_internal.cpp @@ -26,9 +26,7 @@ #include "ie_api.h" #include "ie_icore.hpp" #include "ie_input_info.hpp" -#include "ie_memcpy.h" #include "ie_ngraph_utils.hpp" -#include "ie_parameter.hpp" #include "openvino/core/deprecated.hpp" #include "openvino/core/except.hpp" #include "openvino/core/model.hpp" @@ -71,7 +69,6 @@ IInferencePlugin::IInferencePlugin() : _executorManager(ov::threading::executor_ void IInferencePlugin::VersionStore::copyFrom(const Version& v) { description = v.description; buildNumber = v.buildNumber; - apiVersion = v.apiVersion; } IInferencePlugin::VersionStore::VersionStore(const Version& v) { @@ -85,11 +82,11 @@ IInferencePlugin::VersionStore& IInferencePlugin::VersionStore::operator=(const return *this; } -void IInferencePlugin::SetVersion(const Version& version) { +void IInferencePlugin::SetVersion(const ov::Version& version) { _version = VersionStore(version); } -const Version& IInferencePlugin::GetVersion() const { +const ov::Version& IInferencePlugin::GetVersion() const { return _version; } @@ -183,11 +180,11 @@ void IInferencePlugin::SetProperties(const ov::AnyMap& config) { SetConfig(any_copy(config)); } -Parameter IInferencePlugin::GetConfig(const std::string&, const std::map&) const { +ov::Any IInferencePlugin::GetConfig(const std::string&, const ov::AnyMap&) const { IE_THROW(NotImplemented); } -Parameter IInferencePlugin::GetMetric(const std::string&, const std::map&) const { +ov::Any IInferencePlugin::GetMetric(const std::string&, const ov::AnyMap&) const { IE_THROW(NotImplemented); } diff --git a/src/inference/src/cpu_x86_sse42/blob_transform_sse42.cpp b/src/inference/src/cpu_x86_sse42/blob_transform_sse42.cpp deleted file mode 100644 index ddef2e4bfc120e..00000000000000 --- a/src/inference/src/cpu_x86_sse42/blob_transform_sse42.cpp +++ /dev/null @@ -1,409 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "cpu_x86_sse42/blob_transform_sse42.hpp" - -#include // SSE 4.2 - -namespace InferenceEngine { - -//------------------------------------------------------------------------ -// -// OpenCV universal intrinsics (refactored), x86 specific - require SSE4.1 -// -//------------------------------------------------------------------------ - -static inline void mm_load_deinterleave(const uint8_t* ptr, __m128i& a, __m128i& b, __m128i& c) { - const __m128i m0 = _mm_setr_epi8(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0); - const __m128i m1 = _mm_setr_epi8(0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0); - __m128i s0 = _mm_loadu_si128(reinterpret_cast(ptr)); - __m128i s1 = _mm_loadu_si128(reinterpret_cast(ptr + 16)); - __m128i s2 = _mm_loadu_si128(reinterpret_cast(ptr + 32)); - __m128i a0 = _mm_blendv_epi8(_mm_blendv_epi8(s0, s1, m0), s2, m1); - __m128i b0 = _mm_blendv_epi8(_mm_blendv_epi8(s1, s2, m0), s0, m1); - __m128i c0 = _mm_blendv_epi8(_mm_blendv_epi8(s2, s0, m0), s1, m1); - const __m128i sh_b = _mm_setr_epi8(0, 3, 6, 9, 12, 15, 2, 5, 8, 11, 14, 1, 4, 7, 10, 13); - const __m128i sh_g = _mm_setr_epi8(1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15, 2, 5, 8, 11, 14); - const __m128i sh_r = _mm_setr_epi8(2, 5, 8, 11, 14, 1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15); - a0 = _mm_shuffle_epi8(a0, sh_b); - b0 = _mm_shuffle_epi8(b0, sh_g); - c0 = _mm_shuffle_epi8(c0, sh_r); - a = a0; - b = b0; - c = c0; -} - -static inline void mm_load_deinterleave(const float* ptr, __m128& a, __m128& b, __m128& c) { - __m128 t0 = _mm_loadu_ps(ptr + 0); - __m128 t1 = _mm_loadu_ps(ptr + 4); - __m128 t2 = _mm_loadu_ps(ptr + 8); - - __m128 at12 = _mm_shuffle_ps(t1, t2, _MM_SHUFFLE(0, 1, 0, 2)); - a = _mm_shuffle_ps(t0, at12, _MM_SHUFFLE(2, 0, 3, 0)); - - __m128 bt01 = _mm_shuffle_ps(t0, t1, _MM_SHUFFLE(0, 0, 0, 1)); - __m128 bt12 = _mm_shuffle_ps(t1, t2, _MM_SHUFFLE(0, 2, 0, 3)); - b = _mm_shuffle_ps(bt01, bt12, _MM_SHUFFLE(2, 0, 2, 0)); - - __m128 ct01 = _mm_shuffle_ps(t0, t1, _MM_SHUFFLE(0, 1, 0, 2)); - c = _mm_shuffle_ps(ct01, t2, _MM_SHUFFLE(3, 0, 2, 0)); -} - -static inline void mm_store_interleave(uint8_t* ptr, __m128i a, __m128i b, __m128i c) { - const __m128i sh_a = _mm_setr_epi8(0, 11, 6, 1, 12, 7, 2, 13, 8, 3, 14, 9, 4, 15, 10, 5); - const __m128i sh_b = _mm_setr_epi8(5, 0, 11, 6, 1, 12, 7, 2, 13, 8, 3, 14, 9, 4, 15, 10); - const __m128i sh_c = _mm_setr_epi8(10, 5, 0, 11, 6, 1, 12, 7, 2, 13, 8, 3, 14, 9, 4, 15); - __m128i a0 = _mm_shuffle_epi8(a, sh_a); - __m128i b0 = _mm_shuffle_epi8(b, sh_b); - __m128i c0 = _mm_shuffle_epi8(c, sh_c); - - const __m128i m0 = _mm_setr_epi8(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0); - const __m128i m1 = _mm_setr_epi8(0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0); - __m128i v0 = _mm_blendv_epi8(_mm_blendv_epi8(a0, b0, m1), c0, m0); - __m128i v1 = _mm_blendv_epi8(_mm_blendv_epi8(b0, c0, m1), a0, m0); - __m128i v2 = _mm_blendv_epi8(_mm_blendv_epi8(c0, a0, m1), b0, m0); - - _mm_storeu_si128(reinterpret_cast<__m128i*>(ptr), v0); - _mm_storeu_si128(reinterpret_cast<__m128i*>(ptr + 16), v1); - _mm_storeu_si128(reinterpret_cast<__m128i*>(ptr + 32), v2); -} - -static inline void mm_store_interleave(float* ptr, __m128 a, __m128 b, __m128 c) { - __m128 u0 = _mm_shuffle_ps(a, b, _MM_SHUFFLE(0, 0, 0, 0)); - __m128 u1 = _mm_shuffle_ps(c, a, _MM_SHUFFLE(1, 1, 0, 0)); - __m128 v0 = _mm_shuffle_ps(u0, u1, _MM_SHUFFLE(2, 0, 2, 0)); - __m128 u2 = _mm_shuffle_ps(b, c, _MM_SHUFFLE(1, 1, 1, 1)); - __m128 u3 = _mm_shuffle_ps(a, b, _MM_SHUFFLE(2, 2, 2, 2)); - __m128 v1 = _mm_shuffle_ps(u2, u3, _MM_SHUFFLE(2, 0, 2, 0)); - __m128 u4 = _mm_shuffle_ps(c, a, _MM_SHUFFLE(3, 3, 2, 2)); - __m128 u5 = _mm_shuffle_ps(b, c, _MM_SHUFFLE(3, 3, 3, 3)); - __m128 v2 = _mm_shuffle_ps(u4, u5, _MM_SHUFFLE(2, 0, 2, 0)); - - _mm_storeu_ps(ptr, v0); - _mm_storeu_ps(ptr + 4, v1); - _mm_storeu_ps(ptr + 8, v2); -} - -//------------------------------------------------------------------------ -// -// Blob-copy primitives namually vectored for SSE 4.2 (w/o OpenMP threads) -// -//------------------------------------------------------------------------ - -void blob_copy_4d_split_u8c3(const uint8_t* src_ptr, - uint8_t* dst_ptr, - size_t N_src_stride, - size_t H_src_stride, - size_t N_dst_stride, - size_t H_dst_stride, - size_t C_dst_stride, - int N, - int H, - int W) { - for (int n = 0; n < N; n++) - for (int h = 0; h < H; h++) { - const uint8_t* src = src_ptr + n * N_src_stride + h * H_src_stride; - uint8_t* dst0 = dst_ptr + n * N_dst_stride + 0 * C_dst_stride + h * H_dst_stride; - uint8_t* dst1 = dst_ptr + n * N_dst_stride + 1 * C_dst_stride + h * H_dst_stride; - uint8_t* dst2 = dst_ptr + n * N_dst_stride + 2 * C_dst_stride + h * H_dst_stride; - - int w = 0; - - // SIMD128 manually - for (; w < W - 16; w += 16) { - __m128i r0, r1, r2; - mm_load_deinterleave(&src[3 * w], r0, r1, r2); - _mm_storeu_si128(reinterpret_cast<__m128i*>(dst0 + w), r0); - _mm_storeu_si128(reinterpret_cast<__m128i*>(dst1 + w), r1); - _mm_storeu_si128(reinterpret_cast<__m128i*>(dst2 + w), r2); - } - - for (; w < W; w++) { - dst0[w] = src[3 * w + 0]; - dst1[w] = src[3 * w + 1]; - dst2[w] = src[3 * w + 2]; - } - } -} - -void blob_copy_4d_split_f32c3(const float* src_ptr, - float* dst_ptr, - size_t N_src_stride, - size_t H_src_stride, - size_t N_dst_stride, - size_t H_dst_stride, - size_t C_dst_stride, - int N, - int H, - int W) { - for (int n = 0; n < N; n++) - for (int h = 0; h < H; h++) { - const float* src = src_ptr + n * N_src_stride + h * H_src_stride; - float* dst0 = dst_ptr + n * N_dst_stride + 0 * C_dst_stride + h * H_dst_stride; - float* dst1 = dst_ptr + n * N_dst_stride + 1 * C_dst_stride + h * H_dst_stride; - float* dst2 = dst_ptr + n * N_dst_stride + 2 * C_dst_stride + h * H_dst_stride; - - int w = 0; - - // SIMD128 manually - for (; w < W - 4; w += 4) { - __m128 r0, r1, r2; - mm_load_deinterleave(&src[3 * w], r0, r1, r2); - _mm_storeu_ps(&dst0[w], r0); - _mm_storeu_ps(&dst1[w], r1); - _mm_storeu_ps(&dst2[w], r2); - } - - for (; w < W; w++) { - dst0[w] = src[3 * w + 0]; - dst1[w] = src[3 * w + 1]; - dst2[w] = src[3 * w + 2]; - } - } -} - -void blob_copy_4d_merge_u8c3(const uint8_t* src_ptr, - uint8_t* dst_ptr, - size_t N_src_stride, - size_t H_src_stride, - size_t C_src_stride, - size_t N_dst_stride, - size_t H_dst_stride, - int N, - int H, - int W) { - for (int n = 0; n < N; n++) - for (int h = 0; h < H; h++) { - const uint8_t* src0 = src_ptr + n * N_src_stride + 0 * C_src_stride + h * H_src_stride; - const uint8_t* src1 = src_ptr + n * N_src_stride + 1 * C_src_stride + h * H_src_stride; - const uint8_t* src2 = src_ptr + n * N_src_stride + 2 * C_src_stride + h * H_src_stride; - - uint8_t* dst = dst_ptr + n * N_dst_stride + h * H_dst_stride; - - int w = 0; - - // SIMD128 manually - for (; w < W - 16; w += 16) { - __m128i r0, r1, r2; - r0 = _mm_loadu_si128(reinterpret_cast(src0 + w)); - r1 = _mm_loadu_si128(reinterpret_cast(src1 + w)); - r2 = _mm_loadu_si128(reinterpret_cast(src2 + w)); - mm_store_interleave(&dst[3 * w], r0, r1, r2); - } - - for (; w < W; w++) { - dst[3 * w + 0] = src0[w]; - dst[3 * w + 1] = src1[w]; - dst[3 * w + 2] = src2[w]; - } - } -} - -void blob_copy_4d_merge_f32c3(const float* src_ptr, - float* dst_ptr, - size_t N_src_stride, - size_t H_src_stride, - size_t C_src_stride, - size_t N_dst_stride, - size_t H_dst_stride, - int N, - int H, - int W) { - for (int n = 0; n < N; n++) - for (int h = 0; h < H; h++) { - const float* src0 = src_ptr + n * N_src_stride + 0 * C_src_stride + h * H_src_stride; - const float* src1 = src_ptr + n * N_src_stride + 1 * C_src_stride + h * H_src_stride; - const float* src2 = src_ptr + n * N_src_stride + 2 * C_src_stride + h * H_src_stride; - - float* dst = dst_ptr + n * N_dst_stride + h * H_dst_stride; - - int w = 0; - - // SIMD128 manually - for (; w < W - 4; w += 4) { - __m128 r0, r1, r2; - r0 = _mm_loadu_ps(&src0[w]); - r1 = _mm_loadu_ps(&src1[w]); - r2 = _mm_loadu_ps(&src2[w]); - mm_store_interleave(&dst[3 * w], r0, r1, r2); - } - - for (; w < W; w++) { - dst[3 * w + 0] = src0[w]; - dst[3 * w + 1] = src1[w]; - dst[3 * w + 2] = src2[w]; - } - } -} - -void blob_copy_5d_split_u8c3(const uint8_t* src_ptr, - uint8_t* dst_ptr, - size_t N_src_stride, - size_t D_src_stride, - size_t H_src_stride, - size_t N_dst_stride, - size_t D_dst_stride, - size_t H_dst_stride, - size_t C_dst_stride, - int N, - int D, - int H, - int W) { - for (int n = 0; n < N; n++) - for (int d = 0; d < D; d++) { - for (int h = 0; h < H; h++) { - const uint8_t* src = src_ptr + n * N_src_stride + d * D_src_stride + h * H_src_stride; - uint8_t* dst0 = dst_ptr + n * N_dst_stride + d * D_dst_stride + 0 * C_dst_stride + h * H_dst_stride; - uint8_t* dst1 = dst_ptr + n * N_dst_stride + d * D_dst_stride + 1 * C_dst_stride + h * H_dst_stride; - uint8_t* dst2 = dst_ptr + n * N_dst_stride + d * D_dst_stride + 2 * C_dst_stride + h * H_dst_stride; - - int w = 0; - - // SIMD128 manually - for (; w < W - 16; w += 16) { - __m128i r0, r1, r2; - mm_load_deinterleave(&src[3 * w], r0, r1, r2); - _mm_storeu_si128(reinterpret_cast<__m128i*>(dst0 + w), r0); - _mm_storeu_si128(reinterpret_cast<__m128i*>(dst1 + w), r1); - _mm_storeu_si128(reinterpret_cast<__m128i*>(dst2 + w), r2); - } - - for (; w < W; w++) { - dst0[w] = src[3 * w + 0]; - dst1[w] = src[3 * w + 1]; - dst2[w] = src[3 * w + 2]; - } - } - } -} - -void blob_copy_5d_split_f32c3(const float* src_ptr, - float* dst_ptr, - size_t N_src_stride, - size_t D_src_stride, - size_t H_src_stride, - size_t N_dst_stride, - size_t D_dst_stride, - size_t H_dst_stride, - size_t C_dst_stride, - int N, - int D, - int H, - int W) { - for (int n = 0; n < N; n++) - for (int d = 0; d < D; d++) { - for (int h = 0; h < H; h++) { - const float* src = src_ptr + n * N_src_stride + d * D_src_stride + h * H_src_stride; - float* dst0 = dst_ptr + n * N_dst_stride + d * D_dst_stride + 0 * C_dst_stride + h * H_dst_stride; - float* dst1 = dst_ptr + n * N_dst_stride + d * D_dst_stride + 1 * C_dst_stride + h * H_dst_stride; - float* dst2 = dst_ptr + n * N_dst_stride + d * D_dst_stride + 2 * C_dst_stride + h * H_dst_stride; - - int w = 0; - - // SIMD128 manually - for (; w < W - 4; w += 4) { - __m128 r0, r1, r2; - mm_load_deinterleave(&src[3 * w], r0, r1, r2); - _mm_storeu_ps(&dst0[w], r0); - _mm_storeu_ps(&dst1[w], r1); - _mm_storeu_ps(&dst2[w], r2); - } - - for (; w < W; w++) { - dst0[w] = src[3 * w + 0]; - dst1[w] = src[3 * w + 1]; - dst2[w] = src[3 * w + 2]; - } - } - } -} - -void blob_copy_5d_merge_u8c3(const uint8_t* src_ptr, - uint8_t* dst_ptr, - size_t N_src_stride, - size_t D_src_stride, - size_t H_src_stride, - size_t C_src_stride, - size_t N_dst_stride, - size_t D_dst_stride, - size_t H_dst_stride, - int N, - int D, - int H, - int W) { - for (int n = 0; n < N; n++) - for (int d = 0; d < D; d++) { - for (int h = 0; h < H; h++) { - const uint8_t* src0 = - src_ptr + n * N_src_stride + 0 * C_src_stride + d * D_src_stride + h * H_src_stride; - const uint8_t* src1 = - src_ptr + n * N_src_stride + 1 * C_src_stride + d * D_src_stride + h * H_src_stride; - const uint8_t* src2 = - src_ptr + n * N_src_stride + 2 * C_src_stride + d * D_src_stride + h * H_src_stride; - - uint8_t* dst = dst_ptr + n * N_dst_stride + d * D_dst_stride + h * H_dst_stride; - - int w = 0; - - // SIMD128 manually - for (; w < W - 16; w += 16) { - __m128i r0, r1, r2; - r0 = _mm_loadu_si128(reinterpret_cast(src0 + w)); - r1 = _mm_loadu_si128(reinterpret_cast(src1 + w)); - r2 = _mm_loadu_si128(reinterpret_cast(src2 + w)); - mm_store_interleave(&dst[3 * w], r0, r1, r2); - } - - for (; w < W; w++) { - dst[3 * w + 0] = src0[w]; - dst[3 * w + 1] = src1[w]; - dst[3 * w + 2] = src2[w]; - } - } - } -} - -void blob_copy_5d_merge_f32c3(const float* src_ptr, - float* dst_ptr, - size_t N_src_stride, - size_t D_src_stride, - size_t H_src_stride, - size_t C_src_stride, - size_t N_dst_stride, - size_t D_dst_stride, - size_t H_dst_stride, - int N, - int D, - int H, - int W) { - for (int n = 0; n < N; n++) - for (int d = 0; d < D; d++) { - for (int h = 0; h < H; h++) { - const float* src0 = src_ptr + n * N_src_stride + 0 * C_src_stride + d * D_src_stride + h * H_src_stride; - const float* src1 = src_ptr + n * N_src_stride + 1 * C_src_stride + d * D_src_stride + h * H_src_stride; - const float* src2 = src_ptr + n * N_src_stride + 2 * C_src_stride + d * D_src_stride + h * H_src_stride; - - float* dst = dst_ptr + n * N_dst_stride + d * D_dst_stride + h * H_dst_stride; - - int w = 0; - - // SIMD128 manually - for (; w < W - 4; w += 4) { - __m128 r0, r1, r2; - r0 = _mm_loadu_ps(&src0[w]); - r1 = _mm_loadu_ps(&src1[w]); - r2 = _mm_loadu_ps(&src2[w]); - mm_store_interleave(&dst[3 * w], r0, r1, r2); - } - - for (; w < W; w++) { - dst[3 * w + 0] = src0[w]; - dst[3 * w + 1] = src1[w]; - dst[3 * w + 2] = src2[w]; - } - } - } -} - -} // namespace InferenceEngine diff --git a/src/inference/src/cpu_x86_sse42/blob_transform_sse42.hpp b/src/inference/src/cpu_x86_sse42/blob_transform_sse42.hpp deleted file mode 100644 index eda0fc15f9392d..00000000000000 --- a/src/inference/src/cpu_x86_sse42/blob_transform_sse42.hpp +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include - -namespace InferenceEngine { - -//------------------------------------------------------------------------ -// -// Blob-copy primitives namually vectored for SSE 4.2 (w/o OpenMP threads) -// -//------------------------------------------------------------------------ - -void blob_copy_4d_split_u8c3(const uint8_t* src_ptr, - uint8_t* dst_ptr, - size_t N_src_stride, - size_t H_src_stride, - size_t N_dst_stride, - size_t H_dst_stride, - size_t C_dst_stride, - int N, - int H, - int W); - -void blob_copy_4d_split_f32c3(const float* src_ptr, - float* dst_ptr, - size_t N_src_stride, - size_t H_src_stride, - size_t N_dst_stride, - size_t H_dst_stride, - size_t C_dst_stride, - int N, - int H, - int W); - -void blob_copy_4d_merge_u8c3(const uint8_t* src_ptr, - uint8_t* dst_ptr, - size_t N_src_stride, - size_t H_src_stride, - size_t C_src_stride, - size_t N_dst_stride, - size_t H_dst_stride, - int N, - int H, - int W); - -void blob_copy_4d_merge_f32c3(const float* src_ptr, - float* dst_ptr, - size_t N_src_stride, - size_t H_src_stride, - size_t C_src_stride, - size_t N_dst_stride, - size_t H_dst_stride, - int N, - int H, - int W); - -void blob_copy_5d_split_u8c3(const uint8_t* src_ptr, - uint8_t* dst_ptr, - size_t N_src_stride, - size_t D_src_stride, - size_t H_src_stride, - size_t N_dst_stride, - size_t D_dst_stride, - size_t H_dst_stride, - size_t C_dst_stride, - int N, - int D, - int H, - int W); - -void blob_copy_5d_split_f32c3(const float* src_ptr, - float* dst_ptr, - size_t N_src_stride, - size_t D_src_stride, - size_t H_src_stride, - size_t N_dst_stride, - size_t D_dst_stride, - size_t H_dst_stride, - size_t C_dst_stride, - int N, - int D, - int H, - int W); - -void blob_copy_5d_merge_u8c3(const uint8_t* src_ptr, - uint8_t* dst_ptr, - size_t N_src_stride, - size_t D_src_stride, - size_t H_src_stride, - size_t C_src_stride, - size_t N_dst_stride, - size_t D_dst_stride, - size_t H_dst_stride, - int N, - int D, - int H, - int W); - -void blob_copy_5d_merge_f32c3(const float* src_ptr, - float* dst_ptr, - size_t N_src_stride, - size_t D_src_stride, - size_t H_src_stride, - size_t C_src_stride, - size_t N_dst_stride, - size_t D_dst_stride, - size_t H_dst_stride, - int N, - int D, - int H, - int W); - -} // namespace InferenceEngine diff --git a/src/inference/src/dev/converter_utils.cpp b/src/inference/src/dev/converter_utils.cpp index 6aca89c09c6e8e..6566534df7e83b 100644 --- a/src/inference/src/dev/converter_utils.cpp +++ b/src/inference/src/dev/converter_utils.cpp @@ -20,10 +20,7 @@ #include "ie_input_info.hpp" #include "ie_layouts.h" #include "ie_ngraph_utils.hpp" -#include "ie_plugin_config.hpp" -#include "ie_version.hpp" #include "iplugin_wrapper.hpp" -#include "legacy_op_extension.hpp" #include "openvino/core/except.hpp" #include "openvino/op/parameter.hpp" #include "openvino/runtime/exception.hpp" @@ -213,7 +210,7 @@ class IInferencePluginWrapper : public InferenceEngine::IInferencePlugin { public: IInferencePluginWrapper(const ov::SoPtr& plugin) : m_plugin(plugin) { auto& ver = plugin->get_version(); - InferenceEngine::Version version; + ov::Version version; version.buildNumber = ver.buildNumber; version.description = ver.description; SetVersion(version); @@ -257,15 +254,11 @@ class IInferencePluginWrapper : public InferenceEngine::IInferencePlugin { m_plugin->set_property(config); } - InferenceEngine::Parameter GetConfig( - const std::string& name, - const std::map& options) const override { + ov::Any GetConfig(const std::string& name, const ov::AnyMap& options) const override { return m_plugin->get_property(name, options); } - InferenceEngine::Parameter GetMetric( - const std::string& name, - const std::map& options) const override { + ov::Any GetMetric(const std::string& name, const ov::AnyMap& options) const override { return m_plugin->get_property(name, options); } @@ -373,35 +366,15 @@ class IExecutableNetworkWrapper : public InferenceEngine::IExecutableNetworkInte return m_model->get_runtime_model()->clone(); } - void SetConfig(const std::map& config) override { + void SetConfig(const ov::AnyMap& config) override { m_model->set_property(config); } - InferenceEngine::Parameter GetConfig(const std::string& name) const override { + ov::Any GetConfig(const std::string& name) const override { return m_model->get_property(name); } - InferenceEngine::Parameter GetMetric(const std::string& name) const override { - // Add legacy supported properties - if (METRIC_KEY(SUPPORTED_METRICS) == name || METRIC_KEY(SUPPORTED_CONFIG_KEYS) == name) { - try { - return m_model->get_property(name); - } catch (const ov::Exception&) { - auto props = m_model->get_property(ov::supported_properties.name()).as>(); - std::vector legacy_properties; - for (const auto& prop : props) { - if ((METRIC_KEY(SUPPORTED_METRICS) == name && !prop.is_mutable()) || - (METRIC_KEY(SUPPORTED_CONFIG_KEYS) == name && prop.is_mutable())) - legacy_properties.emplace_back(prop); - } - if (METRIC_KEY(SUPPORTED_METRICS) == name) { - legacy_properties.emplace_back(METRIC_KEY(SUPPORTED_METRICS)); - legacy_properties.emplace_back(METRIC_KEY(SUPPORTED_CONFIG_KEYS)); - } - - return legacy_properties; - } - } + ov::Any GetMetric(const std::string& name) const override { return m_model->get_property(name); } diff --git a/src/inference/src/dev/core_impl.cpp b/src/inference/src/dev/core_impl.cpp index 6ab1a69f0f8d92..89b805254ef9dd 100644 --- a/src/inference/src/dev/core_impl.cpp +++ b/src/inference/src/dev/core_impl.cpp @@ -11,7 +11,6 @@ #include "dev/converter_utils.hpp" #include "dev/icompiled_model_wrapper.hpp" #include "dev/iplugin_wrapper.hpp" -#include "ie_plugin_config.hpp" #include "itt.hpp" #include "model_reader.hpp" #include "openvino/core/any.hpp" @@ -34,7 +33,6 @@ #include "openvino/util/shared_object.hpp" #include "openvino/util/xml_parse_utils.hpp" #include "ov_plugins.hpp" -#include "preprocessing/preprocessing.hpp" #ifdef PROXY_PLUGIN_ENABLED # include "openvino/proxy/plugin.hpp" # include "openvino/proxy/properties.hpp" @@ -742,14 +740,14 @@ ov::SoPtr ov::CoreImpl::compile_model(const std::shared_ptr< cacheContent.blobId = ov::ModelCache::compute_hash(model, create_compile_config(plugin, parsed._config)); std::unique_ptr lock = cacheGuard.get_hash_lock(cacheContent.blobId); res = load_model_from_cache(cacheContent, plugin, parsed._config, ov::SoPtr{}, [&]() { - return compile_model_and_cache(model, - plugin, + return compile_model_and_cache(plugin, + model, parsed._config, ov::SoPtr{}, cacheContent); }); } else { - res = compile_model_with_preprocess(plugin, model, ov::SoPtr{}, parsed._config); + res = plugin.compile_model(model, parsed._config); } return res; } @@ -775,34 +773,14 @@ ov::SoPtr ov::CoreImpl::compile_model(const std::shared_ptr< cacheContent.blobId = ov::ModelCache::compute_hash(model, create_compile_config(plugin, parsed._config)); std::unique_ptr lock = cacheGuard.get_hash_lock(cacheContent.blobId); res = load_model_from_cache(cacheContent, plugin, parsed._config, context, [&]() { - return compile_model_and_cache(model, plugin, parsed._config, context, cacheContent); + return compile_model_and_cache(plugin, model, parsed._config, context, cacheContent); }); } else { - res = compile_model_with_preprocess(plugin, model, context, parsed._config); + res = plugin.compile_model(model, context, parsed._config); } return res; } -ov::SoPtr ov::CoreImpl::compile_model_with_preprocess(ov::Plugin& plugin, - const std::shared_ptr& model, - const ov::SoPtr& context, - const ov::AnyMap& config) const { - std::shared_ptr preprocessed_model = model; - - // Disable conversion for proxy plugin and virtual devices to add pre-processing based on API of internal plugins - if (!is_new_api() && !is_virtual_device(plugin.get_name()) && !is_proxy_device(plugin)) { - ov::pass::Manager manager; - manager.register_pass(); - - auto cloned_model = model->clone(); - manager.run_passes(cloned_model); - preprocessed_model = cloned_model; - } - - return context ? plugin.compile_model(preprocessed_model, context, config) - : plugin.compile_model(preprocessed_model, config); -} - ov::SoPtr ov::CoreImpl::compile_model(const std::string& model_path, const std::string& device_name, const ov::AnyMap& config) const { @@ -821,7 +799,7 @@ ov::SoPtr ov::CoreImpl::compile_model(const std::string& mod compiled_model = load_model_from_cache(cacheContent, plugin, parsed._config, ov::SoPtr{}, [&]() { auto model = read_model(model_path, std::string{}); - return compile_model_and_cache(model, plugin, parsed._config, {}, cacheContent); + return compile_model_and_cache(plugin, model, parsed._config, {}, cacheContent); }); } else if (cacheManager) { // this code path is enabled for AUTO / MULTI / BATCH / PROXY devices which don't support @@ -829,7 +807,7 @@ ov::SoPtr ov::CoreImpl::compile_model(const std::string& mod compiled_model = plugin.compile_model(model_path, parsed._config); } else { auto model = read_model(model_path, std::string()); - compiled_model = compile_model_with_preprocess(plugin, model, ov::SoPtr{}, parsed._config); + compiled_model = plugin.compile_model(model, parsed._config); } return compiled_model; } @@ -854,15 +832,15 @@ ov::SoPtr ov::CoreImpl::compile_model(const std::string& mod compiled_model = load_model_from_cache(cacheContent, plugin, parsed._config, ov::SoPtr{}, [&]() { auto model = read_model(model_str, weights); - return compile_model_and_cache(model, - plugin, + return compile_model_and_cache(plugin, + model, parsed._config, ov::SoPtr{}, cacheContent); }); } else { auto model = read_model(model_str, weights); - compiled_model = compile_model_with_preprocess(plugin, model, ov::SoPtr{}, parsed._config); + compiled_model = plugin.compile_model(model, parsed._config); } return compiled_model; } @@ -921,7 +899,7 @@ bool ov::CoreImpl::is_hidden_device(const std::string& device_name) const { std::vector ov::CoreImpl::get_available_devices() const { std::vector devices; - const std::string propertyName = METRIC_KEY(AVAILABLE_DEVICES); + const std::string propertyName = ov::available_devices.name(); for (auto&& deviceName : get_registered_devices()) { std::vector devicesIDs; @@ -966,7 +944,8 @@ ov::SoPtr ov::CoreImpl::create_context(const std::string& de } ov::AnyMap ov::CoreImpl::get_supported_property(const std::string& full_device_name, - const ov::AnyMap& user_properties) const { + const ov::AnyMap& user_properties, + const bool keep_core_property) const { if (is_virtual_device(full_device_name)) { // Considerations: // 1. in case of virtual devices all the magic will happen on the level when @@ -1001,19 +980,10 @@ ov::AnyMap ov::CoreImpl::get_supported_property(const std::string& full_device_n // virtual plugins should bypass core-level properties to HW plugins // so, we need to report them as supported - std::vector supported_config_keys = core_level_properties; - - OPENVINO_SUPPRESS_DEPRECATED_START - // try to search against IE API 1.0' SUPPORTED_CONFIG_KEYS - try { - const auto supported_keys = - GetMetric(device_name, METRIC_KEY(SUPPORTED_CONFIG_KEYS), {}).as>(); - for (auto&& config_key : supported_keys) { - supported_config_keys.emplace_back(config_key); - } - } catch (ov::Exception&) { + std::vector supported_config_keys; + if (keep_core_property) { + supported_config_keys = core_level_properties; } - OPENVINO_SUPPRESS_DEPRECATED_END // try to search against OV API 2.0' mutable supported_properties try { @@ -1413,14 +1383,14 @@ bool ov::CoreImpl::device_supports_cache_dir(const ov::Plugin& plugin) const { } } -ov::SoPtr ov::CoreImpl::compile_model_and_cache(const std::shared_ptr& model, - ov::Plugin& plugin, +ov::SoPtr ov::CoreImpl::compile_model_and_cache(ov::Plugin& plugin, + const std::shared_ptr& model, const ov::AnyMap& parsedConfig, const ov::SoPtr& context, const CacheContent& cacheContent) const { OV_ITT_SCOPED_TASK(ov::itt::domains::OV, "CoreImpl::compile_model_and_cache"); - ov::SoPtr execNetwork; - execNetwork = compile_model_with_preprocess(plugin, model, context, parsedConfig); + ov::SoPtr compiled_model = + context ? plugin.compile_model(model, context, parsedConfig) : plugin.compile_model(model, parsedConfig); if (cacheContent.cacheManager && device_supports_model_caching(plugin)) { try { // need to export network for further import from "cache" @@ -1431,17 +1401,17 @@ ov::SoPtr ov::CoreImpl::compile_model_and_cache(const std::s plugin.get_property(ov::internal::compiled_model_runtime_properties.name(), {}).as(); } cacheContent.cacheManager->write_cache_entry(cacheContent.blobId, [&](std::ostream& networkStream) { - networkStream << ov::CompiledBlobHeader(InferenceEngine::GetInferenceEngineVersion()->buildNumber, + networkStream << ov::CompiledBlobHeader(ov::get_openvino_version().buildNumber, ov::ModelCache::calculate_file_info(cacheContent.modelPath), compiled_model_runtime_properties); - execNetwork->export_model(networkStream); + compiled_model->export_model(networkStream); }); } catch (...) { cacheContent.cacheManager->remove_cache_entry(cacheContent.blobId); throw; } } - return execNetwork; + return compiled_model; } ov::SoPtr ov::CoreImpl::load_model_from_cache( @@ -1616,7 +1586,7 @@ ov::CoreImpl::CoreConfig::CacheConfig ov::CoreImpl::CoreConfig::CacheConfig::cre std::shared_ptr cache_manager = nullptr; if (!dir.empty()) { - FileUtils::createDirectoryRecursive(dir); + ov::util::create_directory_recursive(dir); cache_manager = std::make_shared(dir); } diff --git a/src/inference/src/dev/core_impl.hpp b/src/inference/src/dev/core_impl.hpp index e7fa69178e282a..4543f5ce342349 100644 --- a/src/inference/src/dev/core_impl.hpp +++ b/src/inference/src/dev/core_impl.hpp @@ -152,8 +152,8 @@ class CoreImpl : public InferenceEngine::ICore, public std::enable_shared_from_t const bool m_new_api; - ov::SoPtr compile_model_and_cache(const std::shared_ptr& model, - ov::Plugin& plugin, + ov::SoPtr compile_model_and_cache(ov::Plugin& plugin, + const std::shared_ptr& model, const ov::AnyMap& parsedConfig, const ov::SoPtr& context, const CacheContent& cacheContent) const; @@ -173,17 +173,12 @@ class CoreImpl : public InferenceEngine::ICore, public std::enable_shared_from_t OPENVINO_DEPRECATED("Don't use this method, it will be removed soon") bool device_supports_cache_dir(const ov::Plugin& plugin) const; - ov::SoPtr compile_model_with_preprocess(ov::Plugin& plugin, - const std::shared_ptr& model, - const ov::SoPtr& context, - const ov::AnyMap& config) const; - ov::AnyMap create_compile_config(const ov::Plugin& plugin, const ov::AnyMap& origConfig) const; bool is_hidden_device(const std::string& device_name) const; void register_plugin_in_registry_unsafe(const std::string& device_name, PluginDescriptor& desc); - template > + template > void try_to_register_plugin_extensions(const std::basic_string& path) const { try { auto plugin_extensions = ov::detail::load_extensions(path); @@ -277,7 +272,7 @@ class CoreImpl : public InferenceEngine::ICore, public std::enable_shared_from_t bool DeviceSupportsModelCaching(const std::string& deviceName) const override; - std::map GetVersions(const std::string& deviceName) const; + std::map GetVersions(const std::string& deviceName) const; // Common API @@ -362,7 +357,7 @@ class CoreImpl : public InferenceEngine::ICore, public std::enable_shared_from_t ov::SoPtr create_context(const std::string& device_name, const AnyMap& args) const override; - ov::AnyMap get_supported_property(const std::string& device_name, const ov::AnyMap& config) const override; + ov::AnyMap get_supported_property(const std::string& device_name, const ov::AnyMap& config, const bool keep_core_property = true) const override; bool is_new_api() const override; diff --git a/src/inference/src/dev/core_impl_ie.cpp b/src/inference/src/dev/core_impl_ie.cpp index 7bf0142a302f5e..5be5624aba8151 100644 --- a/src/inference/src/dev/core_impl_ie.cpp +++ b/src/inference/src/dev/core_impl_ie.cpp @@ -8,7 +8,6 @@ #include "blob_factory.hpp" #include "compilation_context.hpp" #include "core_impl.hpp" -#include "cpp_interfaces/interface/ie_internal_plugin_config.hpp" #include "cpp_interfaces/interface/ie_iplugin_internal.hpp" #include "dev/converter_utils.hpp" #include "dev/icompiled_model_wrapper.hpp" @@ -185,8 +184,8 @@ std::map ov::CoreImpl::GetSupportedConfig(const std::s return ov::any_copy(get_supported_property(deviceName, any_copy(configs))); } -std::map ov::CoreImpl::GetVersions(const std::string& deviceName) const { - std::map versions; +std::map ov::CoreImpl::GetVersions(const std::string& deviceName) const { + std::map versions; std::vector deviceNames; { diff --git a/src/inference/src/dev/icompiled_model_wrapper.cpp b/src/inference/src/dev/icompiled_model_wrapper.cpp index a9410a768083d0..563c428cdf6c9e 100644 --- a/src/inference/src/dev/icompiled_model_wrapper.cpp +++ b/src/inference/src/dev/icompiled_model_wrapper.cpp @@ -5,7 +5,6 @@ #include "icompiled_model_wrapper.hpp" #include "dev/converter_utils.hpp" -#include "ie_plugin_config.hpp" #include "openvino/core/except.hpp" InferenceEngine::ICompiledModelWrapper::ICompiledModelWrapper( @@ -49,48 +48,7 @@ ov::Any InferenceEngine::ICompiledModelWrapper::get_property(const std::string& if (ov::loaded_from_cache == name) { return m_model->isLoadedFromCache(); } - - auto get_supported_properties = [&]() { - auto ro_properties = m_model->GetMetric(METRIC_KEY(SUPPORTED_METRICS)).as>(); - auto rw_properties = m_model->GetMetric(METRIC_KEY(SUPPORTED_CONFIG_KEYS)).as>(); - std::vector supported_properties; - for (auto&& ro_property : ro_properties) { - if (ro_property != METRIC_KEY(SUPPORTED_METRICS) && ro_property != METRIC_KEY(SUPPORTED_CONFIG_KEYS)) { - supported_properties.emplace_back(ro_property, ov::PropertyMutability::RO); - } - } - for (auto&& rw_property : rw_properties) { - supported_properties.emplace_back(rw_property, ov::PropertyMutability::RW); - } - supported_properties.emplace_back(ov::supported_properties.name(), ov::PropertyMutability::RO); - supported_properties.emplace_back(ov::loaded_from_cache.name(), ov::PropertyMutability::RO); - return supported_properties; - }; - - if (ov::supported_properties == name) { - try { - auto supported_properties = m_model->GetMetric(name).as>(); - supported_properties.erase(std::remove_if(supported_properties.begin(), - supported_properties.end(), - [](const ov::PropertyName& name) { - return name == METRIC_KEY(SUPPORTED_METRICS) || - name == METRIC_KEY(SUPPORTED_CONFIG_KEYS); - }), - supported_properties.end()); - return supported_properties; - } catch (ov::Exception&) { - return get_supported_properties(); - } catch (InferenceEngine::Exception&) { - return get_supported_properties(); - } - } - try { - return m_model->GetMetric(name); - } catch (ov::Exception&) { - return m_model->GetConfig(name); - } catch (InferenceEngine::Exception&) { - return m_model->GetConfig(name); - } + return m_model->GetConfig(name); } std::shared_ptr diff --git a/src/inference/src/dev/make_tensor.cpp b/src/inference/src/dev/make_tensor.cpp index e91fccdbbf3c8e..9f7ea21f1dc79e 100644 --- a/src/inference/src/dev/make_tensor.cpp +++ b/src/inference/src/dev/make_tensor.cpp @@ -10,7 +10,6 @@ #include "ie_ngraph_utils.hpp" #include "openvino/runtime/iremote_tensor.hpp" #include "openvino/runtime/properties.hpp" -#include "remote_utils.hpp" #ifdef PROXY_PLUGIN_ENABLED # include "openvino/proxy/plugin.hpp" #endif @@ -483,8 +482,6 @@ ov::SoPtr make_tensor(const std::shared_ptr& blo } if (blob == nullptr) { return {}; - } else if (unwrap && std::dynamic_pointer_cast(blob) != nullptr) { - return std::dynamic_pointer_cast(blob)->get_tensor(); } ELSE_IF(float) ELSE_IF(double) diff --git a/src/inference/src/dev/plugin.cpp b/src/inference/src/dev/plugin.cpp index 554163858fd8fc..f8bfb69250f6a2 100644 --- a/src/inference/src/dev/plugin.cpp +++ b/src/inference/src/dev/plugin.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -7,7 +7,6 @@ #include #include "cpp_interfaces/interface/ie_iplugin_internal.hpp" -#include "ie_plugin_config.hpp" #include "iplugin_wrapper.hpp" #include "openvino/runtime/internal_properties.hpp" #include "openvino/runtime/properties.hpp" @@ -17,8 +16,12 @@ OPENVINO_ASSERT(m_ptr != nullptr, "OpenVINO Runtime Plugin was not initialized."); \ try { \ __VA_ARGS__; \ + } catch (const ov::NotImplemented&) { \ + OPENVINO_NOT_IMPLEMENTED; \ + } catch (const std::exception& ex) { \ + OPENVINO_THROW(ex.what()); \ } catch (...) { \ - ::InferenceEngine::details::Rethrow(); \ + OPENVINO_THROW("Unexpected exception"); \ } ov::Plugin::~Plugin() { m_ptr = {}; @@ -106,87 +109,13 @@ ov::SoPtr ov::Plugin::get_default_context(const AnyMap& para } ov::Any ov::Plugin::get_property(const std::string& name, const AnyMap& arguments) const { - OV_PLUGIN_CALL_STATEMENT({ - if (ov::supported_properties == name) { - try { - return {m_ptr->get_property(name, arguments), {m_so}}; - } catch (const InferenceEngine::Exception&) { - std::vector supported_properties; - try { - auto ro_properties = - m_ptr->get_property(METRIC_KEY(SUPPORTED_METRICS), arguments).as>(); - for (auto&& ro_property : ro_properties) { - if (ro_property != METRIC_KEY(SUPPORTED_METRICS) && - ro_property != METRIC_KEY(SUPPORTED_CONFIG_KEYS)) { - supported_properties.emplace_back(ro_property, PropertyMutability::RO); - } - } - } catch (const ov::Exception&) { - } catch (const InferenceEngine::Exception&) { - } - try { - auto rw_properties = m_ptr->get_property(METRIC_KEY(SUPPORTED_CONFIG_KEYS), arguments) - .as>(); - for (auto&& rw_property : rw_properties) { - supported_properties.emplace_back(rw_property, PropertyMutability::RW); - } - } catch (const ov::Exception&) { - } catch (const InferenceEngine::Exception&) { - } - supported_properties.emplace_back(ov::supported_properties.name(), PropertyMutability::RO); - return supported_properties; - } - } - // Add legacy supported properties - if (METRIC_KEY(SUPPORTED_METRICS) == name || METRIC_KEY(SUPPORTED_CONFIG_KEYS) == name) { - try { - return {m_ptr->get_property(name, arguments), {m_so}}; - } catch (const ov::Exception&) { - auto props = - m_ptr->get_property(ov::supported_properties.name(), arguments).as>(); - std::vector legacy_properties; - for (const auto& prop : props) { - if ((METRIC_KEY(SUPPORTED_METRICS) == name && !prop.is_mutable()) || - (METRIC_KEY(SUPPORTED_CONFIG_KEYS) == name && prop.is_mutable())) - legacy_properties.emplace_back(prop); - } - if (METRIC_KEY(SUPPORTED_METRICS) == name) { - legacy_properties.emplace_back(METRIC_KEY(SUPPORTED_METRICS)); - legacy_properties.emplace_back(METRIC_KEY(SUPPORTED_CONFIG_KEYS)); - } - if (METRIC_KEY(SUPPORTED_METRICS) == name && supports_model_caching(false)) - legacy_properties.emplace_back(METRIC_KEY(IMPORT_EXPORT_SUPPORT)); - - return legacy_properties; - } - } - if (METRIC_KEY(IMPORT_EXPORT_SUPPORT) == name) { - try { - return {m_ptr->get_property(name, arguments), {m_so}}; - } catch (const ov::Exception&) { - if (!supports_model_caching(false)) - throw; - // if device has ov::device::capability::EXPORT_IMPORT it means always true - return true; - } - } - return {m_ptr->get_property(name, arguments), {m_so}}; - }); + OV_PLUGIN_CALL_STATEMENT({ return {m_ptr->get_property(name, arguments), {m_so}}; }); } -bool ov::Plugin::supports_model_caching(bool check_old_api) const { +bool ov::Plugin::supports_model_caching() const { bool supported(false); - if (check_old_api) { - auto supportedMetricKeys = get_property(METRIC_KEY(SUPPORTED_METRICS), {}).as>(); - supported = util::contains(supportedMetricKeys, METRIC_KEY(IMPORT_EXPORT_SUPPORT)) && - get_property(METRIC_KEY(IMPORT_EXPORT_SUPPORT), {}).as(); - } - if (!supported) { - supported = util::contains(get_property(ov::supported_properties), ov::device::capabilities) && - util::contains(get_property(ov::device::capabilities), ov::device::capability::EXPORT_IMPORT); - } - if (supported) { - supported = util::contains(get_property(ov::internal::supported_properties), ov::internal::caching_properties); - } + supported = util::contains(get_property(ov::supported_properties), ov::device::capabilities) && + util::contains(get_property(ov::device::capabilities), ov::device::capability::EXPORT_IMPORT) && + util::contains(get_property(ov::internal::supported_properties), ov::internal::caching_properties); return supported; } diff --git a/src/inference/src/dev/plugin.hpp b/src/inference/src/dev/plugin.hpp index 8aca7678ddc5f7..f31dc85b63ebac 100644 --- a/src/inference/src/dev/plugin.hpp +++ b/src/inference/src/dev/plugin.hpp @@ -74,7 +74,7 @@ class Plugin { T get_property(const ov::Property& property, const AnyMap& arguments) const { return get_property(property.name(), arguments).template as(); } - bool supports_model_caching(bool check_old_api = true) const; + bool supports_model_caching() const; }; } // namespace ov diff --git a/src/inference/src/dev/preprocessing/preprocessing.cpp b/src/inference/src/dev/preprocessing/preprocessing.cpp deleted file mode 100644 index ce19eda01efa27..00000000000000 --- a/src/inference/src/dev/preprocessing/preprocessing.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "preprocessing.hpp" - -#include "dev/converter_utils.hpp" -#include "ie_ngraph_utils.hpp" -#include "openvino/cc/pass/itt.hpp" -#include "openvino/core/preprocess/color_format.hpp" -#include "openvino/core/preprocess/pre_post_process.hpp" -#include "openvino/op/constant.hpp" -#include "openvino/pass/graph_rewrite.hpp" -#include "openvino/pass/manager.hpp" -#include "transformations/utils/utils.hpp" - -bool ov::pass::AddPreprocessing::run_on_model(const std::shared_ptr& model) { - RUN_ON_MODEL_SCOPE(AddPreprocessing); - ov::preprocess::PrePostProcessor preproc(model); - - for (size_t i = 0; i < model->inputs().size(); i++) { - ov::Output const_input(model->input(i).get_node(), model->input(i).get_index()); - InferenceEngine::InputInfo::Ptr input_info; - // I don't remove rt info to have information in InputsInfo about pre-processing in legacy - // ExecutableNetwork - ov::legacy_convert::fill_input_info(const_input, input_info); - OPENVINO_ASSERT(input_info); - - preproc.input(i).tensor().set_element_type( - InferenceEngine::details::convertPrecision(input_info->getPrecision())); - - if (input_info->getLayout() != InferenceEngine::Layout::BLOCKED && - input_info->getLayout() != InferenceEngine::Layout::SCALAR) { - std::stringstream stream; - stream << input_info->getLayout(); - preproc.input(i).tensor().set_layout(ov::Layout{stream.str()}); - } - - if (const_input.get_partial_shape().is_static() && const_input.get_shape().size() == 4) - preproc.input(i).model().set_layout("NCHW"); - } - - std::vector legacy_names(model->get_output_size()); - for (size_t i = 0; i < model->get_output_size(); i++) { - ov::Output const_output(model->output(i).get_node(), model->output(i).get_index()); - legacy_names[i] = ov::op::util::create_ie_output_name(const_output.get_node()->input_value(0)); - InferenceEngine::DataPtr output_info; - // I don't remove rt info to have information in InputsInfo about pre-processing in legacy - // ExecutableNetwork - ov::legacy_convert::fill_output_info(const_output, output_info); - OPENVINO_ASSERT(output_info); - auto element_type = InferenceEngine::details::convertPrecision(output_info->getPrecision()); - if (element_type != model->output(i).get_element_type()) { - preproc.output(i).tensor().set_element_type(element_type); - } - if (output_info->getLayout() != InferenceEngine::Layout::BLOCKED && - output_info->getLayout() != InferenceEngine::Layout::SCALAR) { - std::stringstream stream; - stream << output_info->getLayout(); - if (stream.str() == "NHWC") { - if (const_output.get_partial_shape().is_static() && const_output.get_shape().size() == 4) - preproc.output(i).model().set_layout("NCHW"); - preproc.output(i).postprocess().convert_layout(ov::Layout{stream.str()}); - } - } - } - - preproc.build(); - - for (size_t i = 0; i < model->get_output_size(); i++) { - ov::descriptor::set_ov_tensor_legacy_name(model->output(i).get_node()->input_value(0).get_tensor(), - legacy_names[i]); - } - - return false; -} diff --git a/src/inference/src/dev/preprocessing/preprocessing.hpp b/src/inference/src/dev/preprocessing/preprocessing.hpp deleted file mode 100644 index c0a8494f744b76..00000000000000 --- a/src/inference/src/dev/preprocessing/preprocessing.hpp +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "ie_input_info.hpp" -#include "openvino/pass/pass.hpp" - -namespace ov { -namespace pass { - -/** - * @brief Converts the following preprocessing information to OpenVINO operations: - * - * The order of operations is the following: - * (x - mean) / stdScale - */ -class AddPreprocessing : public ov::pass::ModelPass { -public: - OPENVINO_RTTI("AddLegacyPreprocessing"); - bool run_on_model(const std::shared_ptr& m) override; -}; - -} // namespace pass -} // namespace ov diff --git a/src/inference/src/dev/threading/cpu_streams_executor.cpp b/src/inference/src/dev/threading/cpu_streams_executor.cpp index e3eeafe85930ad..3d4b71f0505535 100644 --- a/src/inference/src/dev/threading/cpu_streams_executor.cpp +++ b/src/inference/src/dev/threading/cpu_streams_executor.cpp @@ -30,32 +30,18 @@ struct CPUStreamsExecutor::Impl { CpuSet _mask; int _ncpus = 0; int _threadBindingStep = 0; - int _offset = 0; - int _cpuIdxOffset = 0; std::vector _cpu_ids; - Observer(custom::task_arena& arena, - CpuSet mask, - int ncpus, - const int streamId, - const int threadsPerStream, - const int threadBindingStep, - const int threadBindingOffset, - const int cpuIdxOffset = 0, - const std::vector cpu_ids = {}) + Observer(custom::task_arena& arena, CpuSet mask, int ncpus, const std::vector cpu_ids = {}) : custom::task_scheduler_observer(arena), _mask{std::move(mask)}, _ncpus(ncpus), - _threadBindingStep(threadBindingStep), - _offset{streamId * threadsPerStream + threadBindingOffset}, - _cpuIdxOffset(cpuIdxOffset), _cpu_ids(cpu_ids) {} void on_scheduler_entry(bool) override { - pin_thread_to_vacant_core(_offset + tbb::this_task_arena::current_thread_index(), + pin_thread_to_vacant_core(tbb::this_task_arena::current_thread_index(), _threadBindingStep, _ncpus, _mask, - _cpu_ids, - _cpuIdxOffset); + _cpu_ids); } void on_scheduler_exit(bool) override { pin_current_thread_by_mask(_ncpus, _mask); @@ -73,41 +59,41 @@ struct CPUStreamsExecutor::Impl { _impl->_streamIdQueue.pop(); } } - _numaNodeId = _impl->_config._streams - ? _impl->_usedNumaNodes.at((_streamId % _impl->_config._streams) / - ((_impl->_config._streams + _impl->_usedNumaNodes.size() - 1) / - _impl->_usedNumaNodes.size())) - : _impl->_usedNumaNodes.at(_streamId % _impl->_usedNumaNodes.size()); + _numaNodeId = + _impl->_config.get_streams() + ? _impl->_usedNumaNodes.at((_streamId % _impl->_config.get_streams()) / + ((_impl->_config.get_streams() + _impl->_usedNumaNodes.size() - 1) / + _impl->_usedNumaNodes.size())) + : _impl->_usedNumaNodes.at(_streamId % _impl->_usedNumaNodes.size()); #if OV_THREAD == OV_THREAD_TBB || OV_THREAD == OV_THREAD_TBB_AUTO - if (is_cpu_map_available() && _impl->_config._streams_info_table.size() > 0) { + if (is_cpu_map_available() && _impl->_config.get_streams_info_table().size() > 0) { init_stream(); - } else { - init_stream_legacy(); } #elif OV_THREAD == OV_THREAD_OMP - omp_set_num_threads(_impl->_config._threadsPerStream); - if (!check_open_mp_env_vars(false) && (ThreadBindingType::NONE != _impl->_config._threadBindingType)) { + omp_set_num_threads(_impl->_config.get_threads_per_stream()); + if (!check_open_mp_env_vars(false) && + (ThreadBindingType::NONE != _impl->_config.get_thread_binding_type())) { CpuSet processMask; int ncpus = 0; std::tie(processMask, ncpus) = get_process_mask(); if (nullptr != processMask) { - parallel_nt(_impl->_config._threadsPerStream, [&](int threadIndex, int threadsPerStream) { - int thrIdx = _streamId * _impl->_config._threadsPerStream + threadIndex + - _impl->_config._threadBindingOffset; - pin_thread_to_vacant_core(thrIdx, _impl->_config._threadBindingStep, ncpus, processMask); + parallel_nt(_impl->_config.get_threads_per_stream(), [&](int threadIndex, int threadsPerStream) { + int thrIdx = _streamId * _impl->_config.get_threads_per_stream() + threadIndex + + _impl->_config.get_thread_binding_offset(); + pin_thread_to_vacant_core(thrIdx, _impl->_config.get_thread_binding_step(), ncpus, processMask); }); } } #elif OV_THREAD == OV_THREAD_SEQ - if (ThreadBindingType::NUMA == _impl->_config._threadBindingType) { + if (ThreadBindingType::NUMA == _impl->_config.get_thread_binding_type()) { pin_current_thread_to_socket(_numaNodeId); - } else if (ThreadBindingType::CORES == _impl->_config._threadBindingType) { + } else if (ThreadBindingType::CORES == _impl->_config.get_thread_binding_type()) { CpuSet processMask; int ncpus = 0; std::tie(processMask, ncpus) = get_process_mask(); if (nullptr != processMask) { - pin_thread_to_vacant_core(_streamId + _impl->_config._threadBindingOffset, - _impl->_config._threadBindingStep, + pin_thread_to_vacant_core(_streamId + _impl->_config.get_thread_binding_offset(), + _impl->_config.get_thread_binding_step(), ncpus, processMask); } @@ -120,7 +106,7 @@ struct CPUStreamsExecutor::Impl { _impl->_streamIdQueue.push(_streamId); } #if OV_THREAD == OV_THREAD_TBB || OV_THREAD == OV_THREAD_TBB_AUTO - if (_impl->_config._name.find("StreamsExecutor") == std::string::npos) { + if (_impl->_config.get_name().find("StreamsExecutor") == std::string::npos) { set_cpu_used(_cpu_ids, NOT_USED); } if (nullptr != _observer) { @@ -136,6 +122,7 @@ struct CPUStreamsExecutor::Impl { const int core_type, const int numa_node_id, const int max_threads_per_core) { + auto stream_processors = _impl->_config.get_stream_processor_ids(); _numaNodeId = std::max(0, numa_node_id); _socketId = get_socket_by_numa_node(_numaNodeId); if (stream_type == STREAM_WITHOUT_PARAM) { @@ -157,23 +144,15 @@ struct CPUStreamsExecutor::Impl { .set_max_threads_per_core(max_threads_per_core)}); } else { _taskArena.reset(new custom::task_arena{concurrency}); - _cpu_ids = static_cast(_impl->_config._stream_processor_ids.size()) == _impl->_config._streams - ? _impl->_config._stream_processor_ids[stream_id] + _cpu_ids = static_cast(stream_processors.size()) == _impl->_config.get_streams() + ? stream_processors[stream_id] : _cpu_ids; if (_cpu_ids.size() > 0) { CpuSet processMask; int ncpus = 0; std::tie(processMask, ncpus) = get_process_mask(); if (nullptr != processMask) { - _observer.reset(new Observer{*_taskArena, - std::move(processMask), - ncpus, - 0, - concurrency, - 0, - 0, - 0, - _cpu_ids}); + _observer.reset(new Observer{*_taskArena, std::move(processMask), ncpus, _cpu_ids}); _observer->observe(true); } } @@ -186,11 +165,12 @@ struct CPUStreamsExecutor::Impl { int max_threads_per_core; StreamCreateType stream_type; const auto org_proc_type_table = get_org_proc_type_table(); - const auto stream_id = _impl->_config._streams == 0 ? 0 : _streamId % _impl->_config._streams; + int streams_num = _impl->_config.get_streams(); + const auto stream_id = streams_num == 0 ? 0 : _streamId % streams_num; get_cur_stream_info(stream_id, - _impl->_config._cpu_reservation, + _impl->_config.get_cpu_reservation(), org_proc_type_table, - _impl->_config._streams_info_table, + _impl->_config.get_streams_info_table(), stream_type, concurrency, cpu_core_type, @@ -206,112 +186,6 @@ struct CPUStreamsExecutor::Impl { numa_node_id, max_threads_per_core); } - - void init_stream_legacy() { - const auto concurrency = (0 == _impl->_config._threadsPerStream) ? custom::task_arena::automatic - : _impl->_config._threadsPerStream; - if (ThreadBindingType::HYBRID_AWARE == _impl->_config._threadBindingType) { - if (Config::PreferredCoreType::ROUND_ROBIN != _impl->_config._threadPreferredCoreType) { - if (Config::PreferredCoreType::ANY == _impl->_config._threadPreferredCoreType) { - _taskArena.reset(new custom::task_arena{concurrency}); - } else { - const auto selected_core_type = - Config::PreferredCoreType::BIG == _impl->_config._threadPreferredCoreType - ? custom::info::core_types().back() // running on Big cores only - : custom::info::core_types().front(); // running on Little cores only - _taskArena.reset(new custom::task_arena{custom::task_arena::constraints{} - .set_core_type(selected_core_type) - .set_max_concurrency(concurrency)}); - } - } else { - // assigning the stream to the core type in the round-robin fashion - // wrapping around total_streams (i.e. how many streams all different core types can handle - // together). Binding priority: Big core, Logical big core, Small core - const auto total_streams = _impl->total_streams_on_core_types.back().second; - const auto big_core_streams = _impl->total_streams_on_core_types.front().second; - const auto hybrid_core = _impl->total_streams_on_core_types.size() > 1; - const auto phy_core_streams = - _impl->_config._big_core_streams == 0 - ? 0 - : _impl->num_big_core_phys / _impl->_config._threads_per_stream_big; - const auto streamId_wrapped = _streamId % total_streams; - const auto& selected_core_type = - std::find_if( - _impl->total_streams_on_core_types.cbegin(), - _impl->total_streams_on_core_types.cend(), - [streamId_wrapped](const decltype(_impl->total_streams_on_core_types)::value_type& p) { - return p.second > streamId_wrapped; - }) - ->first; - const auto small_core = hybrid_core && selected_core_type == 0; - const auto logic_core = !small_core && streamId_wrapped >= phy_core_streams; - const auto small_core_skip = small_core && _impl->_config._threads_per_stream_small == 3 && - _impl->_config._small_core_streams > 1; - const auto max_concurrency = - small_core ? _impl->_config._threads_per_stream_small : _impl->_config._threads_per_stream_big; - // Special handling of _threads_per_stream_small == 3 - const auto small_core_id = small_core_skip ? 0 : streamId_wrapped - big_core_streams; - const auto stream_id = - hybrid_core - ? (small_core ? small_core_id - : (logic_core ? streamId_wrapped - phy_core_streams : streamId_wrapped)) - : streamId_wrapped; - const auto thread_binding_step = hybrid_core ? (small_core ? _impl->_config._threadBindingStep : 2) - : _impl->_config._threadBindingStep; - // Special handling of _threads_per_stream_small == 3, need to skip 4 (Four cores share one L2 - // cache on the small core), stream_id = 0, cpu_idx_offset cumulative plus 4 - const auto small_core_offset = - small_core_skip ? _impl->_config._small_core_offset + (streamId_wrapped - big_core_streams) * 4 - : _impl->_config._small_core_offset; - const auto cpu_idx_offset = - hybrid_core - // Prevent conflicts with system scheduling, so default cpu id on big core starts from 1 - ? (small_core ? small_core_offset : (logic_core ? 0 : 1)) - : 0; -# ifdef _WIN32 - _taskArena.reset(new custom::task_arena{custom::task_arena::constraints{} - .set_core_type(selected_core_type) - .set_max_concurrency(max_concurrency)}); -# else - _taskArena.reset(new custom::task_arena{max_concurrency}); -# endif - CpuSet processMask; - int ncpus = 0; - std::tie(processMask, ncpus) = get_process_mask(); - if (nullptr != processMask) { - _observer.reset(new Observer{*_taskArena, - std::move(processMask), - ncpus, - stream_id, - max_concurrency, - thread_binding_step, - _impl->_config._threadBindingOffset, - cpu_idx_offset}); - _observer->observe(true); - } - } - } else if (ThreadBindingType::NUMA == _impl->_config._threadBindingType) { - _taskArena.reset(new custom::task_arena{custom::task_arena::constraints{_numaNodeId, concurrency}}); - } else if ((0 != _impl->_config._threadsPerStream) || - (ThreadBindingType::CORES == _impl->_config._threadBindingType)) { - _taskArena.reset(new custom::task_arena{concurrency}); - if (ThreadBindingType::CORES == _impl->_config._threadBindingType) { - CpuSet processMask; - int ncpus = 0; - std::tie(processMask, ncpus) = get_process_mask(); - if (nullptr != processMask) { - _observer.reset(new Observer{*_taskArena, - std::move(processMask), - ncpus, - _streamId, - _impl->_config._threadsPerStream, - _impl->_config._threadBindingStep, - _impl->_config._threadBindingOffset}); - _observer->observe(true); - } - } - } - } #endif Impl* _impl = nullptr; @@ -439,46 +313,17 @@ struct CPUStreamsExecutor::Impl { this) { _exectorMgr = executor_manager(); auto numaNodes = get_available_numa_nodes(); - if (_config._streams != 0) { + int streams_num = _config.get_streams(); + if (streams_num != 0) { std::copy_n(std::begin(numaNodes), - std::min(_config._streams, numaNodes.size()), + std::min(streams_num, numaNodes.size()), std::back_inserter(_usedNumaNodes)); } else { _usedNumaNodes = numaNodes; } -#if (OV_THREAD == OV_THREAD_TBB || OV_THREAD == OV_THREAD_TBB_AUTO) - if (!is_cpu_map_available() && ThreadBindingType::HYBRID_AWARE == config._threadBindingType) { - const auto core_types = custom::info::core_types(); - const auto num_core_phys = get_number_of_cpu_cores(); - num_big_core_phys = get_number_of_cpu_cores(true); - const auto num_small_core_phys = num_core_phys - num_big_core_phys; - int sum = 0; - // reversed order, so BIG cores are first - for (auto iter = core_types.rbegin(); iter < core_types.rend(); iter++) { - const auto& type = *iter; - // calculating the #streams per core type - const int num_streams_for_core_type = - type == 0 ? std::max(1, - std::min(config._small_core_streams, - config._threads_per_stream_small == 0 - ? 0 - : num_small_core_phys / config._threads_per_stream_small)) - : std::max(1, - std::min(config._big_core_streams, - config._threads_per_stream_big == 0 - ? 0 - : num_big_core_phys / config._threads_per_stream_big * 2)); - sum += num_streams_for_core_type; - // prefix sum, so the core type for a given stream id will be deduced just as a upper_bound - // (notice that the map keeps the elements in the descending order, so the big cores are populated - // first) - total_streams_on_core_types.push_back({type, sum}); - } - } -#endif - for (auto streamId = 0; streamId < _config._streams; ++streamId) { + for (auto streamId = 0; streamId < streams_num; ++streamId) { _threads.emplace_back([this, streamId] { - openvino::itt::threadName(_config._name + "_" + std::to_string(streamId)); + openvino::itt::threadName(_config.get_name() + "_" + std::to_string(streamId)); for (bool stopped = false; !stopped;) { Task task; { @@ -548,15 +393,6 @@ struct CPUStreamsExecutor::Impl { bool _isStopped = false; std::vector _usedNumaNodes; CustomThreadLocal _streams; -#if (OV_THREAD == OV_THREAD_TBB || OV_THREAD == OV_THREAD_TBB_AUTO) - // stream id mapping to the core type - // stored in the reversed order (so the big cores, with the highest core_type_id value, are populated first) - // every entry is the core type and #streams that this AND ALL EARLIER entries can handle (prefix sum) - // (so mapping is actually just an upper_bound: core type is deduced from the entry for which the id < #streams) - using StreamIdToCoreTypes = std::vector>; - StreamIdToCoreTypes total_streams_on_core_types; - int num_big_core_phys; -#endif std::shared_ptr _exectorMgr; }; @@ -595,7 +431,7 @@ void CPUStreamsExecutor::execute(Task task) { } void CPUStreamsExecutor::run(Task task) { - if (0 == _impl->_config._streams) { + if (0 == _impl->_config.get_streams()) { _impl->Defer(std::move(task)); } else { _impl->Enqueue(std::move(task)); diff --git a/src/inference/src/dev/threading/executor_manager.cpp b/src/inference/src/dev/threading/executor_manager.cpp index f540f79f27d6ac..d0c639f35b7982 100644 --- a/src/inference/src/dev/threading/executor_manager.cpp +++ b/src/inference/src/dev/threading/executor_manager.cpp @@ -128,20 +128,14 @@ std::shared_ptr ExecutorManagerImpl::get_executor( std::shared_ptr ExecutorManagerImpl::get_idle_cpu_streams_executor( const ov::threading::IStreamsExecutor::Config& config) { std::lock_guard guard(streamExecutorMutex); - for (const auto& it : cpuStreamsExecutors) { + for (auto& it : cpuStreamsExecutors) { const auto& executor = it.second; if (executor.use_count() != 1) continue; - const auto& executorConfig = it.first; - if (executorConfig._name == config._name && executorConfig._streams == config._streams && - executorConfig._threadsPerStream == config._threadsPerStream && - executorConfig._threadBindingType == config._threadBindingType && - executorConfig._threadBindingStep == config._threadBindingStep && - executorConfig._threadBindingOffset == config._threadBindingOffset) - if (executorConfig._threadBindingType != ov::threading::IStreamsExecutor::ThreadBindingType::HYBRID_AWARE || - executorConfig._threadPreferredCoreType == config._threadPreferredCoreType) - return executor; + auto& executorConfig = it.first; + if (executorConfig == config) + return executor; } auto newExec = std::make_shared(config); tbbThreadsCreated = true; @@ -167,23 +161,30 @@ void ExecutorManagerImpl::clear(const std::string& id) { cpuStreamsExecutors.clear(); } else { executors.erase(id); - cpuStreamsExecutors.erase( - std::remove_if(cpuStreamsExecutors.begin(), - cpuStreamsExecutors.end(), - [&](const std::pair>& it) { - return it.first._name == id; - }), - cpuStreamsExecutors.end()); + cpuStreamsExecutors.erase(std::remove_if(cpuStreamsExecutors.begin(), + cpuStreamsExecutors.end(), + [&](std::pair>& it) { + return it.first.get_name() == id; + }), + cpuStreamsExecutors.end()); } } void ExecutorManagerImpl::execute_task_by_streams_executor( ov::threading::IStreamsExecutor::Config::PreferredCoreType core_type, ov::threading::Task task) { - ov::threading::IStreamsExecutor::Config streamsConfig("StreamsExecutor"); - streamsConfig.update_executor_config(1, 1, core_type, false); - if (!streamsConfig._streams_info_table.empty()) { + ov::threading::IStreamsExecutor::Config streamsConfig("StreamsExecutor", + 1, + 1, + ov::threading::IStreamsExecutor::ThreadBindingType::NONE, + 1, + 0, + 0, + core_type, + {}, + false); + if (!streamsConfig.get_streams_info_table().empty()) { auto taskExecutor = std::make_shared(streamsConfig); std::vector tasks{std::move(task)}; taskExecutor->run_and_wait(tasks); diff --git a/src/inference/src/dev/threading/istreams_executor.cpp b/src/inference/src/dev/threading/istreams_executor.cpp index f52f87dcfe8050..b7151e15b74e5e 100644 --- a/src/inference/src/dev/threading/istreams_executor.cpp +++ b/src/inference/src/dev/threading/istreams_executor.cpp @@ -9,8 +9,6 @@ #include #include -#include "cpp_interfaces/interface/ie_internal_plugin_config.hpp" -#include "ie_plugin_config.hpp" #include "openvino/core/parallel.hpp" #include "openvino/runtime/internal_properties.hpp" #include "openvino/runtime/properties.hpp" @@ -31,90 +29,15 @@ void IStreamsExecutor::Config::set_property(const ov::AnyMap& property) { for (const auto& it : property) { const auto& key = it.first; const auto value = it.second; - OPENVINO_SUPPRESS_DEPRECATED_START - if (key == CONFIG_KEY(CPU_BIND_THREAD)) { - if (value.as() == CONFIG_VALUE(YES) || value.as() == CONFIG_VALUE(NUMA)) { -#if (defined(__APPLE__) || defined(_WIN32)) - _threadBindingType = IStreamsExecutor::ThreadBindingType::NUMA; -#else - _threadBindingType = (value.as() == CONFIG_VALUE(YES)) - ? IStreamsExecutor::ThreadBindingType::CORES - : IStreamsExecutor::ThreadBindingType::NUMA; -#endif - } else if (value.as() == CONFIG_VALUE(HYBRID_AWARE)) { - _threadBindingType = IStreamsExecutor::ThreadBindingType::HYBRID_AWARE; - } else if (value.as() == CONFIG_VALUE(NO)) { - _threadBindingType = IStreamsExecutor::ThreadBindingType::NONE; - } else { - OPENVINO_THROW("Wrong value for property key ", - CONFIG_KEY(CPU_BIND_THREAD), - ". Expected only YES(binds to cores) / NO(no binding) / NUMA(binds to NUMA nodes) / " - "HYBRID_AWARE (let the runtime recognize and use the hybrid cores)"); - } - OPENVINO_SUPPRESS_DEPRECATED_START - } else if (key == ov::affinity) { - ov::Affinity affinity; - std::stringstream{value.as()} >> affinity; - switch (affinity) { - case ov::Affinity::NONE: - _threadBindingType = ThreadBindingType::NONE; - break; - case ov::Affinity::CORE: { -#if (defined(__APPLE__) || defined(_WIN32)) - _threadBindingType = ThreadBindingType::NUMA; -#else - _threadBindingType = ThreadBindingType::CORES; -#endif - } break; - case ov::Affinity::NUMA: - _threadBindingType = ThreadBindingType::NUMA; - break; - case ov::Affinity::HYBRID_AWARE: - _threadBindingType = ThreadBindingType::HYBRID_AWARE; - break; - default: - OPENVINO_THROW("Unsupported affinity type"); - } - OPENVINO_SUPPRESS_DEPRECATED_END - } else if (key == CONFIG_KEY(CPU_THROUGHPUT_STREAMS)) { - if (value.as() == CONFIG_VALUE(CPU_THROUGHPUT_NUMA)) { - _streams = static_cast(get_available_numa_nodes().size()); - _streams_changed = true; - } else if (value.as() == CONFIG_VALUE(CPU_THROUGHPUT_AUTO)) { - // bare minimum of streams (that evenly divides available number of cores) - _streams = get_default_num_streams(); - _streams_changed = true; - } else { - int val_i; - try { - val_i = value.as(); - } catch (const std::exception&) { - OPENVINO_THROW("Wrong value for property key ", - CONFIG_KEY(CPU_THROUGHPUT_STREAMS), - ". Expected only positive numbers (#streams) or ", - "PluginConfigParams::CPU_THROUGHPUT_NUMA/CPU_THROUGHPUT_AUTO"); - } - if (val_i < 0) { - OPENVINO_THROW("Wrong value for property key ", - CONFIG_KEY(CPU_THROUGHPUT_STREAMS), - ". Expected only positive numbers (#streams)"); - } - _streams = val_i; - _streams_changed = true; - } - } else if (key == ov::num_streams) { + if (key == ov::num_streams) { auto streams = value.as(); if (streams == ov::streams::NUMA) { - _streams = static_cast(get_available_numa_nodes().size()); - _streams_changed = true; + _streams = 1; } else if (streams == ov::streams::AUTO) { // bare minimum of streams (that evenly divides available number of cores) - if (!is_cpu_map_available()) { - _streams = get_default_num_streams(); - } + _streams = get_default_num_streams(); } else if (streams.num >= 0) { _streams = streams.num; - _streams_changed = true; } else { OPENVINO_THROW("Wrong value for property key ", ov::num_streams.name(), @@ -122,208 +45,56 @@ void IStreamsExecutor::Config::set_property(const ov::AnyMap& property) { "ov::streams::NUMA|ov::streams::AUTO, Got: ", streams); } - } else if (key == CONFIG_KEY(CPU_THREADS_NUM) || key == ov::inference_num_threads) { + } else if (key == ov::inference_num_threads) { int val_i; try { val_i = value.as(); } catch (const std::exception&) { OPENVINO_THROW("Wrong value for property key ", - CONFIG_KEY(CPU_THREADS_NUM), + ov::inference_num_threads.name(), ". Expected only positive numbers (#threads)"); } if (val_i < 0) { OPENVINO_THROW("Wrong value for property key ", - CONFIG_KEY(CPU_THREADS_NUM), + ov::inference_num_threads.name(), ". Expected only positive numbers (#threads)"); } _threads = val_i; - } else if (key == CONFIG_KEY_INTERNAL(CPU_THREADS_PER_STREAM)) { - int val_i; - try { - val_i = value.as(); - } catch (const std::exception&) { - OPENVINO_THROW("Wrong value for property key ", - CONFIG_KEY_INTERNAL(CPU_THREADS_PER_STREAM), - ". Expected only non negative numbers (#threads)"); - } - if (val_i < 0) { - OPENVINO_THROW("Wrong value for property key ", - CONFIG_KEY_INTERNAL(CPU_THREADS_PER_STREAM), - ". Expected only non negative numbers (#threads)"); - } - _threadsPerStream = val_i; } else if (key == ov::internal::threads_per_stream) { - _threadsPerStream = static_cast(value.as()); - } else if (key == CONFIG_KEY_INTERNAL(BIG_CORE_STREAMS)) { - int val_i; - try { - val_i = value.as(); - } catch (const std::exception&) { - OPENVINO_THROW("Wrong value for HYBRID_AWARE key ", - CONFIG_KEY_INTERNAL(BIG_CORE_STREAMS), - ". Expected only non negative numbers (#streams)"); - } - if (val_i < 0) { - OPENVINO_THROW("Wrong value for HYBRID_AWARE key ", - CONFIG_KEY_INTERNAL(BIG_CORE_STREAMS), - ". Expected only non negative numbers (#streams)"); - } - _big_core_streams = val_i; - } else if (key == CONFIG_KEY_INTERNAL(SMALL_CORE_STREAMS)) { - int val_i; - try { - val_i = value.as(); - } catch (const std::exception&) { - OPENVINO_THROW("Wrong value for HYBRID_AWARE key ", - CONFIG_KEY_INTERNAL(SMALL_CORE_STREAMS), - ". Expected only non negative numbers (#streams)"); - } - if (val_i < 0) { - OPENVINO_THROW("Wrong value for HYBRID_AWARE key ", - CONFIG_KEY_INTERNAL(SMALL_CORE_STREAMS), - ". Expected only non negative numbers (#streams)"); - } - _small_core_streams = val_i; - } else if (key == CONFIG_KEY_INTERNAL(THREADS_PER_STREAM_BIG)) { - int val_i; - try { - val_i = value.as(); - } catch (const std::exception&) { - OPENVINO_THROW("Wrong value for HYBRID_AWARE key ", - CONFIG_KEY_INTERNAL(THREADS_PER_STREAM_BIG), - ". Expected only non negative numbers (#threads)"); - } - if (val_i < 0) { - OPENVINO_THROW("Wrong value for HYBRID_AWARE key ", - CONFIG_KEY_INTERNAL(THREADS_PER_STREAM_BIG), - ". Expected only non negative numbers (#threads)"); - } - _threads_per_stream_big = val_i; - } else if (key == CONFIG_KEY_INTERNAL(THREADS_PER_STREAM_SMALL)) { - int val_i; - try { - val_i = value.as(); - } catch (const std::exception&) { - OPENVINO_THROW("Wrong value for HYBRID_AWARE key ", - CONFIG_KEY_INTERNAL(THREADS_PER_STREAM_SMALL), - ". Expected only non negative numbers (#threads)"); - } - if (val_i < 0) { - OPENVINO_THROW("Wrong value for HYBRID_AWARE key ", - CONFIG_KEY_INTERNAL(THREADS_PER_STREAM_SMALL), - ". Expected only non negative numbers (#threads)"); - } - _threads_per_stream_small = val_i; - } else if (key == CONFIG_KEY_INTERNAL(SMALL_CORE_OFFSET)) { - int val_i; - try { - val_i = value.as(); - } catch (const std::exception&) { - OPENVINO_THROW("Wrong value for HYBRID_AWARE key ", - CONFIG_KEY_INTERNAL(SMALL_CORE_OFFSET), - ". Expected only non negative numbers"); - } - if (val_i < 0) { - OPENVINO_THROW("Wrong value for HYBRID_AWARE key ", - CONFIG_KEY_INTERNAL(SMALL_CORE_OFFSET), - ". Expected only non negative numbers"); - } - _small_core_offset = val_i; - } else if (key == CONFIG_KEY_INTERNAL(ENABLE_HYPER_THREAD)) { - if (value.as() == CONFIG_VALUE(YES)) { - _enable_hyper_thread = true; - } else if (value.as() == CONFIG_VALUE(NO)) { - _enable_hyper_thread = false; - } else { - OPENVINO_THROW("Unsupported enable hyper thread type"); - } + _threads_per_stream = static_cast(value.as()); } else { OPENVINO_THROW("Wrong value for property key ", key); } - OPENVINO_SUPPRESS_DEPRECATED_END } } ov::Any IStreamsExecutor::Config::get_property(const std::string& key) const { if (key == ov::supported_properties) { - OPENVINO_SUPPRESS_DEPRECATED_START std::vector properties{ - CONFIG_KEY(CPU_THROUGHPUT_STREAMS), - CONFIG_KEY(CPU_BIND_THREAD), - CONFIG_KEY(CPU_THREADS_NUM), - CONFIG_KEY_INTERNAL(CPU_THREADS_PER_STREAM), - CONFIG_KEY_INTERNAL(BIG_CORE_STREAMS), - CONFIG_KEY_INTERNAL(SMALL_CORE_STREAMS), - CONFIG_KEY_INTERNAL(THREADS_PER_STREAM_BIG), - CONFIG_KEY_INTERNAL(THREADS_PER_STREAM_SMALL), - CONFIG_KEY_INTERNAL(SMALL_CORE_OFFSET), - CONFIG_KEY_INTERNAL(ENABLE_HYPER_THREAD), ov::num_streams.name(), ov::inference_num_threads.name(), ov::internal::threads_per_stream.name(), - ov::affinity.name(), }; - OPENVINO_SUPPRESS_DEPRECATED_END return properties; - OPENVINO_SUPPRESS_DEPRECATED_START - } else if (key == ov::affinity) { - switch (_threadBindingType) { - case IStreamsExecutor::ThreadBindingType::NONE: - return ov::Affinity::NONE; - case IStreamsExecutor::ThreadBindingType::CORES: - return ov::Affinity::CORE; - case IStreamsExecutor::ThreadBindingType::NUMA: - return ov::Affinity::NUMA; - case IStreamsExecutor::ThreadBindingType::HYBRID_AWARE: - return ov::Affinity::HYBRID_AWARE; - } - OPENVINO_SUPPRESS_DEPRECATED_END } else if (key == ov::num_streams) { return decltype(ov::num_streams)::value_type{_streams}; - OPENVINO_SUPPRESS_DEPRECATED_START - } else if (key == CONFIG_KEY(CPU_BIND_THREAD)) { - switch (_threadBindingType) { - case IStreamsExecutor::ThreadBindingType::NONE: - return {CONFIG_VALUE(NO)}; - case IStreamsExecutor::ThreadBindingType::CORES: - return {CONFIG_VALUE(YES)}; - case IStreamsExecutor::ThreadBindingType::NUMA: - return {CONFIG_VALUE(NUMA)}; - case IStreamsExecutor::ThreadBindingType::HYBRID_AWARE: - return {CONFIG_VALUE(HYBRID_AWARE)}; - } - } else if (key == CONFIG_KEY(CPU_THROUGHPUT_STREAMS)) { - return {std::to_string(_streams)}; - } else if (key == CONFIG_KEY(CPU_THREADS_NUM)) { - return {std::to_string(_threads)}; } else if (key == ov::inference_num_threads) { return decltype(ov::inference_num_threads)::value_type{_threads}; - } else if (key == CONFIG_KEY_INTERNAL(CPU_THREADS_PER_STREAM) || key == ov::internal::threads_per_stream) { - return {std::to_string(_threadsPerStream)}; - } else if (key == CONFIG_KEY_INTERNAL(BIG_CORE_STREAMS)) { - return {std::to_string(_big_core_streams)}; - } else if (key == CONFIG_KEY_INTERNAL(SMALL_CORE_STREAMS)) { - return {std::to_string(_small_core_streams)}; - } else if (key == CONFIG_KEY_INTERNAL(THREADS_PER_STREAM_BIG)) { - return {std::to_string(_threads_per_stream_big)}; - } else if (key == CONFIG_KEY_INTERNAL(THREADS_PER_STREAM_SMALL)) { - return {std::to_string(_threads_per_stream_small)}; - } else if (key == CONFIG_KEY_INTERNAL(SMALL_CORE_OFFSET)) { - return {std::to_string(_small_core_offset)}; - } else if (key == CONFIG_KEY_INTERNAL(ENABLE_HYPER_THREAD)) { - return {_enable_hyper_thread ? CONFIG_VALUE(YES) : CONFIG_VALUE(NO)}; - OPENVINO_SUPPRESS_DEPRECATED_END + } else if (key == ov::internal::threads_per_stream) { + return decltype(ov::internal::threads_per_stream)::value_type{_threads_per_stream}; } else { OPENVINO_THROW("Wrong value for property key ", key); } return {}; } -int IStreamsExecutor::Config::get_default_num_streams(const bool enable_hyper_thread) { - const int sockets = static_cast(get_available_numa_nodes().size()); +int IStreamsExecutor::Config::get_default_num_streams() { // bare minimum of streams (that evenly divides available number of core) - const int num_cores = sockets == 1 ? (enable_hyper_thread ? parallel_get_max_threads() : get_number_of_cpu_cores()) - : get_number_of_cpu_cores(); + const auto proc_type_table = get_proc_type_table(); + if (proc_type_table.empty()) { + return 1; + } + const auto num_cores = proc_type_table[0][MAIN_CORE_PROC] + proc_type_table[0][EFFICIENT_CORE_PROC]; if (0 == num_cores % 4) return std::max(4, num_cores / 4); else if (0 == num_cores % 5) @@ -334,202 +105,81 @@ int IStreamsExecutor::Config::get_default_num_streams(const bool enable_hyper_th return 1; } -int IStreamsExecutor::Config::get_hybrid_num_streams(std::map& config, - const int stream_mode) { - const int num_cores = parallel_get_max_threads(); - const int num_cores_phy = get_number_of_cpu_cores(); - const int num_big_cores_phy = get_number_of_cpu_cores(true); - const int num_small_cores = num_cores_phy - num_big_cores_phy; - const int num_big_cores = num_cores > num_cores_phy ? num_big_cores_phy * 2 : num_big_cores_phy; - int big_core_streams = 0; - int small_core_streams = 0; - int threads_per_stream_big = 0; - int threads_per_stream_small = 0; - - if (stream_mode == DEFAULT) { - // bare minimum of streams (that evenly divides available number of core) - if (0 == num_big_cores_phy % 4) { - threads_per_stream_big = 4; - } else if (0 == num_big_cores_phy % 5) { - threads_per_stream_big = 5; - } else if (0 == num_big_cores_phy % 3) { - threads_per_stream_big = 3; - } else { // if user disables some cores say in BIOS, so we got weird #cores which is not easy to divide - threads_per_stream_big = num_big_cores_phy; - } +IStreamsExecutor::Config IStreamsExecutor::Config::make_default_multi_threaded( + const IStreamsExecutor::Config& initial) { + const auto proc_type_table = get_proc_type_table(); + auto streamConfig = initial; - big_core_streams = num_big_cores / threads_per_stream_big; - threads_per_stream_small = threads_per_stream_big; - if (num_small_cores == 0) { - threads_per_stream_small = 0; - } else if (num_small_cores < threads_per_stream_small) { - small_core_streams = 1; - threads_per_stream_small = num_small_cores; - threads_per_stream_big = threads_per_stream_small; - // Balance the computation of physical core and logical core, the number of threads on the physical core and - // logical core should be equal - big_core_streams = num_big_cores_phy / threads_per_stream_big * 2; - } else { - small_core_streams = num_small_cores / threads_per_stream_small; - } - } else if (stream_mode == AGGRESSIVE) { - big_core_streams = num_big_cores; - small_core_streams = num_small_cores; - threads_per_stream_big = num_big_cores / big_core_streams; - threads_per_stream_small = num_small_cores == 0 ? 0 : num_small_cores / small_core_streams; - } else if (stream_mode == LESSAGGRESSIVE) { - big_core_streams = num_big_cores / 2; - small_core_streams = num_small_cores / 2; - threads_per_stream_big = num_big_cores / big_core_streams; - threads_per_stream_small = num_small_cores == 0 ? 0 : num_small_cores / small_core_streams; - } else { - OPENVINO_THROW("Wrong stream mode to get num of streams: ", stream_mode); + if (proc_type_table.empty()) { + return streamConfig; } - OPENVINO_SUPPRESS_DEPRECATED_START - config[CONFIG_KEY_INTERNAL(BIG_CORE_STREAMS)] = std::to_string(big_core_streams); - config[CONFIG_KEY_INTERNAL(SMALL_CORE_STREAMS)] = std::to_string(small_core_streams); - config[CONFIG_KEY_INTERNAL(THREADS_PER_STREAM_BIG)] = std::to_string(threads_per_stream_big); - config[CONFIG_KEY_INTERNAL(THREADS_PER_STREAM_SMALL)] = std::to_string(threads_per_stream_small); - // This is default setting for specific CPU which Pcore is in front and Ecore is in the back. - config[CONFIG_KEY_INTERNAL(SMALL_CORE_OFFSET)] = std::to_string(num_small_cores == 0 ? 0 : num_big_cores); - OPENVINO_SUPPRESS_DEPRECATED_END - return big_core_streams + small_core_streams; -} -void IStreamsExecutor::Config::update_hybrid_custom_threads(Config& config) { - const auto num_cores = parallel_get_max_threads(); - const auto num_cores_phys = get_number_of_cpu_cores(); - const auto num_big_cores_phys = get_number_of_cpu_cores(true); - const auto num_big_cores = num_cores > num_cores_phys ? num_big_cores_phys * 2 : num_big_cores_phys; - const auto num_small_cores_phys = num_cores_phys - num_big_cores_phys; - const auto threads = config._threads ? config._threads : num_cores; - const auto streams = config._streams > 0 ? config._streams : 1; - - config._small_core_offset = num_big_cores; - int threads_per_stream = std::max(1, threads / streams); - - if ((num_big_cores_phys / threads_per_stream >= streams) && (1 < threads_per_stream)) { - config._big_core_streams = streams; - config._threads_per_stream_big = threads_per_stream; - config._small_core_streams = 0; - config._threads_per_stream_small = 0; - } else if ((num_small_cores_phys / threads_per_stream >= streams) && (num_big_cores_phys < threads_per_stream)) { - config._big_core_streams = 0; - config._threads_per_stream_big = 0; - config._small_core_streams = streams; - config._threads_per_stream_small = threads_per_stream; - } else { - const int threads_per_stream_big = std::min(num_big_cores_phys, threads_per_stream); - const int threads_per_stream_small = std::min(num_small_cores_phys, threads_per_stream); - - threads_per_stream = std::min(threads_per_stream_big, threads_per_stream_small); - while (threads_per_stream > 1) { - const int base_big_streams = num_big_cores_phys / threads_per_stream; - const int base_small_streams = num_small_cores_phys > 0 ? num_small_cores_phys / threads_per_stream : 0; - if (base_big_streams + base_small_streams >= streams) { - config._big_core_streams = base_big_streams; - config._small_core_streams = streams - base_big_streams; - break; - } else if (base_big_streams * 2 + base_small_streams >= streams) { - config._big_core_streams = streams - base_small_streams; - config._small_core_streams = base_small_streams; - break; - } else { - threads_per_stream = threads_per_stream > 1 ? threads_per_stream - 1 : 1; + const auto numa_nodes = proc_type_table.size() > 1 ? proc_type_table.size() - 1 : proc_type_table.size(); + const bool latency_case = static_cast(streamConfig._streams) <= numa_nodes; + + // by default, do not use the hyper-threading (to minimize threads synch overheads) + int num_cores = !latency_case && numa_nodes == 1 + ? proc_type_table[0][ALL_PROC] + : proc_type_table[0][MAIN_CORE_PROC] + proc_type_table[0][EFFICIENT_CORE_PROC]; + + // additional latency-case logic for hybrid processors: + if (proc_type_table[0][EFFICIENT_CORE_PROC] > 0 && proc_type_table[0][MAIN_CORE_PROC] > 0) { + if (streamConfig._thread_preferred_core_type == IStreamsExecutor::Config::ANY) { + // by default the latency case uses (faster) Big cores only, depending on the compute ratio + const bool big_only = proc_type_table[0][MAIN_CORE_PROC] > (proc_type_table[0][EFFICIENT_CORE_PROC] / 2); + // selecting the preferred core type + if (big_only) { + streamConfig._thread_preferred_core_type = IStreamsExecutor::Config::PreferredCoreType::BIG; + const int hyper_threading_threshold = + 2; // min #cores, for which the hyper-threading becomes useful for the latency case + // additionally selecting the #cores to use in the "Big-only" case + num_cores = (proc_type_table[0][MAIN_CORE_PROC] <= hyper_threading_threshold) + ? proc_type_table[0][MAIN_CORE_PROC] + proc_type_table[0][HYPER_THREADING_PROC] + : proc_type_table[0][MAIN_CORE_PROC]; } + } else if (streamConfig._thread_preferred_core_type == IStreamsExecutor::Config::BIG) { + num_cores = proc_type_table[0][MAIN_CORE_PROC]; + } else if (streamConfig._thread_preferred_core_type == IStreamsExecutor::Config::LITTLE) { + num_cores = proc_type_table[0][EFFICIENT_CORE_PROC]; } + } - if (threads_per_stream == 1) { - const int stream_loops = streams / num_cores; - const int remain_streams = streams - stream_loops * num_cores; - if (num_big_cores_phys >= remain_streams) { - config._big_core_streams = remain_streams + num_big_cores * stream_loops; - config._small_core_streams = num_small_cores_phys * stream_loops; - } else if (num_big_cores_phys + num_small_cores_phys >= remain_streams) { - config._big_core_streams = num_big_cores_phys + num_big_cores * stream_loops; - config._small_core_streams = remain_streams - num_big_cores_phys + num_small_cores_phys * stream_loops; - } else { - config._big_core_streams = remain_streams - num_small_cores_phys + num_big_cores * stream_loops; - config._small_core_streams = num_small_cores_phys * (stream_loops + 1); + const auto threads = streamConfig._threads ? streamConfig._threads : num_cores; + int threads_per_stream = streamConfig._streams ? std::max(1, threads / streamConfig._streams) : threads; + if (proc_type_table[0][EFFICIENT_CORE_PROC] > 0 && proc_type_table[0][MAIN_CORE_PROC] > 0 && + streamConfig._thread_preferred_core_type == IStreamsExecutor::Config::ANY) { + if (streamConfig._streams > 1) { + threads_per_stream = + std::min(std::min(proc_type_table[0][MAIN_CORE_PROC], proc_type_table[0][EFFICIENT_CORE_PROC]), + threads_per_stream); + while (1) { + int streams_num = proc_type_table[0][MAIN_CORE_PROC] / threads_per_stream + + proc_type_table[0][HYPER_THREADING_PROC] / threads_per_stream + + proc_type_table[0][EFFICIENT_CORE_PROC] / threads_per_stream; + if (streams_num >= streamConfig._streams) { + break; + } else { + if (threads_per_stream > 1) { + threads_per_stream--; + } + } } } - - config._threads_per_stream_big = threads_per_stream; - config._threads_per_stream_small = threads_per_stream; } + streamConfig._threads_per_stream = threads_per_stream; + streamConfig._threads = streamConfig._threads_per_stream * streamConfig._streams; + streamConfig.update_executor_config(); + return streamConfig; } -IStreamsExecutor::Config IStreamsExecutor::Config::make_default_multi_threaded(const IStreamsExecutor::Config& initial, - const bool fp_intesive) { - const auto envThreads = parallel_get_env_threads(); - const auto& numaNodes = get_available_numa_nodes(); - const int numaNodesNum = static_cast(numaNodes.size()); - auto streamExecutorConfig = initial; - const bool bLatencyCase = streamExecutorConfig._streams <= numaNodesNum; +void IStreamsExecutor::Config::reserve_cpu_threads() { + int status = _name.find("StreamsExecutor") != std::string::npos ? NOT_USED : CPU_USED; - // by default, do not use the hyper-threading (to minimize threads synch overheads) - int num_cores_default = get_number_of_cpu_cores(); -#if (OV_THREAD == OV_THREAD_TBB || OV_THREAD == OV_THREAD_TBB_AUTO) - // additional latency-case logic for hybrid processors: - if (ThreadBindingType::HYBRID_AWARE == streamExecutorConfig._threadBindingType) { - const auto core_types = custom::info::core_types(); - const auto num_little_cores = - custom::info::default_concurrency(custom::task_arena::constraints{}.set_core_type(core_types.front())); - const auto num_big_cores_phys = get_number_of_cpu_cores(true); - const int int8_threshold = 4; // ~relative efficiency of the VNNI-intensive code for Big vs Little cores; - const int fp32_threshold = 2; // ~relative efficiency of the AVX2 fp32 code for Big vs Little cores; - // by default the latency case uses (faster) Big cores only, depending on the compute ratio - const bool bLatencyCaseBigOnly = - num_big_cores_phys > (num_little_cores / (fp_intesive ? fp32_threshold : int8_threshold)); - // selecting the preferred core type - streamExecutorConfig._threadPreferredCoreType = - bLatencyCase ? (bLatencyCaseBigOnly ? IStreamsExecutor::Config::PreferredCoreType::BIG - : IStreamsExecutor::Config::PreferredCoreType::ANY) - : IStreamsExecutor::Config::PreferredCoreType::ROUND_ROBIN; - // additionally selecting the #cores to use in the "Big-only" case - if (bLatencyCaseBigOnly) { - const int hyper_threading_threshold = - 2; // min #cores, for which the hyper-threading becomes useful for the latency case - const auto num_big_cores = - custom::info::default_concurrency(custom::task_arena::constraints{}.set_core_type(core_types.back())); - num_cores_default = (num_big_cores_phys <= hyper_threading_threshold) ? num_big_cores : num_big_cores_phys; - } - // if nstreams or nthreads are set, need to calculate the Hybrid aware parameters here - if (!bLatencyCase && (streamExecutorConfig._big_core_streams == 0 || streamExecutorConfig._threads)) { - update_hybrid_custom_threads(streamExecutorConfig); - } - OPENVINO_DEBUG << "[ p_e_core_info ] streams (threads): " << streamExecutorConfig._streams << "(" - << streamExecutorConfig._threads_per_stream_big * streamExecutorConfig._big_core_streams + - streamExecutorConfig._threads_per_stream_small * streamExecutorConfig._small_core_streams - << ") -- PCore: " << streamExecutorConfig._big_core_streams << "(" - << streamExecutorConfig._threads_per_stream_big - << ") ECore: " << streamExecutorConfig._small_core_streams << "(" - << streamExecutorConfig._threads_per_stream_small << ")"; + if (_streams_info_table.size() == 0 || (status == CPU_USED && !_cpu_reservation)) { + return; } -#endif - const auto hwCores = - !bLatencyCase && numaNodesNum == 1 - // throughput case on a single-NUMA node machine uses all available cores - ? (streamExecutorConfig._enable_hyper_thread ? parallel_get_max_threads() : num_cores_default) - // in the rest of cases: - // multi-node machine - // or - // latency case, single-node yet hybrid case that uses - // all core types - // or - // big-cores only, but the #cores is "enough" (pls see the logic above) - // it is usually beneficial not to use the hyper-threading (which is default) - : num_cores_default; - const auto threads = - streamExecutorConfig._threads ? streamExecutorConfig._threads : (envThreads ? envThreads : hwCores); - streamExecutorConfig._threadsPerStream = - streamExecutorConfig._streams ? std::max(1, threads / streamExecutorConfig._streams) : threads; - streamExecutorConfig._threads = - (!bLatencyCase && ThreadBindingType::HYBRID_AWARE == streamExecutorConfig._threadBindingType) - ? streamExecutorConfig._big_core_streams * streamExecutorConfig._threads_per_stream_big + - streamExecutorConfig._small_core_streams * streamExecutorConfig._threads_per_stream_small - : streamExecutorConfig._threadsPerStream * streamExecutorConfig._streams; - return streamExecutorConfig; + + reserve_available_cpus(_streams_info_table, _stream_processor_ids, status); } IStreamsExecutor::Config IStreamsExecutor::Config::reserve_cpu_threads(const IStreamsExecutor::Config& initial) { @@ -551,120 +201,150 @@ IStreamsExecutor::Config IStreamsExecutor::Config::reserve_cpu_threads(const ISt config._streams_info_table[i][NUMBER_OF_STREAMS] * config._streams_info_table[i][THREADS_PER_STREAM]; } } + config._threads_per_stream = config._streams_info_table[0][THREADS_PER_STREAM]; OPENVINO_DEBUG << "[ threading ] " << config._name << " reserve_cpu_threads " << config._streams << "(" << config._threads << ")"; return config; } -void IStreamsExecutor::Config::update_executor_config(int stream_nums, - int threads_per_stream, - IStreamsExecutor::Config::PreferredCoreType core_type, - bool cpu_pinning) { - const auto proc_type_table = ov::get_proc_type_table(); +void IStreamsExecutor::Config::update_executor_config() { + const auto proc_type_table = get_proc_type_table(); + bool streams_info_available = false; if (proc_type_table.empty()) { return; } - if (proc_type_table.size() > 1) { - core_type = ov::threading::IStreamsExecutor::Config::ANY; + if (!_streams_info_table.empty()) { + streams_info_available = true; + std::vector threads_proc_type(HYPER_THREADING_PROC + 1, 0); + for (size_t i = 0; i < _streams_info_table.size(); i++) { + if (_streams_info_table[i][NUMBER_OF_STREAMS] > 0) { + threads_proc_type[_streams_info_table[i][PROC_TYPE]] += + _streams_info_table[i][THREADS_PER_STREAM] * _streams_info_table[i][NUMBER_OF_STREAMS]; + } + } + for (size_t i = ALL_PROC; i < threads_proc_type.size(); i++) { + if (threads_proc_type[i] > proc_type_table[0][i]) { + streams_info_available = false; + break; + } + } } - // IStreamsExecutor::Config config = initial; - const auto total_num_cores = proc_type_table[0][ALL_PROC]; - const auto total_num_big_cores = proc_type_table[0][MAIN_CORE_PROC] + proc_type_table[0][HYPER_THREADING_PROC]; - const auto total_num_little_cores = proc_type_table[0][EFFICIENT_CORE_PROC]; + if (!streams_info_available) { + _streams_info_table.clear(); - int num_cores = total_num_cores; - if (core_type == ov::threading::IStreamsExecutor::Config::BIG) { - num_cores = total_num_big_cores; - } else if (core_type == ov::threading::IStreamsExecutor::Config::LITTLE) { - num_cores = total_num_little_cores; - } + const auto total_num_cores = proc_type_table[0][ALL_PROC]; + const auto total_num_big_cores = proc_type_table[0][MAIN_CORE_PROC] + proc_type_table[0][HYPER_THREADING_PROC]; + const auto total_num_little_cores = proc_type_table[0][EFFICIENT_CORE_PROC]; - int streams = std::min(stream_nums, num_cores); + if ((total_num_little_cores == 0 && _thread_preferred_core_type == IStreamsExecutor::Config::LITTLE) || + (total_num_big_cores == 0 && _thread_preferred_core_type == IStreamsExecutor::Config::BIG) || + (proc_type_table.size() > 1 && _thread_preferred_core_type == IStreamsExecutor::Config::BIG)) { + _thread_preferred_core_type = IStreamsExecutor::Config::ANY; + } - if (streams == 0) { - return; - } + int num_cores = total_num_cores; + if (_thread_preferred_core_type == IStreamsExecutor::Config::BIG) { + num_cores = total_num_big_cores; + } else if (_thread_preferred_core_type == IStreamsExecutor::Config::LITTLE) { + num_cores = total_num_little_cores; + } - _streams = streams; - _threadPreferredCoreType = core_type; - _threadsPerStream = threads_per_stream; - - // create stream_info_table based on core type - std::vector stream_info(ov::CPU_STREAMS_TABLE_SIZE, 0); - stream_info[ov::THREADS_PER_STREAM] = _threadsPerStream; - stream_info[ov::STREAM_NUMA_NODE_ID] = 0; - stream_info[ov::STREAM_SOCKET_ID] = 0; - if (core_type == ov::threading::IStreamsExecutor::Config::BIG) { - if (proc_type_table[0][ov::MAIN_CORE_PROC] < _streams) { - if (proc_type_table[0][ov::MAIN_CORE_PROC] > 0) { - stream_info[ov::NUMBER_OF_STREAMS] = proc_type_table[0][ov::MAIN_CORE_PROC]; - stream_info[ov::PROC_TYPE] = ov::MAIN_CORE_PROC; - _streams_info_table.push_back(stream_info); - } - if (proc_type_table[0][ov::HYPER_THREADING_PROC] > 0) { - stream_info[ov::NUMBER_OF_STREAMS] = proc_type_table[0][ov::HYPER_THREADING_PROC]; - stream_info[ov::PROC_TYPE] = ov::HYPER_THREADING_PROC; + _streams = _streams > 0 ? std::min(_streams, num_cores) : _streams; + if (_streams == 0) { + set_config_zero_stream(); + return; + } + + _threads_per_stream = + _threads_per_stream > 0 ? std::min(num_cores, _streams * _threads_per_stream) / _streams : 0; + if (_threads_per_stream == 0) { + return; + } + + // create stream_info_table based on core type + std::vector stream_info(CPU_STREAMS_TABLE_SIZE, 0); + stream_info[THREADS_PER_STREAM] = _threads_per_stream; + stream_info[STREAM_NUMA_NODE_ID] = 0; + stream_info[STREAM_SOCKET_ID] = 0; + int cur_threads = _streams * _threads_per_stream; + if (_thread_preferred_core_type == IStreamsExecutor::Config::LITTLE) { + stream_info[PROC_TYPE] = EFFICIENT_CORE_PROC; + stream_info[NUMBER_OF_STREAMS] = _streams; + _streams_info_table.push_back(stream_info); + } else { + int start = proc_type_table.size() > 1 ? 1 : 0; + std::vector core_types; + // Using cores crossed sockets or hyper threads when streams = 1 + if (_streams == 1 && _threads_per_stream > proc_type_table[start][ov::MAIN_CORE_PROC]) { + stream_info[NUMBER_OF_STREAMS] = _streams; + stream_info[PROC_TYPE] = ALL_PROC; + stream_info[STREAM_NUMA_NODE_ID] = proc_type_table.size() > 1 ? -1 : 0; + stream_info[STREAM_SOCKET_ID] = proc_type_table.size() > 1 ? -1 : 0; _streams_info_table.push_back(stream_info); + stream_info[NUMBER_OF_STREAMS] = 0; } - } else { - stream_info[ov::PROC_TYPE] = ov::MAIN_CORE_PROC; - stream_info[ov::NUMBER_OF_STREAMS] = _streams; - _streams_info_table.push_back(stream_info); - } - } else if (core_type == ov::threading::IStreamsExecutor::Config::LITTLE) { - stream_info[ov::PROC_TYPE] = ov::EFFICIENT_CORE_PROC; - stream_info[ov::NUMBER_OF_STREAMS] = _streams; - _streams_info_table.push_back(stream_info); - } else { - int total_streams = 0; - if (proc_type_table.size() == 1) { - for (int i = ov::MAIN_CORE_PROC; i <= ov::HYPER_THREADING_PROC; i++) { - if (proc_type_table[0][i] > 0) { - stream_info[ov::NUMBER_OF_STREAMS] = - (total_streams + proc_type_table[0][i] > _streams ? _streams - total_streams - : proc_type_table[0][i]); - stream_info[ov::PROC_TYPE] = i; - stream_info[ov::STREAM_NUMA_NODE_ID] = proc_type_table[0][PROC_NUMA_NODE_ID]; - stream_info[ov::STREAM_SOCKET_ID] = proc_type_table[0][PROC_SOCKET_ID]; - _streams_info_table.push_back(stream_info); - total_streams += stream_info[ov::NUMBER_OF_STREAMS]; - } - if (total_streams >= _streams) - break; + if (_thread_preferred_core_type == IStreamsExecutor::Config::BIG && + proc_type_table[0][EFFICIENT_CORE_PROC] > 0) { + core_types = {MAIN_CORE_PROC, HYPER_THREADING_PROC}; + } else { + core_types = {MAIN_CORE_PROC, EFFICIENT_CORE_PROC, HYPER_THREADING_PROC}; } - } else { - for (size_t i = 1; i < proc_type_table.size(); i++) { - for (int j = ov::MAIN_CORE_PROC; j < ov::HYPER_THREADING_PROC; j++) { - if (proc_type_table[i][j] > 0) { - stream_info[ov::NUMBER_OF_STREAMS] = - (total_streams + proc_type_table[i][j] > _streams ? _streams - total_streams - : proc_type_table[i][j]); - stream_info[ov::PROC_TYPE] = j; - stream_info[ov::STREAM_NUMA_NODE_ID] = proc_type_table[i][PROC_NUMA_NODE_ID]; - stream_info[ov::STREAM_SOCKET_ID] = proc_type_table[i][PROC_SOCKET_ID]; + for (int j : core_types) { + for (size_t i = start; i < proc_type_table.size(); i++) { + if (proc_type_table[i][j] > 0 && cur_threads > 0) { + if (_threads_per_stream > proc_type_table[i][j]) { + stream_info[THREADS_PER_STREAM] = std::min(proc_type_table[i][j], cur_threads); + cur_threads -= stream_info[THREADS_PER_STREAM]; + } else { + stream_info[NUMBER_OF_STREAMS] = + std::min(proc_type_table[i][j], cur_threads) / _threads_per_stream; + cur_threads -= stream_info[NUMBER_OF_STREAMS] * _threads_per_stream; + } + stream_info[PROC_TYPE] = j; + stream_info[STREAM_NUMA_NODE_ID] = proc_type_table[i][PROC_NUMA_NODE_ID]; + stream_info[STREAM_SOCKET_ID] = proc_type_table[i][PROC_SOCKET_ID]; _streams_info_table.push_back(stream_info); - total_streams += stream_info[ov::NUMBER_OF_STREAMS]; } - if (total_streams >= _streams) - break; } - if (total_streams >= _streams) - break; } } } - if (cpu_pinning) { - _cpu_reservation = cpu_pinning; - auto new_config = reserve_cpu_threads(*this); - _stream_processor_ids = new_config._stream_processor_ids; - _streams = new_config._streams; - _threads = new_config._threads; + if (_cpu_reservation) { + reserve_cpu_threads(); + } + + // Recaculate _streams, _threads and _threads_per_stream by _streams_info_table + int num_streams = 0; + _threads = 0; + for (size_t i = 0; i < _streams_info_table.size(); i++) { + if (_streams_info_table[i][NUMBER_OF_STREAMS] > 0) { + num_streams += _streams_info_table[i][NUMBER_OF_STREAMS]; + _threads += _streams_info_table[i][NUMBER_OF_STREAMS] * _streams_info_table[i][THREADS_PER_STREAM]; + } + } + _threads_per_stream = _streams_info_table[0][THREADS_PER_STREAM]; + _streams = _streams > 0 ? num_streams : _streams; + + OPENVINO_DEBUG << "[ threading ] proc_type_table:"; + for (size_t i = 0; i < proc_type_table.size(); i++) { + OPENVINO_DEBUG << proc_type_table[i][ALL_PROC] << " " << proc_type_table[i][MAIN_CORE_PROC] << " " + << proc_type_table[i][EFFICIENT_CORE_PROC] << " " << proc_type_table[i][HYPER_THREADING_PROC] + << " " << proc_type_table[i][PROC_NUMA_NODE_ID] << " " << proc_type_table[i][PROC_SOCKET_ID]; + } + + OPENVINO_DEBUG << "[ threading ] streams_info_table:"; + for (size_t i = 0; i < _streams_info_table.size(); i++) { + OPENVINO_DEBUG << _streams_info_table[i][NUMBER_OF_STREAMS] << " " << _streams_info_table[i][PROC_TYPE] << " " + << _streams_info_table[i][THREADS_PER_STREAM] << " " + << _streams_info_table[i][STREAM_NUMA_NODE_ID] << " " + << _streams_info_table[i][STREAM_SOCKET_ID]; } + OPENVINO_DEBUG << "[ threading ] " << _name << ": " << _streams << "(" << _threads << ")"; } void IStreamsExecutor::Config::set_config_zero_stream() { diff --git a/src/inference/src/dev/threading/thread_affinity.cpp b/src/inference/src/dev/threading/thread_affinity.cpp index a91052f893858b..f1cd0958d5427b 100644 --- a/src/inference/src/dev/threading/thread_affinity.cpp +++ b/src/inference/src/dev/threading/thread_affinity.cpp @@ -51,8 +51,7 @@ bool pin_thread_to_vacant_core(int thrIdx, int hyperthreads, int ncores, const CpuSet& procMask, - const std::vector& cpu_ids, - int cpuIdxOffset) { + const std::vector& cpu_ids) { if (procMask == nullptr) return false; const size_t size = CPU_ALLOC_SIZE(ncores); @@ -64,7 +63,7 @@ bool pin_thread_to_vacant_core(int thrIdx, mapped_idx = cpu_ids[thrIdx]; } else { // Place threads with specified step - int cpu_idx = cpuIdxOffset; + int cpu_idx = 0; for (int i = 0, offset = 0; i < thrIdx; ++i) { cpu_idx += hyperthreads; if (cpu_idx >= num_cpus) @@ -72,8 +71,8 @@ bool pin_thread_to_vacant_core(int thrIdx, } // Find index of 'cpu_idx'-th bit that equals to 1 - mapped_idx = cpuIdxOffset - 1; - while (cpu_idx >= cpuIdxOffset) { + mapped_idx = -1; + while (cpu_idx >= 0) { mapped_idx++; if (CPU_ISSET_S(mapped_idx, size, procMask.get())) --cpu_idx; @@ -125,8 +124,7 @@ bool pin_thread_to_vacant_core(int thrIdx, int hyperthreads, int ncores, const CpuSet& procMask, - const std::vector& cpu_ids, - int cpuIdxOffset) { + const std::vector& cpu_ids) { return 0 != SetThreadAffinityMask(GetCurrentThread(), DWORD_PTR(1) << cpu_ids[thrIdx]); } bool pin_current_thread_by_mask(int ncores, const CpuSet& procMask) { @@ -146,8 +144,7 @@ bool pin_thread_to_vacant_core(int thrIdx, int hyperthreads, int ncores, const CpuSet& procMask, - const std::vector& cpu_ids, - int cpuIdxOffset) { + const std::vector& cpu_ids) { return false; } bool pin_current_thread_by_mask(int ncores, const CpuSet& procMask) { diff --git a/src/inference/src/dev/threading/thread_affinity.hpp b/src/inference/src/dev/threading/thread_affinity.hpp index 6d31989148de92..5428825b1ff6d7 100644 --- a/src/inference/src/dev/threading/thread_affinity.hpp +++ b/src/inference/src/dev/threading/thread_affinity.hpp @@ -80,8 +80,7 @@ bool pin_thread_to_vacant_core(int thrIdx, int hyperThreads, int ncores, const CpuSet& processMask, - const std::vector& cpu_ids = {}, - int cpuIdxOffset = 0); + const std::vector& cpu_ids = {}); /** * @brief Pins thread to a spare core in the round-robin scheme, while respecting the given process mask. diff --git a/src/inference/src/file_utils.cpp b/src/inference/src/file_utils.cpp deleted file mode 100644 index b4602873988ccd..00000000000000 --- a/src/inference/src/file_utils.cpp +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#ifndef FILE_UTILS_CPP -#define FILE_UTILS_CPP - -#include -#include -#include - -#ifdef __MACH__ -# include -# include -#endif - -#include -#include -#include - -#include "ie_common.h" -#include "openvino/core/except.hpp" -#include "openvino/util/file_util.hpp" - -#ifndef _WIN32 -# include -# include -# include -#else -# if defined(WINAPI_FAMILY) && !WINAPI_PARTITION_DESKTOP -# error "Only WINAPI_PARTITION_DESKTOP is supported, because of GetModuleHandleEx[A|W]" -# endif -# ifndef NOMINMAX -# define NOMINMAX -# endif -# include -#endif - -long long FileUtils::fileSize(const char* charfilepath) { - return ov::util::file_size(charfilepath); -} - -std::string FileUtils::absoluteFilePath(const std::string& filePath) { - return ov::util::get_absolute_file_path(filePath); -} - -bool FileUtils::directoryExists(const std::string& path) { - return ov::util::directory_exists(path); -} - -void FileUtils::createDirectoryRecursive(const std::string& dirPath) { - ov::util::create_directory_recursive(dirPath); -} - -namespace InferenceEngine { - -namespace { - -template > -std::basic_string getPathName(const std::basic_string& s) { - size_t i = s.rfind(ov::util::FileTraits::file_separator, s.length()); - if (i != std::string::npos) { - return (s.substr(0, i)); - } - - return {}; -} - -#if defined __GNUC__ || defined __clang__ -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wunused-function" -#endif - -std::string getIELibraryPathA() { -#ifdef _WIN32 - CHAR ie_library_path[MAX_PATH]; - HMODULE hm = NULL; - if (!GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, - reinterpret_cast(getIELibraryPath), - &hm)) { - OPENVINO_THROW("GetModuleHandle returned ", GetLastError()); - } - GetModuleFileNameA(hm, (LPSTR)ie_library_path, sizeof(ie_library_path)); - return getPathName(std::string(ie_library_path)); -#elif defined(__APPLE__) || defined(__linux__) || defined(__EMSCRIPTEN__) -# ifdef USE_STATIC_IE -# ifdef __APPLE__ - Dl_info info; - dladdr(reinterpret_cast(getIELibraryPath), &info); - std::string path = getPathName(std::string(info.dli_fname)); -# else - char result[PATH_MAX]; - ssize_t count = readlink("/proc/self/exe", result, PATH_MAX); - std::string path = getPathName(std::string(result, (count > 0) ? count : 0)); -# endif // __APPLE__ - return FileUtils::makePath(path, std::string("lib")); -# else - Dl_info info; - dladdr(reinterpret_cast(getIELibraryPath), &info); - std::string path = FileUtils::absoluteFilePath(info.dli_fname); - return getPathName(path); -# endif // USE_STATIC_IE -#else -# error "Unsupported OS" -#endif // _WIN32 -} - -#if defined __GNUC__ || defined __clang__ -# pragma GCC diagnostic pop -#endif - -} // namespace - -#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT - -std::wstring getIELibraryPathW() { -# ifdef _WIN32 - WCHAR ie_library_path[MAX_PATH]; - HMODULE hm = NULL; - if (!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, - reinterpret_cast(getIELibraryPath), - &hm)) { - OPENVINO_THROW("GetModuleHandle returned ", GetLastError()); - } - GetModuleFileNameW(hm, (LPWSTR)ie_library_path, sizeof(ie_library_path) / sizeof(ie_library_path[0])); - return getPathName(std::wstring(ie_library_path)); -# elif defined(__linux__) || defined(__APPLE__) || defined(__EMSCRIPTEN__) - return ::ov::util::string_to_wstring(getIELibraryPathA().c_str()); -# else -# error "Unsupported OS" -# endif -} - -#endif // OPENVINO_ENABLE_UNICODE_PATH_SUPPORT - -std::string getIELibraryPath() { -#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT - return ov::util::wstring_to_string(getIELibraryPathW()); -#else - return getIELibraryPathA(); -#endif -} - -} // namespace InferenceEngine - -#endif diff --git a/src/inference/src/ie_cache_manager.hpp b/src/inference/src/ie_cache_manager.hpp index 09a0f57e5f1309..01f6cc943d68ab 100644 --- a/src/inference/src/ie_cache_manager.hpp +++ b/src/inference/src/ie_cache_manager.hpp @@ -14,8 +14,8 @@ #include #include -#include "file_utils.h" #include "ie_api.h" +#include "openvino/util/file_util.hpp" namespace ov { @@ -82,7 +82,7 @@ class FileStorageCacheManager final : public ICacheManager { std::string m_cachePath; std::string getBlobFile(const std::string& blobHash) const { - return FileUtils::makePath(m_cachePath, blobHash + ".blob"); + return ov::util::make_path(m_cachePath, blobHash + ".blob"); } public: @@ -106,7 +106,7 @@ class FileStorageCacheManager final : public ICacheManager { void read_cache_entry(const std::string& id, StreamReader reader) override { auto blobFileName = getBlobFile(id); - if (FileUtils::fileExist(blobFileName)) { + if (ov::util::file_exists(blobFileName)) { std::ifstream stream(blobFileName, std::ios_base::binary); reader(stream); } @@ -114,7 +114,7 @@ class FileStorageCacheManager final : public ICacheManager { void remove_cache_entry(const std::string& id) override { auto blobFileName = getBlobFile(id); - if (FileUtils::fileExist(blobFileName)) + if (ov::util::file_exists(blobFileName)) std::remove(blobFileName.c_str()); } }; diff --git a/src/inference/src/ie_common.cpp b/src/inference/src/ie_common.cpp index 702fe9641c8b4a..b15e49a9d8b371 100644 --- a/src/inference/src/ie_common.cpp +++ b/src/inference/src/ie_common.cpp @@ -12,7 +12,6 @@ #include #include "ie_blob.h" -#include "ie_parameter.hpp" #include "openvino/core/except.hpp" #include "openvino/runtime/exception.hpp" diff --git a/src/inference/src/ie_core.cpp b/src/inference/src/ie_core.cpp index 49b64ed72114a7..3073ae4f65be06 100644 --- a/src/inference/src/ie_core.cpp +++ b/src/inference/src/ie_core.cpp @@ -19,15 +19,12 @@ #include "compilation_context.hpp" #include "cpp/ie_cnn_network.h" #include "cpp_interfaces/interface/ie_iexecutable_network_internal.hpp" -#include "cpp_interfaces/interface/ie_internal_plugin_config.hpp" #include "dev/converter_utils.hpp" #include "dev/core_impl.hpp" -#include "file_utils.h" #include "ie_cache_manager.hpp" #include "ie_icore.hpp" #include "ie_network_reader.hpp" #include "ie_ngraph_utils.hpp" -#include "ie_plugin_config.hpp" #include "itt.hpp" #include "openvino/core/except.hpp" #include "openvino/core/so_extension.hpp" @@ -42,7 +39,6 @@ #include "openvino/util/shared_object.hpp" #include "openvino/util/xml_parse_utils.hpp" -using namespace InferenceEngine::PluginConfigParams; using namespace InferenceEngine; using namespace std::placeholders; @@ -93,7 +89,7 @@ Core::Core(const std::string& xmlConfigFile) { } } -std::map Core::GetVersions(const std::string& deviceName) const { +std::map Core::GetVersions(const std::string& deviceName) const { return _impl->GetVersions(deviceName); } @@ -275,7 +271,7 @@ void Core::SetConfig(const std::map& config, const std } } -Parameter Core::GetConfig(const std::string& deviceName, const std::string& name) const { +ov::Any Core::GetConfig(const std::string& deviceName, const std::string& name) const { // HETERO case { if (deviceName.find("HETERO:") == 0) { @@ -298,9 +294,8 @@ Parameter Core::GetConfig(const std::string& deviceName, const std::string& name } } - if (name == CONFIG_KEY(FORCE_TBB_TERMINATE)) { - const auto flag = ov::threading::executor_manager()->get_property(ov::force_tbb_terminate.name()).as(); - return flag ? CONFIG_VALUE(YES) : CONFIG_VALUE(NO); + if (name == ov::force_tbb_terminate.name()) { + return ov::threading::executor_manager()->get_property(ov::force_tbb_terminate.name()).as(); } try { @@ -311,7 +306,7 @@ Parameter Core::GetConfig(const std::string& deviceName, const std::string& name } } -Parameter Core::GetMetric(const std::string& deviceName, const std::string& name, const ParamMap& options) const { +ov::Any Core::GetMetric(const std::string& deviceName, const std::string& name, const ov::AnyMap& options) const { try { return _impl->GetMetric(deviceName, name, options); } catch (const ov::Exception& ex) { diff --git a/src/inference/src/ie_memcpy.cpp b/src/inference/src/ie_memcpy.cpp deleted file mode 100644 index 878f873fe0ddf5..00000000000000 --- a/src/inference/src/ie_memcpy.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ie_memcpy.h" - -#include -#include - -int ie_memcpy(void* dest, size_t destsz, void const* src, size_t count) { - if (!src || count > destsz || - count > (dest > src ? ((uintptr_t)dest - (uintptr_t)src) : ((uintptr_t)src - (uintptr_t)dest))) { - // zero out dest if error detected - memset(dest, 0, destsz); - return -1; - } - - memcpy(dest, src, count); - return 0; -} diff --git a/src/inference/src/ie_network_reader.cpp b/src/inference/src/ie_network_reader.cpp index dc64c6831ce6a3..9858dc01677740 100644 --- a/src/inference/src/ie_network_reader.cpp +++ b/src/inference/src/ie_network_reader.cpp @@ -14,13 +14,11 @@ #include "cnn_network_ngraph_impl.hpp" #include "cpp/ie_cnn_network.h" #include "dev/converter_utils.hpp" -#include "file_utils.h" #include "ie_api.h" #include "ie_common.h" #include "ie_icnn_network.hpp" #include "ie_input_info.hpp" #include "itt.hpp" -#include "legacy_op_extension.hpp" #include "openvino/core/deprecated.hpp" #include "openvino/core/except.hpp" #include "openvino/core/preprocess/pre_post_process.hpp" @@ -28,6 +26,7 @@ #include "openvino/frontend/manager.hpp" #include "openvino/runtime/shared_buffer.hpp" #include "openvino/runtime/so_ptr.hpp" +#include "openvino/util/file_util.hpp" #include "openvino/util/shared_object.hpp" #include "transformations/rt_info/old_api_map_order_attribute.hpp" #include "transformations/utils/utils.hpp" diff --git a/src/inference/src/ie_version.cpp b/src/inference/src/ie_version.cpp deleted file mode 100644 index 462a92e27d3aa2..00000000000000 --- a/src/inference/src/ie_version.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ie_version.hpp" - -IE_SUPPRESS_DEPRECATED_START -namespace InferenceEngine { - -const Version* GetInferenceEngineVersion() noexcept { - // Use local static variable to make sure it is always properly initialized - // even if called from global constructor - static Version inferenceEngineVersion = {{2, 1}, // inference engine API version - CI_BUILD_NUMBER, - "IE"}; - return &inferenceEngineVersion; -} -} // namespace InferenceEngine diff --git a/src/inference/src/os/lin/lin_system_conf.cpp b/src/inference/src/os/lin/lin_system_conf.cpp index 1cb25f90004df0..988fdab3baeba5 100644 --- a/src/inference/src/os/lin/lin_system_conf.cpp +++ b/src/inference/src/os/lin/lin_system_conf.cpp @@ -15,6 +15,7 @@ #include "ie_common.h" #include "openvino/core/except.hpp" #include "openvino/runtime/system_conf.hpp" +#include "openvino/util/log.hpp" #include "os/cpu_map_info.hpp" namespace ov { @@ -278,6 +279,21 @@ CPU::CPU() { }; _org_proc_type_table = _proc_type_table; + + OPENVINO_DEBUG << "[ threading ] cpu_mapping_table:"; + for (size_t i = 0; i < _cpu_mapping_table.size(); i++) { + OPENVINO_DEBUG << _cpu_mapping_table[i][CPU_MAP_PROCESSOR_ID] << " " + << _cpu_mapping_table[i][CPU_MAP_NUMA_NODE_ID] << " " << _cpu_mapping_table[i][CPU_MAP_SOCKET_ID] + << " " << _cpu_mapping_table[i][CPU_MAP_CORE_ID] << " " + << _cpu_mapping_table[i][CPU_MAP_CORE_TYPE] << " " << _cpu_mapping_table[i][CPU_MAP_GROUP_ID] + << " " << _cpu_mapping_table[i][CPU_MAP_USED_FLAG]; + } + OPENVINO_DEBUG << "[ threading ] org_proc_type_table:"; + for (size_t i = 0; i < _proc_type_table.size(); i++) { + OPENVINO_DEBUG << _proc_type_table[i][ALL_PROC] << " " << _proc_type_table[i][MAIN_CORE_PROC] << " " + << _proc_type_table[i][EFFICIENT_CORE_PROC] << " " << _proc_type_table[i][HYPER_THREADING_PROC] + << " " << _proc_type_table[i][PROC_NUMA_NODE_ID] << " " << _proc_type_table[i][PROC_SOCKET_ID]; + } } void parse_node_info_linux(const std::vector node_info_table, diff --git a/src/inference/src/os/win/win_system_conf.cpp b/src/inference/src/os/win/win_system_conf.cpp index 0b905d29401355..17384035973c12 100644 --- a/src/inference/src/os/win/win_system_conf.cpp +++ b/src/inference/src/os/win/win_system_conf.cpp @@ -39,6 +39,18 @@ CPU::CPU() { _proc_type_table, _cpu_mapping_table); _org_proc_type_table = _proc_type_table; + + // ensure that get_org_numa_id and get_org_socket_id can return the correct value + for (size_t i = 0; i < _cpu_mapping_table.size(); i++) { + auto numa_id = _cpu_mapping_table[i][CPU_MAP_NUMA_NODE_ID]; + auto socket_id = _cpu_mapping_table[i][CPU_MAP_SOCKET_ID]; + if (_numaid_mapping_table.find(numa_id) == _numaid_mapping_table.end()) { + _numaid_mapping_table.insert({numa_id, numa_id}); + } + if (_socketid_mapping_table.find(socket_id) == _socketid_mapping_table.end()) { + _socketid_mapping_table.insert({socket_id, socket_id}); + } + } } void parse_processor_info_win(const char* base_ptr, diff --git a/src/inference/src/precision_utils.cpp b/src/inference/src/precision_utils.cpp deleted file mode 100644 index e324fa52b90836..00000000000000 --- a/src/inference/src/precision_utils.cpp +++ /dev/null @@ -1,167 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "precision_utils.h" - -#include - -namespace InferenceEngine { -namespace PrecisionUtils { - -void f16tof32Arrays(float* dst, const short* src, size_t nelem, float scale, float bias) { - const ie_fp16* _src = reinterpret_cast(src); - - for (size_t i = 0; i < nelem; i++) { - dst[i] = PrecisionUtils::f16tof32(_src[i]) * scale + bias; - } -} - -void f32tof16Arrays(short* dst, const float* src, size_t nelem, float scale, float bias) { - for (size_t i = 0; i < nelem; i++) { - dst[i] = PrecisionUtils::f32tof16(src[i] * scale + bias); - } -} - -// Function to convert F32 into F16 -// F32: exp_bias:127 SEEEEEEE EMMMMMMM MMMMMMMM MMMMMMMM. -// F16: exp_bias:15 SEEEEEMM MMMMMMMM -#define EXP_MASK_F32 0x7F800000U -#define EXP_MASK_F16 0x7C00U - -// small helper function to represent uint32_t value as float32 -inline float asfloat(uint32_t v) { - // Both type-punning casts and unions are UB per C++ spec - // But compilers usually only break code with casts - union { - float f; - uint32_t i; - }; - i = v; - return f; -} - -// Function to convert F16 into F32 -float f16tof32(ie_fp16 x) { - // this is storage for output result - uint32_t u = static_cast(x); - - // get sign in 32bit format - uint32_t s = ((u & 0x8000) << 16); - - // check for NAN and INF - if ((u & EXP_MASK_F16) == EXP_MASK_F16) { - // keep mantissa only - u &= 0x03FF; - - // check if it is NAN and raise 10 bit to be align with intrin - if (u) { - u |= 0x0200; - } - - u <<= (23 - 10); - u |= EXP_MASK_F32; - u |= s; - } else if ((u & EXP_MASK_F16) == 0) { // check for zero and denormals. - uint16_t h_sig = (u & 0x03ffu); - if (h_sig == 0) { - /* Signed zero */ - u = s; - } else { - /* Subnormal */ - uint16_t h_exp = (u & EXP_MASK_F16); - h_sig <<= 1; - while ((h_sig & 0x0400u) == 0) { - h_sig <<= 1; - h_exp++; - } - uint32_t f_exp = (static_cast(127 - 15 - h_exp)) << 23; - uint32_t f_sig = (static_cast(h_sig & 0x03ffu)) << 13; - u = s + f_exp + f_sig; - } - } else { - // abs - u = (u & 0x7FFF); - - // shift mantissa and exp from f16 to f32 position - u <<= (23 - 10); - - // new bias for exp (f16 bias is 15 and f32 bias is 127) - u += ((127 - 15) << 23); - - // add sign - u |= s; - } - - // finaly represent result as float and return - return asfloat(u); -} - -// This function convert f32 to f16 with rounding to nearest value to minimize error -// the denormal values are converted to 0. -ie_fp16 f32tof16(float x) { - // create minimal positive normal f16 value in f32 format - // exp:-14,mantissa:0 -> 2^-14 * 1.0 - static float min16 = asfloat((127 - 14) << 23); - - // create maximal positive normal f16 value in f32 and f16 formats - // exp:15,mantissa:11111 -> 2^15 * 1.(11111) - static float max16 = asfloat(((127 + 15) << 23) | 0x007FE000); - static uint32_t max16f16 = ((15 + 15) << 10) | 0x3FF; - - // define and declare variable for intermediate and output result - // the union is used to simplify representation changing - union { - float f; - uint32_t u; - } v; - v.f = x; - - // get sign in 16bit format - uint32_t s = (v.u >> 16) & 0x8000; // sign 16: 00000000 00000000 10000000 00000000 - - // make it abs - v.u &= 0x7FFFFFFF; // abs mask: 01111111 11111111 11111111 11111111 - - // check NAN and INF - if ((v.u & EXP_MASK_F32) == EXP_MASK_F32) { - if (v.u & 0x007FFFFF) { - return s | (v.u >> (23 - 10)) | 0x0200; // return NAN f16 - } else { - return s | EXP_MASK_F16; // return INF f16 - } - } - - // to make f32 round to nearest f16 - // create halfULP for f16 and add it to origin value - float halfULP = asfloat(v.u & EXP_MASK_F32) * asfloat((127 - 11) << 23); - v.f += halfULP; - - // if input value is not fit normalized f16 then return 0 - // denormals are not covered by this code and just converted to 0 - if (v.f < min16 * 0.5F) { - return s; - } - - // if input value between min16/2 and min16 then return min16 - if (v.f < min16) { - return s | (1 << 10); - } - - // if input value more than maximal allowed value for f16 - // then return this maximal value - if (v.f >= max16) { - return max16f16 | s; - } - - // change exp bias from 127 to 15 - v.u -= ((127 - 15) << 23); - - // round to f16 - v.u >>= (23 - 10); - - return v.u | s; -} - -} // namespace PrecisionUtils -} // namespace InferenceEngine diff --git a/src/inference/src/system_conf.cpp b/src/inference/src/system_conf.cpp index 68e6e36df4f051..4dd6b1db499028 100644 --- a/src/inference/src/system_conf.cpp +++ b/src/inference/src/system_conf.cpp @@ -13,6 +13,10 @@ #include #include +#ifdef __linux__ +# include +#endif + #include "dev/threading/parallel_custom_arena.hpp" #include "openvino/core/except.hpp" #include "openvino/core/visibility.hpp" @@ -196,6 +200,10 @@ int get_number_of_blocked_cores() { return 0; } +int get_current_socket_id() { + return 0; +} + std::vector> get_proc_type_table() { return {{-1}}; } @@ -253,6 +261,10 @@ bool is_cpu_map_available() { return cpu._proc_type_table.size() > 0; } +int get_current_socket_id() { + return 0; +} + std::vector> get_proc_type_table() { CPU& cpu = cpu_info(); std::lock_guard lock{cpu._cpu_mutex}; @@ -346,6 +358,22 @@ std::vector get_available_numa_nodes() { return nodes; } # endif +int get_current_socket_id() { + CPU& cpu = cpu_info(); + int cur_processor_id = sched_getcpu(); + + for (auto& row : cpu._cpu_mapping_table) { + if (cur_processor_id == row[CPU_MAP_PROCESSOR_ID]) { + return row[CPU_MAP_SOCKET_ID]; + } + } + + return 0; +} +# else +int get_current_socket_id() { + return 0; +} # endif std::vector> get_proc_type_table() { @@ -385,29 +413,6 @@ void reserve_available_cpus(const std::vector> streams_info_tab stream_processors, cpu_status); - OPENVINO_DEBUG << "[ threading ] cpu_mapping_table:"; - for (size_t i = 0; i < cpu._cpu_mapping_table.size(); i++) { - OPENVINO_DEBUG << cpu._cpu_mapping_table[i][CPU_MAP_PROCESSOR_ID] << " " - << cpu._cpu_mapping_table[i][CPU_MAP_NUMA_NODE_ID] << " " - << cpu._cpu_mapping_table[i][CPU_MAP_SOCKET_ID] << " " - << cpu._cpu_mapping_table[i][CPU_MAP_CORE_ID] << " " - << cpu._cpu_mapping_table[i][CPU_MAP_CORE_TYPE] << " " - << cpu._cpu_mapping_table[i][CPU_MAP_GROUP_ID] << " " - << cpu._cpu_mapping_table[i][CPU_MAP_USED_FLAG]; - } - OPENVINO_DEBUG << "[ threading ] proc_type_table:"; - for (size_t i = 0; i < cpu._proc_type_table.size(); i++) { - OPENVINO_DEBUG << cpu._proc_type_table[i][ALL_PROC] << " " << cpu._proc_type_table[i][MAIN_CORE_PROC] << " " - << cpu._proc_type_table[i][EFFICIENT_CORE_PROC] << " " - << cpu._proc_type_table[i][HYPER_THREADING_PROC] << " " - << cpu._proc_type_table[i][PROC_NUMA_NODE_ID] << " " << cpu._proc_type_table[i][PROC_SOCKET_ID]; - } - OPENVINO_DEBUG << "[ threading ] streams_info_table:"; - for (size_t i = 0; i < streams_info_table.size(); i++) { - OPENVINO_DEBUG << streams_info_table[i][NUMBER_OF_STREAMS] << " " << streams_info_table[i][PROC_TYPE] << " " - << streams_info_table[i][THREADS_PER_STREAM] << " " << streams_info_table[i][STREAM_NUMA_NODE_ID] - << " " << streams_info_table[i][STREAM_SOCKET_ID]; - } OPENVINO_DEBUG << "[ threading ] stream_processors:"; for (size_t i = 0; i < stream_processors.size(); i++) { OPENVINO_DEBUG << "{"; diff --git a/src/inference/tests/functional/async_infer_request_test.cpp b/src/inference/tests/functional/async_infer_request_test.cpp deleted file mode 100644 index 68b97e5d69bb6d..00000000000000 --- a/src/inference/tests/functional/async_infer_request_test.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include - -#include - -using namespace ::testing; -using namespace std; -using namespace InferenceEngine; -using namespace InferenceEngine::details; - -IE_SUPPRESS_DEPRECATED_START - -TEST(InferRequestCPPTests, throwsOnUninitializedSetBlob) { - InferRequest req; - ASSERT_THROW(req.SetBlob({}, {}), InferenceEngine::NotAllocated); -} - -TEST(InferRequestCPPTests, throwsOnUninitializedGetBlob) { - InferRequest req; - ASSERT_THROW(req.GetBlob({}), InferenceEngine::NotAllocated); -} - -TEST(InferRequestCPPTests, throwsOnUninitializedInfer) { - InferRequest req; - ASSERT_THROW(req.Infer(), InferenceEngine::NotAllocated); -} - -TEST(InferRequestCPPTests, throwsOnUninitializedGetPerformanceCounts) { - InferRequest req; - ASSERT_THROW(req.GetPerformanceCounts(), InferenceEngine::NotAllocated); -} - -TEST(InferRequestCPPTests, throwsOnUninitializedSetInput) { - InferRequest req; - ASSERT_THROW(req.SetInput({{}}), InferenceEngine::NotAllocated); -} - -TEST(InferRequestCPPTests, throwsOnUninitializedSetOutput) { - InferRequest req; - ASSERT_THROW(req.SetOutput({{}}), InferenceEngine::NotAllocated); -} - -TEST(InferRequestCPPTests, throwsOnUninitializedStartAsync) { - InferRequest req; - ASSERT_THROW(req.StartAsync(), InferenceEngine::NotAllocated); -} - -TEST(InferRequestCPPTests, throwsOnUninitializedWait) { - InferRequest req; - ASSERT_THROW(req.Wait({}), InferenceEngine::NotAllocated); -} - -TEST(InferRequestCPPTests, throwsOnUninitializedSetCompletionCallback) { - InferRequest req; - std::function f; - ASSERT_THROW(req.SetCompletionCallback(f), InferenceEngine::NotAllocated); -} - -IE_SUPPRESS_DEPRECATED_START - -TEST(InferRequestCPPTests, throwsOnUninitializedCast) { - InferRequest req; - ASSERT_THROW((void)static_cast(req), InferenceEngine::NotAllocated); -} - -IE_SUPPRESS_DEPRECATED_END - -TEST(InferRequestCPPTests, throwsOnUninitializedQueryState) { - InferRequest req; - ASSERT_THROW(req.QueryState(), InferenceEngine::NotAllocated); -} diff --git a/src/inference/tests/functional/caching_test.cpp b/src/inference/tests/functional/caching_test.cpp index 8956d5dfa2eddf..1b45c2bd4a7e9d 100644 --- a/src/inference/tests/functional/caching_test.cpp +++ b/src/inference/tests/functional/caching_test.cpp @@ -15,7 +15,6 @@ #include "common_test_utils/file_utils.hpp" #include "common_test_utils/subgraph_builders/conv_pool_relu.hpp" -#include "ie_plugin_config.hpp" #include "openvino/core/any.hpp" #include "openvino/core/except.hpp" #include "openvino/core/layout.hpp" diff --git a/src/inference/tests/functional/cnn_network_test.cpp b/src/inference/tests/functional/cnn_network_test.cpp deleted file mode 100644 index 8430248649aa0c..00000000000000 --- a/src/inference/tests/functional/cnn_network_test.cpp +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include - -#include - -#include "cpp/ie_cnn_network.h" -#include "inference_engine.hpp" -#include "openvino/opsets/opset.hpp" -#include "openvino/pass/serialize.hpp" -#include "openvino/util/file_util.hpp" - -using namespace InferenceEngine; - -using CNNNetworkTests = ::testing::Test; - -IE_SUPPRESS_DEPRECATED_START - -TEST_F(CNNNetworkTests, throwsOnInitWithNull) { - std::shared_ptr nlptr = nullptr; - ASSERT_THROW(CNNNetwork network(nlptr), InferenceEngine::Exception); -} - -TEST_F(CNNNetworkTests, throwsOnUninitializedCastToICNNNetwork) { - CNNNetwork network; - ASSERT_THROW((void)static_cast(network), InferenceEngine::Exception); -} - -TEST_F(CNNNetworkTests, throwsOnConstUninitializedCastToICNNNetwork) { - const CNNNetwork network; - ASSERT_THROW((void)static_cast(network), InferenceEngine::Exception); -} - -IE_SUPPRESS_DEPRECATED_END - -TEST_F(CNNNetworkTests, throwsOnInitWithNullNgraph) { - std::shared_ptr nlptr = nullptr; - ASSERT_THROW(CNNNetwork network(nlptr), InferenceEngine::Exception); -} - -TEST_F(CNNNetworkTests, throwsOnUninitializedGetOutputsInfo) { - CNNNetwork network; - ASSERT_THROW(network.getOutputsInfo(), InferenceEngine::Exception); -} - -TEST_F(CNNNetworkTests, throwsOnUninitializedGetInputsInfo) { - CNNNetwork network; - ASSERT_THROW(network.getInputsInfo(), InferenceEngine::Exception); -} - -TEST_F(CNNNetworkTests, throwsOnUninitializedLayerCount) { - CNNNetwork network; - ASSERT_THROW(network.layerCount(), InferenceEngine::Exception); -} - -TEST_F(CNNNetworkTests, throwsOnUninitializedGetName) { - CNNNetwork network; - ASSERT_THROW(network.getName(), InferenceEngine::Exception); -} - -TEST_F(CNNNetworkTests, throwsOnUninitializedGetFunction) { - CNNNetwork network; - ASSERT_THROW(network.getFunction(), InferenceEngine::Exception); -} - -TEST_F(CNNNetworkTests, throwsOnConstUninitializedGetFunction) { - const CNNNetwork network; - ASSERT_THROW(network.getFunction(), InferenceEngine::Exception); -} - -TEST_F(CNNNetworkTests, throwsOnConstUninitializedBegin) { - CNNNetwork network; - ASSERT_THROW(network.getFunction(), InferenceEngine::Exception); -} - -TEST_F(CNNNetworkTests, throwsOnConstUninitializedGetInputShapes) { - CNNNetwork network; - ASSERT_THROW(network.getInputShapes(), InferenceEngine::Exception); -} - -static std::shared_ptr CNNNetworkTests_create_model() { - auto param1 = std::make_shared(ov::element::f32, ov::PartialShape::dynamic()); - param1->set_friendly_name("p1_friendly"); - param1->output(0).set_names({"p1_1", "p1_2"}); - auto param2 = std::make_shared(ov::element::f32, ov::PartialShape{-1, 3, 224, 224}); - param2->set_friendly_name("p2_friendly"); - param2->output(0).set_names({"p2_1", "p2_2"}); - auto param3 = std::make_shared(ov::element::f32, ov::PartialShape{1, 3, 224, 224}); - param3->set_friendly_name("p3_friendly"); - param3->output(0).set_names({"p3_1", "p3_2"}); - return std::make_shared(ov::OutputVector{param1, param2, param3}, - ov::ParameterVector{param1, param2, param3}); -} - -TEST_F(CNNNetworkTests, throwsHasDynamicInputs) { - auto model = CNNNetworkTests_create_model(); - CNNNetwork network(model); - InferenceEngine::Core core; - try { - core.LoadNetwork(network); - FAIL() << "LoadNetwork with dynamic inputs shall throw"; - } catch (const InferenceEngine::Exception& e) { - EXPECT_TRUE(std::string(e.what()).find("InferenceEngine::Core::LoadNetwork") != std::string::npos) << e.what(); - EXPECT_TRUE(std::string(e.what()).find("p1_1") != std::string::npos) << e.what(); - EXPECT_TRUE(std::string(e.what()).find("p1_2") != std::string::npos) << e.what(); - EXPECT_TRUE(std::string(e.what()).find("p2_1") != std::string::npos) << e.what(); - EXPECT_TRUE(std::string(e.what()).find("p2_2") != std::string::npos) << e.what(); - EXPECT_TRUE(std::string(e.what()).find("p3_1") == std::string::npos) << e.what(); - EXPECT_TRUE(std::string(e.what()).find("p3_2") == std::string::npos) << e.what(); - } -} - -TEST_F(CNNNetworkTests, throwsHasDynamicInputs_queryNetwork) { - auto model = CNNNetworkTests_create_model(); - CNNNetwork network(model); - InferenceEngine::Core core; - try { - core.QueryNetwork(network, "mock"); - FAIL() << "QueryNetwork with dynamic inputs shall throw"; - } catch (const InferenceEngine::Exception& e) { - EXPECT_TRUE(std::string(e.what()).find("InferenceEngine::Core::QueryNetwork") != std::string::npos) << e.what(); - EXPECT_TRUE(std::string(e.what()).find("p1_1") != std::string::npos) << e.what(); - EXPECT_TRUE(std::string(e.what()).find("p1_2") != std::string::npos) << e.what(); - EXPECT_TRUE(std::string(e.what()).find("p2_1") != std::string::npos) << e.what(); - EXPECT_TRUE(std::string(e.what()).find("p2_2") != std::string::npos) << e.what(); - EXPECT_TRUE(std::string(e.what()).find("p3_1") == std::string::npos) << e.what(); - EXPECT_TRUE(std::string(e.what()).find("p3_2") == std::string::npos) << e.what(); - } -} diff --git a/src/inference/tests/functional/core_threading.cpp b/src/inference/tests/functional/core_threading.cpp deleted file mode 100644 index 6850f638c568f8..00000000000000 --- a/src/inference/tests/functional/core_threading.cpp +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "openvino/util/file_util.hpp" -#ifdef __GLIBC__ -# include -# if __GLIBC_MINOR__ < 34 -# define OV_TEST_GLIBC_VERSION_LESS_2_34 -# endif -#endif - -class IECoreThreadingTests : public ::testing::Test { -protected: - std::string modelName = "IECoreThreadingTests.xml", weightsName = "IECoreThreadingTests.bin"; - -public: - void SetUp() override { - auto prefix = ov::test::utils::generateTestFilePrefix(); - modelName = prefix + modelName; - weightsName = prefix + weightsName; - ov::test::utils::generate_test_model(modelName, weightsName); - } - - void TearDown() override { - ov::test::utils::removeIRFiles(modelName, weightsName); - } - - void runParallel(std::function func, - const unsigned int iterations = 100, - const unsigned int threadsNum = 8) { - std::vector threads(threadsNum); - - for (auto& thread : threads) { - thread = std::thread([&]() { - for (unsigned int i = 0; i < iterations; ++i) { - func(); - } - }); - } - - for (auto& thread : threads) { - if (thread.joinable()) - thread.join(); - } - } -}; - -// tested function: SetConfig -TEST_F(IECoreThreadingTests, SetConfigPluginDoesNotExist) { - InferenceEngine::Core ie; - std::map localConfig = { - {CONFIG_KEY(PERF_COUNT), InferenceEngine::PluginConfigParams::YES}}; - - runParallel( - [&]() { - ie.SetConfig(localConfig); - }, - 10000); -} - -// TODO: CVS-68982 -#ifndef OPENVINO_STATIC_LIBRARY - -// tested function: RegisterPlugin -TEST_F(IECoreThreadingTests, RegisterPlugin) { - InferenceEngine::Core ie; - std::atomic index{0}; - runParallel( - [&]() { - const std::string deviceName = std::to_string(index++); - ie.RegisterPlugin(ov::util::make_plugin_library_name(ov::test::utils::getExecutableDirectory(), - std::string("mock_engine") + OV_BUILD_POSTFIX), - deviceName); - ie.GetVersions(deviceName); - ie.UnregisterPlugin(deviceName); - }, - 4000); -} - -// tested function: RegisterPlugins -TEST_F(IECoreThreadingTests, RegisterPlugins) { - InferenceEngine::Core ie; - std::atomic index{0}; - - auto getPluginXml = [&]() -> std::tuple { - std::string indexStr = std::to_string(index++); - std::string pluginsXML = "test_plugins" + indexStr + ".xml"; - std::ofstream file(pluginsXML); - - file << "::file_separator; - file << ov::util::FileTraits::library_prefix(); - file << "mock_engine"; - file << OV_BUILD_POSTFIX; - file << ov::util::FileTraits::dot_symbol; - file << ov::util::FileTraits::library_ext(); - file << "\" name=\""; - file << indexStr; - file << "\">"; - file.flush(); - file.close(); - - return std::tie(pluginsXML, indexStr); - }; - - runParallel( - [&]() { - std::string fileName, deviceName; - std::tie(fileName, deviceName) = getPluginXml(); - ie.RegisterPlugins(fileName); - ie.GetVersions(deviceName); - ASSERT_EQ(0, std::remove(fileName.c_str())); - }, - 1000); -} - -#endif // !OPENVINO_STATIC_LIBRARY - -// tested function: GetAvailableDevices, UnregisterPlugin -// TODO: some initialization (e.g. thread/dlopen) sporadically fails during such stress-test scenario -TEST_F(IECoreThreadingTests, GetAvailableDevices) { -#ifdef OV_TEST_GLIBC_VERSION_LESS_2_34 - GTEST_SKIP(); -#endif - InferenceEngine::Core ie; - runParallel( - [&]() { - std::vector devices = ie.GetAvailableDevices(); - - // unregister all the devices - for (auto&& deviceName : devices) { - try { - ie.UnregisterPlugin(deviceName); - } catch (const InferenceEngine::Exception& ex) { - // if several threads unload plugin at once, the first thread does this - // while all others will throw an exception that plugin is not registered - ASSERT_STR_CONTAINS(ex.what(), "name is not registered in the"); - } - } - }, - 30); -} diff --git a/src/inference/tests/functional/data_test.cpp b/src/inference/tests/functional/data_test.cpp deleted file mode 100644 index e3ff4e6f69f1d0..00000000000000 --- a/src/inference/tests/functional/data_test.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include -#include - -using namespace ::testing; -using namespace std; -using namespace InferenceEngine; -IE_SUPPRESS_DEPRECATED_START - -class DataTests : public ::testing::Test { -protected: - const std::string data_name = "test_data_name"; - const Precision precision = Precision::FP32; - - const SizeVector notEmptyDims = {1, 1, 1, 1}; - const SizeVector emptyDims = {}; - const size_t batchSize = 1; - - class BlockingDescTest : public BlockingDesc { - public: - BlockingDescTest(const SizeVector& blocked_dims, const SizeVector& order) : BlockingDesc(blocked_dims, order) {} - - void fillDescTest(const SizeVector& blocked_dims, const SizeVector& order) { - fillDesc(blocked_dims, order); - } - }; -}; - -TEST_F(DataTests, canSetEmptyDimsForDataDefault) { - Data data(data_name, precision); - ASSERT_NO_THROW(data.setDims(emptyDims)); - ASSERT_FALSE(data.isInitialized()); -} - -TEST_F(DataTests, canSetEmptyDimsForDataBlocked) { - Data data(data_name, precision, BLOCKED); - ASSERT_NO_THROW(data.setDims(emptyDims)); -} - -TEST_F(DataTests, canSetNotEmptyDimsForDataBlocked) { - Data data(data_name, precision, BLOCKED); - ASSERT_NO_THROW(data.setDims(notEmptyDims)); -} - -TEST_F(DataTests, canSetNotEmptyDimsForDataNCHW) { - Data data(data_name, precision, NCHW); - ASSERT_NO_THROW(data.setDims(notEmptyDims)); - ASSERT_TRUE(data.isInitialized()); -} - -TEST_F(DataTests, canSetEmptyDimsForTensorDescNCHW) { - TensorDesc desc(precision, emptyDims, NCHW); - ASSERT_NO_THROW(desc.setDims(emptyDims)); -} - -TEST_F(DataTests, canSetEmptyDimsForTensorDescBlocked) { - TensorDesc desc(precision, emptyDims, BLOCKED); - ASSERT_NO_THROW(desc.setDims(emptyDims)); -} - -TEST_F(DataTests, canSetNotEmptyDimsForTensorDescBlocked) { - TensorDesc desc(precision, notEmptyDims, BLOCKED); - ASSERT_NO_THROW(desc.setDims(notEmptyDims)); -} - -TEST_F(DataTests, canSetEmptyDimsForBlockingDescOrder) { - ASSERT_NO_THROW(BlockingDesc(emptyDims, emptyDims)); -} - -TEST_F(DataTests, throwOnFillDescByEmptyDimsForBlockingDesc) { - BlockingDescTest desc(emptyDims, emptyDims); - ASSERT_THROW(desc.fillDescTest(emptyDims, emptyDims), Exception); -} - -TEST_F(DataTests, throwOnSetEmptyDimsForBlockingDescBlocked) { - ASSERT_NO_THROW(BlockingDesc(emptyDims, BLOCKED)); -} - -TEST_F(DataTests, throwOnSetEmptyDimsForBlockingDescNCHW) { - ASSERT_NO_THROW(BlockingDesc(emptyDims, NCHW)); -} - -TEST_F(DataTests, canSetNotEmptyDimsForBlockingDescBlocked) { - ASSERT_NO_THROW(BlockingDesc(notEmptyDims, BLOCKED)); -} - -TEST_F(DataTests, canSetNotEmptyDimsForBlockingDescNCHW) { - ASSERT_NO_THROW(BlockingDesc(notEmptyDims, NCHW)); -} - -TEST_F(DataTests, setPrecision) { - Data data(data_name, {Precision::FP32, emptyDims, Layout::NCHW}); - - EXPECT_EQ(Precision::FP32, data.getPrecision()); - EXPECT_EQ(Precision::FP32, data.getTensorDesc().getPrecision()); - - data.setPrecision(Precision::FP16); - EXPECT_EQ(Precision::FP16, data.getPrecision()); - EXPECT_EQ(Precision::FP16, data.getTensorDesc().getPrecision()); -} diff --git a/src/inference/tests/functional/executable_network.cpp b/src/inference/tests/functional/executable_network.cpp deleted file mode 100644 index 5d741e876749c4..00000000000000 --- a/src/inference/tests/functional/executable_network.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include - -#include - -using namespace ::testing; -using namespace std; -using namespace InferenceEngine; -using namespace InferenceEngine::details; - -TEST(ExecutableNetworkTests, throwsOnUninitializedGetOutputsInfo) { - ExecutableNetwork exec; - ASSERT_THROW(exec.GetOutputsInfo(), InferenceEngine::NotAllocated); -} - -TEST(ExecutableNetworkTests, throwsOnUninitializedGetInputsInfo) { - ExecutableNetwork exec; - ASSERT_THROW(exec.GetInputsInfo(), InferenceEngine::NotAllocated); -} - -TEST(ExecutableNetworkTests, throwsOnUninitializedExport) { - ExecutableNetwork exec; - ASSERT_THROW(exec.Export(std::string()), InferenceEngine::NotAllocated); -} - -TEST(ExecutableNetworkTests, throwsOnUninitializedExportStream) { - ExecutableNetwork exec; - ASSERT_THROW(exec.Export(std::cout), InferenceEngine::NotAllocated); -} - -TEST(ExecutableNetworkTests, throwsOnUninitializedGetExecGraphInfo) { - ExecutableNetwork exec; - ASSERT_THROW(exec.GetExecGraphInfo(), InferenceEngine::NotAllocated); -} - -TEST(ExecutableNetworkTests, throwsOnUninitializedSetConfig) { - ExecutableNetwork exec; - ASSERT_THROW(exec.SetConfig({{}}), InferenceEngine::NotAllocated); -} - -TEST(ExecutableNetworkTests, throwsOnUninitializedGetConfig) { - ExecutableNetwork exec; - ASSERT_THROW(exec.GetConfig({}), InferenceEngine::NotAllocated); -} - -TEST(ExecutableNetworkTests, throwsOnUninitializedGetMetric) { - ExecutableNetwork exec; - ASSERT_THROW(exec.GetMetric({}), InferenceEngine::NotAllocated); -} diff --git a/src/inference/tests/functional/get_supported_property_test.cpp b/src/inference/tests/functional/get_supported_property_test.cpp index c1fea82d2552de..4bb7ffa2ef6946 100644 --- a/src/inference/tests/functional/get_supported_property_test.cpp +++ b/src/inference/tests/functional/get_supported_property_test.cpp @@ -14,7 +14,7 @@ #include "openvino/util/file_util.hpp" #include "openvino/util/shared_object.hpp" -using TestParam = std::tuple; +using TestParam = std::tuple; class GetPropertyTest : public ::testing::TestWithParam { public: ov::Core core; @@ -22,6 +22,7 @@ class GetPropertyTest : public ::testing::TestWithParam { void SetUp() override { m_properties = std::get<0>(GetParam()); m_expected_properties = std::get<1>(GetParam()); + m_keep_core_property = std::get<2>(GetParam()); } void reg_plugin(ov::Core& core, std::shared_ptr& plugin) { @@ -47,6 +48,7 @@ class GetPropertyTest : public ::testing::TestWithParam { std::shared_ptr m_mock_plugin; ov::AnyMap m_properties; ov::AnyMap m_expected_properties; + bool m_keep_core_property; std::string m_plugin_name{"MOCK_HARDWARE"}; }; @@ -73,7 +75,8 @@ TEST_P(GetPropertyTest, canGenerateCorrectPropertyList) { reg_plugin(core, base_plugin); core.get_property(m_plugin_name, ov::supported_properties); std::map config; - auto actual_output = m_mock_plugin->get_core()->get_supported_property(m_plugin_name, m_properties); + auto actual_output = + m_mock_plugin->get_core()->get_supported_property(m_plugin_name, m_properties, m_keep_core_property); for (auto& iter : m_expected_properties) { ASSERT_TRUE(actual_output.find(iter.first) != actual_output.end()); ASSERT_EQ(actual_output.find(iter.first)->second, iter.second); @@ -87,14 +90,23 @@ TEST_P(GetPropertyTest, canGenerateCorrectPropertyList) { static const std::vector test_variants = { TestParam{ov::AnyMap({ov::hint::allow_auto_batching(false), ov::num_streams(2)}), - ov::AnyMap({ov::hint::allow_auto_batching(false), ov::num_streams(2)})}, + ov::AnyMap({ov::hint::allow_auto_batching(false), ov::num_streams(2)}), + true}, TestParam{ov::AnyMap({ov::auto_batch_timeout(0), ov::enable_profiling(false)}), - ov::AnyMap({ov::auto_batch_timeout(0)})}, + ov::AnyMap({ov::auto_batch_timeout(0)}), + true}, TestParam{ov::AnyMap({ov::cache_dir("test"), ov::force_tbb_terminate(false)}), - ov::AnyMap({ov::cache_dir("test"), ov::force_tbb_terminate(false)})}, + ov::AnyMap({ov::cache_dir("test"), ov::force_tbb_terminate(false)}), + true}, TestParam{ov::AnyMap({ov::cache_dir("test"), ov::device::properties("MOCK_HARDWARE", ov::num_streams(2), ov::enable_profiling(true))}), - ov::AnyMap({ov::cache_dir("test"), ov::num_streams(2)})}, + ov::AnyMap({ov::cache_dir("test"), ov::num_streams(2)}), + true}, + TestParam{ov::AnyMap({ov::num_streams(2)}), ov::AnyMap({ov::num_streams(2)}), false}, + TestParam{ov::AnyMap({ov::cache_dir("test")}), ov::AnyMap({}), false}, + TestParam{ov::AnyMap({ov::hint::allow_auto_batching(false)}), ov::AnyMap({}), false}, + TestParam{ov::AnyMap({ov::auto_batch_timeout(0)}), ov::AnyMap({}), false}, + TestParam{ov::AnyMap({ov::force_tbb_terminate(false)}), ov::AnyMap({}), false}, }; INSTANTIATE_TEST_SUITE_P(GetSupportedPropertyTest, diff --git a/src/inference/tests/functional/ie_precision_test.cpp b/src/inference/tests/functional/ie_precision_test.cpp deleted file mode 100644 index 65bb27f0e476ab..00000000000000 --- a/src/inference/tests/functional/ie_precision_test.cpp +++ /dev/null @@ -1,172 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include - -#include -#include - -IE_SUPPRESS_DEPRECATED_START - -using Precision = InferenceEngine::Precision; - -using PrecisionTests = ::testing::Test; - -TEST_F(PrecisionTests, ShowsCorrectPrecisionNames) { - EXPECT_STREQ(Precision(Precision::I64).name(), "I64"); - EXPECT_STREQ(Precision(Precision::U64).name(), "U64"); - EXPECT_STREQ(Precision(Precision::BF16).name(), "BF16"); - EXPECT_STREQ(Precision(Precision::FP16).name(), "FP16"); - EXPECT_STREQ(Precision(Precision::FP32).name(), "FP32"); - EXPECT_STREQ(Precision(Precision::FP64).name(), "FP64"); - EXPECT_STREQ(Precision(Precision::I16).name(), "I16"); - EXPECT_STREQ(Precision(Precision::I32).name(), "I32"); - EXPECT_STREQ(Precision(Precision::U32).name(), "U32"); - EXPECT_STREQ(Precision(Precision::U16).name(), "U16"); - EXPECT_STREQ(Precision(Precision::I4).name(), "I4"); - EXPECT_STREQ(Precision(Precision::I8).name(), "I8"); - EXPECT_STREQ(Precision(Precision::Q78).name(), "Q78"); - EXPECT_STREQ(Precision(Precision::U4).name(), "U4"); - EXPECT_STREQ(Precision(Precision::U8).name(), "U8"); - EXPECT_STREQ(Precision(Precision::MIXED).name(), "MIXED"); - EXPECT_STREQ(Precision(Precision::UNSPECIFIED).name(), "UNSPECIFIED"); - EXPECT_STREQ(Precision(static_cast(-3)).name(), "UNSPECIFIED"); - EXPECT_STREQ(Precision(1, "Custom Name").name(), "Custom Name"); -} - -TEST_F(PrecisionTests, sizeIsCorrect) { - EXPECT_EQ(Precision(Precision::I64).size(), 8); - EXPECT_EQ(Precision(Precision::U64).size(), 8); - EXPECT_EQ(Precision(Precision::BF16).size(), 2); - EXPECT_EQ(Precision(Precision::FP16).size(), 2); - EXPECT_EQ(Precision(Precision::FP32).size(), 4); - EXPECT_EQ(Precision(Precision::FP64).size(), 8); - EXPECT_EQ(Precision(Precision::I32).size(), 4); - EXPECT_EQ(Precision(Precision::U32).size(), 4); - EXPECT_EQ(Precision(Precision::I16).size(), 2); - EXPECT_EQ(Precision(Precision::U16).size(), 2); - EXPECT_EQ(Precision(Precision::I4).size(), 1); - EXPECT_EQ(Precision(Precision::I8).size(), 1); - EXPECT_EQ(Precision(Precision::Q78).size(), 2); - EXPECT_EQ(Precision(Precision::U8).size(), 1); - EXPECT_EQ(Precision(Precision::U4).size(), 1); - EXPECT_EQ(Precision(10 * 8).size(), 10); - EXPECT_THROW(Precision(Precision::MIXED).size(), InferenceEngine::Exception); - EXPECT_THROW(Precision(Precision::UNSPECIFIED).size(), InferenceEngine::Exception); -} - -TEST_F(PrecisionTests, bitsSizeIsCorrect) { - EXPECT_EQ(Precision(Precision::I64).bitsSize(), 64); - EXPECT_EQ(Precision(Precision::U64).bitsSize(), 64); - EXPECT_EQ(Precision(Precision::BF16).bitsSize(), 16); - EXPECT_EQ(Precision(Precision::FP16).bitsSize(), 16); - EXPECT_EQ(Precision(Precision::FP32).bitsSize(), 32); - EXPECT_EQ(Precision(Precision::FP64).bitsSize(), 64); - EXPECT_EQ(Precision(Precision::I32).bitsSize(), 32); - EXPECT_EQ(Precision(Precision::U32).bitsSize(), 32); - EXPECT_EQ(Precision(Precision::I16).bitsSize(), 16); - EXPECT_EQ(Precision(Precision::U16).bitsSize(), 16); - EXPECT_EQ(Precision(Precision::I4).bitsSize(), 4); - EXPECT_EQ(Precision(Precision::I8).bitsSize(), 8); - EXPECT_EQ(Precision(Precision::Q78).bitsSize(), 16); - EXPECT_EQ(Precision(Precision::U8).bitsSize(), 8); - EXPECT_EQ(Precision(Precision::U4).bitsSize(), 4); - EXPECT_EQ(Precision(10 * 8).bitsSize(), 80); - EXPECT_THROW(Precision(Precision::MIXED).bitsSize(), InferenceEngine::Exception); - EXPECT_THROW(Precision(Precision::UNSPECIFIED).bitsSize(), InferenceEngine::Exception); -} - -TEST_F(PrecisionTests, is_float) { - EXPECT_TRUE(Precision(Precision::BF16).is_float()); - EXPECT_TRUE(Precision(Precision::FP16).is_float()); - EXPECT_TRUE(Precision(Precision::FP32).is_float()); - EXPECT_TRUE(Precision(Precision::FP64).is_float()); - EXPECT_FALSE(Precision(Precision::I64).is_float()); - EXPECT_FALSE(Precision(Precision::U64).is_float()); - EXPECT_FALSE(Precision(Precision::I32).is_float()); - EXPECT_FALSE(Precision(Precision::U32).is_float()); - EXPECT_FALSE(Precision(Precision::I16).is_float()); - EXPECT_FALSE(Precision(Precision::U16).is_float()); - EXPECT_FALSE(Precision(Precision::I8).is_float()); - EXPECT_FALSE(Precision(Precision::I4).is_float()); - EXPECT_FALSE(Precision(Precision::Q78).is_float()); - EXPECT_FALSE(Precision(Precision::U4).is_float()); - EXPECT_FALSE(Precision(Precision::U8).is_float()); - EXPECT_FALSE(Precision(Precision::MIXED).is_float()); - EXPECT_FALSE(Precision(10).is_float()); - EXPECT_FALSE(Precision(static_cast(-3)).is_float()); - EXPECT_FALSE(Precision(Precision::UNSPECIFIED).is_float()); -} - -TEST_F(PrecisionTests, constructFromSTR) { - EXPECT_EQ(Precision(Precision::I64), Precision::FromStr("I64")); - EXPECT_EQ(Precision(Precision::U64), Precision::FromStr("U64")); - EXPECT_EQ(Precision(Precision::BF16), Precision::FromStr("BF16")); - EXPECT_EQ(Precision(Precision::FP16), Precision::FromStr("FP16")); - EXPECT_EQ(Precision(Precision::FP32), Precision::FromStr("FP32")); - EXPECT_EQ(Precision(Precision::FP64), Precision::FromStr("FP64")); - EXPECT_EQ(Precision(Precision::I32), Precision::FromStr("I32")); - EXPECT_EQ(Precision(Precision::U32), Precision::FromStr("U32")); - EXPECT_EQ(Precision(Precision::I16), Precision::FromStr("I16")); - EXPECT_EQ(Precision(Precision::U16), Precision::FromStr("U16")); - EXPECT_EQ(Precision(Precision::I4), Precision::FromStr("I4")); - EXPECT_EQ(Precision(Precision::I8), Precision::FromStr("I8")); - EXPECT_EQ(Precision(Precision::Q78), Precision::FromStr("Q78")); - EXPECT_EQ(Precision(Precision::U4), Precision::FromStr("U4")); - EXPECT_EQ(Precision(Precision::U8), Precision::FromStr("U8")); - EXPECT_EQ(Precision(Precision::MIXED), Precision::FromStr("MIXED")); - EXPECT_EQ(Precision(static_cast(-3)), Precision::FromStr("UNSPECIFIED")); - EXPECT_EQ(Precision(Precision::UNSPECIFIED), Precision::FromStr("UNSPECIFIED")); -} - -TEST_F(PrecisionTests, canCompareCustomPrecisions) { - Precision p(12); - Precision p1(12, "XXX"); - EXPECT_FALSE(p == p1); - - std::string d; - d.push_back('X'); - d.push_back('X'); - d.push_back('X'); - Precision p2(12, d.c_str()); - EXPECT_TRUE(p2 == p1); - - Precision p3(13, "XXX"); - EXPECT_FALSE(p3 == p1); - - Precision p4(13); - EXPECT_FALSE(p4 == p); - - Precision p5(12); - EXPECT_TRUE(p5 == p); -} - -TEST_F(PrecisionTests, canUseInIfs) { - Precision p; - EXPECT_TRUE(!p); - p = Precision::FP32; - EXPECT_FALSE(!p); - EXPECT_TRUE(p); - p = Precision(static_cast(-3)); - EXPECT_TRUE(!p); -} - -TEST_F(PrecisionTests, canCreateFromStruct) { - struct X { - int a; - int b; - }; - auto precision = Precision::fromType(); - EXPECT_EQ(precision.size(), sizeof(X)); -} - -TEST_F(PrecisionTests, canCreateMoreThan255bitsPrecisions) { - struct Y { - uint8_t a[257]; - }; - - EXPECT_NO_THROW(Precision::fromType()); - EXPECT_EQ(Precision::fromType().size(), 257); -} diff --git a/src/inference/tests/functional/import_model.cpp b/src/inference/tests/functional/import_model.cpp new file mode 100644 index 00000000000000..e5864f8eb99c8a --- /dev/null +++ b/src/inference/tests/functional/import_model.cpp @@ -0,0 +1,15 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "common_test_utils/common_utils.hpp" +#include "gtest/gtest.h" +#include "openvino/runtime/core.hpp" + +// Test is disabled due to issue 128924 +TEST(ImportModel, DISABLED_ImportModelWithNullContextThrows) { + ov::Core core; + ov::RemoteContext context; + std::istringstream stream("None"); + ASSERT_THROW(core.import_model(stream, context, {}), ov::Exception); +} diff --git a/src/inference/tests/functional/matmul_sr_tests.cpp b/src/inference/tests/functional/matmul_sr_tests.cpp index 3d17cfd915fa58..9e073ed17185c4 100644 --- a/src/inference/tests/functional/matmul_sr_tests.cpp +++ b/src/inference/tests/functional/matmul_sr_tests.cpp @@ -12,7 +12,6 @@ #include "common_test_utils/graph_comparator.hpp" #include "common_test_utils/ov_test_utils.hpp" #include "common_test_utils/test_common.hpp" -#include "ie_common.h" #include "openvino/op/add.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/matmul.hpp" diff --git a/src/inference/tests/functional/ov_extension_test.cpp b/src/inference/tests/functional/ov_extension_test.cpp index 08a60b81e44e08..ca2cefca071745 100644 --- a/src/inference/tests/functional/ov_extension_test.cpp +++ b/src/inference/tests/functional/ov_extension_test.cpp @@ -8,7 +8,6 @@ #include "openvino/util/file_util.hpp" using namespace testing; -using namespace InferenceEngine; using namespace ov::test::utils; namespace { diff --git a/src/inference/tests/functional/ov_infer_request_test.cpp b/src/inference/tests/functional/ov_infer_request_test.cpp index 8aede54728dccc..935b056b2fef7e 100644 --- a/src/inference/tests/functional/ov_infer_request_test.cpp +++ b/src/inference/tests/functional/ov_infer_request_test.cpp @@ -12,8 +12,6 @@ using namespace ::testing; using namespace std; -using namespace InferenceEngine; -using namespace InferenceEngine::details; TEST(InferRequestOVTests, throwsOnUninitializedSetTensor) { ov::InferRequest req; diff --git a/src/inference/tests/functional/ov_shared_object_test.cpp b/src/inference/tests/functional/ov_shared_object_test.cpp index 3c268ea94fa610..424adb88cddcbc 100644 --- a/src/inference/tests/functional/ov_shared_object_test.cpp +++ b/src/inference/tests/functional/ov_shared_object_test.cpp @@ -2,9 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // -#include #include +#include + #include "common_test_utils/file_utils.hpp" #include "cpp_interfaces/interface/ie_iplugin_internal.hpp" #include "openvino/util/shared_object.hpp" @@ -15,8 +16,8 @@ using namespace std; class SharedObjectOVTests : public ::testing::Test { protected: std::string get_mock_engine_name() { - return FileUtils::makePluginLibraryName(ov::test::utils::getExecutableDirectory(), - std::string("mock_engine") + OV_BUILD_POSTFIX); + return ov::util::make_plugin_library_name(ov::test::utils::getExecutableDirectory(), + std::string("mock_engine") + OV_BUILD_POSTFIX); } void loadDll(const string& libraryName) { diff --git a/src/inference/tests/functional/pre_allocator_test.cpp b/src/inference/tests/functional/pre_allocator_test.cpp deleted file mode 100644 index eb0099884050dd..00000000000000 --- a/src/inference/tests/functional/pre_allocator_test.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include - -#include - -#include "details/ie_pre_allocator.hpp" -#include "ie_allocator.hpp" - -using namespace ::testing; -using namespace std; -using namespace InferenceEngine; - -IE_SUPPRESS_DEPRECATED_START - -class PreallocatorTests : public ::testing::Test { -protected: - std::vector mybuf; - - void SetUp() override { - mybuf.resize(10); - allocator = details::make_pre_allocator(&*mybuf.begin(), mybuf.size()); - } - std::shared_ptr allocator; -}; - -TEST_F(PreallocatorTests, canAccessPreAllocatedMemory) { - void* handle = allocator->alloc(3); - float* ptr = reinterpret_cast(allocator->lock(handle)); - - mybuf = {1.1f, 2.2f, 3.3f}; - - ASSERT_EQ(ptr, &*mybuf.begin()); - ASSERT_EQ(ptr[0], 1.1f); - ASSERT_EQ(ptr[1], 2.2f); - ASSERT_EQ(ptr[2], 3.3f); -} - -TEST_F(PreallocatorTests, canNotAllocateMoreMemory) { - // large block such as 10k will result in nullptr - EXPECT_EQ(nullptr, allocator->lock(allocator->alloc(10 * sizeof(float) + 1))); - EXPECT_NE(nullptr, allocator->lock(allocator->alloc(10 * sizeof(float)))); -} - -TEST_F(PreallocatorTests, canNotLockWrongHandle) { - void* handle = allocator->alloc(3); - EXPECT_EQ(nullptr, allocator->lock(1 + reinterpret_cast(handle))); -} diff --git a/src/inference/tests/functional/tensor_desc_test.cpp b/src/inference/tests/functional/tensor_desc_test.cpp deleted file mode 100644 index 64dc1372e926c1..00000000000000 --- a/src/inference/tests/functional/tensor_desc_test.cpp +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include -#include - -#include -#include - -using namespace ::testing; -using namespace std; -using namespace InferenceEngine; - -IE_SUPPRESS_DEPRECATED_START - -using TensorDescTests = ::testing::Test; - -TEST_F(TensorDescTests, CreateBlobWithIncorrectLayout) { - ASSERT_THROW(make_shared_blob({Precision::FP32, {1, 3, 32}, Layout::NC}), Exception); -} - -TEST_F(TensorDescTests, CreateBlockedBlobNCHW) { - TensorDesc desc(Precision::FP32, {1, 4, 2, 1}, {{1, 2, 2, 1, 2}, {0, 1, 2, 3, 1}}); - float data[8] = {1, 2, 3, 4, 5, 6, 7, 8}; - Blob::Ptr blockedBlob = make_shared_blob(desc, data); - Blob::Ptr nchwBlob = make_shared_blob({Precision::FP32, {1, 4, 2, 1}, Layout::NCHW}, data); - ASSERT_NE(blockedBlob->getTensorDesc().offset(5), nchwBlob->getTensorDesc().offset(5)); - ASSERT_EQ(6, blockedBlob->getTensorDesc().offset(5)); - ASSERT_EQ(5, nchwBlob->getTensorDesc().offset(5)); - ASSERT_EQ(Layout::NCHW, nchwBlob->getTensorDesc().getLayout()); - ASSERT_EQ(Layout::BLOCKED, blockedBlob->getTensorDesc().getLayout()); -} - -TEST_F(TensorDescTests, CreateBlockedBlobNCDHW) { - TensorDesc desc(Precision::FP32, {1, 4, 2, 2, 1}, {{1, 2, 2, 2, 1, 2}, {0, 1, 2, 3, 4, 1}}); - float data[8] = {1, 2, 3, 4, 5, 6, 7, 8}; - Blob::Ptr blockedBlob = make_shared_blob(desc, data); - Blob::Ptr ncdhwBlob = make_shared_blob({Precision::FP32, {1, 4, 2, 2, 1}, Layout::NCDHW}, data); - ASSERT_NE(blockedBlob->getTensorDesc().offset(6), ncdhwBlob->getTensorDesc().offset(6)); - ASSERT_EQ(5, blockedBlob->getTensorDesc().offset(6)); - ASSERT_EQ(6, ncdhwBlob->getTensorDesc().offset(6)); - ASSERT_EQ(Layout::NCDHW, ncdhwBlob->getTensorDesc().getLayout()); - ASSERT_EQ(Layout::BLOCKED, blockedBlob->getTensorDesc().getLayout()); -} - -TEST_F(TensorDescTests, CompareHWCandCHWLayouts) { - TensorDesc descCHW(Precision::FP32, {1, 3, 4}, Layout::CHW); - TensorDesc descHWC(Precision::FP32, {1, 3, 4}, Layout::HWC); - SizeVector chw = {0, 1, 2}; - SizeVector hwc = {1, 2, 0}; - - ASSERT_NE(descCHW, descHWC); - ASSERT_NE(descCHW.getBlockingDesc(), descHWC.getBlockingDesc()); - ASSERT_NE(descCHW.getBlockingDesc().getOrder(), descHWC.getBlockingDesc().getOrder()); - ASSERT_EQ(descCHW.getBlockingDesc().getOrder(), chw); - ASSERT_EQ(descHWC.getBlockingDesc().getOrder(), hwc); -} - -TEST_F(TensorDescTests, CompareNHWCandNCHWLayouts) { - TensorDesc descNCHW(Precision::FP32, {1, 3, 4, 2}, Layout::NCHW); - TensorDesc descNHWC(Precision::FP32, {1, 3, 4, 2}, Layout::NHWC); - SizeVector nchw = {0, 1, 2, 3}; - SizeVector nhwc = {0, 2, 3, 1}; - - ASSERT_NE(descNCHW, descNHWC); - ASSERT_NE(descNCHW.getBlockingDesc(), descNHWC.getBlockingDesc()); - ASSERT_NE(descNCHW.getBlockingDesc().getOrder(), descNHWC.getBlockingDesc().getOrder()); - ASSERT_EQ(descNCHW.getBlockingDesc().getOrder(), nchw); - ASSERT_EQ(descNHWC.getBlockingDesc().getOrder(), nhwc); -} - -TEST_F(TensorDescTests, CompareNDHWCandNCDHWLayouts) { - TensorDesc descNCDHW(Precision::FP32, {1, 3, 4, 4, 2}, Layout::NCDHW); - TensorDesc descNDHWC(Precision::FP32, {1, 3, 4, 4, 2}, Layout::NDHWC); - SizeVector ncdhw = {0, 1, 2, 3, 4}; - SizeVector ndhwc = {0, 2, 3, 4, 1}; - - ASSERT_NE(descNCDHW, descNDHWC); - ASSERT_NE(descNCDHW.getBlockingDesc(), descNDHWC.getBlockingDesc()); - ASSERT_NE(descNCDHW.getBlockingDesc().getOrder(), descNDHWC.getBlockingDesc().getOrder()); - ASSERT_EQ(descNCDHW.getBlockingDesc().getOrder(), ncdhw); - ASSERT_EQ(descNDHWC.getBlockingDesc().getOrder(), ndhwc); -} - -TEST_F(TensorDescTests, SetLayout) { - TensorDesc descNCHW(Precision::FP32, {1, 2, 3, 4}, Layout::NCHW); - TensorDesc decsNHWC = descNCHW; - decsNHWC.setLayout(Layout::NHWC); - - TensorDesc refNHWC(descNCHW.getPrecision(), descNCHW.getDims(), Layout::NHWC); - ASSERT_EQ(decsNHWC, refNHWC); -} - -TEST_F(TensorDescTests, setDimsForBLOCKED) { - TensorDesc desc(Precision::FP32, {1, 2, 3, 4, 5, 6}, Layout::BLOCKED); - SizeVector newDims{7, 7, 7, 7, 7, 7}; - desc.setDims(newDims); - EXPECT_EQ(desc.getDims(), newDims); - EXPECT_EQ(desc.getBlockingDesc().getBlockDims(), newDims); -} - -TEST_F(TensorDescTests, setDimsForNHWC) { - TensorDesc desc(Precision::FP32, {1, 2, 3, 4}, Layout::NHWC); - auto refOrder = desc.getBlockingDesc().getOrder(); - SizeVector newDims{7, 7, 7, 7}; - desc.setDims(newDims); - EXPECT_EQ(desc.getDims(), newDims); - EXPECT_EQ(desc.getLayout(), Layout::NHWC); - EXPECT_EQ(desc.getBlockingDesc().getBlockDims(), newDims); - EXPECT_EQ(desc.getBlockingDesc().getOrder(), refOrder); -} diff --git a/src/inference/tests/functional/variable_state.cpp b/src/inference/tests/functional/variable_state.cpp deleted file mode 100644 index 5d23b4b7132614..00000000000000 --- a/src/inference/tests/functional/variable_state.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include - -#include - -#include "openvino/core/deprecated.hpp" - -using namespace ::testing; -using namespace std; -using namespace InferenceEngine; -using namespace InferenceEngine::details; -OPENVINO_SUPPRESS_DEPRECATED_START - -TEST(VariableStateCPPTests, throwsOnUninitializedReset) { - VariableState req; - ASSERT_THROW(req.Reset(), InferenceEngine::NotAllocated); -} - -TEST(VariableStateCPPTests, throwsOnUninitializedGetname) { - VariableState req; - ASSERT_THROW(req.GetName(), InferenceEngine::NotAllocated); -} - -TEST(VariableStateCPPTests, throwsOnUninitializedGetState) { - VariableState req; - ASSERT_THROW(req.GetState(), InferenceEngine::NotAllocated); -} - -TEST(VariableStateCPPTests, throwsOnUninitializedSetState) { - VariableState req; - Blob::Ptr blob; - ASSERT_THROW(req.SetState(blob), InferenceEngine::NotAllocated); -} diff --git a/src/inference/tests/unit/add_preprocessing.cpp b/src/inference/tests/unit/add_preprocessing.cpp deleted file mode 100644 index 4bad1b27ada2e8..00000000000000 --- a/src/inference/tests/unit/add_preprocessing.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include - -#include -#include -#include -#include - -#include "common_test_utils/ov_test_utils.hpp" -#include "common_test_utils/test_common.hpp" -#include "dev/preprocessing/preprocessing.hpp" -#include "openvino/op/add.hpp" -#include "openvino/runtime/common.hpp" - -using namespace testing; - -using AddPreprocessingTests = ::testing::Test; - -TEST_F(AddPreprocessingTests, AddPreprocessingNCDHW) { - auto shape = ov::Shape{3, 2, 3, 1, 2}; - auto input = std::make_shared(ov::element::f32, shape); - auto constant = ov::op::v0::Constant::create(ov::element::f32, shape, {1}); - auto add = std::make_shared(input, constant); - - auto model = std::make_shared(ov::NodeVector{add}, ov::ParameterVector{input}); - - ov::pass::Manager manager; - manager.register_pass(); - ASSERT_NO_THROW(manager.run_passes(model)); -} - -TEST_F(AddPreprocessingTests, AddPreprocessingBlocked) { - auto shape = ov::Shape{3, 2, 3, 1, 2, 3}; - auto input = std::make_shared(ov::element::f32, shape); - auto constant = ov::op::v0::Constant::create(ov::element::f32, shape, {1}); - auto add = std::make_shared(input, constant); - - auto model = std::make_shared(ov::NodeVector{add}, ov::ParameterVector{input}); - - ov::pass::Manager manager; - manager.register_pass(); - ASSERT_NO_THROW(manager.run_passes(model)); -} - -TEST_F(AddPreprocessingTests, AddPreprocessingScalar) { - auto shape = ov::Shape{}; - auto input = std::make_shared(ov::element::f32, shape); - auto constant = ov::op::v0::Constant::create(ov::element::f32, shape, {1}); - auto add = std::make_shared(input, constant); - - auto model = std::make_shared(ov::NodeVector{add}, ov::ParameterVector{input}); - - ov::pass::Manager manager; - manager.register_pass(); - ASSERT_NO_THROW(manager.run_passes(model)); -} diff --git a/src/inference/tests/unit/core.cpp b/src/inference/tests/unit/core.cpp index 8cb1cfc8f74ca7..c654787bd9d056 100644 --- a/src/inference/tests/unit/core.cpp +++ b/src/inference/tests/unit/core.cpp @@ -12,7 +12,6 @@ #include "common_test_utils/file_utils.hpp" #include "common_test_utils/test_assertions.hpp" #include "dev/core_impl.hpp" -#include "file_utils.h" #include "openvino/op/relu.hpp" #include "openvino/util/file_util.hpp" @@ -57,7 +56,7 @@ TEST(CoreTests_get_plugin_path_from_xml, Use_abs_path_as_is) { TEST(CoreTests_get_plugin_path_from_xml, Convert_relative_path_as_relative_to_xmldir) { auto xml_path = "path_to_plugins.xml"; - auto lib_path = FileUtils::makePath(std::string("."), std::string("test_name.ext")); // ./test_name.ext + auto lib_path = ov::util::make_path(std::string("."), std::string("test_name.ext")); // ./test_name.ext for (auto as_abs_only : std::vector{true, false}) { auto abs_path = from_file_path(get_plugin_path(lib_path, xml_path, as_abs_only)); // XMLDIR/test_name.ext EXPECT_TRUE(is_absolute_file_path(abs_path)); @@ -73,7 +72,7 @@ TEST(CoreTests_get_plugin_path_from_xml, Convert_filename_to_abs_path_if_as_abs_ auto abs_path = from_file_path(get_plugin_path(name, xml_path, true)); // XMLDIR/libtest_name.ext.so EXPECT_TRUE(is_absolute_file_path(abs_path)); - auto lib_name = FileUtils::makePluginLibraryName({}, std::string(name)); + auto lib_name = ov::util::make_plugin_library_name({}, std::string(name)); auto ref_path = ov::util::get_absolute_file_path(lib_name); EXPECT_STREQ(abs_path.c_str(), ref_path.c_str()); // XMLDIR/libtest_name.ext.so == CWD/libtest_name.ext.so } @@ -82,12 +81,12 @@ TEST(CoreTests_get_plugin_path_from_xml, Use_filename_if_not_as_abs_only) { auto xml_path = "path_to_plugins.xml"; auto name = "test_name.ext"; // test_name.ext auto lib_name = from_file_path(get_plugin_path(name, xml_path)); // libtest_name.ext.so - auto ref_name = FileUtils::makePluginLibraryName({}, std::string(name)); + auto ref_name = ov::util::make_plugin_library_name({}, std::string(name)); EXPECT_STREQ(lib_name.c_str(), ref_name.c_str()); } TEST(CoreTests_get_plugin_path, Use_abs_path_as_is) { - auto lib_name = FileUtils::makePluginLibraryName({}, std::string("test_name")); // libtest_name.so + auto lib_name = ov::util::make_plugin_library_name({}, std::string("test_name")); // libtest_name.so auto lib_path = ov::util::get_absolute_file_path(lib_name); auto abs_path = from_file_path(get_plugin_path(lib_path)); EXPECT_TRUE(is_absolute_file_path(abs_path)); @@ -95,7 +94,8 @@ TEST(CoreTests_get_plugin_path, Use_abs_path_as_is) { } TEST(CoreTests_get_plugin_path, Relative_path_is_from_workdir) { - auto lib_name = FileUtils::makePluginLibraryName(std::string("."), std::string("test_name")); // ./libtest_name.so + auto lib_name = + ov::util::make_plugin_library_name(std::string("."), std::string("test_name")); // ./libtest_name.so auto abs_path = from_file_path(get_plugin_path(lib_name)); EXPECT_TRUE(is_absolute_file_path(abs_path)); EXPECT_STREQ(abs_path.c_str(), get_absolute_file_path(lib_name).c_str()); @@ -114,8 +114,8 @@ class CoreTests_get_plugin_path_Class : public ::testing::Test { std::remove(lib_path.c_str()); } - std::string lib_name = FileUtils::makePluginLibraryName({}, std::string("test_name")); // libtest_name.so - std::string lib_path = ov::util::get_absolute_file_path(lib_name); // CWD/libtest_name.so + std::string lib_name = ov::util::make_plugin_library_name({}, std::string("test_name")); // libtest_name.so + std::string lib_path = ov::util::get_absolute_file_path(lib_name); // CWD/libtest_name.so }; TEST_F(CoreTests_get_plugin_path_Class, Filename_is_from_workdir_if_exists) { @@ -129,7 +129,7 @@ TEST(CoreTests_get_plugin_path, Use_filename_as_is_if_not_exist_in_workdir) { auto abs_path = from_file_path(get_plugin_path(lib_name)); // libtest_name.ext.so -> libtest_name.ext.so EXPECT_FALSE(is_absolute_file_path(abs_path)); - auto ref_path = FileUtils::makePluginLibraryName({}, std::string(lib_name)); + auto ref_path = ov::util::make_plugin_library_name({}, std::string(lib_name)); EXPECT_STREQ(abs_path.c_str(), ref_path.c_str()); } diff --git a/src/inference/tests/unit/cpp_interfaces/exception_test.cpp b/src/inference/tests/unit/cpp_interfaces/exception_test.cpp deleted file mode 100644 index 6a236a6fbbdde8..00000000000000 --- a/src/inference/tests/unit/cpp_interfaces/exception_test.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include - -#include - -using namespace InferenceEngine; -IE_SUPPRESS_DEPRECATED_START - -using ExceptionTests = ::testing::Test; - -template -class WrapperClass { -public: - static InferenceEngine::StatusCode toStatusWrapper(InferenceEngine::ResponseDesc* resp) { - TO_STATUS(IE_EXCEPTION_SWITCH( - statusCode, - ExceptionType, - InferenceEngine::details::ThrowNow{IE_LOCATION_PARAM} <<= std::stringstream{})) - } - - static InferenceEngine::StatusCode toStatusWrapperMsg(std::string& msg, InferenceEngine::ResponseDesc* resp) { - TO_STATUS(IE_EXCEPTION_SWITCH( - statusCode, - ExceptionType, - InferenceEngine::details::ThrowNow{IE_LOCATION_PARAM} <<= std::stringstream{} << msg)) - } -}; - -// TO_STATUS macros tests -TEST_F(ExceptionTests, canConvertToStatus) { - ResponseDesc* resp = nullptr; - ASSERT_EQ(WrapperClass::toStatusWrapper(resp), StatusCode::GENERAL_ERROR); - ASSERT_EQ(WrapperClass::toStatusWrapper(resp), StatusCode::NOT_IMPLEMENTED); - ASSERT_EQ(WrapperClass::toStatusWrapper(resp), StatusCode::NETWORK_NOT_LOADED); - ASSERT_EQ(WrapperClass::toStatusWrapper(resp), StatusCode::PARAMETER_MISMATCH); - ASSERT_EQ(WrapperClass::toStatusWrapper(resp), StatusCode::NOT_FOUND); - ASSERT_EQ(WrapperClass::toStatusWrapper(resp), StatusCode::OUT_OF_BOUNDS); - ASSERT_EQ(WrapperClass::toStatusWrapper(resp), StatusCode::UNEXPECTED); - ASSERT_EQ(WrapperClass::toStatusWrapper(resp), StatusCode::REQUEST_BUSY); - ASSERT_EQ(WrapperClass::toStatusWrapper(resp), StatusCode::RESULT_NOT_READY); - ASSERT_EQ(WrapperClass::toStatusWrapper(resp), StatusCode::NOT_ALLOCATED); - ASSERT_EQ(WrapperClass::toStatusWrapper(resp), StatusCode::INFER_NOT_STARTED); -} - -// CALL_STATUS_FNC macros tests -TEST_F(ExceptionTests, canConvertStatusToException) { - auto actual = std::make_shared>(); - ASSERT_THROW(CALL_STATUS_FNC_NO_ARGS(toStatusWrapper), InferenceEngine::InferNotStarted); -} - -TEST_F(ExceptionTests, canHandleNullPtr) { - class Mock { - public: - StatusCode func0(ResponseDesc*) { - return StatusCode ::OK; - } - StatusCode func1(int, ResponseDesc*) { - return StatusCode ::OK; - } - }; - // shared_ptr holding the nullptr - std::shared_ptr actual; - // check that accessing the nullptr thru macros throws - ASSERT_THROW(CALL_STATUS_FNC_NO_ARGS(func0), InferenceEngine::Exception); - ASSERT_THROW(CALL_STATUS_FNC(func1, 0), InferenceEngine::Exception); -} - -TEST_F(ExceptionTests, throwAfterConvertStatusToClassContainMessage) { - std::string refMessage = "Exception message!"; - auto actual = std::make_shared>(); - try { - CALL_STATUS_FNC(toStatusWrapperMsg, refMessage); - } catch (const NotAllocated& iex) { - std::string actualMessage = iex.what(); - ASSERT_TRUE(actualMessage.find(refMessage) != std::string::npos); - } -} diff --git a/src/inference/tests/unit/cpp_interfaces/ie_infer_async_request_base_test.cpp b/src/inference/tests/unit/cpp_interfaces/ie_infer_async_request_base_test.cpp deleted file mode 100644 index 6b13290c3e7250..00000000000000 --- a/src/inference/tests/unit/cpp_interfaces/ie_infer_async_request_base_test.cpp +++ /dev/null @@ -1,328 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include - -#include -#include -#include - -#include "cpp_interfaces/interface/ie_iexecutable_network_internal.hpp" -#include "openvino/runtime/so_ptr.hpp" -#include "unit_test_utils/mocks/cpp_interfaces/interface/mock_iexecutable_network_internal.hpp" -#include "unit_test_utils/mocks/cpp_interfaces/interface/mock_iinfer_request_internal.hpp" -#include "unit_test_utils/mocks/cpp_interfaces/interface/mock_iinference_plugin.hpp" -#include "unit_test_utils/mocks/mock_iinfer_request.hpp" -#include "unit_test_utils/mocks/mock_not_empty_icnn_network.hpp" - -using namespace ::testing; -using namespace std; -using namespace InferenceEngine; -using namespace InferenceEngine::details; - -constexpr const char* MockNotEmptyICNNNetwork::INPUT_BLOB_NAME; -constexpr const char* MockNotEmptyICNNNetwork::OUTPUT_BLOB_NAME; - -IE_SUPPRESS_DEPRECATED_START - -class InferRequestBaseTests : public ::testing::Test { -protected: - std::shared_ptr mock_impl; - shared_ptr request; - ResponseDesc dsc; - - void SetUp() override { - mock_impl.reset(new MockIInferRequestInternal()); - request = std::make_shared(mock_impl); - } -}; - -// StartAsync -TEST_F(InferRequestBaseTests, canForwardStartAsync) { - EXPECT_CALL(*mock_impl.get(), StartAsync()).Times(1); - ASSERT_EQ(OK, request->StartAsync(&dsc)); -} - -TEST_F(InferRequestBaseTests, canReportErrorInStartAsync) { - EXPECT_CALL(*mock_impl.get(), StartAsync()).WillOnce(Throw(std::runtime_error("compare"))); - ASSERT_NE(request->StartAsync(&dsc), OK); - ASSERT_STREQ(dsc.msg, "compare"); -} - -TEST_F(InferRequestBaseTests, canCatchUnknownErrorInStartAsync) { - EXPECT_CALL(*mock_impl.get(), StartAsync()).WillOnce(Throw(5)); - ASSERT_EQ(UNEXPECTED, request->StartAsync(nullptr)); -} - -// Wait -TEST_F(InferRequestBaseTests, canForwardWait) { - int64_t ms = 0; - EXPECT_CALL(*mock_impl.get(), Wait(ms)).WillOnce(Return(StatusCode::OK)); - ASSERT_EQ(OK, request->Wait(ms, &dsc)) << dsc.msg; -} - -TEST_F(InferRequestBaseTests, canReportErrorInWait) { - EXPECT_CALL(*mock_impl.get(), Wait(_)).WillOnce(Throw(std::runtime_error("compare"))); - int64_t ms = 0; - ASSERT_NE(request->Wait(ms, &dsc), OK); - ASSERT_STREQ(dsc.msg, "compare"); -} - -TEST_F(InferRequestBaseTests, canCatchUnknownErrorInWait) { - EXPECT_CALL(*mock_impl.get(), Wait(_)).WillOnce(Throw(5)); - int64_t ms = 0; - ASSERT_EQ(UNEXPECTED, request->Wait(ms, nullptr)); -} - -// Infer -TEST_F(InferRequestBaseTests, canForwardInfer) { - EXPECT_CALL(*mock_impl.get(), Infer()).Times(1); - ASSERT_EQ(OK, request->Infer(&dsc)); -} - -TEST_F(InferRequestBaseTests, canReportErrorInInfer) { - EXPECT_CALL(*mock_impl.get(), Infer()).WillOnce(Throw(std::runtime_error("compare"))); - ASSERT_NE(request->Infer(&dsc), OK); - ASSERT_STREQ(dsc.msg, "compare"); -} - -TEST_F(InferRequestBaseTests, canCatchUnknownErrorInInfer) { - EXPECT_CALL(*mock_impl.get(), Infer()).WillOnce(Throw(5)); - ASSERT_EQ(UNEXPECTED, request->Infer(nullptr)); -} - -// GetPerformanceCounts -TEST_F(InferRequestBaseTests, canForwardGetPerformanceCounts) { - std::map info; - EXPECT_CALL(*mock_impl.get(), GetPerformanceCounts()) - .WillOnce(Return(std::map{})); - ASSERT_EQ(OK, request->GetPerformanceCounts(info, &dsc)) << dsc.msg; -} - -TEST_F(InferRequestBaseTests, canReportErrorInGetPerformanceCounts) { - std::map info; - EXPECT_CALL(*mock_impl.get(), GetPerformanceCounts()).WillOnce(Throw(std::runtime_error("compare"))); - ASSERT_NE(request->GetPerformanceCounts(info, &dsc), OK); - ASSERT_STREQ(dsc.msg, "compare"); -} - -TEST_F(InferRequestBaseTests, canCatchUnknownErrorInGetPerformanceCounts) { - std::map info; - EXPECT_CALL(*mock_impl.get(), GetPerformanceCounts()).WillOnce(Throw(5)); - ASSERT_EQ(UNEXPECTED, request->GetPerformanceCounts(info, nullptr)); -} - -// GetBlob -TEST_F(InferRequestBaseTests, canForwardGetBlob) { - Blob::Ptr data; - EXPECT_CALL(*mock_impl.get(), GetBlob(_)).WillOnce(Return(Blob::Ptr{})); - ASSERT_EQ(OK, request->GetBlob("", data, &dsc)) << dsc.msg; -} - -TEST_F(InferRequestBaseTests, canReportErrorInGetBlob) { - EXPECT_CALL(*mock_impl.get(), GetBlob(_)).WillOnce(Throw(std::runtime_error("compare"))); - Blob::Ptr data; - ASSERT_NE(request->GetBlob("", data, &dsc), OK); - ASSERT_STREQ(dsc.msg, "compare"); -} - -TEST_F(InferRequestBaseTests, canCatchUnknownErrorInGetBlob) { - Blob::Ptr data; - EXPECT_CALL(*mock_impl.get(), GetBlob(_)).WillOnce(Throw(5)); - ASSERT_EQ(UNEXPECTED, request->GetBlob("notEmpty", data, nullptr)); -} - -// SetBlob -TEST_F(InferRequestBaseTests, canForwardSetBlob) { - Blob::Ptr data; - const char* name = ""; - EXPECT_CALL(*mock_impl.get(), SetBlob(name, Ref(data))).Times(1); - ASSERT_EQ(OK, request->SetBlob(name, data, &dsc)); -} - -TEST_F(InferRequestBaseTests, canReportErrorInSetBlob) { - EXPECT_CALL(*mock_impl.get(), SetBlob(_, _)).WillOnce(Throw(std::runtime_error("compare"))); - Blob::Ptr data; - ASSERT_NE(request->SetBlob("", data, &dsc), OK); - ASSERT_STREQ(dsc.msg, "compare"); -} - -TEST_F(InferRequestBaseTests, canCatchUnknownErrorInSetBlob) { - Blob::Ptr data; - EXPECT_CALL(*mock_impl.get(), SetBlob(_, _)).WillOnce(Throw(5)); - ASSERT_EQ(UNEXPECTED, request->SetBlob("notEmpty", data, nullptr)); -} - -// SetCompletionCallback -TEST_F(InferRequestBaseTests, canForwardSetCompletionCallback) { - InferenceEngine::IInferRequest::CompletionCallback callback = nullptr; - EXPECT_CALL(*mock_impl.get(), SetCallback(_)).Times(1); - ASSERT_NO_THROW(request->SetCompletionCallback(callback)); -} - -TEST_F(InferRequestBaseTests, canReportErrorInSetCompletionCallback) { - EXPECT_CALL(*mock_impl.get(), SetCallback(_)).WillOnce(Throw(std::runtime_error("compare"))); - ASSERT_NE(request->SetCompletionCallback(nullptr), OK); -} - -class InferRequestTests : public ::testing::Test { -protected: - std::shared_ptr mock_request; - IInferRequestInternal::Ptr request; - ResponseDesc dsc; - - std::shared_ptr mockIExeNet; - InferenceEngine::SoExecutableNetworkInternal exeNetwork; - MockIInferencePlugin* mockIPlugin; - std::shared_ptr plugin; - shared_ptr mockInferRequestInternal; - MockNotEmptyICNNNetwork mockNotEmptyNet; - std::string _incorrectName; - std::string _inputName; - std::string _failedToFindInOutError; - std::string _inputDataNotAllocatedError; - std::string _inputDataIsEmptyError; - - void TearDown() override { - EXPECT_TRUE(Mock::VerifyAndClearExpectations(mockInferRequestInternal.get())); - EXPECT_TRUE(Mock::VerifyAndClearExpectations(mock_request.get())); - request = {}; - } - - void SetUp() override { - mock_request = make_shared(); - mockIExeNet = std::make_shared(); - ON_CALL(*mockIExeNet, CreateInferRequest()).WillByDefault(Return(mock_request)); - auto mockIPluginPtr = std::make_shared(); - ON_CALL(*mockIPluginPtr, LoadNetwork(MatcherCast(_), _)).WillByDefault(Return(mockIExeNet)); - plugin = mockIPluginPtr; - exeNetwork = ov::SoPtr(plugin->LoadNetwork(CNNNetwork{}, {}), {}); - request = exeNetwork->CreateInferRequest(); - _incorrectName = "incorrect_name"; - _inputName = MockNotEmptyICNNNetwork::INPUT_BLOB_NAME; - _failedToFindInOutError = "[ NOT_FOUND ] Failed to find input or output with name: \'" + _incorrectName + "\'"; - _inputDataNotAllocatedError = - std::string("[ NOT_ALLOCATED ] Input data was not allocated. Input name: \'") + _inputName + "\'"; - _inputDataIsEmptyError = std::string("Input data is empty. Input name: \'") + _inputName + "\'"; - } - - IInferRequestInternal::Ptr getInferRequestWithMockImplInside() { - IInferRequest::Ptr inferRequest; - InputsDataMap inputsInfo; - mockNotEmptyNet.getInputsInfo(inputsInfo); - OutputsDataMap outputsInfo; - mockNotEmptyNet.getOutputsInfo(outputsInfo); - mockInferRequestInternal = make_shared(inputsInfo, outputsInfo); - auto mockIExeNet = std::make_shared(); - ON_CALL(*mockIExeNet, CreateInferRequest()).WillByDefault(Return(mockInferRequestInternal)); - auto mockIPluginPtr = std::make_shared(); - ON_CALL(*mockIPluginPtr, LoadNetwork(MatcherCast(_), _)).WillByDefault(Return(mockIExeNet)); - plugin = mockIPluginPtr; - exeNetwork = ov::SoPtr(plugin->LoadNetwork(CNNNetwork{}, {}), {}); - return exeNetwork->CreateInferRequest(); - } - - std::string getExceptionMessage(std::function function) { - std::string actualError; - try { - function(); - } catch (const Exception& iie) { - actualError = iie.what(); - } - return actualError; - } -}; - -// StartAsync -TEST_F(InferRequestTests, canForwardStartAsync) { - EXPECT_CALL(*mock_request.get(), StartAsync()); - ASSERT_NO_THROW(request->StartAsync()); -} - -TEST_F(InferRequestTests, throwsIfStartAsyncReturnNotOK) { - EXPECT_CALL(*mock_request.get(), StartAsync()).WillOnce(Throw(GeneralError{""})); - ASSERT_THROW(request->StartAsync(), Exception); -} - -// Wait -TEST_F(InferRequestTests, canForwardWait) { - int64_t ms = 0; - EXPECT_CALL(*mock_request.get(), Wait(_)).WillOnce(Return(OK)); - ASSERT_TRUE(OK == request->Wait(ms)); -} - -TEST_F(InferRequestTests, canForwardStatusFromWait) { - EXPECT_CALL(*mock_request.get(), Wait(_)).WillOnce(Return(RESULT_NOT_READY)); - ASSERT_EQ(request->Wait(0), RESULT_NOT_READY); -} - -// Infer -TEST_F(InferRequestTests, canForwardInfer) { - EXPECT_CALL(*mock_request.get(), Infer()); - ASSERT_NO_THROW(request->Infer()); -} - -TEST_F(InferRequestTests, throwsIfInferReturnNotOK) { - EXPECT_CALL(*mock_request.get(), Infer()).WillOnce(Throw(GeneralError{""})); - ASSERT_THROW(request->Infer(), Exception); -} - -// GetPerformanceCounts -TEST_F(InferRequestTests, canForwardGetPerformanceCounts) { - std::map info; - EXPECT_CALL(*mock_request.get(), GetPerformanceCounts()).WillOnce(Return(info)); - ASSERT_NO_THROW(info = request->GetPerformanceCounts()); -} - -TEST_F(InferRequestTests, throwsIfGetPerformanceCountsReturnNotOK) { - std::map info; - EXPECT_CALL(*mock_request.get(), GetPerformanceCounts()).WillOnce(Throw(GeneralError{""})); - ASSERT_THROW(info = request->GetPerformanceCounts(), Exception); -} - -MATCHER_P(blob_in_map_pointer_is_same, ref_blob, "") { - auto a = arg.begin()->second.get(); - return reinterpret_cast(arg.begin()->second->buffer()) == reinterpret_cast(ref_blob->buffer()); -} - -// GetBlob -TEST_F(InferRequestTests, canForwardGetBlob) { - Blob::Ptr blob = make_shared_blob({Precision::FP32, {}, NCHW}); - blob->allocate(); - std::string name = "blob1"; - - EXPECT_CALL(*mock_request.get(), GetBlob(_)).WillOnce(Return(blob)); - ASSERT_NO_THROW(request->GetBlob(name)); -} - -TEST_F(InferRequestTests, throwsIfGetBlobReturnNotOK) { - Blob::Ptr blob; - std::string name = "blob1"; - - EXPECT_CALL(*mock_request.get(), GetBlob(_)).WillOnce(Throw(GeneralError{""})); - ASSERT_THROW(blob = request->GetBlob(name), Exception); -} - -// SetBlob -TEST_F(InferRequestTests, canForwardSetBlob) { - Blob::Ptr blob; - std::string name = "blob1"; - - EXPECT_CALL(*mock_request.get(), SetBlob(name, blob)); - ASSERT_NO_THROW(request->SetBlob(name, blob)); -} - -TEST_F(InferRequestTests, throwsIfSetBlobReturnNotOK) { - Blob::Ptr blob; - std::string name = "blob1"; - - EXPECT_CALL(*mock_request.get(), SetBlob(_, _)).WillOnce(Throw(GeneralError{""})); - ASSERT_THROW(request->SetBlob(name, blob), Exception); -} - -TEST_F(InferRequestTests, canForwardAnyCallback) { - EXPECT_CALL(*mock_request.get(), SetCallback(_)); - ASSERT_NO_THROW(request->SetCallback([](std::exception_ptr) {})); -} diff --git a/src/inference/tests/unit/cpp_interfaces/ie_memory_state_internal_test.cpp b/src/inference/tests/unit/cpp_interfaces/ie_memory_state_internal_test.cpp deleted file mode 100644 index 1a9c846deaa0fa..00000000000000 --- a/src/inference/tests/unit/cpp_interfaces/ie_memory_state_internal_test.cpp +++ /dev/null @@ -1,187 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include - -#include -#include -#include - -#include "cpp_interfaces/interface/ie_iexecutable_network_internal.hpp" -#include "cpp_interfaces/interface/ie_iplugin_internal.hpp" -#include "unit_test_utils/mocks/cpp_interfaces/interface/mock_iexecutable_network_internal.hpp" -#include "unit_test_utils/mocks/cpp_interfaces/interface/mock_iinference_plugin.hpp" -#include "unit_test_utils/mocks/cpp_interfaces/interface/mock_ivariable_state_internal.hpp" - -using namespace ::testing; -using namespace std; -using namespace InferenceEngine; -using namespace InferenceEngine::details; - -class InferRequestVariableStateTests : public ::testing::Test { -protected: - shared_ptr mockExeNetworkInternal; - shared_ptr mockInferRequestInternal; - shared_ptr mockVariableStateInternal; - MockIInferencePlugin* mockIPlugin; - std::shared_ptr plugin; - ov::SoPtr net; - IInferRequestInternal::Ptr req; - - void SetUp() override { - mockExeNetworkInternal = make_shared(); - mockInferRequestInternal = make_shared(); - mockVariableStateInternal = make_shared(); - ON_CALL(*mockExeNetworkInternal, CreateInferRequest()).WillByDefault(Return(mockInferRequestInternal)); - auto mockIPluginPtr = std::make_shared(); - ON_CALL(*mockIPluginPtr, LoadNetwork(MatcherCast(_), _)) - .WillByDefault(Return(mockExeNetworkInternal)); - plugin = mockIPluginPtr; - net = ov::SoPtr(plugin->LoadNetwork(CNNNetwork{}, {}), {}); - req = net->CreateInferRequest(); - } -}; - -class VariableStateInternalMockImpl : public IVariableStateInternal { -public: - VariableStateInternalMockImpl(const char* name) : IVariableStateInternal(name) {} - MOCK_METHOD0(Reset, void()); -}; - -TEST_F(InferRequestVariableStateTests, VariableStateInternalCanSaveName) { - IVariableStateInternal::Ptr pState(new VariableStateInternalMockImpl("VariableStateInternalMockImpl")); - ASSERT_STREQ(pState->GetName().c_str(), "VariableStateInternalMockImpl"); -} - -TEST_F(InferRequestVariableStateTests, VariableStateInternalCanSaveState) { - IVariableStateInternal::Ptr pState(new VariableStateInternalMockImpl("VariableStateInternalMockImpl")); - float data[] = {123, 124, 125}; - auto stateBlob = make_shared_blob({Precision::FP32, {3}, C}, data, sizeof(data) / sizeof(*data)); - - pState->SetState(stateBlob); - auto saver = pState->GetState(); - - ASSERT_NE(saver, nullptr); - ASSERT_FLOAT_EQ(saver->cbuffer().as()[0], 123); - ASSERT_FLOAT_EQ(saver->cbuffer().as()[1], 124); - ASSERT_FLOAT_EQ(saver->cbuffer().as()[2], 125); -} - -TEST_F(InferRequestVariableStateTests, VariableStateInternalCanSaveStateByReference) { - IVariableStateInternal::Ptr pState(new VariableStateInternalMockImpl("VariableStateInternalMockImpl")); - float data[] = {123, 124, 125}; - auto stateBlob = make_shared_blob({Precision::FP32, {3}, C}, data, sizeof(data) / sizeof(*data)); - - pState->SetState(stateBlob); - - data[0] = 121; - data[1] = 122; - data[2] = 123; - auto saver = pState->GetState(); - - ASSERT_NE(saver, nullptr); - ASSERT_FLOAT_EQ(saver->cbuffer().as()[0], 121); - ASSERT_FLOAT_EQ(saver->cbuffer().as()[1], 122); - ASSERT_FLOAT_EQ(saver->cbuffer().as()[2], 123); -} - -// Tests for InferRequest::QueryState -TEST_F(InferRequestVariableStateTests, InferRequestCanConvertOneVariableStateFromCppToAPI) { - std::vector toReturn(1); - toReturn[0] = mockVariableStateInternal; - - EXPECT_CALL(*mockInferRequestInternal.get(), QueryState()).Times(1).WillRepeatedly(Return(toReturn)); - - auto state = req->QueryState(); - ASSERT_EQ(state.size(), 1); -} - -TEST_F(InferRequestVariableStateTests, InferRequestCanConvertZeroVariableStateFromCppToAPI) { - std::vector toReturn; - - EXPECT_CALL(*mockInferRequestInternal.get(), QueryState()).WillOnce(Return(toReturn)); - - auto state = req->QueryState(); - ASSERT_EQ(state.size(), 0); -} - -TEST_F(InferRequestVariableStateTests, InferRequestCanConvert2VariableStatesFromCPPtoAPI) { - std::vector toReturn; - toReturn.push_back(mockVariableStateInternal); - toReturn.push_back(mockVariableStateInternal); - - EXPECT_CALL(*mockInferRequestInternal.get(), QueryState()).Times(1).WillRepeatedly(Return(toReturn)); - - auto state = req->QueryState(); - ASSERT_EQ(state.size(), 2); -} - -TEST_F(InferRequestVariableStateTests, InfReqVariableStatePropagatesReset) { - std::vector toReturn; - toReturn.push_back(mockVariableStateInternal); - - EXPECT_CALL(*mockInferRequestInternal.get(), QueryState()).Times(1).WillRepeatedly(Return(toReturn)); - EXPECT_CALL(*mockVariableStateInternal.get(), Reset()).Times(1); - - auto state = req->QueryState(); - state.front()->Reset(); -} - -TEST_F(InferRequestVariableStateTests, InfReqVariableStatePropagatesExceptionsFromReset) { - std::vector toReturn; - toReturn.push_back(mockVariableStateInternal); - - EXPECT_CALL(*mockInferRequestInternal.get(), QueryState()).Times(1).WillRepeatedly(Return(toReturn)); - EXPECT_CALL(*mockVariableStateInternal.get(), Reset()).WillOnce(Throw(std::logic_error("some error"))); - - auto state = req->QueryState(); - EXPECT_ANY_THROW(state.front()->Reset()); -} - -TEST_F(InferRequestVariableStateTests, InfReqVariableStatePropagatesGetName) { - std::vector toReturn; - toReturn.push_back(mockVariableStateInternal); - - EXPECT_CALL(*mockInferRequestInternal.get(), QueryState()).Times(1).WillRepeatedly(Return(toReturn)); - EXPECT_CALL(*mockVariableStateInternal.get(), GetName()).WillOnce(Return("someName")); - - auto state = req->QueryState(); - EXPECT_STREQ(state.front()->GetName().c_str(), "someName"); -} - -TEST_F(InferRequestVariableStateTests, InfReqVariableStateCanPropagateSetState) { - std::vector toReturn; - Blob::Ptr saver; - toReturn.push_back(mockVariableStateInternal); - - EXPECT_CALL(*mockInferRequestInternal.get(), QueryState()).WillRepeatedly(Return(toReturn)); - EXPECT_CALL(*mockVariableStateInternal.get(), SetState(_)).WillOnce(SaveArg<0>(&saver)); - - float data[] = {123, 124, 125}; - auto stateBlob = make_shared_blob({Precision::FP32, {3}, C}, data, sizeof(data) / sizeof(*data)); - - EXPECT_NO_THROW(req->QueryState().front()->SetState(stateBlob)); - ASSERT_FLOAT_EQ(saver->buffer().as()[0], 123); - ASSERT_FLOAT_EQ(saver->buffer().as()[1], 124); - ASSERT_FLOAT_EQ(saver->buffer().as()[2], 125); -} - -TEST_F(InferRequestVariableStateTests, InfReqVariableStateCanPropagateGetLastState) { - std::vector toReturn; - - float data[] = {123, 124, 125}; - auto stateBlob = make_shared_blob({Precision::FP32, {3}, C}, data, sizeof(data) / sizeof(*data)); - - toReturn.push_back(mockVariableStateInternal); - - EXPECT_CALL(*mockInferRequestInternal.get(), QueryState()).WillRepeatedly(Return(toReturn)); - EXPECT_CALL(*mockVariableStateInternal.get(), GetState()).WillOnce(Return(stateBlob)); - - auto saver = req->QueryState().front()->GetState(); - ASSERT_NE(saver, nullptr); - ASSERT_FLOAT_EQ(saver->cbuffer().as()[0], 123); - ASSERT_FLOAT_EQ(saver->cbuffer().as()[1], 124); - ASSERT_FLOAT_EQ(saver->cbuffer().as()[2], 125); -} diff --git a/src/inference/tests/unit/executor_config_test.cpp b/src/inference/tests/unit/executor_config_test.cpp new file mode 100644 index 00000000000000..6a02b35241a686 --- /dev/null +++ b/src/inference/tests/unit/executor_config_test.cpp @@ -0,0 +1,1146 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "common_test_utils/test_common.hpp" +#include "openvino/runtime/threading/istreams_executor.hpp" +#include "os/cpu_map_info.hpp" + +using namespace testing; +using namespace ov; +using namespace threading; + +namespace { + +#if defined(__linux__) || defined(_WIN32) + +struct ExecutorConfigTestCase { + std::vector> _proc_type_table; + std::vector> _cpu_mapping_table; + int _num_streams; + int _threads_per_stream; + ov::threading::IStreamsExecutor::Config::PreferredCoreType _core_type; + bool _cpu_pinning; + std::vector> _streams_info_table_in; + std::vector> _streams_info_table; + std::vector> _stream_processors; +}; + +class ExecutorConfigTest : public ov::test::TestsCommon, + public testing::WithParamInterface> { +public: + void SetUp() override { + auto test_data = std::get<0>(GetParam()); + + CPU& cpu = cpu_info(); + cpu._org_proc_type_table = test_data._proc_type_table; + cpu._proc_type_table = test_data._proc_type_table; + cpu._cpu_mapping_table = test_data._cpu_mapping_table; + cpu._numa_nodes = cpu._proc_type_table.size() > 1 ? static_cast(cpu._proc_type_table.size()) - 1 : 1; + cpu._sockets = cpu._numa_nodes; + + ov::threading::IStreamsExecutor::Config config{"config test", + test_data._num_streams, + test_data._threads_per_stream, + ov::threading::IStreamsExecutor::ThreadBindingType::NONE, + 1, + 0, + 0, + test_data._core_type, + test_data._streams_info_table_in, + test_data._cpu_pinning}; + + ASSERT_EQ(test_data._cpu_pinning, config.get_cpu_reservation()); + ASSERT_EQ(test_data._streams_info_table, config.get_streams_info_table()); + ASSERT_EQ(test_data._stream_processors, config.get_stream_processor_ids()); + } +}; + +ExecutorConfigTestCase _1sockets_streams_4_threads_1 = { + // param[in]: proc_type_table, {total processors, number of physical processors, number of Efficient processors, + // number of hyper threading processors} + { + {12, 6, 0, 6, 0, 0}, + }, + // param[in]: cpu_mapping_table, {PROCESSOR_ID, NUMA_ID, SOCKET_ID, CORE_ID, CORE_TYPE, GROUP_ID, Used} + { + {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, + {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, + {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, + {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, + {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 4, MAIN_CORE_PROC, 8, -1}, + {9, 0, 0, 4, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 5, MAIN_CORE_PROC, 10, -1}, + {11, 0, 0, 5, HYPER_THREADING_PROC, 11, -1}, + }, + 4, // param[in]: the number of streams + 1, // param[in]: the number of threads per stream + ov::threading::IStreamsExecutor::Config::ANY, // param[in]: specified cpu core type + false, // param[in]: specified cpu pinning + {}, // param[in]: streams info table + // param[out]: streams_info_table, {NUMBER_OF_STREAMS, PROC_TYPE, THREADS_PER_STREAM, STREAM_NUMA_NODE_ID, + // STREAM_SOCKET_ID} + { + {4, MAIN_CORE_PROC, 1, 0, 0}, + }, + // param[out]: stream_processors, the list of processor ids on each stream. + {}, +}; + +ExecutorConfigTestCase _1sockets_streams_4_threads_0 = { + { + {12, 6, 0, 6, 0, 0}, + }, + { + {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, + {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, + {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, + {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, + {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 4, MAIN_CORE_PROC, 8, -1}, + {9, 0, 0, 4, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 5, MAIN_CORE_PROC, 10, -1}, + {11, 0, 0, 5, HYPER_THREADING_PROC, 11, -1}, + }, + 4, + 0, + ov::threading::IStreamsExecutor::Config::ANY, + false, + {}, + {}, + {}, +}; + +ExecutorConfigTestCase _1sockets_streams_1_threads_12 = { + { + {12, 6, 0, 6, 0, 0}, + }, + { + {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, + {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, + {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, + {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, + {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 4, MAIN_CORE_PROC, 8, -1}, + {9, 0, 0, 4, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 5, MAIN_CORE_PROC, 10, -1}, + {11, 0, 0, 5, HYPER_THREADING_PROC, 11, -1}, + }, + 1, + 12, + ov::threading::IStreamsExecutor::Config::ANY, + false, + {}, + { + {1, ALL_PROC, 12, 0, 0}, + {0, MAIN_CORE_PROC, 6, 0, 0}, + {0, HYPER_THREADING_PROC, 6, 0, 0}, + }, + {}, +}; + +ExecutorConfigTestCase _1sockets_streams_1_threads_10 = { + { + {12, 6, 0, 6, 0, 0}, + }, + { + {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, + {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, + {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, + {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, + {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 4, MAIN_CORE_PROC, 8, -1}, + {9, 0, 0, 4, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 5, MAIN_CORE_PROC, 10, -1}, + {11, 0, 0, 5, HYPER_THREADING_PROC, 11, -1}, + }, + 1, + 10, + ov::threading::IStreamsExecutor::Config::ANY, + false, + {}, + { + {1, ALL_PROC, 10, 0, 0}, + {0, MAIN_CORE_PROC, 6, 0, 0}, + {0, HYPER_THREADING_PROC, 4, 0, 0}, + }, + {}, +}; + +ExecutorConfigTestCase _1sockets_streams_12_threads_1 = { + { + {12, 6, 0, 6, 0, 0}, + }, + { + {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, + {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, + {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, + {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, + {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 4, MAIN_CORE_PROC, 8, -1}, + {9, 0, 0, 4, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 5, MAIN_CORE_PROC, 10, -1}, + {11, 0, 0, 5, HYPER_THREADING_PROC, 11, -1}, + }, + 12, + 1, + ov::threading::IStreamsExecutor::Config::ANY, + false, + {}, + { + {6, MAIN_CORE_PROC, 1, 0, 0}, + {6, HYPER_THREADING_PROC, 1, 0, 0}, + }, + {}, +}; + +ExecutorConfigTestCase _1sockets_streams_13_threads_1 = { + { + {12, 6, 0, 6, 0, 0}, + }, + { + {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, + {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, + {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, + {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, + {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 4, MAIN_CORE_PROC, 8, -1}, + {9, 0, 0, 4, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 5, MAIN_CORE_PROC, 10, -1}, + {11, 0, 0, 5, HYPER_THREADING_PROC, 11, -1}, + }, + 13, + 1, + ov::threading::IStreamsExecutor::Config::ANY, + false, + {}, + { + {6, MAIN_CORE_PROC, 1, 0, 0}, + {6, HYPER_THREADING_PROC, 1, 0, 0}, + }, + {}, +}; + +ExecutorConfigTestCase _1sockets_streams_6_threads_1_core_e = { + { + {12, 6, 0, 6, 0, 0}, + }, + { + {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, + {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, + {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, + {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, + {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 4, MAIN_CORE_PROC, 8, -1}, + {9, 0, 0, 4, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 5, MAIN_CORE_PROC, 10, -1}, + {11, 0, 0, 5, HYPER_THREADING_PROC, 11, -1}, + }, + 7, + 1, + ov::threading::IStreamsExecutor::Config::LITTLE, + false, + {}, + { + {6, MAIN_CORE_PROC, 1, 0, 0}, + {1, HYPER_THREADING_PROC, 1, 0, 0}, + }, + {}, +}; + +ExecutorConfigTestCase _1sockets_streams_5_threads_1_binding = { + { + {12, 6, 0, 6, 0, 0}, + }, + { + {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, + {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, + {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, + {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, + {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 4, MAIN_CORE_PROC, 8, -1}, + {9, 0, 0, 4, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 5, MAIN_CORE_PROC, 10, -1}, + {11, 0, 0, 5, HYPER_THREADING_PROC, 11, -1}, + }, + 5, + 1, + ov::threading::IStreamsExecutor::Config::ANY, + true, + {}, + { + {5, MAIN_CORE_PROC, 1, 0, 0}, + }, + {{0}, {2}, {4}, {6}, {8}}, +}; + +ExecutorConfigTestCase _2sockets_streams_36_threads_1 = { + { + {72, 36, 0, 36, -1, -1}, + {36, 18, 0, 18, 0, 0}, + {36, 18, 0, 18, 1, 1}, + }, + { + {0, 0, 0, 0, HYPER_THREADING_PROC, 0, -1}, {1, 0, 0, 1, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 2, HYPER_THREADING_PROC, 2, -1}, {3, 0, 0, 3, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 4, HYPER_THREADING_PROC, 4, -1}, {5, 0, 0, 5, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 6, HYPER_THREADING_PROC, 6, -1}, {7, 0, 0, 7, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 8, HYPER_THREADING_PROC, 8, -1}, {9, 0, 0, 9, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 10, HYPER_THREADING_PROC, 10, -1}, {11, 0, 0, 11, HYPER_THREADING_PROC, 11, -1}, + {12, 0, 0, 12, HYPER_THREADING_PROC, 12, -1}, {13, 0, 0, 13, HYPER_THREADING_PROC, 13, -1}, + {14, 0, 0, 14, HYPER_THREADING_PROC, 14, -1}, {15, 0, 0, 15, HYPER_THREADING_PROC, 15, -1}, + {16, 0, 0, 16, HYPER_THREADING_PROC, 16, -1}, {17, 0, 0, 17, HYPER_THREADING_PROC, 17, -1}, + {18, 1, 1, 18, HYPER_THREADING_PROC, 18, -1}, {19, 1, 1, 19, HYPER_THREADING_PROC, 19, -1}, + {20, 1, 1, 20, HYPER_THREADING_PROC, 20, -1}, {21, 1, 1, 21, HYPER_THREADING_PROC, 21, -1}, + {22, 1, 1, 22, HYPER_THREADING_PROC, 22, -1}, {23, 1, 1, 23, HYPER_THREADING_PROC, 23, -1}, + {24, 1, 1, 24, HYPER_THREADING_PROC, 24, -1}, {25, 1, 1, 25, HYPER_THREADING_PROC, 25, -1}, + {26, 1, 1, 26, HYPER_THREADING_PROC, 26, -1}, {27, 1, 1, 27, HYPER_THREADING_PROC, 27, -1}, + {28, 1, 1, 28, HYPER_THREADING_PROC, 28, -1}, {29, 1, 1, 29, HYPER_THREADING_PROC, 29, -1}, + {30, 1, 1, 30, HYPER_THREADING_PROC, 30, -1}, {31, 1, 1, 31, HYPER_THREADING_PROC, 31, -1}, + {32, 1, 1, 32, HYPER_THREADING_PROC, 32, -1}, {33, 1, 1, 33, HYPER_THREADING_PROC, 33, -1}, + {34, 1, 1, 34, HYPER_THREADING_PROC, 34, -1}, {35, 1, 1, 35, HYPER_THREADING_PROC, 35, -1}, + {36, 0, 0, 36, MAIN_CORE_PROC, 36, -1}, {37, 0, 0, 37, MAIN_CORE_PROC, 37, -1}, + {38, 0, 0, 38, MAIN_CORE_PROC, 38, -1}, {39, 0, 0, 39, MAIN_CORE_PROC, 39, -1}, + {40, 0, 0, 40, MAIN_CORE_PROC, 40, -1}, {41, 0, 0, 41, MAIN_CORE_PROC, 41, -1}, + {42, 0, 0, 42, MAIN_CORE_PROC, 42, -1}, {43, 0, 0, 43, MAIN_CORE_PROC, 43, -1}, + {44, 0, 0, 44, MAIN_CORE_PROC, 44, -1}, {45, 0, 0, 45, MAIN_CORE_PROC, 45, -1}, + {46, 0, 0, 46, MAIN_CORE_PROC, 46, -1}, {47, 0, 0, 47, MAIN_CORE_PROC, 47, -1}, + {48, 0, 0, 48, MAIN_CORE_PROC, 48, -1}, {49, 0, 0, 49, MAIN_CORE_PROC, 49, -1}, + {50, 0, 0, 50, MAIN_CORE_PROC, 50, -1}, {51, 0, 0, 51, MAIN_CORE_PROC, 51, -1}, + {52, 0, 0, 52, MAIN_CORE_PROC, 52, -1}, {53, 0, 0, 53, MAIN_CORE_PROC, 53, -1}, + {54, 1, 1, 54, MAIN_CORE_PROC, 54, -1}, {55, 1, 1, 55, MAIN_CORE_PROC, 55, -1}, + {56, 1, 1, 56, MAIN_CORE_PROC, 56, -1}, {57, 1, 1, 57, MAIN_CORE_PROC, 57, -1}, + {58, 1, 1, 58, MAIN_CORE_PROC, 58, -1}, {59, 1, 1, 59, MAIN_CORE_PROC, 59, -1}, + {60, 1, 1, 60, MAIN_CORE_PROC, 60, -1}, {61, 1, 1, 61, MAIN_CORE_PROC, 61, -1}, + {62, 1, 1, 62, MAIN_CORE_PROC, 62, -1}, {63, 1, 1, 63, MAIN_CORE_PROC, 63, -1}, + {64, 1, 1, 64, MAIN_CORE_PROC, 64, -1}, {65, 1, 1, 65, MAIN_CORE_PROC, 65, -1}, + {66, 1, 1, 66, MAIN_CORE_PROC, 66, -1}, {67, 1, 1, 67, MAIN_CORE_PROC, 67, -1}, + {68, 1, 1, 68, MAIN_CORE_PROC, 68, -1}, {69, 1, 1, 69, MAIN_CORE_PROC, 69, -1}, + {70, 1, 1, 70, MAIN_CORE_PROC, 70, -1}, {71, 1, 1, 71, MAIN_CORE_PROC, 71, -1}, + }, + 36, + 1, + ov::threading::IStreamsExecutor::Config::ANY, + false, + {}, + { + {18, MAIN_CORE_PROC, 1, 0, 0}, + {18, MAIN_CORE_PROC, 1, 1, 1}, + }, + {}, +}; + +ExecutorConfigTestCase _2sockets_streams_4_threads_5 = { + { + {72, 36, 0, 36, -1, -1}, + {36, 18, 0, 18, 0, 0}, + {36, 18, 0, 18, 1, 1}, + }, + { + {0, 0, 0, 0, HYPER_THREADING_PROC, 0, -1}, {1, 0, 0, 1, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 2, HYPER_THREADING_PROC, 2, -1}, {3, 0, 0, 3, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 4, HYPER_THREADING_PROC, 4, -1}, {5, 0, 0, 5, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 6, HYPER_THREADING_PROC, 6, -1}, {7, 0, 0, 7, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 8, HYPER_THREADING_PROC, 8, -1}, {9, 0, 0, 9, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 10, HYPER_THREADING_PROC, 10, -1}, {11, 0, 0, 11, HYPER_THREADING_PROC, 11, -1}, + {12, 0, 0, 12, HYPER_THREADING_PROC, 12, -1}, {13, 0, 0, 13, HYPER_THREADING_PROC, 13, -1}, + {14, 0, 0, 14, HYPER_THREADING_PROC, 14, -1}, {15, 0, 0, 15, HYPER_THREADING_PROC, 15, -1}, + {16, 0, 0, 16, HYPER_THREADING_PROC, 16, -1}, {17, 0, 0, 17, HYPER_THREADING_PROC, 17, -1}, + {18, 1, 1, 18, HYPER_THREADING_PROC, 18, -1}, {19, 1, 1, 19, HYPER_THREADING_PROC, 19, -1}, + {20, 1, 1, 20, HYPER_THREADING_PROC, 20, -1}, {21, 1, 1, 21, HYPER_THREADING_PROC, 21, -1}, + {22, 1, 1, 22, HYPER_THREADING_PROC, 22, -1}, {23, 1, 1, 23, HYPER_THREADING_PROC, 23, -1}, + {24, 1, 1, 24, HYPER_THREADING_PROC, 24, -1}, {25, 1, 1, 25, HYPER_THREADING_PROC, 25, -1}, + {26, 1, 1, 26, HYPER_THREADING_PROC, 26, -1}, {27, 1, 1, 27, HYPER_THREADING_PROC, 27, -1}, + {28, 1, 1, 28, HYPER_THREADING_PROC, 28, -1}, {29, 1, 1, 29, HYPER_THREADING_PROC, 29, -1}, + {30, 1, 1, 30, HYPER_THREADING_PROC, 30, -1}, {31, 1, 1, 31, HYPER_THREADING_PROC, 31, -1}, + {32, 1, 1, 32, HYPER_THREADING_PROC, 32, -1}, {33, 1, 1, 33, HYPER_THREADING_PROC, 33, -1}, + {34, 1, 1, 34, HYPER_THREADING_PROC, 34, -1}, {35, 1, 1, 35, HYPER_THREADING_PROC, 35, -1}, + {36, 0, 0, 36, MAIN_CORE_PROC, 36, -1}, {37, 0, 0, 37, MAIN_CORE_PROC, 37, -1}, + {38, 0, 0, 38, MAIN_CORE_PROC, 38, -1}, {39, 0, 0, 39, MAIN_CORE_PROC, 39, -1}, + {40, 0, 0, 40, MAIN_CORE_PROC, 40, -1}, {41, 0, 0, 41, MAIN_CORE_PROC, 41, -1}, + {42, 0, 0, 42, MAIN_CORE_PROC, 42, -1}, {43, 0, 0, 43, MAIN_CORE_PROC, 43, -1}, + {44, 0, 0, 44, MAIN_CORE_PROC, 44, -1}, {45, 0, 0, 45, MAIN_CORE_PROC, 45, -1}, + {46, 0, 0, 46, MAIN_CORE_PROC, 46, -1}, {47, 0, 0, 47, MAIN_CORE_PROC, 47, -1}, + {48, 0, 0, 48, MAIN_CORE_PROC, 48, -1}, {49, 0, 0, 49, MAIN_CORE_PROC, 49, -1}, + {50, 0, 0, 50, MAIN_CORE_PROC, 50, -1}, {51, 0, 0, 51, MAIN_CORE_PROC, 51, -1}, + {52, 0, 0, 52, MAIN_CORE_PROC, 52, -1}, {53, 0, 0, 53, MAIN_CORE_PROC, 53, -1}, + {54, 1, 1, 54, MAIN_CORE_PROC, 54, -1}, {55, 1, 1, 55, MAIN_CORE_PROC, 55, -1}, + {56, 1, 1, 56, MAIN_CORE_PROC, 56, -1}, {57, 1, 1, 57, MAIN_CORE_PROC, 57, -1}, + {58, 1, 1, 58, MAIN_CORE_PROC, 58, -1}, {59, 1, 1, 59, MAIN_CORE_PROC, 59, -1}, + {60, 1, 1, 60, MAIN_CORE_PROC, 60, -1}, {61, 1, 1, 61, MAIN_CORE_PROC, 61, -1}, + {62, 1, 1, 62, MAIN_CORE_PROC, 62, -1}, {63, 1, 1, 63, MAIN_CORE_PROC, 63, -1}, + {64, 1, 1, 64, MAIN_CORE_PROC, 64, -1}, {65, 1, 1, 65, MAIN_CORE_PROC, 65, -1}, + {66, 1, 1, 66, MAIN_CORE_PROC, 66, -1}, {67, 1, 1, 67, MAIN_CORE_PROC, 67, -1}, + {68, 1, 1, 68, MAIN_CORE_PROC, 68, -1}, {69, 1, 1, 69, MAIN_CORE_PROC, 69, -1}, + {70, 1, 1, 70, MAIN_CORE_PROC, 70, -1}, {71, 1, 1, 71, MAIN_CORE_PROC, 71, -1}, + }, + 4, + 5, + ov::threading::IStreamsExecutor::Config::ANY, + false, + {}, + { + {3, MAIN_CORE_PROC, 5, 0, 0}, + {1, MAIN_CORE_PROC, 5, 1, 1}, + }, + {}, +}; + +ExecutorConfigTestCase _2sockets_streams_1_threads_36 = { + { + {72, 36, 0, 36, -1, -1}, + {36, 18, 0, 18, 0, 0}, + {36, 18, 0, 18, 1, 1}, + }, + { + {0, 0, 0, 0, HYPER_THREADING_PROC, 0, -1}, {1, 0, 0, 1, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 2, HYPER_THREADING_PROC, 2, -1}, {3, 0, 0, 3, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 4, HYPER_THREADING_PROC, 4, -1}, {5, 0, 0, 5, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 6, HYPER_THREADING_PROC, 6, -1}, {7, 0, 0, 7, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 8, HYPER_THREADING_PROC, 8, -1}, {9, 0, 0, 9, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 10, HYPER_THREADING_PROC, 10, -1}, {11, 0, 0, 11, HYPER_THREADING_PROC, 11, -1}, + {12, 0, 0, 12, HYPER_THREADING_PROC, 12, -1}, {13, 0, 0, 13, HYPER_THREADING_PROC, 13, -1}, + {14, 0, 0, 14, HYPER_THREADING_PROC, 14, -1}, {15, 0, 0, 15, HYPER_THREADING_PROC, 15, -1}, + {16, 0, 0, 16, HYPER_THREADING_PROC, 16, -1}, {17, 0, 0, 17, HYPER_THREADING_PROC, 17, -1}, + {18, 1, 1, 18, HYPER_THREADING_PROC, 18, -1}, {19, 1, 1, 19, HYPER_THREADING_PROC, 19, -1}, + {20, 1, 1, 20, HYPER_THREADING_PROC, 20, -1}, {21, 1, 1, 21, HYPER_THREADING_PROC, 21, -1}, + {22, 1, 1, 22, HYPER_THREADING_PROC, 22, -1}, {23, 1, 1, 23, HYPER_THREADING_PROC, 23, -1}, + {24, 1, 1, 24, HYPER_THREADING_PROC, 24, -1}, {25, 1, 1, 25, HYPER_THREADING_PROC, 25, -1}, + {26, 1, 1, 26, HYPER_THREADING_PROC, 26, -1}, {27, 1, 1, 27, HYPER_THREADING_PROC, 27, -1}, + {28, 1, 1, 28, HYPER_THREADING_PROC, 28, -1}, {29, 1, 1, 29, HYPER_THREADING_PROC, 29, -1}, + {30, 1, 1, 30, HYPER_THREADING_PROC, 30, -1}, {31, 1, 1, 31, HYPER_THREADING_PROC, 31, -1}, + {32, 1, 1, 32, HYPER_THREADING_PROC, 32, -1}, {33, 1, 1, 33, HYPER_THREADING_PROC, 33, -1}, + {34, 1, 1, 34, HYPER_THREADING_PROC, 34, -1}, {35, 1, 1, 35, HYPER_THREADING_PROC, 35, -1}, + {36, 0, 0, 36, MAIN_CORE_PROC, 36, -1}, {37, 0, 0, 37, MAIN_CORE_PROC, 37, -1}, + {38, 0, 0, 38, MAIN_CORE_PROC, 38, -1}, {39, 0, 0, 39, MAIN_CORE_PROC, 39, -1}, + {40, 0, 0, 40, MAIN_CORE_PROC, 40, -1}, {41, 0, 0, 41, MAIN_CORE_PROC, 41, -1}, + {42, 0, 0, 42, MAIN_CORE_PROC, 42, -1}, {43, 0, 0, 43, MAIN_CORE_PROC, 43, -1}, + {44, 0, 0, 44, MAIN_CORE_PROC, 44, -1}, {45, 0, 0, 45, MAIN_CORE_PROC, 45, -1}, + {46, 0, 0, 46, MAIN_CORE_PROC, 46, -1}, {47, 0, 0, 47, MAIN_CORE_PROC, 47, -1}, + {48, 0, 0, 48, MAIN_CORE_PROC, 48, -1}, {49, 0, 0, 49, MAIN_CORE_PROC, 49, -1}, + {50, 0, 0, 50, MAIN_CORE_PROC, 50, -1}, {51, 0, 0, 51, MAIN_CORE_PROC, 51, -1}, + {52, 0, 0, 52, MAIN_CORE_PROC, 52, -1}, {53, 0, 0, 53, MAIN_CORE_PROC, 53, -1}, + {54, 1, 1, 54, MAIN_CORE_PROC, 54, -1}, {55, 1, 1, 55, MAIN_CORE_PROC, 55, -1}, + {56, 1, 1, 56, MAIN_CORE_PROC, 56, -1}, {57, 1, 1, 57, MAIN_CORE_PROC, 57, -1}, + {58, 1, 1, 58, MAIN_CORE_PROC, 58, -1}, {59, 1, 1, 59, MAIN_CORE_PROC, 59, -1}, + {60, 1, 1, 60, MAIN_CORE_PROC, 60, -1}, {61, 1, 1, 61, MAIN_CORE_PROC, 61, -1}, + {62, 1, 1, 62, MAIN_CORE_PROC, 62, -1}, {63, 1, 1, 63, MAIN_CORE_PROC, 63, -1}, + {64, 1, 1, 64, MAIN_CORE_PROC, 64, -1}, {65, 1, 1, 65, MAIN_CORE_PROC, 65, -1}, + {66, 1, 1, 66, MAIN_CORE_PROC, 66, -1}, {67, 1, 1, 67, MAIN_CORE_PROC, 67, -1}, + {68, 1, 1, 68, MAIN_CORE_PROC, 68, -1}, {69, 1, 1, 69, MAIN_CORE_PROC, 69, -1}, + {70, 1, 1, 70, MAIN_CORE_PROC, 70, -1}, {71, 1, 1, 71, MAIN_CORE_PROC, 71, -1}, + }, + 1, + 36, + ov::threading::IStreamsExecutor::Config::ANY, + false, + {}, + { + {1, ALL_PROC, 36, -1, -1}, + {0, MAIN_CORE_PROC, 18, 0, 0}, + {0, MAIN_CORE_PROC, 18, 1, 1}, + }, + {}, +}; + +ExecutorConfigTestCase _2sockets_streams_1_threads_30 = { + { + {72, 36, 0, 36, -1, -1}, + {36, 18, 0, 18, 0, 0}, + {36, 18, 0, 18, 1, 1}, + }, + { + {0, 0, 0, 0, HYPER_THREADING_PROC, 0, -1}, {1, 0, 0, 1, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 2, HYPER_THREADING_PROC, 2, -1}, {3, 0, 0, 3, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 4, HYPER_THREADING_PROC, 4, -1}, {5, 0, 0, 5, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 6, HYPER_THREADING_PROC, 6, -1}, {7, 0, 0, 7, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 8, HYPER_THREADING_PROC, 8, -1}, {9, 0, 0, 9, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 10, HYPER_THREADING_PROC, 10, -1}, {11, 0, 0, 11, HYPER_THREADING_PROC, 11, -1}, + {12, 0, 0, 12, HYPER_THREADING_PROC, 12, -1}, {13, 0, 0, 13, HYPER_THREADING_PROC, 13, -1}, + {14, 0, 0, 14, HYPER_THREADING_PROC, 14, -1}, {15, 0, 0, 15, HYPER_THREADING_PROC, 15, -1}, + {16, 0, 0, 16, HYPER_THREADING_PROC, 16, -1}, {17, 0, 0, 17, HYPER_THREADING_PROC, 17, -1}, + {18, 1, 1, 18, HYPER_THREADING_PROC, 18, -1}, {19, 1, 1, 19, HYPER_THREADING_PROC, 19, -1}, + {20, 1, 1, 20, HYPER_THREADING_PROC, 20, -1}, {21, 1, 1, 21, HYPER_THREADING_PROC, 21, -1}, + {22, 1, 1, 22, HYPER_THREADING_PROC, 22, -1}, {23, 1, 1, 23, HYPER_THREADING_PROC, 23, -1}, + {24, 1, 1, 24, HYPER_THREADING_PROC, 24, -1}, {25, 1, 1, 25, HYPER_THREADING_PROC, 25, -1}, + {26, 1, 1, 26, HYPER_THREADING_PROC, 26, -1}, {27, 1, 1, 27, HYPER_THREADING_PROC, 27, -1}, + {28, 1, 1, 28, HYPER_THREADING_PROC, 28, -1}, {29, 1, 1, 29, HYPER_THREADING_PROC, 29, -1}, + {30, 1, 1, 30, HYPER_THREADING_PROC, 30, -1}, {31, 1, 1, 31, HYPER_THREADING_PROC, 31, -1}, + {32, 1, 1, 32, HYPER_THREADING_PROC, 32, -1}, {33, 1, 1, 33, HYPER_THREADING_PROC, 33, -1}, + {34, 1, 1, 34, HYPER_THREADING_PROC, 34, -1}, {35, 1, 1, 35, HYPER_THREADING_PROC, 35, -1}, + {36, 0, 0, 36, MAIN_CORE_PROC, 36, -1}, {37, 0, 0, 37, MAIN_CORE_PROC, 37, -1}, + {38, 0, 0, 38, MAIN_CORE_PROC, 38, -1}, {39, 0, 0, 39, MAIN_CORE_PROC, 39, -1}, + {40, 0, 0, 40, MAIN_CORE_PROC, 40, -1}, {41, 0, 0, 41, MAIN_CORE_PROC, 41, -1}, + {42, 0, 0, 42, MAIN_CORE_PROC, 42, -1}, {43, 0, 0, 43, MAIN_CORE_PROC, 43, -1}, + {44, 0, 0, 44, MAIN_CORE_PROC, 44, -1}, {45, 0, 0, 45, MAIN_CORE_PROC, 45, -1}, + {46, 0, 0, 46, MAIN_CORE_PROC, 46, -1}, {47, 0, 0, 47, MAIN_CORE_PROC, 47, -1}, + {48, 0, 0, 48, MAIN_CORE_PROC, 48, -1}, {49, 0, 0, 49, MAIN_CORE_PROC, 49, -1}, + {50, 0, 0, 50, MAIN_CORE_PROC, 50, -1}, {51, 0, 0, 51, MAIN_CORE_PROC, 51, -1}, + {52, 0, 0, 52, MAIN_CORE_PROC, 52, -1}, {53, 0, 0, 53, MAIN_CORE_PROC, 53, -1}, + {54, 1, 1, 54, MAIN_CORE_PROC, 54, -1}, {55, 1, 1, 55, MAIN_CORE_PROC, 55, -1}, + {56, 1, 1, 56, MAIN_CORE_PROC, 56, -1}, {57, 1, 1, 57, MAIN_CORE_PROC, 57, -1}, + {58, 1, 1, 58, MAIN_CORE_PROC, 58, -1}, {59, 1, 1, 59, MAIN_CORE_PROC, 59, -1}, + {60, 1, 1, 60, MAIN_CORE_PROC, 60, -1}, {61, 1, 1, 61, MAIN_CORE_PROC, 61, -1}, + {62, 1, 1, 62, MAIN_CORE_PROC, 62, -1}, {63, 1, 1, 63, MAIN_CORE_PROC, 63, -1}, + {64, 1, 1, 64, MAIN_CORE_PROC, 64, -1}, {65, 1, 1, 65, MAIN_CORE_PROC, 65, -1}, + {66, 1, 1, 66, MAIN_CORE_PROC, 66, -1}, {67, 1, 1, 67, MAIN_CORE_PROC, 67, -1}, + {68, 1, 1, 68, MAIN_CORE_PROC, 68, -1}, {69, 1, 1, 69, MAIN_CORE_PROC, 69, -1}, + {70, 1, 1, 70, MAIN_CORE_PROC, 70, -1}, {71, 1, 1, 71, MAIN_CORE_PROC, 71, -1}, + }, + 1, + 30, + ov::threading::IStreamsExecutor::Config::ANY, + false, + {}, + { + {1, ALL_PROC, 30, -1, -1}, + {0, MAIN_CORE_PROC, 18, 0, 0}, + {0, MAIN_CORE_PROC, 12, 1, 1}, + }, + {}, +}; + +ExecutorConfigTestCase _pecore_streams_5_threads_2 = { + { + {24, 8, 8, 8, 0, 0}, + }, + { + {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 4, MAIN_CORE_PROC, 8, -1}, {9, 0, 0, 4, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 5, MAIN_CORE_PROC, 10, -1}, {11, 0, 0, 5, HYPER_THREADING_PROC, 11, -1}, + {12, 0, 0, 6, MAIN_CORE_PROC, 12, -1}, {13, 0, 0, 6, HYPER_THREADING_PROC, 13, -1}, + {14, 0, 0, 7, MAIN_CORE_PROC, 14, -1}, {15, 0, 0, 7, HYPER_THREADING_PROC, 15, -1}, + {16, 0, 0, 8, EFFICIENT_CORE_PROC, 16, -1}, {17, 0, 0, 9, EFFICIENT_CORE_PROC, 17, -1}, + {18, 0, 0, 10, EFFICIENT_CORE_PROC, 18, -1}, {19, 0, 0, 11, EFFICIENT_CORE_PROC, 19, -1}, + {20, 0, 0, 12, EFFICIENT_CORE_PROC, 20, -1}, {21, 0, 0, 13, EFFICIENT_CORE_PROC, 21, -1}, + {22, 0, 0, 14, EFFICIENT_CORE_PROC, 22, -1}, {23, 0, 0, 15, EFFICIENT_CORE_PROC, 23, -1}, + }, + 5, + 2, + ov::threading::IStreamsExecutor::Config::ANY, + false, + {}, + { + {4, MAIN_CORE_PROC, 2, 0, 0}, + {1, EFFICIENT_CORE_PROC, 2, 0, 0}, + }, + {}, +}; + +ExecutorConfigTestCase _pecore_streams_5_threads_5 = { + { + {24, 8, 8, 8, 0, 0}, + }, + { + {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 4, MAIN_CORE_PROC, 8, -1}, {9, 0, 0, 4, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 5, MAIN_CORE_PROC, 10, -1}, {11, 0, 0, 5, HYPER_THREADING_PROC, 11, -1}, + {12, 0, 0, 6, MAIN_CORE_PROC, 12, -1}, {13, 0, 0, 6, HYPER_THREADING_PROC, 13, -1}, + {14, 0, 0, 7, MAIN_CORE_PROC, 14, -1}, {15, 0, 0, 7, HYPER_THREADING_PROC, 15, -1}, + {16, 0, 0, 8, EFFICIENT_CORE_PROC, 16, -1}, {17, 0, 0, 9, EFFICIENT_CORE_PROC, 17, -1}, + {18, 0, 0, 10, EFFICIENT_CORE_PROC, 18, -1}, {19, 0, 0, 11, EFFICIENT_CORE_PROC, 19, -1}, + {20, 0, 0, 12, EFFICIENT_CORE_PROC, 20, -1}, {21, 0, 0, 13, EFFICIENT_CORE_PROC, 21, -1}, + {22, 0, 0, 14, EFFICIENT_CORE_PROC, 22, -1}, {23, 0, 0, 15, EFFICIENT_CORE_PROC, 23, -1}, + }, + 5, + 5, + ov::threading::IStreamsExecutor::Config::ANY, + false, + {}, + { + {2, MAIN_CORE_PROC, 4, 0, 0}, + {2, EFFICIENT_CORE_PROC, 4, 0, 0}, + {1, HYPER_THREADING_PROC, 4, 0, 0}, + }, + {}, +}; + +ExecutorConfigTestCase _pecore_streams_4_threads_5 = { + { + {24, 8, 8, 8, 0, 0}, + }, + { + {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 4, MAIN_CORE_PROC, 8, -1}, {9, 0, 0, 4, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 5, MAIN_CORE_PROC, 10, -1}, {11, 0, 0, 5, HYPER_THREADING_PROC, 11, -1}, + {12, 0, 0, 6, MAIN_CORE_PROC, 12, -1}, {13, 0, 0, 6, HYPER_THREADING_PROC, 13, -1}, + {14, 0, 0, 7, MAIN_CORE_PROC, 14, -1}, {15, 0, 0, 7, HYPER_THREADING_PROC, 15, -1}, + {16, 0, 0, 8, EFFICIENT_CORE_PROC, 16, -1}, {17, 0, 0, 9, EFFICIENT_CORE_PROC, 17, -1}, + {18, 0, 0, 10, EFFICIENT_CORE_PROC, 18, -1}, {19, 0, 0, 11, EFFICIENT_CORE_PROC, 19, -1}, + {20, 0, 0, 12, EFFICIENT_CORE_PROC, 20, -1}, {21, 0, 0, 13, EFFICIENT_CORE_PROC, 21, -1}, + {22, 0, 0, 14, EFFICIENT_CORE_PROC, 22, -1}, {23, 0, 0, 15, EFFICIENT_CORE_PROC, 23, -1}, + }, + 4, + 5, + ov::threading::IStreamsExecutor::Config::ANY, + false, + {}, + { + {1, MAIN_CORE_PROC, 5, 0, 0}, + {1, EFFICIENT_CORE_PROC, 5, 0, 0}, + {1, HYPER_THREADING_PROC, 5, 0, 0}, + }, + {}, +}; + +ExecutorConfigTestCase _pecore_streams_4_threads_1 = { + { + {24, 8, 8, 8, 0, 0}, + }, + { + {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 4, MAIN_CORE_PROC, 8, -1}, {9, 0, 0, 4, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 5, MAIN_CORE_PROC, 10, -1}, {11, 0, 0, 5, HYPER_THREADING_PROC, 11, -1}, + {12, 0, 0, 6, MAIN_CORE_PROC, 12, -1}, {13, 0, 0, 6, HYPER_THREADING_PROC, 13, -1}, + {14, 0, 0, 7, MAIN_CORE_PROC, 14, -1}, {15, 0, 0, 7, HYPER_THREADING_PROC, 15, -1}, + {16, 0, 0, 8, EFFICIENT_CORE_PROC, 16, -1}, {17, 0, 0, 9, EFFICIENT_CORE_PROC, 17, -1}, + {18, 0, 0, 10, EFFICIENT_CORE_PROC, 18, -1}, {19, 0, 0, 11, EFFICIENT_CORE_PROC, 19, -1}, + {20, 0, 0, 12, EFFICIENT_CORE_PROC, 20, -1}, {21, 0, 0, 13, EFFICIENT_CORE_PROC, 21, -1}, + {22, 0, 0, 14, EFFICIENT_CORE_PROC, 22, -1}, {23, 0, 0, 15, EFFICIENT_CORE_PROC, 23, -1}, + }, + 4, + 1, + ov::threading::IStreamsExecutor::Config::ANY, + false, + {}, + { + {4, MAIN_CORE_PROC, 1, 0, 0}, + }, + {}, +}; + +ExecutorConfigTestCase _pecore_streams_5_threads_10 = { + { + {24, 8, 8, 8, 0, 0}, + }, + { + {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 4, MAIN_CORE_PROC, 8, -1}, {9, 0, 0, 4, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 5, MAIN_CORE_PROC, 10, -1}, {11, 0, 0, 5, HYPER_THREADING_PROC, 11, -1}, + {12, 0, 0, 6, MAIN_CORE_PROC, 12, -1}, {13, 0, 0, 6, HYPER_THREADING_PROC, 13, -1}, + {14, 0, 0, 7, MAIN_CORE_PROC, 14, -1}, {15, 0, 0, 7, HYPER_THREADING_PROC, 15, -1}, + {16, 0, 0, 8, EFFICIENT_CORE_PROC, 16, -1}, {17, 0, 0, 9, EFFICIENT_CORE_PROC, 17, -1}, + {18, 0, 0, 10, EFFICIENT_CORE_PROC, 18, -1}, {19, 0, 0, 11, EFFICIENT_CORE_PROC, 19, -1}, + {20, 0, 0, 12, EFFICIENT_CORE_PROC, 20, -1}, {21, 0, 0, 13, EFFICIENT_CORE_PROC, 21, -1}, + {22, 0, 0, 14, EFFICIENT_CORE_PROC, 22, -1}, {23, 0, 0, 15, EFFICIENT_CORE_PROC, 23, -1}, + }, + 5, + 10, + ov::threading::IStreamsExecutor::Config::ANY, + false, + {}, + { + {2, MAIN_CORE_PROC, 4, 0, 0}, + {2, EFFICIENT_CORE_PROC, 4, 0, 0}, + {1, HYPER_THREADING_PROC, 4, 0, 0}, + }, + {}, +}; + +ExecutorConfigTestCase _pecore_streams_26_threads_1 = { + { + {24, 8, 8, 8, 0, 0}, + }, + { + {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 4, MAIN_CORE_PROC, 8, -1}, {9, 0, 0, 4, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 5, MAIN_CORE_PROC, 10, -1}, {11, 0, 0, 5, HYPER_THREADING_PROC, 11, -1}, + {12, 0, 0, 6, MAIN_CORE_PROC, 12, -1}, {13, 0, 0, 6, HYPER_THREADING_PROC, 13, -1}, + {14, 0, 0, 7, MAIN_CORE_PROC, 14, -1}, {15, 0, 0, 7, HYPER_THREADING_PROC, 15, -1}, + {16, 0, 0, 8, EFFICIENT_CORE_PROC, 16, -1}, {17, 0, 0, 9, EFFICIENT_CORE_PROC, 17, -1}, + {18, 0, 0, 10, EFFICIENT_CORE_PROC, 18, -1}, {19, 0, 0, 11, EFFICIENT_CORE_PROC, 19, -1}, + {20, 0, 0, 12, EFFICIENT_CORE_PROC, 20, -1}, {21, 0, 0, 13, EFFICIENT_CORE_PROC, 21, -1}, + {22, 0, 0, 14, EFFICIENT_CORE_PROC, 22, -1}, {23, 0, 0, 15, EFFICIENT_CORE_PROC, 23, -1}, + }, + 26, + 1, + ov::threading::IStreamsExecutor::Config::ANY, + false, + {}, + { + {8, MAIN_CORE_PROC, 1, 0, 0}, + {8, EFFICIENT_CORE_PROC, 1, 0, 0}, + {8, HYPER_THREADING_PROC, 1, 0, 0}, + }, + {}, +}; + +ExecutorConfigTestCase _pecore_streams_26_threads_1_p = { + { + {24, 8, 8, 8, 0, 0}, + }, + { + {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 4, MAIN_CORE_PROC, 8, -1}, {9, 0, 0, 4, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 5, MAIN_CORE_PROC, 10, -1}, {11, 0, 0, 5, HYPER_THREADING_PROC, 11, -1}, + {12, 0, 0, 6, MAIN_CORE_PROC, 12, -1}, {13, 0, 0, 6, HYPER_THREADING_PROC, 13, -1}, + {14, 0, 0, 7, MAIN_CORE_PROC, 14, -1}, {15, 0, 0, 7, HYPER_THREADING_PROC, 15, -1}, + {16, 0, 0, 8, EFFICIENT_CORE_PROC, 16, -1}, {17, 0, 0, 9, EFFICIENT_CORE_PROC, 17, -1}, + {18, 0, 0, 10, EFFICIENT_CORE_PROC, 18, -1}, {19, 0, 0, 11, EFFICIENT_CORE_PROC, 19, -1}, + {20, 0, 0, 12, EFFICIENT_CORE_PROC, 20, -1}, {21, 0, 0, 13, EFFICIENT_CORE_PROC, 21, -1}, + {22, 0, 0, 14, EFFICIENT_CORE_PROC, 22, -1}, {23, 0, 0, 15, EFFICIENT_CORE_PROC, 23, -1}, + }, + 26, + 1, + ov::threading::IStreamsExecutor::Config::BIG, + false, + {}, + { + {8, MAIN_CORE_PROC, 1, 0, 0}, + {8, HYPER_THREADING_PROC, 1, 0, 0}, + }, + {}, +}; + +ExecutorConfigTestCase _pecore_streams_26_threads_1_e = { + { + {24, 8, 8, 8, 0, 0}, + }, + { + {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 4, MAIN_CORE_PROC, 8, -1}, {9, 0, 0, 4, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 5, MAIN_CORE_PROC, 10, -1}, {11, 0, 0, 5, HYPER_THREADING_PROC, 11, -1}, + {12, 0, 0, 6, MAIN_CORE_PROC, 12, -1}, {13, 0, 0, 6, HYPER_THREADING_PROC, 13, -1}, + {14, 0, 0, 7, MAIN_CORE_PROC, 14, -1}, {15, 0, 0, 7, HYPER_THREADING_PROC, 15, -1}, + {16, 0, 0, 8, EFFICIENT_CORE_PROC, 16, -1}, {17, 0, 0, 9, EFFICIENT_CORE_PROC, 17, -1}, + {18, 0, 0, 10, EFFICIENT_CORE_PROC, 18, -1}, {19, 0, 0, 11, EFFICIENT_CORE_PROC, 19, -1}, + {20, 0, 0, 12, EFFICIENT_CORE_PROC, 20, -1}, {21, 0, 0, 13, EFFICIENT_CORE_PROC, 21, -1}, + {22, 0, 0, 14, EFFICIENT_CORE_PROC, 22, -1}, {23, 0, 0, 15, EFFICIENT_CORE_PROC, 23, -1}, + }, + 26, + 1, + ov::threading::IStreamsExecutor::Config::LITTLE, + false, + {}, + { + {8, EFFICIENT_CORE_PROC, 1, 0, 0}, + }, + {}, +}; + +ExecutorConfigTestCase _pecore_streams_1_threads_0 = { + { + {24, 8, 8, 8, 0, 0}, + }, + { + {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 4, MAIN_CORE_PROC, 8, -1}, {9, 0, 0, 4, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 5, MAIN_CORE_PROC, 10, -1}, {11, 0, 0, 5, HYPER_THREADING_PROC, 11, -1}, + {12, 0, 0, 6, MAIN_CORE_PROC, 12, -1}, {13, 0, 0, 6, HYPER_THREADING_PROC, 13, -1}, + {14, 0, 0, 7, MAIN_CORE_PROC, 14, -1}, {15, 0, 0, 7, HYPER_THREADING_PROC, 15, -1}, + {16, 0, 0, 8, EFFICIENT_CORE_PROC, 16, -1}, {17, 0, 0, 9, EFFICIENT_CORE_PROC, 17, -1}, + {18, 0, 0, 10, EFFICIENT_CORE_PROC, 18, -1}, {19, 0, 0, 11, EFFICIENT_CORE_PROC, 19, -1}, + {20, 0, 0, 12, EFFICIENT_CORE_PROC, 20, -1}, {21, 0, 0, 13, EFFICIENT_CORE_PROC, 21, -1}, + {22, 0, 0, 14, EFFICIENT_CORE_PROC, 22, -1}, {23, 0, 0, 15, EFFICIENT_CORE_PROC, 23, -1}, + }, + 1, + 0, + ov::threading::IStreamsExecutor::Config::ANY, + false, + {}, + {}, + {}, +}; + +ExecutorConfigTestCase _pecore_streams_1_threads_1_p = { + { + {24, 8, 8, 8, 0, 0}, + }, + { + {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 4, MAIN_CORE_PROC, 8, -1}, {9, 0, 0, 4, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 5, MAIN_CORE_PROC, 10, -1}, {11, 0, 0, 5, HYPER_THREADING_PROC, 11, -1}, + {12, 0, 0, 6, MAIN_CORE_PROC, 12, -1}, {13, 0, 0, 6, HYPER_THREADING_PROC, 13, -1}, + {14, 0, 0, 7, MAIN_CORE_PROC, 14, -1}, {15, 0, 0, 7, HYPER_THREADING_PROC, 15, -1}, + {16, 0, 0, 8, EFFICIENT_CORE_PROC, 16, -1}, {17, 0, 0, 9, EFFICIENT_CORE_PROC, 17, -1}, + {18, 0, 0, 10, EFFICIENT_CORE_PROC, 18, -1}, {19, 0, 0, 11, EFFICIENT_CORE_PROC, 19, -1}, + {20, 0, 0, 12, EFFICIENT_CORE_PROC, 20, -1}, {21, 0, 0, 13, EFFICIENT_CORE_PROC, 21, -1}, + {22, 0, 0, 14, EFFICIENT_CORE_PROC, 22, -1}, {23, 0, 0, 15, EFFICIENT_CORE_PROC, 23, -1}, + }, + 1, + 1, + ov::threading::IStreamsExecutor::Config::BIG, + false, + {}, + { + {1, MAIN_CORE_PROC, 1, 0, 0}, + }, + {}, +}; + +ExecutorConfigTestCase _pecore_streams_1_threads_1_e = { + { + {24, 8, 8, 8, 0, 0}, + }, + { + {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 4, MAIN_CORE_PROC, 8, -1}, {9, 0, 0, 4, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 5, MAIN_CORE_PROC, 10, -1}, {11, 0, 0, 5, HYPER_THREADING_PROC, 11, -1}, + {12, 0, 0, 6, MAIN_CORE_PROC, 12, -1}, {13, 0, 0, 6, HYPER_THREADING_PROC, 13, -1}, + {14, 0, 0, 7, MAIN_CORE_PROC, 14, -1}, {15, 0, 0, 7, HYPER_THREADING_PROC, 15, -1}, + {16, 0, 0, 8, EFFICIENT_CORE_PROC, 16, -1}, {17, 0, 0, 9, EFFICIENT_CORE_PROC, 17, -1}, + {18, 0, 0, 10, EFFICIENT_CORE_PROC, 18, -1}, {19, 0, 0, 11, EFFICIENT_CORE_PROC, 19, -1}, + {20, 0, 0, 12, EFFICIENT_CORE_PROC, 20, -1}, {21, 0, 0, 13, EFFICIENT_CORE_PROC, 21, -1}, + {22, 0, 0, 14, EFFICIENT_CORE_PROC, 22, -1}, {23, 0, 0, 15, EFFICIENT_CORE_PROC, 23, -1}, + }, + 1, + 1, + ov::threading::IStreamsExecutor::Config::LITTLE, + false, + {}, + { + {1, EFFICIENT_CORE_PROC, 1, 0, 0}, + }, + {}, +}; + +ExecutorConfigTestCase _pecore_streams_1_threads_16_p = { + { + {24, 8, 8, 8, 0, 0}, + }, + { + {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 4, MAIN_CORE_PROC, 8, -1}, {9, 0, 0, 4, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 5, MAIN_CORE_PROC, 10, -1}, {11, 0, 0, 5, HYPER_THREADING_PROC, 11, -1}, + {12, 0, 0, 6, MAIN_CORE_PROC, 12, -1}, {13, 0, 0, 6, HYPER_THREADING_PROC, 13, -1}, + {14, 0, 0, 7, MAIN_CORE_PROC, 14, -1}, {15, 0, 0, 7, HYPER_THREADING_PROC, 15, -1}, + {16, 0, 0, 8, EFFICIENT_CORE_PROC, 16, -1}, {17, 0, 0, 9, EFFICIENT_CORE_PROC, 17, -1}, + {18, 0, 0, 10, EFFICIENT_CORE_PROC, 18, -1}, {19, 0, 0, 11, EFFICIENT_CORE_PROC, 19, -1}, + {20, 0, 0, 12, EFFICIENT_CORE_PROC, 20, -1}, {21, 0, 0, 13, EFFICIENT_CORE_PROC, 21, -1}, + {22, 0, 0, 14, EFFICIENT_CORE_PROC, 22, -1}, {23, 0, 0, 15, EFFICIENT_CORE_PROC, 23, -1}, + }, + 1, + 16, + ov::threading::IStreamsExecutor::Config::BIG, + false, + {}, + { + {1, ALL_PROC, 16, 0, 0}, + {0, MAIN_CORE_PROC, 8, 0, 0}, + {0, HYPER_THREADING_PROC, 8, 0, 0}, + }, + {}, +}; + +ExecutorConfigTestCase _pecore_streams_1_threads_18_p = { + { + {24, 8, 8, 8, 0, 0}, + }, + { + {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 4, MAIN_CORE_PROC, 8, -1}, {9, 0, 0, 4, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 5, MAIN_CORE_PROC, 10, -1}, {11, 0, 0, 5, HYPER_THREADING_PROC, 11, -1}, + {12, 0, 0, 6, MAIN_CORE_PROC, 12, -1}, {13, 0, 0, 6, HYPER_THREADING_PROC, 13, -1}, + {14, 0, 0, 7, MAIN_CORE_PROC, 14, -1}, {15, 0, 0, 7, HYPER_THREADING_PROC, 15, -1}, + {16, 0, 0, 8, EFFICIENT_CORE_PROC, 16, -1}, {17, 0, 0, 9, EFFICIENT_CORE_PROC, 17, -1}, + {18, 0, 0, 10, EFFICIENT_CORE_PROC, 18, -1}, {19, 0, 0, 11, EFFICIENT_CORE_PROC, 19, -1}, + {20, 0, 0, 12, EFFICIENT_CORE_PROC, 20, -1}, {21, 0, 0, 13, EFFICIENT_CORE_PROC, 21, -1}, + {22, 0, 0, 14, EFFICIENT_CORE_PROC, 22, -1}, {23, 0, 0, 15, EFFICIENT_CORE_PROC, 23, -1}, + }, + 1, + 18, + ov::threading::IStreamsExecutor::Config::BIG, + false, + {}, + { + {1, ALL_PROC, 16, 0, 0}, + {0, MAIN_CORE_PROC, 8, 0, 0}, + {0, HYPER_THREADING_PROC, 8, 0, 0}, + }, + {}, +}; + +ExecutorConfigTestCase _pecore_streams_1_threads_10_p = { + { + {24, 8, 8, 8, 0, 0}, + }, + { + {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 4, MAIN_CORE_PROC, 8, -1}, {9, 0, 0, 4, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 5, MAIN_CORE_PROC, 10, -1}, {11, 0, 0, 5, HYPER_THREADING_PROC, 11, -1}, + {12, 0, 0, 6, MAIN_CORE_PROC, 12, -1}, {13, 0, 0, 6, HYPER_THREADING_PROC, 13, -1}, + {14, 0, 0, 7, MAIN_CORE_PROC, 14, -1}, {15, 0, 0, 7, HYPER_THREADING_PROC, 15, -1}, + {16, 0, 0, 8, EFFICIENT_CORE_PROC, 16, -1}, {17, 0, 0, 9, EFFICIENT_CORE_PROC, 17, -1}, + {18, 0, 0, 10, EFFICIENT_CORE_PROC, 18, -1}, {19, 0, 0, 11, EFFICIENT_CORE_PROC, 19, -1}, + {20, 0, 0, 12, EFFICIENT_CORE_PROC, 20, -1}, {21, 0, 0, 13, EFFICIENT_CORE_PROC, 21, -1}, + {22, 0, 0, 14, EFFICIENT_CORE_PROC, 22, -1}, {23, 0, 0, 15, EFFICIENT_CORE_PROC, 23, -1}, + }, + 1, + 10, + ov::threading::IStreamsExecutor::Config::BIG, + false, + {}, + { + {1, ALL_PROC, 10, 0, 0}, + {0, MAIN_CORE_PROC, 8, 0, 0}, + {0, HYPER_THREADING_PROC, 2, 0, 0}, + }, + {}, +}; + +ExecutorConfigTestCase _pecore_streams_10_threads_1_e = { + { + {24, 8, 8, 8, 0, 0}, + }, + { + {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 4, MAIN_CORE_PROC, 8, -1}, {9, 0, 0, 4, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 5, MAIN_CORE_PROC, 10, -1}, {11, 0, 0, 5, HYPER_THREADING_PROC, 11, -1}, + {12, 0, 0, 6, MAIN_CORE_PROC, 12, -1}, {13, 0, 0, 6, HYPER_THREADING_PROC, 13, -1}, + {14, 0, 0, 7, MAIN_CORE_PROC, 14, -1}, {15, 0, 0, 7, HYPER_THREADING_PROC, 15, -1}, + {16, 0, 0, 8, EFFICIENT_CORE_PROC, 16, -1}, {17, 0, 0, 9, EFFICIENT_CORE_PROC, 17, -1}, + {18, 0, 0, 10, EFFICIENT_CORE_PROC, 18, -1}, {19, 0, 0, 11, EFFICIENT_CORE_PROC, 19, -1}, + {20, 0, 0, 12, EFFICIENT_CORE_PROC, 20, -1}, {21, 0, 0, 13, EFFICIENT_CORE_PROC, 21, -1}, + {22, 0, 0, 14, EFFICIENT_CORE_PROC, 22, -1}, {23, 0, 0, 15, EFFICIENT_CORE_PROC, 23, -1}, + }, + 10, + 1, + ov::threading::IStreamsExecutor::Config::LITTLE, + false, + {}, + { + {8, EFFICIENT_CORE_PROC, 1, 0, 0}, + }, + {}, +}; + +ExecutorConfigTestCase _pecore_streams_10_threads_1_binding = { + { + {24, 8, 8, 8, 0, 0}, + }, + { + {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 4, MAIN_CORE_PROC, 8, -1}, {9, 0, 0, 4, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 5, MAIN_CORE_PROC, 10, -1}, {11, 0, 0, 5, HYPER_THREADING_PROC, 11, -1}, + {12, 0, 0, 6, MAIN_CORE_PROC, 12, -1}, {13, 0, 0, 6, HYPER_THREADING_PROC, 13, -1}, + {14, 0, 0, 7, MAIN_CORE_PROC, 14, -1}, {15, 0, 0, 7, HYPER_THREADING_PROC, 15, -1}, + {16, 0, 0, 8, EFFICIENT_CORE_PROC, 16, -1}, {17, 0, 0, 9, EFFICIENT_CORE_PROC, 17, -1}, + {18, 0, 0, 10, EFFICIENT_CORE_PROC, 18, -1}, {19, 0, 0, 11, EFFICIENT_CORE_PROC, 19, -1}, + {20, 0, 0, 12, EFFICIENT_CORE_PROC, 20, -1}, {21, 0, 0, 13, EFFICIENT_CORE_PROC, 21, -1}, + {22, 0, 0, 14, EFFICIENT_CORE_PROC, 22, -1}, {23, 0, 0, 15, EFFICIENT_CORE_PROC, 23, -1}, + }, + 10, + 2, + ov::threading::IStreamsExecutor::Config::ANY, + true, + {}, + { + {4, MAIN_CORE_PROC, 2, 0, 0}, + {4, EFFICIENT_CORE_PROC, 2, 0, 0}, + {2, HYPER_THREADING_PROC, 2, 0, 0}, + }, + {{0, 2}, {4, 6}, {8, 10}, {12, 14}, {16, 17}, {18, 19}, {20, 21}, {22, 23}, {1, 3}, {5, 7}}, +}; + +ExecutorConfigTestCase _pecore_streams_info_table_1 = { + { + {24, 8, 8, 8, 0, 0}, + }, + { + {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 4, MAIN_CORE_PROC, 8, -1}, {9, 0, 0, 4, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 5, MAIN_CORE_PROC, 10, -1}, {11, 0, 0, 5, HYPER_THREADING_PROC, 11, -1}, + {12, 0, 0, 6, MAIN_CORE_PROC, 12, -1}, {13, 0, 0, 6, HYPER_THREADING_PROC, 13, -1}, + {14, 0, 0, 7, MAIN_CORE_PROC, 14, -1}, {15, 0, 0, 7, HYPER_THREADING_PROC, 15, -1}, + {16, 0, 0, 8, EFFICIENT_CORE_PROC, 16, -1}, {17, 0, 0, 9, EFFICIENT_CORE_PROC, 17, -1}, + {18, 0, 0, 10, EFFICIENT_CORE_PROC, 18, -1}, {19, 0, 0, 11, EFFICIENT_CORE_PROC, 19, -1}, + {20, 0, 0, 12, EFFICIENT_CORE_PROC, 20, -1}, {21, 0, 0, 13, EFFICIENT_CORE_PROC, 21, -1}, + {22, 0, 0, 14, EFFICIENT_CORE_PROC, 22, -1}, {23, 0, 0, 15, EFFICIENT_CORE_PROC, 23, -1}, + }, + 1, + 8, + ov::threading::IStreamsExecutor::Config::BIG, + false, + { + {2, MAIN_CORE_PROC, 2, 0, 0}, + {2, EFFICIENT_CORE_PROC, 2, 0, 0}, + }, + { + {2, MAIN_CORE_PROC, 2, 0, 0}, + {2, EFFICIENT_CORE_PROC, 2, 0, 0}, + }, + {}, +}; + +ExecutorConfigTestCase _pecore_streams_info_table_2 = { + { + {24, 8, 8, 8, 0, 0}, + }, + { + {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 4, MAIN_CORE_PROC, 8, -1}, {9, 0, 0, 4, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 5, MAIN_CORE_PROC, 10, -1}, {11, 0, 0, 5, HYPER_THREADING_PROC, 11, -1}, + {12, 0, 0, 6, MAIN_CORE_PROC, 12, -1}, {13, 0, 0, 6, HYPER_THREADING_PROC, 13, -1}, + {14, 0, 0, 7, MAIN_CORE_PROC, 14, -1}, {15, 0, 0, 7, HYPER_THREADING_PROC, 15, -1}, + {16, 0, 0, 8, EFFICIENT_CORE_PROC, 16, -1}, {17, 0, 0, 9, EFFICIENT_CORE_PROC, 17, -1}, + {18, 0, 0, 10, EFFICIENT_CORE_PROC, 18, -1}, {19, 0, 0, 11, EFFICIENT_CORE_PROC, 19, -1}, + {20, 0, 0, 12, EFFICIENT_CORE_PROC, 20, -1}, {21, 0, 0, 13, EFFICIENT_CORE_PROC, 21, -1}, + {22, 0, 0, 14, EFFICIENT_CORE_PROC, 22, -1}, {23, 0, 0, 15, EFFICIENT_CORE_PROC, 23, -1}, + }, + 1, + 8, + ov::threading::IStreamsExecutor::Config::BIG, + false, + { + {5, MAIN_CORE_PROC, 2, 0, 0}, + {2, EFFICIENT_CORE_PROC, 2, 0, 0}, + }, + { + {1, MAIN_CORE_PROC, 8, 0, 0}, + }, + {}, +}; + +ExecutorConfigTestCase _pecore_streams_info_table_3 = { + { + {24, 8, 8, 8, 0, 0}, + }, + { + {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, + {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, + {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, + {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, + {8, 0, 0, 4, MAIN_CORE_PROC, 8, -1}, {9, 0, 0, 4, HYPER_THREADING_PROC, 9, -1}, + {10, 0, 0, 5, MAIN_CORE_PROC, 10, -1}, {11, 0, 0, 5, HYPER_THREADING_PROC, 11, -1}, + {12, 0, 0, 6, MAIN_CORE_PROC, 12, -1}, {13, 0, 0, 6, HYPER_THREADING_PROC, 13, -1}, + {14, 0, 0, 7, MAIN_CORE_PROC, 14, -1}, {15, 0, 0, 7, HYPER_THREADING_PROC, 15, -1}, + {16, 0, 0, 8, EFFICIENT_CORE_PROC, 16, -1}, {17, 0, 0, 9, EFFICIENT_CORE_PROC, 17, -1}, + {18, 0, 0, 10, EFFICIENT_CORE_PROC, 18, -1}, {19, 0, 0, 11, EFFICIENT_CORE_PROC, 19, -1}, + {20, 0, 0, 12, EFFICIENT_CORE_PROC, 20, -1}, {21, 0, 0, 13, EFFICIENT_CORE_PROC, 21, -1}, + {22, 0, 0, 14, EFFICIENT_CORE_PROC, 22, -1}, {23, 0, 0, 15, EFFICIENT_CORE_PROC, 23, -1}, + }, + 1, + 8, + ov::threading::IStreamsExecutor::Config::BIG, + true, + { + {2, MAIN_CORE_PROC, 2, 0, 0}, + {2, EFFICIENT_CORE_PROC, 2, 0, 0}, + {2, HYPER_THREADING_PROC, 2, 0, 0}, + }, + { + {2, MAIN_CORE_PROC, 2, 0, 0}, + {2, EFFICIENT_CORE_PROC, 2, 0, 0}, + {2, HYPER_THREADING_PROC, 2, 0, 0}, + }, + {{0, 2}, {4, 6}, {16, 17}, {18, 19}, {1, 3}, {5, 7}}, +}; + +TEST_P(ExecutorConfigTest, ExecutorConfig) {} + +INSTANTIATE_TEST_SUITE_P(smoke_ExecutorConfig, + ExecutorConfigTest, + testing::Values(_1sockets_streams_4_threads_1, + _1sockets_streams_4_threads_0, + _1sockets_streams_1_threads_12, + _1sockets_streams_1_threads_10, + _1sockets_streams_12_threads_1, + _1sockets_streams_13_threads_1, + _1sockets_streams_6_threads_1_core_e, + _1sockets_streams_5_threads_1_binding, + _2sockets_streams_36_threads_1, + _2sockets_streams_4_threads_5, + _2sockets_streams_1_threads_36, + _2sockets_streams_1_threads_30, + _pecore_streams_5_threads_2, + _pecore_streams_5_threads_5, + _pecore_streams_4_threads_5, + _pecore_streams_4_threads_1, + _pecore_streams_5_threads_10, + _pecore_streams_26_threads_1, + _pecore_streams_26_threads_1_p, + _pecore_streams_26_threads_1_e, + _pecore_streams_1_threads_0, + _pecore_streams_1_threads_1_p, + _pecore_streams_1_threads_1_e, + _pecore_streams_1_threads_16_p, + _pecore_streams_1_threads_18_p, + _pecore_streams_1_threads_10_p, + _pecore_streams_10_threads_1_e, + _pecore_streams_10_threads_1_binding, + _pecore_streams_info_table_1, + _pecore_streams_info_table_2, + _pecore_streams_info_table_3)); +#endif +} // namespace \ No newline at end of file diff --git a/src/inference/tests/unit/ie_executor_manager_tests.cpp b/src/inference/tests/unit/executor_manager_tests.cpp similarity index 100% rename from src/inference/tests/unit/ie_executor_manager_tests.cpp rename to src/inference/tests/unit/executor_manager_tests.cpp diff --git a/src/inference/tests/unit/ie_blob_test.cpp b/src/inference/tests/unit/ie_blob_test.cpp deleted file mode 100644 index ae7dd7e7a8d5c4..00000000000000 --- a/src/inference/tests/unit/ie_blob_test.cpp +++ /dev/null @@ -1,553 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include -#include - -#include "blob_factory.hpp" -#include "openvino/runtime/make_tensor.hpp" -#include "unit_test_utils/mocks/mock_allocator.hpp" - -IE_SUPPRESS_DEPRECATED_START - -class BlobTests : public ::testing::Test { -protected: - std::shared_ptr createMockAllocator() { - return std::shared_ptr(new MockAllocator()); - } -}; - -// Testing TBlob(const TensorDesc& tensorDesc, T* ptr, size_t data_size = 0) -TEST_F(BlobTests, TBlobThrowsIfPtrForPreAllocatorIsNullPtr) { - ASSERT_THROW(InferenceEngine::TBlob({InferenceEngine::Precision::FP32, {1}, InferenceEngine::C}, nullptr), - InferenceEngine::Exception); -} - -// Testing TBlob(const TensorDesc& tensorDesc, const std::std::shared_ptr& alloc) -TEST_F(BlobTests, TBlobThrowsIfAllocatorIsNullPtr) { - ASSERT_THROW(InferenceEngine::TBlob({InferenceEngine::Precision::FP32, {1}, InferenceEngine::C}, - std::shared_ptr()), - InferenceEngine::Exception); -} - -TEST_F(BlobTests, canCreateBlobUsingDefaultAllocator) { - InferenceEngine::SizeVector v = {1, 2, 3}; - auto allocator = createMockAllocator(); - - EXPECT_CALL(*allocator.get(), alloc(1 * 2 * 3 * sizeof(float))) - .WillRepeatedly(testing::Return(reinterpret_cast(1))); - EXPECT_CALL(*allocator.get(), free(::testing::_)).Times(1); - - { - InferenceEngine::TBlob blob({InferenceEngine::Precision::FP32, v, InferenceEngine::CHW}, - std::dynamic_pointer_cast(allocator)); - blob.allocate(); - } -} - -TEST_F(BlobTests, secondAllocateWontMemLeak) { - InferenceEngine::SizeVector v = {1, 2, 3}; - auto allocator = createMockAllocator(); - - EXPECT_CALL(*allocator.get(), alloc(1 * 2 * 3 * sizeof(float))) - .Times(2) - .WillRepeatedly(testing::Return(reinterpret_cast(1))); - EXPECT_CALL(*allocator.get(), free(::testing::_)).Times(2).WillRepeatedly(testing::Return(true)); - - { - InferenceEngine::TBlob blob({InferenceEngine::Precision::FP32, v, InferenceEngine::CHW}, - std::dynamic_pointer_cast(allocator)); - blob.allocate(); - blob.allocate(); - } -} - -TEST_F(BlobTests, doesNotUnlockIfLockFailed) { - InferenceEngine::SizeVector v = {1, 2, 3}; - auto allocator = createMockAllocator(); - - EXPECT_CALL(*allocator.get(), alloc(1 * 2 * 3 * sizeof(float))) - .WillRepeatedly(testing::Return(reinterpret_cast(1))); - EXPECT_CALL(*allocator.get(), lock(reinterpret_cast(1), InferenceEngine::LOCK_FOR_WRITE)).Times(1); - EXPECT_CALL(*allocator.get(), free(::testing::_)).Times(1); - - InferenceEngine::TBlob blob({InferenceEngine::Precision::FP32, v, InferenceEngine::CHW}, - std::dynamic_pointer_cast(allocator)); - blob.allocate(); - { - float* ptr = blob.data(); - (void)ptr; - } -} - -TEST_F(BlobTests, canAccessDataUsingAllocator) { - InferenceEngine::SizeVector v = {1, 2, 3}; - auto allocator = createMockAllocator(); - - float data[] = {5.f, 6.f, 7.f}; - - EXPECT_CALL(*allocator.get(), alloc(1 * 2 * 3 * sizeof(float))) - .WillRepeatedly(testing::Return(reinterpret_cast(1))); - EXPECT_CALL(*allocator.get(), lock(reinterpret_cast(1), InferenceEngine::LOCK_FOR_WRITE)) - .WillRepeatedly(testing::Return(data)); - EXPECT_CALL(*allocator.get(), unlock(reinterpret_cast(1))).Times(1); - EXPECT_CALL(*allocator.get(), free(::testing::_)).Times(1); - - InferenceEngine::TBlob blob({InferenceEngine::Precision::FP32, v, InferenceEngine::CHW}, - std::dynamic_pointer_cast(allocator)); - blob.allocate(); - { - float* ptr = blob.data(); - ASSERT_EQ(ptr[2], 7); - } -} - -TEST_F(BlobTests, canLockReadOnlyDataForRead) { - InferenceEngine::SizeVector v = {1, 2, 3}; - auto allocator = createMockAllocator(); - - float data[] = {5, 6, 7}; - - EXPECT_CALL(*allocator.get(), alloc(1 * 2 * 3 * sizeof(float))) - .WillRepeatedly(testing::Return(reinterpret_cast(1))); - EXPECT_CALL(*allocator.get(), lock(::testing::_, InferenceEngine::LOCK_FOR_READ)) - .WillRepeatedly(testing::Return(data)); - EXPECT_CALL(*allocator.get(), free(::testing::_)).Times(1); - EXPECT_CALL(*allocator.get(), unlock(reinterpret_cast(1))).Times(1); - - InferenceEngine::TBlob blob({InferenceEngine::Precision::FP32, v, InferenceEngine::CHW}, - std::dynamic_pointer_cast(allocator)); - blob.allocate(); - - const float* ptr = blob.readOnly(); - ASSERT_EQ(ptr[2], 7); -} - -TEST_F(BlobTests, canAccessDataUsingBufferBaseMethod) { - InferenceEngine::SizeVector v = {1, 2, 3}; - auto allocator = createMockAllocator(); - - float data[] = {5, 6, 7}; - - EXPECT_CALL(*allocator.get(), alloc(1 * 2 * 3 * sizeof(float))) - .WillRepeatedly(testing::Return(reinterpret_cast(1))); - EXPECT_CALL(*allocator.get(), lock(::testing::_, InferenceEngine::LOCK_FOR_WRITE)) - .WillRepeatedly(testing::Return(data)); - EXPECT_CALL(*allocator.get(), unlock(reinterpret_cast(1))).Times(1); - EXPECT_CALL(*allocator.get(), free(::testing::_)).Times(1); - - InferenceEngine::TBlob blob({InferenceEngine::Precision::FP32, v, InferenceEngine::CHW}, - std::dynamic_pointer_cast(allocator)); - blob.allocate(); - auto buffer = blob.rwmap(); - const float* ptr = buffer.as(); - ASSERT_EQ(ptr[2], 7); -} - -TEST_F(BlobTests, canMoveFromTBlobWithSameType) { - InferenceEngine::SizeVector v = {1, 2, 3}; - auto allocator = createMockAllocator(); - - uint8_t data[] = {5, 6}; - - EXPECT_CALL(*allocator.get(), alloc(1 * 2 * 3 * sizeof(uint8_t))) - .WillRepeatedly(testing::Return(reinterpret_cast(1))); - EXPECT_CALL(*allocator.get(), lock(::testing::_, InferenceEngine::LOCK_FOR_WRITE)) - .WillRepeatedly(testing::Return(data)); - EXPECT_CALL(*allocator.get(), unlock(reinterpret_cast(1))).Times(1); - EXPECT_CALL(*allocator.get(), free(::testing::_)).Times(1); - - InferenceEngine::TBlob blob({InferenceEngine::Precision::U8, v, InferenceEngine::CHW}, - std::dynamic_pointer_cast(allocator)); - blob.allocate(); - - InferenceEngine::TBlob newBlob(std::move(blob)); - - auto buffer = newBlob.rwmap(); - uint8_t* ptr = buffer.as(); - ASSERT_EQ(ptr[0], data[0]); -} - -TEST_F(BlobTests, saveDimsAndSizeAfterMove) { - InferenceEngine::SizeVector v = {1, 2, 3}; - auto allocator = createMockAllocator(); - - InferenceEngine::TBlob blob({InferenceEngine::Precision::U8, v, InferenceEngine::CHW}, - std::dynamic_pointer_cast(allocator)); - - InferenceEngine::TBlob newBlob(std::move(blob)); - - ASSERT_EQ(newBlob.size(), 1 * 2 * 3); - ASSERT_EQ(newBlob.getTensorDesc().getDims()[0], 1); - ASSERT_EQ(newBlob.getTensorDesc().getDims()[1], 2); - ASSERT_EQ(newBlob.getTensorDesc().getDims()[2], 3); -} - -TEST_F(BlobTests, canCopyBlob) { - InferenceEngine::SizeVector v = {1, 3}; - InferenceEngine::TBlob blob({InferenceEngine::Precision::U8, v, InferenceEngine::HW}); - blob.allocate(); - blob.data()[0] = 1; - blob.data()[1] = 2; - blob.data()[2] = 3; - - InferenceEngine::TBlob blob2(blob); - - ASSERT_EQ(blob2.getTensorDesc().getDims().size(), blob.getTensorDesc().getDims().size()); - ASSERT_EQ(blob2.getTensorDesc().getDims()[0], blob.getTensorDesc().getDims()[0]); - ASSERT_EQ(blob2.getTensorDesc().getDims()[1], blob.getTensorDesc().getDims()[1]); - ASSERT_EQ(blob2.size(), blob.size()); - ASSERT_EQ(blob2.data()[0], blob.data()[0]); - ASSERT_EQ(blob2.data()[1], blob.data()[1]); - ASSERT_EQ(blob2.data()[2], blob.data()[2]); -} - -TEST_F(BlobTests, canCompareToNullPtrWithoutDereferencing) { - InferenceEngine::SizeVector v = {1, 2, 3}; - auto allocator = createMockAllocator(); - - InferenceEngine::TBlob blob({InferenceEngine::Precision::U8, v, InferenceEngine::CHW}, - std::dynamic_pointer_cast(allocator)); - - ASSERT_TRUE(blob.readOnly() == nullptr); - ASSERT_TRUE(blob.data() == nullptr); - ASSERT_TRUE(blob.rwmap() == nullptr); - - ASSERT_TRUE(nullptr == blob.readOnly()); - ASSERT_TRUE(nullptr == blob.data()); - ASSERT_TRUE(nullptr == blob.rwmap()); -} - -TEST_F(BlobTests, canCreateBlob) { - InferenceEngine::SizeVector size = {1, 1, 1}; - InferenceEngine::TBlob blob({InferenceEngine::Precision::FP32, size, InferenceEngine::CHW}); - ASSERT_NE(blob.size(), 0); - ASSERT_EQ(blob.rwmap(), nullptr); -} - -TEST_F(BlobTests, canAllocateBlob) { - InferenceEngine::SizeVector size = {1, 1, 1}; - InferenceEngine::TBlob blob({InferenceEngine::Precision::FP32, size, InferenceEngine::CHW}); - blob.allocate(); - float* buffer = static_cast(blob.data()); - ASSERT_NE(buffer, nullptr); -} - -TEST_F(BlobTests, canDeallocateBlob) { - InferenceEngine::SizeVector size = {1, 1, 1}; - InferenceEngine::TBlob blob({InferenceEngine::Precision::FP32, size, InferenceEngine::CHW}); - blob.allocate(); - blob.deallocate(); - ASSERT_EQ(nullptr, blob.data().as()); -} - -TEST_F(BlobTests, canCreateBlobWithoutDims) { - InferenceEngine::TBlob blob( - InferenceEngine::TensorDesc(InferenceEngine::Precision::FP32, InferenceEngine::NCHW)); - ASSERT_EQ(blob.getTensorDesc().getDims().size(), 0); -} - -TEST_F(BlobTests, canReadDataFromConstBlob) { - InferenceEngine::TBlob blob({InferenceEngine::Precision::FP32, {1, 1, 1}, InferenceEngine::CHW}); - blob.allocate(); - blob.data()[0] = 1.0f; - InferenceEngine::TBlob const blob2 = blob; - const float* buf = blob2.readOnly(); - ASSERT_NE(buf, nullptr); -} - -TEST_F(BlobTests, canMakeSharedBlob) { - InferenceEngine::SizeVector size = {1, 1, 1}; - InferenceEngine::TBlob::Ptr blob1 = InferenceEngine::make_shared_blob( - InferenceEngine::TensorDesc(InferenceEngine::Precision::FP32, InferenceEngine::NCHW)); - InferenceEngine::TBlob::Ptr blob2 = - InferenceEngine::make_shared_blob({InferenceEngine::Precision::FP32, size, InferenceEngine::CHW}); - InferenceEngine::TBlob::Ptr blob3 = - InferenceEngine::make_shared_blob({InferenceEngine::Precision::FP32, {0}, InferenceEngine::C}); - InferenceEngine::TBlob::Ptr blob4 = - InferenceEngine::make_shared_blob({InferenceEngine::Precision::FP32, size, InferenceEngine::HWC}); - ASSERT_EQ(blob1->size(), 0); - ASSERT_EQ(blob2->size(), 1); - ASSERT_EQ(blob3->size(), 0); - ASSERT_EQ(blob4->size(), 1); -} - -TEST_F(BlobTests, cannotCreateBlobWithIncorrectPrecision) { - InferenceEngine::TensorDesc desc(InferenceEngine::Precision::FP16, {1, 3, 227, 227}, InferenceEngine::Layout::NCHW); - ASSERT_THROW(InferenceEngine::make_shared_blob(desc), InferenceEngine::Exception); -} - -// SetShape -TEST_F(BlobTests, canSetShape) { - auto b = InferenceEngine::make_shared_blob( - InferenceEngine::TensorDesc(InferenceEngine::Precision::FP32, {1, 2, 3}, InferenceEngine::ANY)); - b->allocate(); - - ASSERT_NO_THROW(b->setShape({4, 5, 6})); - - auto newDims = b->getTensorDesc().getDims(); - ASSERT_EQ(newDims.size(), 3); - ASSERT_EQ(newDims[0], 4); - ASSERT_EQ(newDims[1], 5); - ASSERT_EQ(newDims[2], 6); -} - -TEST_F(BlobTests, makeRoiBlobNchw) { - // we create main blob with NCHW layout. We will crop ROI from this blob. - InferenceEngine::SizeVector dims = {1, 3, 6, 5}; // RGB picture of size (WxH) = 5x6 - InferenceEngine::Blob::Ptr blob = InferenceEngine::make_shared_blob( - InferenceEngine::TensorDesc(InferenceEngine::Precision::U8, dims, InferenceEngine::NCHW)); - blob->allocate(); - - // create ROI blob based on the already created blob - InferenceEngine::ROI roi = {0, - 2, - 1, - 2, - 4}; // cropped picture with: id = 0, (x,y) = (2,1), sizeX (W) = 2, sizeY (H) = 4 - InferenceEngine::Blob::Ptr roiBlob = make_shared_blob(blob, roi); - - // check that BlockingDesc is constructed properly for the ROI blob - InferenceEngine::SizeVector refDims = {1, 3, 4, 2}; - InferenceEngine::SizeVector refOrder = {0, 1, 2, 3}; - size_t refOffset = 7; - InferenceEngine::SizeVector refStrides = {90, 30, 5, 1}; - ASSERT_EQ(roiBlob->getTensorDesc().getBlockingDesc().getBlockDims(), refDims); - ASSERT_EQ(roiBlob->getTensorDesc().getBlockingDesc().getOrder(), refOrder); - ASSERT_EQ(roiBlob->getTensorDesc().getBlockingDesc().getOffsetPadding(), refOffset); - ASSERT_EQ(roiBlob->getTensorDesc().getBlockingDesc().getStrides(), refStrides); -} - -TEST_F(BlobTests, makeRoiBlobNhwc) { - // we create main blob with NHWC layout. We will crop ROI from this blob. - InferenceEngine::SizeVector dims = {1, 3, 4, 8}; // RGB picture of size (WxH) = 8x4 - InferenceEngine::Blob::Ptr blob = InferenceEngine::make_shared_blob( - InferenceEngine::TensorDesc(InferenceEngine::Precision::U8, dims, InferenceEngine::NHWC)); - blob->allocate(); - - // create ROI blob based on the already created blob - InferenceEngine::ROI roi = {0, - 3, - 2, - 5, - 2}; // cropped picture with: id = 0, (x,y) = (3,2), sizeX (W) = 5, sizeY (H) = 2 - InferenceEngine::Blob::Ptr roiBlob = make_shared_blob(blob, roi); - - // check that BlockingDesc is constructed properly for the ROI blob - InferenceEngine::SizeVector refDims = {1, 2, 5, 3}; - InferenceEngine::SizeVector refOrder = {0, 2, 3, 1}; - size_t refOffset = 57; - InferenceEngine::SizeVector refStrides = {96, 24, 3, 1}; - ASSERT_EQ(roiBlob->getTensorDesc().getBlockingDesc().getBlockDims(), refDims); - ASSERT_EQ(roiBlob->getTensorDesc().getBlockingDesc().getOrder(), refOrder); - ASSERT_EQ(roiBlob->getTensorDesc().getBlockingDesc().getOffsetPadding(), refOffset); - ASSERT_EQ(roiBlob->getTensorDesc().getBlockingDesc().getStrides(), refStrides); -} - -TEST_F(BlobTests, makeRoiBlobWrongSize) { - // we create main blob with NCHW layout. We will crop ROI from this blob. - InferenceEngine::SizeVector dims = {1, 3, 4, 4}; // RGB picture of size (WxH) = 4x4 - InferenceEngine::Blob::Ptr blob = InferenceEngine::make_shared_blob( - InferenceEngine::TensorDesc(InferenceEngine::Precision::U8, dims, InferenceEngine::NCHW)); - blob->allocate(); - - // try to create ROI blob with wrong size - InferenceEngine::ROI roi = {0, - 1, - 1, - 4, - 4}; // cropped picture with: id = 0, (x,y) = (1,1), sizeX (W) = 4, sizeY (H) = 4 - ASSERT_THROW(make_shared_blob(blob, roi), InferenceEngine::Exception); -} - -TEST_F(BlobTests, readRoiBlob) { - // Create original Blob - - const auto origDesc = - InferenceEngine::TensorDesc(InferenceEngine::Precision::I32, {1, 3, 4, 8}, InferenceEngine::NCHW); - - const auto origBlob = InferenceEngine::make_shared_blob(origDesc); - origBlob->allocate(); - - // Fill the original Blob - - { - auto origMemory = origBlob->wmap(); - const auto origPtr = origMemory.as(); - ASSERT_NE(nullptr, origPtr); - - for (size_t i = 0; i < origBlob->size(); ++i) { - origPtr[i] = static_cast(i); - } - } - - // Create ROI Blob - - const auto roi = InferenceEngine::ROI(0, 4, 2, 4, 2); - - const auto roiBlob = InferenceEngine::as(origBlob->createROI(roi)); - ASSERT_NE(nullptr, roiBlob); - - // Read ROI Blob - - { - const auto roiOffset = roiBlob->getTensorDesc().getBlockingDesc().getOffsetPadding(); - - auto roiMemory = roiBlob->rmap(); - auto roiPtr = roiMemory.as(); - ASSERT_NE(nullptr, roiPtr); - - // Blob::rmap returns pointer to the original blob start, we have to add ROI offset manually. - roiPtr += roiOffset; - - for (size_t i = 0; i < roiBlob->size(); ++i) { - ASSERT_EQ(roiPtr[i], i + roiOffset); - } - } -} - -///////////////////////////////////////// - -TEST_F(BlobTests, makeRangeRoiBlobNchw) { - // we create main blob with NCHW layout. We will crop ROI from this blob. - InferenceEngine::SizeVector dims = {1, 3, 6, 5}; // RGB picture of size (WxH) = 5x6 - InferenceEngine::Blob::Ptr blob = InferenceEngine::make_shared_blob( - InferenceEngine::TensorDesc(InferenceEngine::Precision::U8, dims, InferenceEngine::NCHW)); - blob->allocate(); - - // create ROI blob based on the already created blob - InferenceEngine::ROI roi = {0, - 2, - 1, - 2, - 4}; // cropped picture with: id = 0, (x,y) = (2,1), sizeX (W) = 2, sizeY (H) = 4 - InferenceEngine::Blob::Ptr roiBlob = - make_shared_blob(blob, {0, 0, roi.posY, roi.posX}, {1, 3, roi.posY + roi.sizeY, roi.posX + roi.sizeX}); - - // check that BlockingDesc is constructed properly for the ROI blob - InferenceEngine::SizeVector refDims = {1, 3, 4, 2}; - InferenceEngine::SizeVector refOrder = {0, 1, 2, 3}; - size_t refOffset = 7; - InferenceEngine::SizeVector refStrides = {90, 30, 5, 1}; - ASSERT_EQ(roiBlob->getTensorDesc().getBlockingDesc().getBlockDims(), refDims); - ASSERT_EQ(roiBlob->getTensorDesc().getBlockingDesc().getOrder(), refOrder); - ASSERT_EQ(roiBlob->getTensorDesc().getBlockingDesc().getOffsetPadding(), refOffset); - ASSERT_EQ(roiBlob->getTensorDesc().getBlockingDesc().getStrides(), refStrides); -} - -TEST_F(BlobTests, makeRangeRoiBlobNhwc) { - // we create main blob with NHWC layout. We will crop ROI from this blob. - InferenceEngine::SizeVector dims = {1, 3, 4, 8}; // RGB picture of size (WxH) = 8x4 - InferenceEngine::Blob::Ptr blob = InferenceEngine::make_shared_blob( - InferenceEngine::TensorDesc(InferenceEngine::Precision::U8, dims, InferenceEngine::NHWC)); - blob->allocate(); - - // create ROI blob based on the already created blob - InferenceEngine::ROI roi = {0, - 3, - 2, - 5, - 2}; // cropped picture with: id = 0, (x,y) = (3,2), sizeX (W) = 5, sizeY (H) = 2 - InferenceEngine::Blob::Ptr roiBlob = - make_shared_blob(blob, {0, 0, roi.posY, roi.posX}, {1, 3, roi.posY + roi.sizeY, roi.posX + roi.sizeX}); - - // check that BlockingDesc is constructed properly for the ROI blob - InferenceEngine::SizeVector refDims = {1, 2, 5, 3}; - InferenceEngine::SizeVector refOrder = {0, 2, 3, 1}; - size_t refOffset = 57; - InferenceEngine::SizeVector refStrides = {96, 24, 3, 1}; - ASSERT_EQ(roiBlob->getTensorDesc().getBlockingDesc().getBlockDims(), refDims); - ASSERT_EQ(roiBlob->getTensorDesc().getBlockingDesc().getOrder(), refOrder); - ASSERT_EQ(roiBlob->getTensorDesc().getBlockingDesc().getOffsetPadding(), refOffset); - ASSERT_EQ(roiBlob->getTensorDesc().getBlockingDesc().getStrides(), refStrides); -} - -TEST_F(BlobTests, makeRangeRoiBlobWrongSize) { - // we create main blob with NCHW layout. We will crop ROI from this blob. - InferenceEngine::SizeVector dims = {1, 3, 4, 4}; // RGB picture of size (WxH) = 4x4 - InferenceEngine::Blob::Ptr blob = InferenceEngine::make_shared_blob( - InferenceEngine::TensorDesc(InferenceEngine::Precision::U8, dims, InferenceEngine::NCHW)); - blob->allocate(); - - // try to create ROI blob with wrong size - InferenceEngine::ROI roi = {0, - 1, - 1, - 4, - 4}; // cropped picture with: id = 0, (x,y) = (1,1), sizeX (W) = 4, sizeY (H) = 4 - ASSERT_THROW(make_shared_blob(blob, {0, 0, roi.posY, roi.posX}, {1, 3, roi.posY + roi.sizeY, roi.posX + roi.sizeX}), - InferenceEngine::Exception); -} - -TEST_F(BlobTests, readRangeRoiBlob) { - // Create original Blob - - const auto origDesc = - InferenceEngine::TensorDesc(InferenceEngine::Precision::I32, {1, 3, 4, 8}, InferenceEngine::NCHW); - - const auto origBlob = InferenceEngine::make_shared_blob(origDesc); - origBlob->allocate(); - - // Fill the original Blob - - { - auto origMemory = origBlob->wmap(); - const auto origPtr = origMemory.as(); - ASSERT_NE(nullptr, origPtr); - - for (size_t i = 0; i < origBlob->size(); ++i) { - origPtr[i] = static_cast(i); - } - } - - // Create ROI Blob - - const auto roi = InferenceEngine::ROI(0, 4, 2, 4, 2); - - const auto roiBlob = InferenceEngine::as( - origBlob->createROI({0, 0, roi.posY, roi.posX}, {1, 3, roi.posY + roi.sizeY, roi.posX + roi.sizeX})); - ASSERT_NE(nullptr, roiBlob); - - // Read ROI Blob - - { - const auto roiOffset = roiBlob->getTensorDesc().getBlockingDesc().getOffsetPadding(); - - auto roiMemory = roiBlob->rmap(); - auto roiPtr = roiMemory.as(); - ASSERT_NE(nullptr, roiPtr); - - // Blob::rmap returns pointer to the original blob start, we have to add ROI offset manually. - roiPtr += roiOffset; - - for (size_t i = 0; i < roiBlob->size(); ++i) { - ASSERT_EQ(roiPtr[i], i + roiOffset); - } - } -} - -TEST_F(BlobTests, setBiggerShapeOnPreAllocatedMemory) { - const auto t = ov::make_tensor(ov::element::i64, ov::Shape{2, 6}); - const auto b = ov::tensor_to_blob({t, nullptr}); - - const auto origin_ptr = t->data(); - b->setShape({2, 8}); - - ASSERT_EQ(b->buffer(), t->data()); - // New allocation, pointer different than origin. - ASSERT_NE(b->buffer().as(), origin_ptr); -} - -TEST_F(BlobTests, setSmallerShapeOnPreAllocatedMemory) { - const auto t = ov::make_tensor(ov::element::i64, ov::Shape{2, 6}); - const auto b = ov::tensor_to_blob({t, nullptr}); - - const auto origin_ptr = t->data(); - b->setShape({2, 4}); - - ASSERT_EQ(b->buffer(), t->data()); - // No new allocation same as origin pointer - ASSERT_EQ(b->buffer(), origin_ptr); -} diff --git a/src/inference/tests/unit/ie_exception_test.cpp b/src/inference/tests/unit/ie_exception_test.cpp deleted file mode 100644 index 1c5fd3e7354cbe..00000000000000 --- a/src/inference/tests/unit/ie_exception_test.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include - -#include - -#include "ie_common.h" - -IE_SUPPRESS_DEPRECATED_START - -// tests/unit/inference_engine/exception_test.cpp - -TEST(ExceptionTests, CanThrowUsingMacro) { - std::string message = "Exception message!"; - ASSERT_THROW(IE_THROW() << message, InferenceEngine::Exception); -} - -TEST(ExceptionTests, CanThrowScoringException) { - InferenceEngine::Exception exception{""}; - ASSERT_THROW(throw exception, InferenceEngine::Exception); -} - -TEST(ExceptionTests, CanDefineExceptionContent) { - InferenceEngine::Exception exception{""}; - ASSERT_STREQ(exception.what(), ""); -} - -#ifndef NDEBUG -TEST(ExceptionTests, ExceptionShowsCorrectMessageDebugVersion) { - std::string message = "exception"; - int lineNum = 0; - try { - lineNum = __LINE__ + 1; - IE_THROW() << message; - } catch (InferenceEngine::Exception& iex) { - std::string ref_message = - std::string{"\n"} + __FILE__ + ":" + std::to_string(lineNum) + " [ GENERAL_ERROR ] " + message; - ASSERT_STREQ(iex.what(), ref_message.c_str()); - } -} -#else -TEST(ExceptionTests, ExceptionShowsCorrectMessageReleaseVersion) { - std::string message = "exception"; - try { - IE_THROW() << message; - } catch (InferenceEngine::Exception& iex) { - std::string ref_message = "[ GENERAL_ERROR ] " + message; - ASSERT_STREQ(iex.what(), ref_message.c_str()); - } -} -#endif - -TEST(ExceptionTests, ExceptionCanBeCaughtAsStandard) { - ASSERT_THROW(IE_THROW(), std::exception); -} - -#ifdef NDEBUG // disabled for debug as macros calls assert() -TEST(ExceptionTests, ExceptionWithAssertThrowsNothingIfTrue) { - ASSERT_NO_THROW(IE_ASSERT(true) << "shouldn't assert if true"); -} - -TEST(ExceptionTests, ExceptionWithAssertThrowsNothingIfExpressionTrue) { - ASSERT_NO_THROW(IE_ASSERT(2 > 0) << "shouldn't assert if true expression"); -} - -TEST(ExceptionTests, ExceptionWithAssertThrowsExceptionIfFalse) { - ASSERT_THROW(IE_ASSERT(false), InferenceEngine::Exception); -} - -TEST(ExceptionTests, ExceptionWithAssertThrowsExceptionIfFalseExpession) { - ASSERT_THROW(IE_ASSERT(0 == 1), InferenceEngine::Exception); -} -#endif // NDEBUG diff --git a/src/inference/tests/unit/ie_executable_network_test.cpp b/src/inference/tests/unit/ie_executable_network_test.cpp deleted file mode 100644 index 142214c3ef8e15..00000000000000 --- a/src/inference/tests/unit/ie_executable_network_test.cpp +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "cpp/ie_executable_network.hpp" - -#include -#include - -#include -#include - -#include "cpp/ie_executable_network_base.hpp" -#include "openvino/runtime/compiled_model.hpp" -#include "openvino/runtime/so_ptr.hpp" -#include "unit_test_utils/mocks/cpp_interfaces/impl/mock_inference_plugin_internal.hpp" -#include "unit_test_utils/mocks/cpp_interfaces/interface/mock_iexecutable_network_internal.hpp" -#include "unit_test_utils/mocks/cpp_interfaces/interface/mock_iinference_plugin.hpp" -#include "unit_test_utils/mocks/cpp_interfaces/interface/mock_ivariable_state_internal.hpp" -#include "unit_test_utils/mocks/mock_iexecutable_network.hpp" -#include "unit_test_utils/mocks/mock_iinfer_request.hpp" - -using testing::_; -using testing::MatcherCast; -using testing::Ref; -using testing::Return; -using testing::SetArgReferee; -using testing::Throw; - -// TODO: add tests for the next methods: -// 1. void Export(const std::string& modelFileName) -// 2. void Export(std::ostream& networkModel) -// 4. CNNNetwork GetExecGraphInfo() -// 5. void SetConfig(const std::map& config) -// 6. Parameter GetConfig(const std::string& name) const -// 7. Parameter GetMetric(const std::string& name) const - -class ExecutableNetworkTests : public ::testing::Test { -protected: - std::shared_ptr mockIExeNet; - ov::SoPtr exeNetwork; - MockIInferencePlugin* mockIPlugin; - std::shared_ptr plugin; - - void TearDown() override { - mockIExeNet.reset(); - exeNetwork = {}; - plugin = {}; - } - - void SetUp() override { - mockIExeNet = std::make_shared(); - auto mockIPluginPtr = std::make_shared(); - ON_CALL(*mockIPluginPtr, LoadNetwork(MatcherCast(_), _)).WillByDefault(Return(mockIExeNet)); - plugin = mockIPluginPtr; - exeNetwork = ov::SoPtr(plugin->LoadNetwork(CNNNetwork{}, {}), {}); - } -}; - -TEST_F(ExecutableNetworkTests, GetOutputsInfoThrowsIfReturnErr) { - EXPECT_CALL(*mockIExeNet.get(), GetOutputsInfo()).Times(1).WillOnce(Throw(InferenceEngine::GeneralError{""})); - - ASSERT_THROW(exeNetwork->GetOutputsInfo(), InferenceEngine::Exception); -} - -TEST_F(ExecutableNetworkTests, GetOutputsInfo) { - InferenceEngine::ConstOutputsDataMap data; - EXPECT_CALL(*mockIExeNet.get(), GetOutputsInfo()) - .Times(1) - .WillRepeatedly(Return(InferenceEngine::ConstOutputsDataMap{})); - ASSERT_NO_THROW(data = exeNetwork->GetOutputsInfo()); - ASSERT_EQ(data, InferenceEngine::ConstOutputsDataMap{}); -} - -TEST_F(ExecutableNetworkTests, GetInputsInfoThrowsIfReturnErr) { - EXPECT_CALL(*mockIExeNet.get(), GetInputsInfo()).Times(1).WillOnce(Throw(InferenceEngine::GeneralError{""})); - - ASSERT_THROW(exeNetwork->GetInputsInfo(), InferenceEngine::Exception); -} - -TEST_F(ExecutableNetworkTests, GetInputsInfo) { - EXPECT_CALL(*mockIExeNet.get(), GetInputsInfo()) - .Times(1) - .WillRepeatedly(Return(InferenceEngine::ConstInputsDataMap{})); - - InferenceEngine::ConstInputsDataMap info; - ASSERT_NO_THROW(info = exeNetwork->GetInputsInfo()); - ASSERT_EQ(info, InferenceEngine::ConstInputsDataMap{}); -} - -class ExecutableNetworkWithIInferReqTests : public ExecutableNetworkTests { -protected: - std::shared_ptr mockIInferReq_p; - - void TearDown() override { - ExecutableNetworkTests::TearDown(); - mockIInferReq_p.reset(); - } - - void SetUp() override { - ExecutableNetworkTests::SetUp(); - mockIInferReq_p = std::make_shared(); - } -}; - -TEST_F(ExecutableNetworkWithIInferReqTests, CanCreateInferRequest) { - EXPECT_CALL(*mockIExeNet.get(), CreateInferRequest()).WillOnce(Return(mockIInferReq_p)); - IInferRequestInternal::Ptr actualInferReq; - ASSERT_NO_THROW(actualInferReq = exeNetwork->CreateInferRequest()); -} - -TEST_F(ExecutableNetworkWithIInferReqTests, CreateInferRequestThrowsIfReturnNotOK) { - EXPECT_CALL(*mockIExeNet.get(), CreateInferRequest()).WillOnce(Throw(InferenceEngine::GeneralError{""})); - ASSERT_THROW(exeNetwork->CreateInferRequest(), InferenceEngine::Exception); -} - -TEST_F(ExecutableNetworkWithIInferReqTests, QueryStateThrowsIfReturnErr) { - EXPECT_CALL(*mockIExeNet.get(), CreateInferRequest()).WillOnce(Return(mockIInferReq_p)); - IInferRequestInternal::Ptr actualInferReq; - ASSERT_NO_THROW(actualInferReq = exeNetwork->CreateInferRequest()); - EXPECT_CALL(*mockIInferReq_p.get(), QueryState()).Times(1).WillOnce(Throw(InferenceEngine::GeneralError{""})); - EXPECT_THROW(actualInferReq->QueryState(), InferenceEngine::Exception); -} - -TEST_F(ExecutableNetworkWithIInferReqTests, QueryState) { - EXPECT_CALL(*mockIExeNet.get(), CreateInferRequest()).WillOnce(Return(mockIInferReq_p)); - IInferRequestInternal::Ptr actualInferReq; - ASSERT_NO_THROW(actualInferReq = exeNetwork->CreateInferRequest()); - auto mockIMemState_p = std::make_shared(); - EXPECT_CALL(*mockIInferReq_p.get(), QueryState()) - .Times(1) - .WillOnce(Return(std::vector>(1, mockIMemState_p))); - std::vector MemState_v; - EXPECT_NO_THROW(MemState_v = actualInferReq->QueryState()); - EXPECT_EQ(MemState_v.size(), 1); -} - -IE_SUPPRESS_DEPRECATED_START - -class ExecutableNetworkBaseTests : public ::testing::Test { -protected: - std::shared_ptr mock_impl; - std::shared_ptr exeNetwork; - ResponseDesc dsc; - - void SetUp() override { - mock_impl.reset(new MockIExecutableNetworkInternal()); - exeNetwork = std::make_shared(mock_impl); - } -}; - -// CreateInferRequest -TEST_F(ExecutableNetworkBaseTests, canForwardCreateInferRequest) { - auto inferReqInternal = std::make_shared(); - EXPECT_CALL(*mock_impl.get(), CreateInferRequest()).Times(1).WillRepeatedly(Return(inferReqInternal)); - IInferRequest::Ptr req; - ASSERT_NO_THROW(exeNetwork->CreateInferRequest(req, &dsc)); -} - -TEST_F(ExecutableNetworkBaseTests, canReportErrorInCreateInferRequest) { - EXPECT_CALL(*mock_impl.get(), CreateInferRequest()).WillOnce(Throw(std::runtime_error("compare"))); - IInferRequest::Ptr req; - ASSERT_NE(OK, exeNetwork->CreateInferRequest(req, &dsc)); - ASSERT_STREQ(dsc.msg, "compare"); -} - -TEST_F(ExecutableNetworkBaseTests, canCatchUnknownErrorInCreateInferRequest) { - EXPECT_CALL(*mock_impl.get(), CreateInferRequest()).WillOnce(Throw(5)); - IInferRequest::Ptr req; - ASSERT_EQ(UNEXPECTED, exeNetwork->CreateInferRequest(req, nullptr)); -} - -// Export -TEST_F(ExecutableNetworkBaseTests, canForwardExport) { - const std::string modelFileName; - EXPECT_CALL(*mock_impl.get(), Export(Ref(modelFileName))).Times(1); - ASSERT_EQ(OK, exeNetwork->Export(modelFileName, &dsc)); -} - -TEST_F(ExecutableNetworkBaseTests, canReportErrorInExport) { - EXPECT_CALL(*mock_impl.get(), Export(_)).WillOnce(Throw(std::runtime_error("compare"))); - ASSERT_NE(exeNetwork->Export({}, &dsc), OK); - ASSERT_STREQ(dsc.msg, "compare"); -} - -TEST_F(ExecutableNetworkBaseTests, canCatchUnknownErrorInExport) { - EXPECT_CALL(*mock_impl.get(), Export(_)).WillOnce(Throw(5)); - ASSERT_EQ(UNEXPECTED, exeNetwork->Export({}, nullptr)); -} diff --git a/src/inference/tests/unit/ie_locked_memory_test.cpp b/src/inference/tests/unit/ie_locked_memory_test.cpp deleted file mode 100644 index d27466f7ad148a..00000000000000 --- a/src/inference/tests/unit/ie_locked_memory_test.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include - -#include "unit_test_utils/mocks/mock_allocator.hpp" - -using namespace InferenceEngine; -using namespace ::testing; - -IE_SUPPRESS_DEPRECATED_START - -TEST(LockedMemoryTest, canUnlockMemoryAfterUsage) { - std::unique_ptr allocator(new MockAllocator()); - char array[] = {1, 2, 3}; - - EXPECT_CALL(*allocator.get(), lock(reinterpret_cast(1), _)) - .WillRepeatedly(Return(reinterpret_cast(array))); - EXPECT_CALL(*allocator.get(), unlock(_)).Times(1); - { - auto x = LockedMemory(allocator.get(), reinterpret_cast(1), 1); - // force locking of memory - auto t = x[0]; - (void)t; - } -} - -TEST(LockedMemoryTest, canReadFromLockedMemory) { - std::unique_ptr allocator(new MockAllocator()); - char array[] = {1, 2, 3, 4, 5}; - - EXPECT_CALL(*allocator.get(), lock(reinterpret_cast(1), _)) - .WillRepeatedly(Return(reinterpret_cast(array))); - EXPECT_CALL(*allocator.get(), unlock(_)).Times(1); - { - auto x = LockedMemory(allocator.get(), reinterpret_cast(1), 0); - // we are getting first element - ASSERT_EQ(1, x[0]); - } -} - -TEST(LockedMemoryTest, canWriteToLockedMemory) { - std::unique_ptr allocator(new MockAllocator()); - char array[] = {1, 2, 3, 4, 5}; - - EXPECT_CALL(*allocator.get(), lock(reinterpret_cast(1), _)) - .WillRepeatedly(Return(reinterpret_cast(array))); - EXPECT_CALL(*allocator.get(), unlock(_)).Times(1); - { - auto x = LockedMemory(allocator.get(), reinterpret_cast(1), 0); - - // we are getting first element - ASSERT_EQ(std::distance(array, &x[0]), 0); - x[0] = 5; - } - EXPECT_EQ(array[0], 5); -} diff --git a/src/inference/tests/unit/make_default_multi_threaded_test.cpp b/src/inference/tests/unit/make_default_multi_threaded_test.cpp new file mode 100644 index 00000000000000..e1917394507045 --- /dev/null +++ b/src/inference/tests/unit/make_default_multi_threaded_test.cpp @@ -0,0 +1,153 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include + +#include "openvino/runtime/threading/istreams_executor.hpp" +#include "os/cpu_map_info.hpp" + +using namespace testing; +using namespace ov; +using namespace threading; + +namespace { + +#if defined(__linux__) || defined(_WIN32) + +struct MakeDefaultMultiThreadsTestCase { + std::vector> _proc_type_table; + int _num_streams; + std::vector> _streams_info_table; +}; + +class MakeDefaultMultiThreadsTest : public ov::test::TestsCommon, + public testing::WithParamInterface> { +public: + void SetUp() override { + auto test_data = std::get<0>(GetParam()); + + CPU& cpu = cpu_info(); + cpu._org_proc_type_table = test_data._proc_type_table; + cpu._proc_type_table = test_data._proc_type_table; + cpu._numa_nodes = + test_data._proc_type_table.size() > 1 ? static_cast(test_data._proc_type_table.size()) - 1 : 1; + + ov::threading::IStreamsExecutor::Config config{"make default multi threads test", test_data._num_streams}; + auto streamsConfig = ov::threading::IStreamsExecutor::Config::make_default_multi_threaded(config); + + ASSERT_EQ(streamsConfig.get_streams_info_table(), test_data._streams_info_table); + } +}; + +MakeDefaultMultiThreadsTestCase _1sockets_streams_1 = { + // param[in]: proc_type_table, {total processors, number of physical processors, number of Efficient processors, + // number of hyper threading processors} + { + {12, 6, 0, 6, 0, 0}, + }, + 1, // param[in]: the number of streams + // param[out]: streams info table + { + {1, 1, 6, 0, 0}, + }, +}; + +MakeDefaultMultiThreadsTestCase _1sockets_streams_2 = { + { + {12, 6, 0, 6, 0, 0}, + }, + 2, + { + {1, 1, 6, 0, 0}, + {1, 3, 6, 0, 0}, + }, +}; + +MakeDefaultMultiThreadsTestCase _2sockets_streams_1 = { + { + {72, 36, 0, 36, -1, -1}, + {36, 18, 0, 18, 0, 0}, + {36, 18, 0, 18, 1, 1}, + }, + 1, + { + {1, 0, 36, -1, -1}, + {0, 1, 18, 0, 0}, + {0, 1, 18, 1, 1}, + }, +}; + +MakeDefaultMultiThreadsTestCase _2sockets_streams_4 = { + { + {72, 36, 0, 36, -1, -1}, + {36, 18, 0, 18, 0, 0}, + {36, 18, 0, 18, 1, 1}, + }, + 4, + { + {2, 1, 9, 0, 0}, + {2, 1, 9, 1, 1}, + }, +}; + +MakeDefaultMultiThreadsTestCase _pecore24_streams_1 = { + { + {24, 8, 8, 8, 0, 0}, + }, + 1, + { + {1, 1, 8, 0, 0}, + }, +}; + +MakeDefaultMultiThreadsTestCase _pecore24_streams_3 = { + { + {24, 8, 8, 8, 0, 0}, + }, + 3, + { + {3, 1, 2, 0, 0}, + }, +}; + +MakeDefaultMultiThreadsTestCase _pecore32_streams_1 = { + { + {32, 8, 16, 8, 0, 0}, + }, + 1, + { + {1, 0, 24, 0, 0}, + {0, 1, 8, 0, 0}, + {0, 2, 16, 0, 0}, + }, +}; + +MakeDefaultMultiThreadsTestCase _pecore32_streams_5 = { + { + {32, 8, 16, 8, 0, 0}, + }, + 5, + { + {1, 1, 5, 0, 0}, + {3, 2, 5, 0, 0}, + {1, 3, 5, 0, 0}, + }, +}; + +TEST_P(MakeDefaultMultiThreadsTest, MakeDefaultMultiThreads) {} + +INSTANTIATE_TEST_SUITE_P(smoke_MakeDefaultMultiThreads, + MakeDefaultMultiThreadsTest, + testing::Values(_1sockets_streams_1, + _1sockets_streams_2, + _2sockets_streams_1, + _2sockets_streams_4, + _pecore24_streams_1, + _pecore24_streams_3, + _pecore32_streams_1, + _pecore32_streams_5)); +#endif +} // namespace diff --git a/src/inference/tests/unit/precision_utils_test.cpp b/src/inference/tests/unit/precision_utils_test.cpp deleted file mode 100644 index 303817a3b49a8d..00000000000000 --- a/src/inference/tests/unit/precision_utils_test.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "precision_utils.h" - -#include - -#include - -using namespace InferenceEngine; - -using PrecisionUtilsTests = ::testing::Test; - -static constexpr ie_fp16 positiveInf = static_cast(0x7C00); -static constexpr ie_fp16 negativeInf = static_cast(0xFC00); -static constexpr ie_fp16 largestNumber = static_cast(0x7BFF); -static constexpr ie_fp16 lowestNumber = static_cast(0xFBFF); - -TEST_F(PrecisionUtilsTests, FP32ToFP16PositiveInfinity) { - const auto fp16ConvertedInf = InferenceEngine::PrecisionUtils::f32tof16(std::numeric_limits::infinity()); - ASSERT_EQ(fp16ConvertedInf, positiveInf); -} - -TEST_F(PrecisionUtilsTests, FP32ToFP16NegativeInfinity) { - const auto fp16ConvertedInf = - InferenceEngine::PrecisionUtils::f32tof16(-1 * std::numeric_limits::infinity()); - ASSERT_EQ(fp16ConvertedInf, negativeInf); -} - -TEST_F(PrecisionUtilsTests, FP16ToFP32PositiveInfinity) { - const auto fp32ConvertedInf = InferenceEngine::PrecisionUtils::f16tof32(positiveInf); - ASSERT_EQ(fp32ConvertedInf, std::numeric_limits::infinity()); -} - -TEST_F(PrecisionUtilsTests, FP16ToFP32NegativeInfinity) { - const auto fp32ConvertedInf = InferenceEngine::PrecisionUtils::f16tof32(negativeInf); - ASSERT_EQ(fp32ConvertedInf, -1 * std::numeric_limits::infinity()); -} - -TEST_F(PrecisionUtilsTests, FP32ToFP16MaximumValue) { - const auto fp16ConvertedMaxValue = InferenceEngine::PrecisionUtils::f32tof16(std::numeric_limits::max()); - ASSERT_EQ(fp16ConvertedMaxValue, largestNumber); -} - -TEST_F(PrecisionUtilsTests, FP32ToFP16LowestValue) { - const auto fp16ConvertedLowestValue = - InferenceEngine::PrecisionUtils::f32tof16(std::numeric_limits::lowest()); - ASSERT_EQ(fp16ConvertedLowestValue, lowestNumber); -} diff --git a/src/inference/tests/unit/saturated_cast_test.cpp b/src/inference/tests/unit/saturated_cast_test.cpp deleted file mode 100644 index 92012232a379f0..00000000000000 --- a/src/inference/tests/unit/saturated_cast_test.cpp +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include - -#include "common_test_utils/test_common.hpp" -#include "ie_precision.hpp" -#include "precision_utils.h" - -#ifdef USE_OPENCV - -# include - -using namespace InferenceEngine; - -class SaturateCastTestsI64ToI32 : public ov::test::TestsCommon { -public: - using fromType = typename PrecisionTrait::value_type; - using toType = typename PrecisionTrait::value_type; -}; - -TEST_F(SaturateCastTestsI64ToI32, I64ToI32NonNarrowingPositive) { - const auto value = fromType{42}; - EXPECT_EQ(PrecisionUtils::saturate_cast(value), cv::saturate_cast(value)); -} - -TEST_F(SaturateCastTestsI64ToI32, I64ToI32NonNarrowingNegative) { - const auto value = fromType{-42}; - EXPECT_EQ(PrecisionUtils::saturate_cast(value), cv::saturate_cast(value)); -} - -TEST_F(SaturateCastTestsI64ToI32, I64ToI32NarrowingMaxToMax) { - const auto value = std::numeric_limits::max(); - EXPECT_EQ(PrecisionUtils::saturate_cast(value), cv::saturate_cast(value)); -} - -TEST_F(SaturateCastTestsI64ToI32, I64ToI32NarrowingNonMaxToMax) { - const auto value = std::numeric_limits::max() - 1; - EXPECT_EQ(PrecisionUtils::saturate_cast(value), cv::saturate_cast(value)); -} - -TEST_F(SaturateCastTestsI64ToI32, I64ToI32NarrowingMinToMin) { - const auto value = std::numeric_limits::min(); - EXPECT_EQ(PrecisionUtils::saturate_cast(value), cv::saturate_cast(value)); -} - -TEST_F(SaturateCastTestsI64ToI32, I64ToI32NarrowingNonMinToMin) { - const auto value = std::numeric_limits::min() + 1; - EXPECT_EQ(PrecisionUtils::saturate_cast(value), cv::saturate_cast(value)); -} - -class SaturateCastTestsU64ToI32 : public ov::test::TestsCommon { -public: - using fromType = typename PrecisionTrait::value_type; - using toType = typename PrecisionTrait::value_type; -}; - -TEST_F(SaturateCastTestsU64ToI32, U64ToI32NonNarrowing) { - const auto value = fromType{42}; - EXPECT_EQ(PrecisionUtils::saturate_cast(value), cv::saturate_cast(value)); -} - -TEST_F(SaturateCastTestsU64ToI32, U64ToI32NarrowingMaxToMax) { - const auto value = std::numeric_limits::max(); - EXPECT_EQ(PrecisionUtils::saturate_cast(value), cv::saturate_cast(value)); -} - -TEST_F(SaturateCastTestsU64ToI32, U64ToI32NarrowingNonMaxToMax) { - const auto value = std::numeric_limits::max() - 1; - EXPECT_EQ(PrecisionUtils::saturate_cast(value), cv::saturate_cast(value)); -} - -class SaturateCastTestsBoolToU8 : public ov::test::TestsCommon { -public: - using fromType = typename PrecisionTrait::value_type; - using toType = typename PrecisionTrait::value_type; -}; - -TEST_F(SaturateCastTestsBoolToU8, BOOLtoU8MaxToNonMax) { - const auto value = std::numeric_limits::max(); - EXPECT_EQ(PrecisionUtils::saturate_cast(value), cv::saturate_cast(value)); -} - -class SaturateCastTestsBoolToI32 : public ov::test::TestsCommon { -public: - using fromType = typename PrecisionTrait::value_type; - using toType = typename PrecisionTrait::value_type; -}; - -TEST_F(SaturateCastTestsBoolToI32, BOOLtoI32MaxToNonMax) { - const auto value = std::numeric_limits::max(); - EXPECT_EQ(PrecisionUtils::saturate_cast(value), cv::saturate_cast(value)); -} - -class SaturateCastTestsU8ToI32 : public ov::test::TestsCommon { -public: - using fromType = typename PrecisionTrait::value_type; - using toType = typename PrecisionTrait::value_type; -}; - -TEST_F(SaturateCastTestsU8ToI32, U8toI32FMaxToNonMax) { - const auto value = std::numeric_limits::max(); - EXPECT_EQ(PrecisionUtils::saturate_cast(value), cv::saturate_cast(value)); -} - -class SaturateCastTestsU16ToI32 : public ov::test::TestsCommon { -public: - using fromType = typename PrecisionTrait::value_type; - using toType = typename PrecisionTrait::value_type; -}; - -TEST_F(SaturateCastTestsU16ToI32, U16toI32FMaxToNonMax) { - const auto value = std::numeric_limits::max(); - EXPECT_EQ(PrecisionUtils::saturate_cast(value), cv::saturate_cast(value)); -} - -#endif // USE_OPENCV diff --git a/src/inference/tests/unit/system_allocator_test.cpp b/src/inference/tests/unit/system_allocator_test.cpp deleted file mode 100644 index bab05bd634d6b3..00000000000000 --- a/src/inference/tests/unit/system_allocator_test.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "system_allocator.hpp" - -#include - -#include - -#include "common_test_utils/test_common.hpp" - -using namespace InferenceEngine; -class SystemAllocatorReleaseTests : public ov::test::TestsCommon {}; - -class SystemAllocatorTests : public ov::test::TestsCommon { -protected: - void SetUp() override { - ov::test::TestsCommon::SetUp(); - ASSERT_EQ(allocator.get(), nullptr); - allocator = createSystemMemoryAllocator(); - ASSERT_NE(allocator.get(), nullptr); - } - - void TearDown() override { - ov::test::TestsCommon::TearDown(); - ASSERT_NE(allocator.get(), nullptr); - allocator.reset(); - ASSERT_EQ(allocator.get(), nullptr); - } - - std::unique_ptr createSystemMemoryAllocator() { - return std::unique_ptr(new SystemMemoryAllocator()); - } - - std::unique_ptr allocator; - -public: -}; - -TEST_F(SystemAllocatorTests, canAllocate) { - void* handle0 = allocator->alloc(0); - void* handle1 = allocator->alloc(100); - EXPECT_NE(handle0, nullptr); - EXPECT_NE(handle1, nullptr); - delete[] reinterpret_cast(handle0); - delete[] reinterpret_cast(handle1); -} - -TEST_F(SystemAllocatorTests, canFree) { - EXPECT_TRUE(allocator->free(nullptr)); - void* handle0 = reinterpret_cast(new char[0]); - void* handle1 = reinterpret_cast(new char[100]); - EXPECT_TRUE(allocator->free(handle0)); - EXPECT_TRUE(allocator->free(handle1)); -} - -TEST_F(SystemAllocatorTests, canLockAndUnlockAllocatedMemory) { - // large block such as 10k will result in sigsegv if not allocated - void* handle = allocator->alloc(10000); - char* ptr = reinterpret_cast(allocator->lock(handle)); - ptr[9999] = 11; - EXPECT_EQ(ptr[9999], 11); - allocator->unlock(ptr); - allocator->free(handle); -} diff --git a/src/inference/tests/unit/update_executor_config_test.cpp b/src/inference/tests/unit/update_executor_config_test.cpp deleted file mode 100644 index abb3612eb8750d..00000000000000 --- a/src/inference/tests/unit/update_executor_config_test.cpp +++ /dev/null @@ -1,163 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include - -#include "common_test_utils/test_common.hpp" -#include "openvino/runtime/threading/istreams_executor.hpp" -#include "os/cpu_map_info.hpp" - -using namespace testing; -using namespace ov; -using namespace threading; - -namespace { - -#if defined(__linux__) || defined(_WIN32) - -struct UpdateExecutorConfigTestCase { - ov::threading::IStreamsExecutor::Config _config; - std::vector> _proc_type_table; - std::vector> _cpu_mapping_table; - int _num_streams; - int _threads_per_stream; - ov::threading::IStreamsExecutor::Config::PreferredCoreType _core_type; - bool _cpu_pinning; - std::vector> _streams_info_table; - std::vector> _stream_processors; -}; - -class UpdateExecutorConfigTest : public ov::test::TestsCommon, - public testing::WithParamInterface> { -public: - void SetUp() override { - auto test_data = std::get<0>(GetParam()); - - CPU& cpu = cpu_info(); - cpu._org_proc_type_table = test_data._proc_type_table; - cpu._proc_type_table = test_data._proc_type_table; - cpu._cpu_mapping_table = test_data._cpu_mapping_table; - cpu._numa_nodes = 1; - - test_data._config.update_executor_config(test_data._num_streams, - test_data._threads_per_stream, - test_data._core_type, - test_data._cpu_pinning); - - ASSERT_EQ(test_data._num_streams, test_data._config._streams); - ASSERT_EQ(test_data._threads_per_stream, test_data._config._threadsPerStream); - ASSERT_EQ(test_data._core_type, test_data._config._threadPreferredCoreType); - ASSERT_EQ(test_data._cpu_pinning, test_data._config._cpu_reservation); - ASSERT_EQ(test_data._num_streams, test_data._config._streams); - ASSERT_EQ(test_data._streams_info_table, test_data._config._streams_info_table); - ASSERT_EQ(test_data._stream_processors, test_data._config._stream_processor_ids); - } -}; - -UpdateExecutorConfigTestCase _update_num_streams = { - ov::threading::IStreamsExecutor::Config{"update num streams test"}, // param[in]: initial configuration - // param[in]: proc_type_table, {total processors, number of physical processors, number of Efficient processors, - // number of hyper threading processors} - { - {12, 6, 0, 6, 0, 0}, - }, - // param[in]: cpu_mapping_table, {PROCESSOR_ID, NUMA_ID, SOCKET_ID, CORE_ID, CORE_TYPE, GROUP_ID, Used} - { - {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, - {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, - {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, - {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, - {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, - {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, - {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, - {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, - {8, 0, 0, 4, MAIN_CORE_PROC, 8, -1}, - {9, 0, 0, 4, HYPER_THREADING_PROC, 9, -1}, - {10, 0, 0, 5, MAIN_CORE_PROC, 10, -1}, - {11, 0, 0, 5, HYPER_THREADING_PROC, 11, -1}, - }, - 4, // param[in]: the number of streams - 1, // param[in]: the number of threads per stream - ov::threading::IStreamsExecutor::Config::ANY, // param[in]: specified cpu core type - false, // param[in]: specified cpu pinning - // param[out]: streams_info_table, {NUMBER_OF_STREAMS, PROC_TYPE, THREADS_PER_STREAM, STREAM_NUMA_NODE_ID, - // STREAM_SOCKET_ID} - { - {4, MAIN_CORE_PROC, 1, 0, 0}, - }, - // param[out]: stream_processors, the list of processor ids on each stream. - {}, -}; - -UpdateExecutorConfigTestCase _update_core_type = { - ov::threading::IStreamsExecutor::Config{"update core type test"}, - { - {24, 8, 8, 8, 0, 0}, - }, - { - {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, - {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, - {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, - {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, - {8, 0, 0, 4, MAIN_CORE_PROC, 8, -1}, {9, 0, 0, 4, HYPER_THREADING_PROC, 9, -1}, - {10, 0, 0, 5, MAIN_CORE_PROC, 10, -1}, {11, 0, 0, 5, HYPER_THREADING_PROC, 11, -1}, - {12, 0, 0, 6, MAIN_CORE_PROC, 12, -1}, {13, 0, 0, 6, HYPER_THREADING_PROC, 13, -1}, - {14, 0, 0, 7, MAIN_CORE_PROC, 14, -1}, {15, 0, 0, 7, HYPER_THREADING_PROC, 15, -1}, - {16, 0, 0, 8, EFFICIENT_CORE_PROC, 16, -1}, {17, 0, 0, 9, EFFICIENT_CORE_PROC, 17, -1}, - {18, 0, 0, 10, EFFICIENT_CORE_PROC, 18, -1}, {19, 0, 0, 11, EFFICIENT_CORE_PROC, 19, -1}, - {20, 0, 0, 12, EFFICIENT_CORE_PROC, 20, -1}, {21, 0, 0, 13, EFFICIENT_CORE_PROC, 21, -1}, - {22, 0, 0, 14, EFFICIENT_CORE_PROC, 22, -1}, {23, 0, 0, 15, EFFICIENT_CORE_PROC, 23, -1}, - }, - 8, - 1, - ov::threading::IStreamsExecutor::Config::LITTLE, - false, - { - {8, EFFICIENT_CORE_PROC, 1, 0, 0}, - }, - {}, -}; - -UpdateExecutorConfigTestCase _update_cpu_pinning = { - ov::threading::IStreamsExecutor::Config{"update cpu pinning test"}, - { - {8, 4, 0, 4, 0, 0}, - }, - { - {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1}, - {1, 0, 0, 0, HYPER_THREADING_PROC, 1, -1}, - {2, 0, 0, 1, MAIN_CORE_PROC, 2, -1}, - {3, 0, 0, 1, HYPER_THREADING_PROC, 3, -1}, - {4, 0, 0, 2, MAIN_CORE_PROC, 4, -1}, - {5, 0, 0, 2, HYPER_THREADING_PROC, 5, -1}, - {6, 0, 0, 3, MAIN_CORE_PROC, 6, -1}, - {7, 0, 0, 3, HYPER_THREADING_PROC, 7, -1}, - }, - 8, - 1, - ov::threading::IStreamsExecutor::Config::ANY, - true, - { - {4, MAIN_CORE_PROC, 1, 0, 0}, - {4, HYPER_THREADING_PROC, 1, 0, 0}, - }, - { - {0}, - {2}, - {4}, - {6}, - {1}, - {3}, - {5}, - {7}, - }, -}; - -TEST_P(UpdateExecutorConfigTest, UpdateExecutorConfig) {} - -INSTANTIATE_TEST_SUITE_P(smoke_UpdateExecutorConfig, - UpdateExecutorConfigTest, - testing::Values(_update_num_streams, _update_core_type, _update_cpu_pinning)); -#endif -} // namespace diff --git a/src/plugins/auto/src/auto_compiled_model.cpp b/src/plugins/auto/src/auto_compiled_model.cpp index 1831f35560dfcd..e35fdc5a8c9004 100644 --- a/src/plugins/auto/src/auto_compiled_model.cpp +++ b/src/plugins/auto/src/auto_compiled_model.cpp @@ -36,9 +36,6 @@ std::shared_ptr AutoCompiledModel::get_runtime_model() const { } ov::Any AutoCompiledModel::get_property(const std::string& name) const { - const auto& add_ro_properties = [](const std::string& name, std::vector& properties) { - properties.emplace_back(ov::PropertyName{name, ov::PropertyMutability::RO}); - }; const auto& default_ro_properties = []() { std::vector ro_properties{ov::model_name, ov::supported_properties, @@ -55,13 +52,6 @@ ov::Any AutoCompiledModel::get_property(const std::string& name) const { std::vector rw_properties{}; return rw_properties; }; - const auto& to_string_vector = [](const std::vector& properties) { - std::vector ret; - for (const auto& property : properties) { - ret.emplace_back(property); - } - return ret; - }; if (name == ov::supported_properties) { auto ro_properties = default_ro_properties(); auto rw_properties = default_rw_properties(); @@ -93,15 +83,7 @@ ov::Any AutoCompiledModel::get_property(const std::string& name) const { return all_devices; } else if (name == ov::hint::model_priority) { auto value = m_context->m_model_priority; - if (m_context->m_ov_core->is_new_api()) { - return value ? ((value > 1) ? ov::hint::Priority::LOW : - ov::hint::Priority::MEDIUM) : ov::hint::Priority::HIGH; - } else { - OPENVINO_SUPPRESS_DEPRECATED_START - return value ? ((value > 1) ? CONFIG_VALUE(MODEL_PRIORITY_LOW) : CONFIG_VALUE( - MODEL_PRIORITY_MED)) : CONFIG_VALUE(MODEL_PRIORITY_HIGH); - OPENVINO_SUPPRESS_DEPRECATED_END - } + return value ? ((value > 1) ? ov::hint::Priority::LOW : ov::hint::Priority::MEDIUM) : ov::hint::Priority::HIGH; } else if (name == ov::optimal_number_of_infer_requests) { const unsigned int default_num_for_tput = 4u; const unsigned int default_num_for_latency = 1u; @@ -136,8 +118,6 @@ ov::Any AutoCompiledModel::get_property(const std::string& name) const { return decltype(ov::optimal_number_of_infer_requests)::value_type{real}; } requests = 0; - // check if the real is default value or actual device didn't support this property. - OPENVINO_ASSERT(m_scheduler->m_compile_context[CPU].m_is_already == true); try { // for benchmark through AUTO:CPU,GPU // SetConfig directly set to CPU/GPU in this case @@ -167,7 +147,7 @@ ov::Any AutoCompiledModel::get_property(const std::string& name) const { LOG_DEBUG_TAG("get_property range_for_streams from %s failed", device_info.device_name.c_str()); } } - if (!m_context->m_batching_disabled) { + if (!m_context->m_batching_disabled && m_model) { if (std::find(actual_dev_supported_properties.begin(), actual_dev_supported_properties.end(), ov::optimal_batch_size) != actual_dev_supported_properties.end()) { @@ -246,16 +226,6 @@ ov::Any AutoCompiledModel::get_property(const std::string& name) const { return m_scheduler->m_compile_context[CPU].m_compiled_model->get_property(name); return m_scheduler->m_compile_context[ACTUALDEVICE].m_compiled_model->get_property(name); } - OPENVINO_SUPPRESS_DEPRECATED_START - } else if (name == METRIC_KEY(SUPPORTED_METRICS)) { - auto ro_properties = default_ro_properties(); - add_ro_properties(METRIC_KEY(SUPPORTED_METRICS), ro_properties); - add_ro_properties(METRIC_KEY(SUPPORTED_CONFIG_KEYS), ro_properties); - return to_string_vector(ro_properties); - } else if (name == METRIC_KEY(SUPPORTED_CONFIG_KEYS)) { - auto rw_properties = default_rw_properties(); - return to_string_vector(rw_properties); - OPENVINO_SUPPRESS_DEPRECATED_END } else if (name == ov::loaded_from_cache) { std::lock_guard lock(m_context->m_fallback_mutex); std::string device_name; diff --git a/src/plugins/auto/src/common.hpp b/src/plugins/auto/src/common.hpp index e0827181aab86b..61a899f7de140d 100644 --- a/src/plugins/auto/src/common.hpp +++ b/src/plugins/auto/src/common.hpp @@ -7,18 +7,17 @@ #include #include -#include "ie_icore.hpp" + +#include "openvino/runtime/auto/properties.hpp" +#include "openvino/runtime/iasync_infer_request.hpp" #include "openvino/runtime/icompiled_model.hpp" +#include "openvino/runtime/icore.hpp" #include "openvino/runtime/isync_infer_request.hpp" -#include "openvino/runtime/iasync_infer_request.hpp" -#include "openvino/runtime/threading/itask_executor.hpp" #include "openvino/runtime/remote_tensor.hpp" +#include "openvino/runtime/threading/itask_executor.hpp" #include "openvino/runtime/threading/thread_safe_containers.hpp" -#include "utils/log_util.hpp" -#include "openvino/runtime/auto/properties.hpp" #include "transformations/utils/utils.hpp" #include "utils/log_util.hpp" -#include "itt.hpp" #ifdef MULTIUNITTEST #define MOCKTESTMACRO virtual diff --git a/src/plugins/auto/src/cumulative_compiled_model.cpp b/src/plugins/auto/src/cumulative_compiled_model.cpp index 84407cc0c6c79e..3ec7a820256d67 100644 --- a/src/plugins/auto/src/cumulative_compiled_model.cpp +++ b/src/plugins/auto/src/cumulative_compiled_model.cpp @@ -12,7 +12,6 @@ #include "openvino/runtime/exec_model_info.hpp" #include "openvino/runtime/properties.hpp" #include "plugin.hpp" -#include "ie_plugin_config.hpp" namespace ov { namespace auto_plugin { @@ -36,9 +35,6 @@ std::shared_ptr AutoCumuCompiledModel::get_runtime_model() cons } ov::Any AutoCumuCompiledModel::get_property(const std::string& name) const { - const auto& add_ro_properties = [](const std::string& name, std::vector& properties) { - properties.emplace_back(ov::PropertyName{name, ov::PropertyMutability::RO}); - }; const auto& default_ro_properties = []() { std::vector ro_properties{ov::model_name, ov::supported_properties, @@ -55,13 +51,6 @@ ov::Any AutoCumuCompiledModel::get_property(const std::string& name) const { std::vector rw_properties{ov::device::priorities}; return rw_properties; }; - const auto& to_string_vector = [](const std::vector& properties) { - std::vector ret; - for (const auto& property : properties) { - ret.emplace_back(property); - } - return ret; - }; if (name == ov::supported_properties) { auto ro_properties = default_ro_properties(); auto rw_properties = default_rw_properties(); @@ -89,15 +78,7 @@ ov::Any AutoCumuCompiledModel::get_property(const std::string& name) const { return all_devices; } else if (name == ov::hint::model_priority) { auto value = m_context->m_model_priority; - if (m_context->m_ov_core->is_new_api()) { - return value ? ((value > 1) ? ov::hint::Priority::LOW : - ov::hint::Priority::MEDIUM) : ov::hint::Priority::HIGH; - } else { - OPENVINO_SUPPRESS_DEPRECATED_START - return value ? ((value > 1) ? CONFIG_VALUE(MODEL_PRIORITY_LOW) : CONFIG_VALUE( - MODEL_PRIORITY_MED)) : CONFIG_VALUE(MODEL_PRIORITY_HIGH); - OPENVINO_SUPPRESS_DEPRECATED_END - } + return value ? ((value > 1) ? ov::hint::Priority::LOW : ov::hint::Priority::MEDIUM) : ov::hint::Priority::HIGH; } else if (name == ov::optimal_number_of_infer_requests) { std::lock_guard lock(m_context->m_fallback_mutex); unsigned int res = 0u; @@ -129,16 +110,6 @@ ov::Any AutoCumuCompiledModel::get_property(const std::string& name) const { } } OPENVINO_THROW("No valid compiled model found to get", name); - OPENVINO_SUPPRESS_DEPRECATED_START - } else if (name == METRIC_KEY(SUPPORTED_METRICS)) { - auto ro_properties = default_ro_properties(); - add_ro_properties(METRIC_KEY(SUPPORTED_METRICS), ro_properties); - add_ro_properties(METRIC_KEY(SUPPORTED_CONFIG_KEYS), ro_properties); - return to_string_vector(ro_properties); - } else if (name == METRIC_KEY(SUPPORTED_CONFIG_KEYS)) { - auto rw_properties = default_rw_properties(); - return to_string_vector(rw_properties); - OPENVINO_SUPPRESS_DEPRECATED_END } else if (name == ov::loaded_from_cache) { bool loaded_from_cache = true; std::lock_guard lock(m_context->m_fallback_mutex); diff --git a/src/plugins/auto/src/plugin.cpp b/src/plugins/auto/src/plugin.cpp index be04f7b50298bb..81d78e1a55982b 100644 --- a/src/plugins/auto/src/plugin.cpp +++ b/src/plugins/auto/src/plugin.cpp @@ -22,8 +22,6 @@ #include "cumulative_compiled_model.hpp" #include "cumulative_schedule.hpp" #include "itt.hpp" -#include "openvino/core/preprocess/pre_post_process.hpp" -#include "ie_ngraph_utils.hpp" namespace { const std::string get_model_precision(const std::shared_ptr &model) { @@ -96,30 +94,6 @@ std::shared_ptr Plugin::import_model(std::istream& model, OPENVINO_NOT_IMPLEMENTED; } -ov::AnyMap Plugin::pre_process_config(const ov::AnyMap& orig_config) const { - ov::AnyMap properties = orig_config; - for (auto& property : properties) { - // for model_priority, the values need to be converted - if (property.first == ov::hint::model_priority.name()) { - ov::Any converted_val{nullptr}; - auto legacy_val = property.second.as(); - OPENVINO_SUPPRESS_DEPRECATED_START - if (legacy_val == InferenceEngine::PluginConfigParams::MODEL_PRIORITY_HIGH) { - converted_val = ov::hint::Priority::HIGH; - } else if (legacy_val == InferenceEngine::PluginConfigParams::MODEL_PRIORITY_MED) { - converted_val = ov::hint::Priority::MEDIUM; - } else if (legacy_val == InferenceEngine::PluginConfigParams::MODEL_PRIORITY_LOW) { - converted_val = ov::hint::Priority::LOW; - OPENVINO_SUPPRESS_DEPRECATED_END - } else { - converted_val = legacy_val; - } - property.second = std::move(converted_val); - } - } - return properties; -} - std::vector Plugin::parse_meta_devices(const std::string& priorities, const ov::AnyMap& properties) const { std::vector meta_devices; @@ -184,10 +158,6 @@ std::vector Plugin::parse_meta_devices(const std::string& pri try { auto device_id = get_core()->get_property(device_name, ov::device::id); return device_id; - } catch (const InferenceEngine::Exception&) { - // some may throw IE exceptions - LOG_DEBUG_TAG("get default device id failed for ", device_name.c_str()); - return ""; } catch (ov::Exception&) { LOG_DEBUG_TAG("get default device id failed for ", device_name.c_str()); return ""; @@ -264,11 +234,7 @@ std::vector Plugin::parse_meta_devices(const std::string& pri full_device_name = get_core()->get_property(device_name_with_id, ov::device::full_name); } catch (ov::Exception&) { LOG_DEBUG_TAG("get full device name failed for ", device_name_with_id.c_str()); - OPENVINO_SUPPRESS_DEPRECATED_START - } catch (InferenceEngine::Exception&) { - LOG_DEBUG_TAG("get full device name failed for ", device_name_with_id.c_str()); } - OPENVINO_SUPPRESS_DEPRECATED_END } if (full_device_name.empty()) { @@ -292,14 +258,7 @@ std::vector Plugin::parse_meta_devices(const std::string& pri device_name_with_id.c_str(), default_device_id.c_str(), unique_name.c_str()); - OPENVINO_SUPPRESS_DEPRECATED_START - } catch (const InferenceEngine::Exception&) { - LOG_DEBUG_TAG("Failed to create meta device for deviceNameWithID:%s, defaultDeviceID:%s, uniqueName:%s", - device_name_with_id.c_str(), - default_device_id.c_str(), - unique_name.c_str()); } - OPENVINO_SUPPRESS_DEPRECATED_END } if (enable_device_priority) { device_priority++; @@ -310,13 +269,7 @@ std::vector Plugin::parse_meta_devices(const std::string& pri } ov::Any Plugin::get_property(const std::string& name, const ov::AnyMap& arguments) const { - OPENVINO_SUPPRESS_DEPRECATED_START - if (METRIC_KEY(SUPPORTED_METRICS) == name) { - return m_plugin_config.supported_ro_properties(get_device_name()); - } else if (METRIC_KEY(SUPPORTED_CONFIG_KEYS) == name) { - return m_plugin_config.supported_rw_properties(get_device_name()); - OPENVINO_SUPPRESS_DEPRECATED_END - } else if (ov::supported_properties == name) { + if (ov::supported_properties == name) { auto ret = m_plugin_config.supported_properties(get_device_name()); return ret; } else if (name == ov::internal::supported_properties.name()) { @@ -338,33 +291,13 @@ ov::Any Plugin::get_property(const std::string& name, const ov::AnyMap& argument } return capabilities; } - auto val = m_plugin_config.get_property(name); - if (!is_new_api()) { - if (name == ov::hint::model_priority.name()) { // need to convert priority values to old API - ov::Any legacy_val{nullptr}; - if (!val.empty()) { - switch (val.as()) { - OPENVINO_SUPPRESS_DEPRECATED_START - case ov::hint::Priority::LOW: legacy_val = InferenceEngine::PluginConfigParams::MODEL_PRIORITY_LOW; break; - case ov::hint::Priority::MEDIUM: legacy_val = InferenceEngine::PluginConfigParams::MODEL_PRIORITY_MED; break; - case ov::hint::Priority::HIGH: legacy_val = InferenceEngine::PluginConfigParams::MODEL_PRIORITY_HIGH; break; - OPENVINO_SUPPRESS_DEPRECATED_END - default: OPENVINO_ASSERT(false, "Unsupported model priority value"); - } - } - return legacy_val; - } else { - return val; - } - } else { - return val; - } - return val; + return m_plugin_config.get_property(name); } void Plugin::set_property(const ov::AnyMap& properties) { // with setConfig, only multi/auto supported internal configs can be accepted - m_plugin_config.set_property(pre_process_config(properties)); + auto property_to_set = properties; + m_plugin_config.set_property(property_to_set); } // ! [plugin:create_plugin_engine] @@ -412,7 +345,7 @@ std::shared_ptr Plugin::compile_model_impl(const std::string load_config.set_property(ov::hint::performance_mode(ov::hint::PerformanceMode::LATENCY)); } // updateFromMap will check config valid - load_config.set_user_property(pre_process_config(properties)); + load_config.set_user_property(properties); load_config.apply_user_properties(); if (!work_mode_auto) { if (iter_config != properties.end() && iter_config->second.as() != "THROUGHPUT") { @@ -463,63 +396,10 @@ std::shared_ptr Plugin::compile_model_impl(const std::string bool is_cumulative = (auto_s_context->m_performance_hint == ov::hint::PerformanceMode::CUMULATIVE_THROUGHPUT) ? true : false; std::list devices_with_priority(support_devices.begin(), support_devices.end()); - std::shared_ptr cloned_model, ppp_model; + std::shared_ptr cloned_model; if (model_path.empty()) { support_devices = filter_device_by_model(support_devices_by_property, model, load_config); cloned_model = model->clone(); - ppp_model = cloned_model->clone(); - - ov::preprocess::PrePostProcessor preproc(ppp_model); - OPENVINO_SUPPRESS_DEPRECATED_START - // temp solution to resolve the precision/layout mismatch between new/old api - if (!is_new_api()) { - for (size_t i = 0; i < ppp_model->inputs().size(); i++) { - ov::Output input(ppp_model->input(i).get_node(), ppp_model->input(i).get_index()); - auto& rt_info = input.get_rt_info(); - auto it = rt_info.find("ie_legacy_td"); - if (it != rt_info.end()) { - auto& td = it->second.as(); - auto element_type = InferenceEngine::details::convertPrecision(td.getPrecision()); - if (element_type != input.get_element_type()) { - preproc.input(i).tensor().set_element_type(element_type); - } - if (td.getLayout() != InferenceEngine::Layout::BLOCKED && - td.getLayout() != InferenceEngine::Layout::SCALAR) { - std::stringstream stream; - stream << td.getLayout(); - if (td.getLayout() == InferenceEngine::Layout::NHWC) { - preproc.input(i).tensor().set_layout(ov::Layout{stream.str()}); - if (input.get_partial_shape().is_static() && input.get_shape().size() == 4) - preproc.input(i).model().set_layout("NCHW"); - } - } - } - } - for (size_t i = 0; i < ppp_model->outputs().size(); i++) { - ov::Output output(ppp_model->output(i).get_node(), ppp_model->output(i).get_index()); - auto& rt_info = output.get_rt_info(); - auto it = rt_info.find("ie_legacy_td"); - if (it != rt_info.end()) { - auto& td = it->second.as(); - auto element_type = InferenceEngine::details::convertPrecision(td.getPrecision()); - if (element_type != output.get_element_type()) { - preproc.output(i).tensor().set_element_type(element_type); - } - if (td.getLayout() != InferenceEngine::Layout::BLOCKED && - td.getLayout() != InferenceEngine::Layout::SCALAR) { - std::stringstream stream; - stream << td.getLayout(); - if (stream.str() == "NHWC") { - if (output.get_partial_shape().is_static() && output.get_shape().size() == 4) - preproc.output(i).model().set_layout("NCHW"); - preproc.output(i).postprocess().convert_layout(ov::Layout{stream.str()}); - } - } - } - } - preproc.build(); - } - OPENVINO_SUPPRESS_DEPRECATED_END } else { // AUTO / MULTI don't support caching explicitly, but can redirect this functionality to actual HW plugin LOG_INFO_TAG("compile model with model path"); @@ -543,7 +423,7 @@ std::shared_ptr Plugin::compile_model_impl(const std::string LOG_INFO_TAG("device:%s, priority:%ld", iter->device_name.c_str(), iter->device_priority); } // clone the model, in case of reshape conflict - auto_s_context->m_model = std::move(cloned_model); + auto_s_context->m_model = cloned_model; auto_s_context->m_model_path = model_path; auto_s_context->m_device_priorities = support_devices; auto_s_context->m_device_priorities_initial = std::move(support_devices); @@ -569,15 +449,11 @@ std::shared_ptr Plugin::compile_model_impl(const std::string device_context._so = auto_s_context->m_hw_compiled_model._so; } catch (ov::NotImplemented&) { LOG_INFO_TAG("underlying hardware does not support hardware context"); - OPENVINO_SUPPRESS_DEPRECATED_START - } catch (InferenceEngine::Exception&) { - LOG_INFO_TAG("underlying hardware does not support hardware context"); } - OPENVINO_SUPPRESS_DEPRECATED_END if (is_cumulative) { - impl = std::make_shared(ppp_model, shared_from_this(), device_context, auto_s_context, scheduler); + impl = std::make_shared(cloned_model, shared_from_this(), device_context, auto_s_context, scheduler); } else { - impl = std::make_shared(ppp_model, shared_from_this(), device_context, auto_s_context, scheduler); + impl = std::make_shared(cloned_model, shared_from_this(), device_context, auto_s_context, scheduler); } return impl; } diff --git a/src/plugins/auto/src/plugin.hpp b/src/plugins/auto/src/plugin.hpp index 47e7e85a9df571..af667b059e09e7 100644 --- a/src/plugins/auto/src/plugin.hpp +++ b/src/plugins/auto/src/plugin.hpp @@ -67,9 +67,6 @@ class Plugin : public ov::IPlugin { const ov::SoPtr& context, const ov::AnyMap& properties) const override; -protected: - ov::AnyMap pre_process_config(const ov::AnyMap& orig_config) const; - private: std::shared_ptr compile_model_impl(const std::string& model_path, const std::shared_ptr& model, diff --git a/src/plugins/auto/src/plugin_config.hpp b/src/plugins/auto/src/plugin_config.hpp index 2c1f54a8517bce..e276dd1e53c5ad 100644 --- a/src/plugins/auto/src/plugin_config.hpp +++ b/src/plugins/auto/src/plugin_config.hpp @@ -12,7 +12,6 @@ #include #include #include -#include namespace ov { namespace auto_plugin { @@ -177,10 +176,6 @@ class PluginConfig { if (iter.second.as() == ov::PropertyMutability::RO) supported_ro_properties.push_back(iter.first); } - OPENVINO_SUPPRESS_DEPRECATED_START - supported_ro_properties.push_back(METRIC_KEY(SUPPORTED_METRICS)); - supported_ro_properties.push_back(METRIC_KEY(SUPPORTED_CONFIG_KEYS)); - OPENVINO_SUPPRESS_DEPRECATED_END auto multi_supported_ro_properties = supported_ro_properties; return plugin_name == "AUTO" ? supported_ro_properties : multi_supported_ro_properties; } diff --git a/src/plugins/auto/src/schedule.hpp b/src/plugins/auto/src/schedule.hpp index c7c8c8c7baaa77..7291f1ff0ffafb 100644 --- a/src/plugins/auto/src/schedule.hpp +++ b/src/plugins/auto/src/schedule.hpp @@ -6,6 +6,8 @@ #pragma once #include "common.hpp" +#include "itt.hpp" + namespace ov { namespace auto_plugin { using Stage = std::pair, ov::threading::Task>; diff --git a/src/plugins/auto/tests/functional/shared_tests_instances/behavior/ov_executable_network/properties.cpp b/src/plugins/auto/tests/functional/shared_tests_instances/behavior/ov_executable_network/properties.cpp index 982e8cac50981b..18f0a61a64a003 100644 --- a/src/plugins/auto/tests/functional/shared_tests_instances/behavior/ov_executable_network/properties.cpp +++ b/src/plugins/auto/tests/functional/shared_tests_instances/behavior/ov_executable_network/properties.cpp @@ -4,7 +4,6 @@ #include "behavior/compiled_model/properties.hpp" -#include "ie_plugin_config.hpp" #include "openvino/runtime/properties.hpp" #include "openvino/runtime/system_conf.hpp" diff --git a/src/plugins/auto/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp b/src/plugins/auto/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp index 50dcc1b0d4fc7f..1a6f122e0b590b 100644 --- a/src/plugins/auto/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp +++ b/src/plugins/auto/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp @@ -4,7 +4,6 @@ #include "behavior/ov_plugin/properties_tests.hpp" -#include "ie_plugin_config.hpp" #include "openvino/runtime/auto/properties.hpp" using namespace ov::test::behavior; diff --git a/src/plugins/auto/tests/functional/shared_tests_instances/core_config.cpp b/src/plugins/auto/tests/functional/shared_tests_instances/core_config.cpp index 2c54a0d17b2f8d..6c1c4e433b08e3 100644 --- a/src/plugins/auto/tests/functional/shared_tests_instances/core_config.cpp +++ b/src/plugins/auto/tests/functional/shared_tests_instances/core_config.cpp @@ -2,12 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "functional_test_utils/core_config.hpp" - #include "shared_test_classes/base/ov_subgraph.hpp" -void CoreConfiguration(LayerTestsUtils::LayerTestsCommon* test) {} - namespace ov { namespace test { diff --git a/src/plugins/auto/tests/unit/auto_unit_test.cpp b/src/plugins/auto/tests/unit/auto_unit_test.cpp index e4c7e8135774cc..8e44a21f2ce230 100644 --- a/src/plugins/auto/tests/unit/auto_unit_test.cpp +++ b/src/plugins/auto/tests/unit/auto_unit_test.cpp @@ -123,9 +123,6 @@ ov::mock_auto_plugin::tests::AutoTest::AutoTest() { core = std::make_shared>(); // replace core with mock Icore plugin->set_core(core); - std::vector supportConfigs = {"SUPPORTED_CONFIG_KEYS", "NUM_STREAMS"}; - ON_CALL(*core, get_property(_, StrEq(METRIC_KEY(SUPPORTED_CONFIG_KEYS)), _)) - .WillByDefault(Return(ov::Any(supportConfigs))); std::vector supportedProps = {ov::compilation_num_threads}; ON_CALL(*core, get_property(_, StrEq(ov::supported_properties.name()), _)) .WillByDefault(RETURN_MOCK_VALUE(supportedProps)); @@ -155,12 +152,8 @@ ov::mock_auto_plugin::tests::AutoTest::AutoTest() { .WillByDefault(RETURN_MOCK_VALUE(iGpuType)); ON_CALL(*core, get_property(StrEq("GPU.1"), StrEq(ov::device::type.name()), _)) .WillByDefault(RETURN_MOCK_VALUE(dGpuType)); - const std::vector metrics = {METRIC_KEY(SUPPORTED_CONFIG_KEYS), - ov::device::full_name.name(), - ov::device::id.name()}; const char igpuFullDeviceName[] = "Intel(R) Gen9 HD Graphics (iGPU)"; const char dgpuFullDeviceName[] = "Intel(R) Iris(R) Xe MAX Graphics (dGPU)"; - ON_CALL(*core, get_property(_, StrEq(METRIC_KEY(SUPPORTED_METRICS)), _)).WillByDefault(RETURN_MOCK_VALUE(metrics)); ON_CALL(*core, get_property(_, ov::supported_properties.name(), _)).WillByDefault(Return(ov::Any(supportedProps))); ON_CALL(*core, get_property(StrEq("GPU"), StrEq(ov::device::full_name.name()), _)) .WillByDefault(RETURN_MOCK_VALUE(igpuFullDeviceName)); @@ -171,7 +164,7 @@ ov::mock_auto_plugin::tests::AutoTest::AutoTest() { .WillByDefault(RETURN_MOCK_VALUE(dgpuFullDeviceName)); const std::vector availableDevs = {"CPU", "GPU.0", "GPU.1"}; ON_CALL(*core, get_available_devices()).WillByDefault(Return(availableDevs)); - ON_CALL(*core, get_supported_property).WillByDefault([](const std::string& device, const ov::AnyMap& fullConfigs) { + ON_CALL(*core, get_supported_property).WillByDefault([](const std::string& device, const ov::AnyMap& fullConfigs, const bool keep_core_property = true) { auto item = fullConfigs.find(ov::device::properties.name()); ov::AnyMap deviceConfigs; if (item != fullConfigs.end()) { diff --git a/src/plugins/auto/tests/unit/compile_model_metric_test.cpp b/src/plugins/auto/tests/unit/compile_model_metric_test.cpp index 772dca30497ae4..41c81fe34edfd1 100644 --- a/src/plugins/auto/tests/unit/compile_model_metric_test.cpp +++ b/src/plugins/auto/tests/unit/compile_model_metric_test.cpp @@ -100,7 +100,7 @@ class ExecNetworkget_propertyOptimalNumInferReq : public tests::AutoTest, using modelPrioPerfHintTestParams = std::tuple; @@ -111,7 +111,7 @@ class ExecNetworkget_propertyOtherTest : public tests::AutoTest, bool isNewAPI; bool actualSleep; std::string actualDeviceName; - std::string performanceMode; + ov::Any performanceMode; ov::Any modelPriority; std::tie(isNewAPI, actualSleep, actualDeviceName, performanceMode, modelPriority) = obj.param; std::ostringstream result; @@ -130,7 +130,7 @@ class ExecNetworkget_propertyOtherTest : public tests::AutoTest, << "false"; } result << "_actualDeviceName_" << actualDeviceName; - result << "_performanceMode_" << performanceMode; + result << "_performanceMode_" << performanceMode.as(); result << "_modelPriority" << modelPriority.as(); return result.str(); } @@ -186,7 +186,7 @@ TEST_P(ExecNetworkget_propertyOptimalNumInferReq, OPTIMAL_NUMBER_OF_INFER_REQUES metaConfig.insert(ov::hint::num_requests(gpuPerfHintNum)); } if (isThroughput) { - metaConfig.insert(ov::hint::performance_mode("THROUGHPUT")); + metaConfig.insert(ov::hint::performance_mode(ov::hint::PerformanceMode::THROUGHPUT)); metaDevices.push_back({ov::test::utils::DEVICE_CPU, metaConfig, cpuCustomerNum, ""}); metaDevices.push_back({actualDeviceName, metaConfig, actualCustomerNum, ""}); // enable autoBatch @@ -312,6 +312,7 @@ const std::vector testConfigs = { ConfigParams{false, 3, 5, false, 2, 5, true, ov::test::utils::DEVICE_GPU, 1, 0, false, true}, ConfigParams{true, 3, 5, false, 2, 5, true, ov::test::utils::DEVICE_GPU, 48, 0, false, true}, ConfigParams{false, 3, 5, true, 2, 5, false, ov::test::utils::DEVICE_GPU, 2, 0, false, true}, + ConfigParams{false, 3, 5, false, 2, 5, false, ov::test::utils::DEVICE_GPU, 2, 0, false, true}, ConfigParams{true, 3, 5, true, 2, 5, false, ov::test::utils::DEVICE_GPU, 2, 0, false, true}, ConfigParams{true, 3, 5, false, 2, 5, true, ov::test::utils::DEVICE_GPU, 48, 48, false, true}, ConfigParams{true, 3, 5, false, 2, 5, true, ov::test::utils::DEVICE_GPU, 6, 6, false, true}, @@ -365,7 +366,7 @@ class ExecNetworkGetMetricOtherTest : public tests::AutoTest, bool isNewAPI; bool actualSleep; std::string actualDeviceName; - std::string performanceMode; + ov::Any performanceMode; ov::Any modelPriority; std::tie(isNewAPI, actualSleep, actualDeviceName, performanceMode, modelPriority) = obj.param; std::ostringstream result; @@ -384,7 +385,7 @@ class ExecNetworkGetMetricOtherTest : public tests::AutoTest, << "false"; } result << "_actualDeviceName_" << actualDeviceName; - result << "_performanceMode_" << performanceMode; + result << "_performanceMode_" << performanceMode.as(); result << "_modelPriority" << modelPriority.as(); return result.str(); } @@ -396,18 +397,22 @@ TEST_P(ExecNetworkGetMetricOtherTest, modelPriority_perfHint_exclusiveAsyncReq_t bool isNewAPI; bool actualSleep; std::string actualDeviceName; - std::string performanceHint; + ov::Any performanceHint; ov::Any modelPriority; std::tie(isNewAPI, actualSleep, actualDeviceName, performanceHint, modelPriority) = this->GetParam(); config.insert(ov::device::priorities(ov::test::utils::DEVICE_CPU + std::string(",") + actualDeviceName)); - config.insert(ov::hint::performance_mode(performanceHint)); + config.insert(ov::hint::performance_mode(performanceHint.as())); config.insert({ov::hint::model_priority.name(), modelPriority.as()}); if (isNewAPI) { ON_CALL(*core.get(), is_new_api()).WillByDefault(Return(true)); } - metaDevices.push_back({ov::test::utils::DEVICE_CPU, {ov::hint::performance_mode(performanceHint)}, 3, ""}); - metaDevices.push_back({actualDeviceName, {ov::hint::performance_mode(performanceHint)}, 2, ""}); + metaDevices.push_back({ov::test::utils::DEVICE_CPU, + {ov::hint::performance_mode(performanceHint.as())}, + 3, + ""}); + metaDevices.push_back( + {actualDeviceName, {ov::hint::performance_mode(performanceHint.as())}, 2, ""}); ON_CALL(*plugin, select_device(_, _, _)).WillByDefault(Return(metaDevices[1])); ON_CALL(*plugin, parse_meta_devices(_, _)).WillByDefault(Return(metaDevices)); @@ -450,7 +455,7 @@ TEST_P(ExecNetworkGetMetricOtherTest, modelPriority_perfHint_exclusiveAsyncReq_t auto AutoExecNetwork = plugin->compile_model(model, config); auto result = AutoExecNetwork->get_property(ov::hint::performance_mode.name()).as(); - EXPECT_EQ(result, performanceHint); + EXPECT_EQ(result, performanceHint.as()); auto resPriority = AutoExecNetwork->get_property(ov::hint::model_priority.name()).as(); EXPECT_EQ(resPriority, modelPriority.as()); } @@ -459,27 +464,63 @@ const std::vector modelPrioPerfHintConfig = { modelPrioPerfHintTestParams{false, true, ov::test::utils::DEVICE_GPU, - "THROUGHPUT", - CONFIG_VALUE(MODEL_PRIORITY_LOW)}, - modelPrioPerfHintTestParams{false, true, ov::test::utils::DEVICE_GPU, "LATENCY", CONFIG_VALUE(MODEL_PRIORITY_LOW)}, + ov::hint::PerformanceMode::THROUGHPUT, + ov::hint::Priority::LOW}, modelPrioPerfHintTestParams{false, true, ov::test::utils::DEVICE_GPU, - "THROUGHPUT", - CONFIG_VALUE(MODEL_PRIORITY_MED)}, - modelPrioPerfHintTestParams{false, true, ov::test::utils::DEVICE_GPU, "LATENCY", CONFIG_VALUE(MODEL_PRIORITY_MED)}, + ov::hint::PerformanceMode::LATENCY, + ov::hint::Priority::LOW}, modelPrioPerfHintTestParams{false, true, ov::test::utils::DEVICE_GPU, - CONFIG_VALUE(THROUGHPUT), - CONFIG_VALUE(MODEL_PRIORITY_HIGH)}, - modelPrioPerfHintTestParams{false, true, ov::test::utils::DEVICE_GPU, "LATENCY", CONFIG_VALUE(MODEL_PRIORITY_HIGH)}, - modelPrioPerfHintTestParams{true, true, ov::test::utils::DEVICE_GPU, "THROUGHPUT", "LOW"}, - modelPrioPerfHintTestParams{true, true, ov::test::utils::DEVICE_GPU, "LATENCY", "LOW"}, - modelPrioPerfHintTestParams{true, true, ov::test::utils::DEVICE_GPU, "THROUGHPUT", "MEDIUM"}, - modelPrioPerfHintTestParams{true, true, ov::test::utils::DEVICE_GPU, "LATENCY", "MEDIUM"}, - modelPrioPerfHintTestParams{true, true, ov::test::utils::DEVICE_GPU, "THROUGHPUT", "HIGH"}, - modelPrioPerfHintTestParams{true, true, ov::test::utils::DEVICE_GPU, "LATENCY", "HIGH"}}; + ov::hint::PerformanceMode::THROUGHPUT, + ov::hint::Priority::MEDIUM}, + modelPrioPerfHintTestParams{false, + true, + ov::test::utils::DEVICE_GPU, + ov::hint::PerformanceMode::LATENCY, + ov::hint::Priority::MEDIUM}, + modelPrioPerfHintTestParams{false, + true, + ov::test::utils::DEVICE_GPU, + ov::hint::PerformanceMode::THROUGHPUT, + ov::hint::Priority::HIGH}, + modelPrioPerfHintTestParams{false, + true, + ov::test::utils::DEVICE_GPU, + ov::hint::PerformanceMode::LATENCY, + ov::hint::Priority::HIGH}, + modelPrioPerfHintTestParams{true, + true, + ov::test::utils::DEVICE_GPU, + ov::hint::PerformanceMode::THROUGHPUT, + ov::hint::Priority::LOW}, + modelPrioPerfHintTestParams{true, + true, + ov::test::utils::DEVICE_GPU, + ov::hint::PerformanceMode::LATENCY, + ov::hint::Priority::LOW}, + modelPrioPerfHintTestParams{true, + true, + ov::test::utils::DEVICE_GPU, + ov::hint::PerformanceMode::THROUGHPUT, + ov::hint::Priority::MEDIUM}, + modelPrioPerfHintTestParams{true, + true, + ov::test::utils::DEVICE_GPU, + ov::hint::PerformanceMode::LATENCY, + ov::hint::Priority::MEDIUM}, + modelPrioPerfHintTestParams{true, + true, + ov::test::utils::DEVICE_GPU, + ov::hint::PerformanceMode::THROUGHPUT, + ov::hint::Priority::HIGH}, + modelPrioPerfHintTestParams{true, + true, + ov::test::utils::DEVICE_GPU, + ov::hint::PerformanceMode::LATENCY, + ov::hint::Priority::HIGH}}; INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, ExecNetworkGetMetricOtherTest, diff --git a/src/plugins/auto/tests/unit/ctput_test.cpp b/src/plugins/auto/tests/unit/ctput_test.cpp index 4b9cfd987b0133..14bfd1d0806ef9 100644 --- a/src/plugins/auto/tests/unit/ctput_test.cpp +++ b/src/plugins/auto/tests/unit/ctput_test.cpp @@ -3,7 +3,6 @@ // #include "include/auto_unit_test.hpp" - using namespace ov::mock_auto_plugin; using Config = std::map; using ConfigParams = std::tuple>; @@ -50,7 +49,7 @@ TEST_P(LoadNetworkWithCTPUTMockTest, CTPUTSingleDevLogicTest) { if (targetDevices.size() == 1) { std::string targetDevice = targetDevices[0]; - config.insert({InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, targetDevices[0]}); + config.insert(ov::device::priorities(targetDevice)); // Call single device logic and performance hint is THROUGHPUT EXPECT_CALL(*core, compile_model(::testing::Matcher&>(_), @@ -95,7 +94,7 @@ TEST_P(LoadNetworkWithCTPUTMockTestExeDevice, CTPUTSingleDevExecutionDevie) { std::tie(targetDevices) = this->GetParam(); plugin->set_device_name("AUTO"); - config.insert({{CONFIG_KEY(PERFORMANCE_HINT), InferenceEngine::PluginConfigParams::CUMULATIVE_THROUGHPUT}}); + config.insert({ov::hint::performance_mode(ov::hint::PerformanceMode::CUMULATIVE_THROUGHPUT)}); config.insert(ov::device::priorities(targetDevices[0])); // Call single device logic and performance hint is THROUGHPUT ASSERT_NO_THROW(exeNetwork = plugin->compile_model(model, config)); @@ -175,13 +174,13 @@ TEST_P(AutoCTPUTCallMulti, CTPUTDeviceLoadFailedNoExceptionThrowTest) { targetDev += ((deviceName == targetDevices.back()) ? "" : ","); } std::shared_ptr exeNetwork; - config.insert({{CONFIG_KEY(PERFORMANCE_HINT), InferenceEngine::PluginConfigParams::CUMULATIVE_THROUGHPUT}}); + config.insert({ov::hint::performance_mode(ov::hint::PerformanceMode::CUMULATIVE_THROUGHPUT)}); config.insert(ov::device::priorities(targetDev)); ON_CALL(*core, compile_model(::testing::Matcher&>(_), ::testing::Matcher(StrEq(loadFailedDevice)), ::testing::Matcher(_))) - .WillByDefault(Throw(InferenceEngine::GeneralError{""})); + .WillByDefault(Throw(ov::Exception{"GeneralError"})); if (loadFailedDevice != ov::test::utils::DEVICE_CPU) { EXPECT_CALL(*core, compile_model(::testing::Matcher&>(_), diff --git a/src/plugins/auto/tests/unit/include/auto_unit_test.hpp b/src/plugins/auto/tests/unit/include/auto_unit_test.hpp index 02043f1e45a1d7..46e4532cff19da 100644 --- a/src/plugins/auto/tests/unit/include/auto_unit_test.hpp +++ b/src/plugins/auto/tests/unit/include/auto_unit_test.hpp @@ -40,9 +40,6 @@ MATCHER_P(ComparePerfHint, perfHint, "Check if perf hint expects.") { return perfHint == arg_perfHint.as(); } -#define IE_SET_METRIC(key, name, ...) \ - typename ::InferenceEngine::Metrics::MetricType<::InferenceEngine::Metrics::key>::type name = __VA_ARGS__; - #define RETURN_MOCK_VALUE(value) \ InvokeWithoutArgs([value]() { \ return ov::Any(value); \ diff --git a/src/plugins/auto/tests/unit/parse_meta_device_test.cpp b/src/plugins/auto/tests/unit/parse_meta_device_test.cpp index 42b6d3de2ca97e..3c023623b4c97a 100644 --- a/src/plugins/auto/tests/unit/parse_meta_device_test.cpp +++ b/src/plugins/auto/tests/unit/parse_meta_device_test.cpp @@ -36,7 +36,7 @@ class ParseMetaDeviceTest : public tests::AutoTest, public ::testing::TestWithPa } void SetUp() override { - ON_CALL(*core, get_supported_property(StrEq("INVALID_DEVICE"), _)).WillByDefault(Throw(ov::Exception(""))); + ON_CALL(*core, get_supported_property(StrEq("INVALID_DEVICE"), _, _)).WillByDefault(Throw(ov::Exception(""))); ON_CALL(*core, get_property(StrEq("GPU.2"), ov::supported_properties.name(), _)) .WillByDefault(Throw(ov::Exception(""))); ON_CALL(*plugin, parse_meta_devices) @@ -80,7 +80,7 @@ TEST_P(ParseMetaDeviceTest, ParseMetaDevicesWithPriority) { EXPECT_CALL(*plugin, parse_meta_devices(_, _)).Times(1); EXPECT_CALL(*core, get_property(_, _, _)).Times(AnyNumber()); EXPECT_CALL(*core, get_available_devices()).Times(1); - EXPECT_CALL(*core, get_supported_property(_, _)).Times(expectedTimes); + EXPECT_CALL(*core, get_supported_property(_, _, _)).Times(expectedTimes); if (throwException) { ASSERT_ANY_THROW(plugin->parse_meta_devices(priorityDevices, {})); } else { @@ -115,7 +115,7 @@ TEST_P(ParseMetaDeviceNoIDTest, ParseMetaDevices) { EXPECT_CALL(*plugin, parse_meta_devices(_, _)).Times(1); EXPECT_CALL(*core, get_property(_, _, _)).Times(AnyNumber()); EXPECT_CALL(*core, get_available_devices()).Times(1); - EXPECT_CALL(*core, get_supported_property(_, _)).Times(expectedTimes); + EXPECT_CALL(*core, get_supported_property(_, _, _)).Times(expectedTimes); if (throwException) { ASSERT_ANY_THROW(plugin->parse_meta_devices(priorityDevices, {})); } else { diff --git a/src/plugins/auto/tests/unit/release_helper_test.cpp b/src/plugins/auto/tests/unit/release_helper_test.cpp index 41af9cb5a804d1..d576e22299ff31 100644 --- a/src/plugins/auto/tests/unit/release_helper_test.cpp +++ b/src/plugins/auto/tests/unit/release_helper_test.cpp @@ -195,7 +195,7 @@ TEST_P(AutoReleaseHelperTest, releaseResource) { compile_model(::testing::Matcher&>(_), ::testing::Matcher(StrEq(ov::test::utils::DEVICE_CPU)), _)) - .WillByDefault(Throw(InferenceEngine::GeneralError{""})); + .WillByDefault(Throw(ov::Exception{"GeneralError"})); } metaDevices = {{ov::test::utils::DEVICE_CPU, {}, -1}, {ov::test::utils::DEVICE_GPU, {}, -1}}; DeviceInformation devInfo; diff --git a/src/plugins/auto_batch/tests/functional/behavior/ov_plugin/auto_batching_tests.cpp b/src/plugins/auto_batch/tests/functional/behavior/ov_plugin/auto_batching_tests.cpp index 7bf21f888e0153..1cdb6ecfb85934 100644 --- a/src/plugins/auto_batch/tests/functional/behavior/ov_plugin/auto_batching_tests.cpp +++ b/src/plugins/auto_batch/tests/functional/behavior/ov_plugin/auto_batching_tests.cpp @@ -3,6 +3,7 @@ // #include "behavior/ov_plugin/auto_batching_tests.hpp" + #include "behavior/compiled_model/properties.hpp" using namespace ov::test::behavior; diff --git a/src/plugins/auto_batch/tests/unit/async_infer_request_test.cpp b/src/plugins/auto_batch/tests/unit/async_infer_request_test.cpp index e7c337a10d5648..a78d71f79b4c58 100644 --- a/src/plugins/auto_batch/tests/unit/async_infer_request_test.cpp +++ b/src/plugins/auto_batch/tests/unit/async_infer_request_test.cpp @@ -207,7 +207,7 @@ class AutoBatchAsyncInferRequestTest : public ::testing::TestWithParam t; for (int n = 0; n < sz; n++) { - IE_ASSERT(workerRequestPtr->_tasks.try_pop(t)); + OPENVINO_ASSERT(workerRequestPtr->_tasks.try_pop(t)); t.first->m_sync_request->m_batched_request_status = SyncInferRequest::eExecutionFlavor::TIMEOUT_EXECUTED; t.first->m_request_without_batch->start_async(); diff --git a/src/plugins/auto_batch/tests/unit/compile_model_get_property_test.cpp b/src/plugins/auto_batch/tests/unit/compile_model_get_property_test.cpp index 883cca1dcd5d5d..d8d545f4894495 100644 --- a/src/plugins/auto_batch/tests/unit/compile_model_get_property_test.cpp +++ b/src/plugins/auto_batch/tests/unit/compile_model_get_property_test.cpp @@ -106,17 +106,6 @@ class CompileModelGetPropertyTest : public ::testing::TestWithParam res_config; - res_config.emplace_back(ov::cache_dir.name()); - res_config.emplace_back(ov::optimal_batch_size.name()); - return res_config; - }); - ON_CALL(*m_mock_i_compile_model.get(), get_property(StrEq("CACHE_DIR"))).WillByDefault(Return("./abc")); ON_CALL(*m_mock_i_compile_model.get(), get_property(StrEq("OPTIMAL_BATCH_SIZE"))).WillByDefault(Return("16")); diff --git a/src/plugins/auto_batch/tests/unit/parse_meta_device_test.cpp b/src/plugins/auto_batch/tests/unit/parse_meta_device_test.cpp index d50b2b45167ac1..0ac4a51d5a4efe 100644 --- a/src/plugins/auto_batch/tests/unit/parse_meta_device_test.cpp +++ b/src/plugins/auto_batch/tests/unit/parse_meta_device_test.cpp @@ -60,7 +60,7 @@ class ParseMetaDeviceTest : public ::testing::TestWithParam std::tie(m_batch_cfg, m_config, m_expected_device_info, m_throw_exception) = this->GetParam(); ON_CALL(*m_core, get_supported_property) - .WillByDefault([](const std::string& device, const ov::AnyMap& configs) { + .WillByDefault([](const std::string& device, const ov::AnyMap& configs, const bool keep_core_property) { ov::AnyMap res_config; if (device == "CPU") { for (auto& c : configs) { diff --git a/src/plugins/hetero/src/plugin.cpp b/src/plugins/hetero/src/plugin.cpp index bfd2735aa5a061..4cc233fcd57bcf 100644 --- a/src/plugins/hetero/src/plugin.cpp +++ b/src/plugins/hetero/src/plugin.cpp @@ -72,7 +72,7 @@ ov::hetero::Plugin::DeviceProperties ov::hetero::Plugin::get_properties_per_devi for (const auto& device_name : device_names) { auto properties_it = device_properties.find(device_name); if (device_properties.end() == properties_it) - device_properties[device_name] = get_core()->get_supported_property(device_name, properties); + device_properties[device_name] = get_core()->get_supported_property(device_name, properties, false); } return device_properties; } diff --git a/src/plugins/hetero/tests/functional/properties_tests.cpp b/src/plugins/hetero/tests/functional/properties_tests.cpp index b4518d5707218f..8a4ae3a9c92ea7 100644 --- a/src/plugins/hetero/tests/functional/properties_tests.cpp +++ b/src/plugins/hetero/tests/functional/properties_tests.cpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // #include "hetero_tests.hpp" -#include "ie/ie_plugin_config.hpp" #include "openvino/runtime/internal_properties.hpp" using namespace ov::hetero::tests; diff --git a/src/plugins/intel_cpu/docs/debug_capabilities/infer_prc.md b/src/plugins/intel_cpu/docs/debug_capabilities/infer_prc.md index b97e55fb368b68..aefd735a057e8c 100644 --- a/src/plugins/intel_cpu/docs/debug_capabilities/infer_prc.md +++ b/src/plugins/intel_cpu/docs/debug_capabilities/infer_prc.md @@ -2,7 +2,56 @@ When developing/debugging accuracy issue related to inference precision feature, you can define following environment variables to control the type & number of nodes for which the specified inference precision is enforced: - - `OV_CPU_INFER_PRC_TYPES` : comma separated list of node types for which infer-precision is enforced. use node type with prefix `-` as negative pattern to disable particular node types from enforcement; - - `OV_CPU_INFER_PRC_CNT` : total number of nodes allowed to enforce; +- `OV_CPU_INFER_PRC_POS_PATTERN` : positive regex pattern to filter node type & orgname. +- `OV_CPU_INFER_PRC_NEG_PATTERN` : negative regex pattern to filter after pos-pattern was matched. +- `OV_CPU_INFER_PRC_CNT` : total number of nodes allowed to enforce; Just adjust these two settings before each run until accuracy issue happens/disappears, from the log we can spot the first node introduces issue when enabled. + +When any of these pattern env-var was set to a valid raw C++ regular expression string, console output will show the nodes finally passed the filter. +so we suggest first `export OV_CPU_INFER_PRC_POS_PATTERN=".*"` to see the full list of nodes, and then add filters one by one. + +for example, for a LLM model we set pos-pattern as ".*" first and following log was generated on console: + +```bash +OV_CPU_INFER_PRC_POS_PATTERN=".*" +infer precision enforced Types: Broadcast,Concatenation,Convert,Eltwise,FullyConnected,Gather,Math,Range,Reduce,Reshape,RoPE,ScaledDotProductAttention,ShapeOf,Transpose, total number of nodes: 1918 + ... +Eltwise : + Eltwise@__module.model.layers.0.input_layernorm/aten::pow/Power + Eltwise@__module.model.layers.0.input_layernorm/aten::add/Add + Eltwise@__module.model.layers.0.input_layernorm/aten::rsqrt/Sqrt + Eltwise@__module.model.layers.0.input_layernorm/aten::rsqrt/Divide + Eltwise@__module.model.layers.0.input_layernorm/aten::mul/Multiply + Eltwise@__module.model.layers.0.input_layernorm/aten::mul/Multiply_1 + ... +FullyConnected : + FullyConnected@__module.model.layers.0.self_attn.q_proj/aten::linear/MatMul + FullyConnected@__module.model.layers.0.self_attn.k_proj/aten::linear/MatMul + FullyConnected@__module.model.layers.0.self_attn.v_proj/aten::linear/MatMul + FullyConnected@__module.model.layers.0.self_attn.o_proj/aten::linear/MatMul + FullyConnected@__module.model.layers.0.mlp.gate_proj/aten::linear/MatMul + FullyConnected@__module.model.layers.0.mlp.up_proj/aten::linear/MatMul + FullyConnected@__module.model.layers.0.mlp.down_proj/aten::linear/MatMul + FullyConnected@__module.model.layers.1.self_attn.q_proj/aten::linear/MatMul + FullyConnected@__module.model.layers.1.self_attn.k_proj/aten::linear/MatMul + FullyConnected@__module.model.layers.1.self_attn.v_proj/aten::linear/MatMul + FullyConnected@__module.model.layers.1.self_attn.o_proj/aten::linear/MatMul + FullyConnected@__module.model.layers.1.mlp.gate_proj/aten::linear/MatMul + FullyConnected@__module.model.layers.1.mlp.up_proj/aten::linear/MatMul + ... +``` + +then we save the log and replace ".*" with the pattern that we selectivly enables to see whether accuracy issue is fixed, for example +suppose we only enables `input_layernorm` for all layers we set pos-pattern as `"__module\.model\.layers\.(\d+)\.input_layernorm/"`, notice +the escape for regex reserved special char . and sub-pattern (\d+) for matching all layer indices. + +if the accuracy issue is gone, we can add more nodes to this pattern, for example we can add `self_attn.q_proj` from all layers, the our pattern +becomes `"__module\.model\.layers\.(\d+)\.input_layernorm/|__module\.model\.layers\.(\d+)\.self_attn\.q_proj/`, then run test again to see whether +the accuracy issue appears. if not, repeat above procedure. + +we can use neg-pattern to elimite nodes from being enforced bf16/f16, for example, set the pattern above to neg-pattern so only matched nodes +are eliminated, and check if accuracy is gone, if not, add more nodes into the pattern. + +notice that the actual string being matched with pattern is in the format of `NodeType@orginialLayers`, so by using `"^FullyConnected@"` as the pattern we can +select all nodes with specific type - `FullyConnected` instead of with specific original layer name. diff --git a/src/plugins/intel_cpu/src/cache/lru_cache.h b/src/plugins/intel_cpu/src/cache/lru_cache.h index 8751f63f82c468..dc1401520e8be2 100644 --- a/src/plugins/intel_cpu/src/cache/lru_cache.h +++ b/src/plugins/intel_cpu/src/cache/lru_cache.h @@ -4,6 +4,7 @@ #pragma once +#include #include #include diff --git a/src/plugins/intel_cpu/src/compiled_model.cpp b/src/plugins/intel_cpu/src/compiled_model.cpp index 7c754a56930cb2..6e755ce01824a0 100644 --- a/src/plugins/intel_cpu/src/compiled_model.cpp +++ b/src/plugins/intel_cpu/src/compiled_model.cpp @@ -46,7 +46,6 @@ CompiledModel::CompiledModel(const std::shared_ptr& model, m_cfg{cfg}, m_name{model->get_name()}, m_loaded_from_cache(loaded_from_cache) { - bool isFloatModel = !ov::op::util::has_op_with_type(m_model); m_mutex = std::make_shared(); const auto& core = m_plugin->get_core(); if (!core) @@ -57,15 +56,9 @@ CompiledModel::CompiledModel(const std::shared_ptr& model, // special case when all InferRequests are muxed into a single queue m_task_executor = m_plugin->get_executor_manager()->get_executor("CPU"); } else { - auto streamsExecutorConfig = - is_cpu_map_available() - ? m_cfg.streamExecutorConfig - : IStreamsExecutor::Config::make_default_multi_threaded(m_cfg.streamExecutorConfig, isFloatModel); - streamsExecutorConfig._name = "CPUStreamsExecutor"; - m_cfg.streamExecutorConfig._threads = streamsExecutorConfig._threads; - m_task_executor = m_plugin->get_executor_manager()->get_idle_cpu_streams_executor(streamsExecutorConfig); + m_task_executor = m_plugin->get_executor_manager()->get_idle_cpu_streams_executor(m_cfg.streamExecutorConfig); } - if (0 != cfg.streamExecutorConfig._streams) { + if (0 != cfg.streams) { m_callback_executor = m_plugin->get_executor_manager()->get_idle_cpu_streams_executor( IStreamsExecutor::Config{"CPUCallbackExecutor", 1, 0, IStreamsExecutor::ThreadBindingType::NONE}); } else { @@ -77,11 +70,11 @@ CompiledModel::CompiledModel(const std::shared_ptr& model, if (m_callback_executor) set_callback_executor(m_callback_executor); - int streams = std::max(1, m_cfg.streamExecutorConfig._streams); + int streams = std::max(1, m_cfg.streamExecutorConfig.get_streams()); std::vector tasks; tasks.resize(streams); m_graphs.resize(streams); - if (m_cfg.streamExecutorConfig._streams != 0) { + if (m_cfg.streams != 0) { auto all_graphs_ready = [&] { return std::all_of(m_graphs.begin(), m_graphs.end(), [&](Graph& graph) { return graph.IsReady(); @@ -117,7 +110,7 @@ CompiledModel::GraphGuard::Lock CompiledModel::get_graph() const { { std::lock_guard lock{*m_mutex.get()}; // disable weights caching if graph was created only once - auto weightsCache = m_cfg.streamExecutorConfig._streams != 1 ? m_socketWeights[socketId] : nullptr; + auto weightsCache = m_cfg.streams != 1 ? m_socketWeights[socketId] : nullptr; auto isQuantizedFlag = (m_cfg.lpTransformsMode == Config::On) && ov::pass::low_precision::LowPrecision::isFunctionQuantized(m_model); @@ -187,7 +180,6 @@ ov::Any CompiledModel::get_property(const std::string& name) const { }; if (name == ov::supported_properties) { - OPENVINO_SUPPRESS_DEPRECATED_START return std::vector{ RO_property(ov::supported_properties.name()), RO_property(ov::model_name.name()), @@ -208,7 +200,6 @@ ov::Any CompiledModel::get_property(const std::string& name) const { RO_property(ov::log::level.name()), RO_property(ov::intel_cpu::sparse_weights_decompression_rate.name()), }; - OPENVINO_SUPPRESS_DEPRECATED_END } if (name == ov::model_name) { @@ -216,16 +207,16 @@ ov::Any CompiledModel::get_property(const std::string& name) const { const std::string modelName = graph.dump()->get_friendly_name(); return decltype(ov::model_name)::value_type(modelName); } else if (name == ov::optimal_number_of_infer_requests) { - const auto streams = config.streamExecutorConfig._streams; + const auto streams = config.streamExecutorConfig.get_streams(); return decltype(ov::optimal_number_of_infer_requests)::value_type( streams > 0 ? streams : 1); // ov::optimal_number_of_infer_requests has no negative values } else if (name == ov::num_streams) { - const auto streams = config.streamExecutorConfig._streams; + const auto streams = config.streamExecutorConfig.get_streams(); return decltype(ov::num_streams)::value_type( streams); // ov::num_streams has special negative values (AUTO = -1, NUMA = -2) OPENVINO_SUPPRESS_DEPRECATED_START } else if (name == ov::affinity) { - const auto affinity = config.streamExecutorConfig._threadBindingType; + const auto affinity = config.threadBindingType; switch (affinity) { case IStreamsExecutor::ThreadBindingType::NONE: return ov::Affinity::NONE; @@ -239,7 +230,7 @@ ov::Any CompiledModel::get_property(const std::string& name) const { return ov::Affinity::NONE; OPENVINO_SUPPRESS_DEPRECATED_END } else if (name == ov::inference_num_threads) { - const auto num_threads = config.streamExecutorConfig._threads; + const auto num_threads = config.streamExecutorConfig.get_threads(); return decltype(ov::inference_num_threads)::value_type(num_threads); } else if (name == ov::enable_profiling.name()) { const bool perfCount = config.collectPerfCounters; diff --git a/src/plugins/intel_cpu/src/config.cpp b/src/plugins/intel_cpu/src/config.cpp index a5ab2a3385b8a3..0bb7e80ea32895 100644 --- a/src/plugins/intel_cpu/src/config.cpp +++ b/src/plugins/intel_cpu/src/config.cpp @@ -26,9 +26,9 @@ using namespace dnnl::impl::cpu::x64; Config::Config() { // this is default mode #if defined(__APPLE__) || defined(_WIN32) - streamExecutorConfig._threadBindingType = IStreamsExecutor::NONE; + threadBindingType = IStreamsExecutor::NONE; #else - streamExecutorConfig._threadBindingType = IStreamsExecutor::CORES; + threadBindingType = IStreamsExecutor::CORES; #endif // for the TBB code-path, additional configuration depending on the OS and CPU types @@ -37,14 +37,14 @@ Config::Config() { // 'CORES' is not implemented for Win/MacOS; so the 'NONE' or 'NUMA' is default auto numaNodes = get_available_numa_nodes(); if (numaNodes.size() > 1) { - streamExecutorConfig._threadBindingType = IStreamsExecutor::NUMA; + threadBindingType = IStreamsExecutor::NUMA; } else { - streamExecutorConfig._threadBindingType = IStreamsExecutor::NONE; + threadBindingType = IStreamsExecutor::NONE; } # endif if (get_available_cores_types().size() > 1 /*Hybrid CPU*/) { - streamExecutorConfig._threadBindingType = IStreamsExecutor::HYBRID_AWARE; + threadBindingType = IStreamsExecutor::HYBRID_AWARE; } #endif CPU_DEBUG_CAP_ENABLE(applyDebugCapsProperties()); @@ -74,26 +74,63 @@ void Config::readProperties(const ov::AnyMap& prop, const ModelType modelType) { if (streamExecutorConfigKeys.end() != std::find(std::begin(streamExecutorConfigKeys), std::end(streamExecutorConfigKeys), key)) { streamExecutorConfig.set_property(key, val.as()); + streams = streamExecutorConfig.get_streams(); + threads = streamExecutorConfig.get_threads(); + threadsPerStream = streamExecutorConfig.get_threads_per_stream(); + if (key == ov::num_streams.name()) { + ov::Any value = val.as(); + auto streams_value = value.as(); + if (streams_value == ov::streams::NUMA) { + latencyThreadingMode = Config::LatencyThreadingMode::PER_NUMA_NODE; + } else if (streams_value == ov::streams::AUTO) { + hintPerfMode = ov::hint::PerformanceMode::THROUGHPUT; + changedHintPerfMode = true; + } else { + streamsChanged = true; + } + } OPENVINO_SUPPRESS_DEPRECATED_START - if (key == ov::affinity.name()) { + } else if (key == ov::affinity.name()) { + try { + ov::Affinity affinity = val.as(); changedCpuPinning = true; - try { - const auto affinity_val = val.as(); - enableCpuPinning = - (affinity_val == ov::Affinity::CORE || affinity_val == ov::Affinity::HYBRID_AWARE) ? true - : false; - } catch (const ov::Exception&) { + enableCpuPinning = + (affinity == ov::Affinity::CORE || affinity == ov::Affinity::HYBRID_AWARE) ? true : false; + switch (affinity) { + case ov::Affinity::NONE: + threadBindingType = IStreamsExecutor::ThreadBindingType::NONE; + break; + case ov::Affinity::CORE: { +#if (defined(__APPLE__) || defined(_WIN32)) + threadBindingType = IStreamsExecutor::ThreadBindingType::NUMA; +#else + threadBindingType = IStreamsExecutor::ThreadBindingType::CORES; +#endif + } break; + case ov::Affinity::NUMA: + threadBindingType = IStreamsExecutor::ThreadBindingType::NUMA; + break; + case ov::Affinity::HYBRID_AWARE: + threadBindingType = IStreamsExecutor::ThreadBindingType::HYBRID_AWARE; + break; + default: OPENVINO_THROW("Wrong value ", val.as(), "for property key ", key, ". Expected only ov::Affinity::CORE/NUMA/HYBRID_AWARE."); } + } catch (const ov::Exception&) { + OPENVINO_THROW("Wrong value ", + val.as(), + "for property key ", + key, + ". Expected only ov::Affinity::CORE/NUMA/HYBRID_AWARE."); } OPENVINO_SUPPRESS_DEPRECATED_END } else if (key == ov::hint::performance_mode.name()) { try { - hintPerfMode = val.as(); + hintPerfMode = !changedHintPerfMode ? val.as() : hintPerfMode; } catch (const ov::Exception&) { OPENVINO_THROW("Wrong value ", val.as(), @@ -306,8 +343,8 @@ void Config::readProperties(const ov::AnyMap& prop, const ModelType modelType) { if (executionMode == ov::hint::ExecutionMode::PERFORMANCE) { inferencePrecision = ov::element::f32; #if defined(OV_CPU_ARM_ENABLE_FP16) - //fp16 precision is used as default precision on ARM for non-convolution networks - //fp16 ACL convolution is slower than fp32 + // fp16 precision is used as default precision on ARM for non-convolution networks + // fp16 ACL convolution is slower than fp32 if (modelType != ModelType::CNN) inferencePrecision = ov::element::f16; #else @@ -323,8 +360,8 @@ void Config::readProperties(const ov::AnyMap& prop, const ModelType modelType) { _config.clear(); if (exclusiveAsyncRequests) { // Exclusive request feature disables the streams - streamExecutorConfig._streams = 1; - streamExecutorConfig._streams_changed = true; + streams = 1; + streamsChanged = true; } this->modelType = modelType; @@ -337,20 +374,6 @@ void Config::updateProperties() { if (!_config.empty()) return; - switch (streamExecutorConfig._threadBindingType) { - case IStreamsExecutor::ThreadBindingType::NONE: - _config.insert({ov::internal::cpu_bind_thread.name(), "NO"}); - break; - case IStreamsExecutor::ThreadBindingType::CORES: - _config.insert({ov::internal::cpu_bind_thread.name(), "YES"}); - break; - case IStreamsExecutor::ThreadBindingType::NUMA: - _config.insert({ov::internal::cpu_bind_thread.name(), ov::util::to_string(ov::Affinity::NUMA)}); - break; - case IStreamsExecutor::ThreadBindingType::HYBRID_AWARE: - _config.insert({ov::internal::cpu_bind_thread.name(), ov::util::to_string(ov::Affinity::HYBRID_AWARE)}); - break; - } if (collectPerfCounters == true) _config.insert({ov::enable_profiling.name(), "YES"}); else diff --git a/src/plugins/intel_cpu/src/config.h b/src/plugins/intel_cpu/src/config.h index 3a5d7a7c486388..8c4910eb02aa32 100644 --- a/src/plugins/intel_cpu/src/config.h +++ b/src/plugins/intel_cpu/src/config.h @@ -62,7 +62,13 @@ struct Config { size_t rtCacheCapacity = 0ul; #endif ov::threading::IStreamsExecutor::Config streamExecutorConfig; + int streams = 1; + bool streamsChanged = false; + int threads = 0; + int threadsPerStream = 0; + ov::threading::IStreamsExecutor::ThreadBindingType threadBindingType = ov::threading::IStreamsExecutor::ThreadBindingType::NONE; ov::hint::PerformanceMode hintPerfMode = ov::hint::PerformanceMode::LATENCY; + bool changedHintPerfMode = false; ov::log::Level logLevel = ov::log::Level::NO; uint32_t hintNumRequests = 0; bool enableCpuPinning = true; diff --git a/src/plugins/intel_cpu/src/cpu_memory.cpp b/src/plugins/intel_cpu/src/cpu_memory.cpp index 71463d9d3b41e4..2aa5644e9d6356 100644 --- a/src/plugins/intel_cpu/src/cpu_memory.cpp +++ b/src/plugins/intel_cpu/src/cpu_memory.cpp @@ -3,6 +3,7 @@ // #include "cpu_memory.h" +#include #include "nodes/reorder.h" namespace ov { diff --git a/src/plugins/intel_cpu/src/cpu_memory.h b/src/plugins/intel_cpu/src/cpu_memory.h index a0e8889852502a..2f047a3f1b137c 100644 --- a/src/plugins/intel_cpu/src/cpu_memory.h +++ b/src/plugins/intel_cpu/src/cpu_memory.h @@ -4,9 +4,19 @@ #pragma once -#include "memory_desc/dnnl_memory_desc.h" +#include "memory_desc/cpu_memory_desc.h" +#include "dnnl_extension_utils.h" +#include "memory_desc/cpu_memory_desc_utils.h" +#include +#include + +#include "openvino/core/type/element_type.hpp" #include "openvino/core/type/element_type_traits.hpp" +#include +#include +#include + /** * @file contains a concept classes to work with memory/tensor/blob abstractions on plugin level. * @@ -176,6 +186,15 @@ class IMemory { virtual void* getData() const = 0; // pointer to the actual memory + template ::type> + T* getDataAs() const { + /** @todo enabling this check requires all the nodes to follow this requirement + * OPENVINO_ASSERT(element::from() == getPrecision(), + * "Memory data element type ", getPrecision(), " is not representable as ", element::from()); + */ + return static_cast(getData()); + } + virtual size_t getSize() const = 0; // in bytes virtual const Shape& getShape() const = 0; virtual const VectorDims& getStaticDims() const = 0; @@ -191,6 +210,11 @@ class IMemory { //oneDNN specifics for backward compatibility virtual dnnl::memory getPrimitive() const = 0; + + ov::element::Type getPrecision() const { + return getDesc().getPrecision(); + } + dnnl::memory::data_type getDataType() const { return DnnlExtensionUtils::ElementTypeToDataType(getDesc().getPrecision()); } diff --git a/src/plugins/intel_cpu/src/cpu_shape.h b/src/plugins/intel_cpu/src/cpu_shape.h index 7623aa12757663..f8dbbfbaca62d9 100644 --- a/src/plugins/intel_cpu/src/cpu_shape.h +++ b/src/plugins/intel_cpu/src/cpu_shape.h @@ -4,9 +4,8 @@ #pragma once -#include "perf_count.h" #include -#include + #include "cpu_types.h" #include "openvino/core/partial_shape.hpp" diff --git a/src/plugins/intel_cpu/src/cpu_streams_calculation.cpp b/src/plugins/intel_cpu/src/cpu_streams_calculation.cpp index b46c40f3f0fb7a..704894b24448ef 100644 --- a/src/plugins/intel_cpu/src/cpu_streams_calculation.cpp +++ b/src/plugins/intel_cpu/src/cpu_streams_calculation.cpp @@ -30,6 +30,7 @@ std::vector> get_streams_info_table(const int input_streams, const int input_threads, const int input_infer_requests, const int model_prefer_threads, + const int input_current_socket_id, const std::string input_perf_hint, const Config::LatencyThreadingMode latencyThreadingMode, const std::vector>& proc_type_table) { @@ -40,6 +41,7 @@ std::vector> get_streams_info_table(const int input_streams, int n_streams = 0; int n_threads = 0; int n_threads_per_stream = 0; + int current_socket_id = -1; auto update_ids_method = [&](const std::vector& one_proc_info) { stream_info[STREAM_NUMA_NODE_ID] = one_proc_info[PROC_NUMA_NODE_ID]; @@ -47,7 +49,8 @@ std::vector> get_streams_info_table(const int input_streams, }; auto update_mix_stream_info = [&](const std::vector& one_proc_info, - const std::vector>& one_proc_table) { + const std::vector>& one_proc_table, + const int& target_proc) { stream_info[PROC_TYPE] = ALL_PROC; stream_info[NUMBER_OF_STREAMS] = 1; stream_info[THREADS_PER_STREAM] = n_threads_per_stream; @@ -55,28 +58,34 @@ std::vector> get_streams_info_table(const int input_streams, streams_info_table.push_back(stream_info); stream_info[NUMBER_OF_STREAMS] = 0; int total_threads = stream_info[THREADS_PER_STREAM]; - int numa_node_id = stream_info[STREAM_NUMA_NODE_ID]; int socket_id = stream_info[STREAM_SOCKET_ID]; int node_start = one_proc_table.size() == 1 ? 0 : 1; int node_end = one_proc_table.size() == 1 ? 1 : one_proc_table.size(); - for (int n = MAIN_CORE_PROC; n <= HYPER_THREADING_PROC; n++) { - for (int index = node_start; index < node_end; index++) { - if (((numa_node_id < 0) || (numa_node_id == one_proc_table[index][PROC_NUMA_NODE_ID])) && - ((socket_id < 0) || (socket_id == one_proc_table[index][PROC_SOCKET_ID]))) { - if (0 != one_proc_table[index][n]) { - stream_info[PROC_TYPE] = n; - if (total_threads <= one_proc_table[index][n]) { - stream_info[THREADS_PER_STREAM] = total_threads; + // When n_mode is 3, the following loop only selects CPUs on socket with the same id as current_socket_id. + // When n_mode is 2, the following loop only selects CPUs on sockets with id different from current_socket_id. + // When n_mode is 1, the following loop selects CPUs on all sockets. + for (int n_mode = current_socket_id < 0 ? 1 : 3; (n_mode > 0) && (total_threads > 0); n_mode--) { + for (int n = MAIN_CORE_PROC; (n <= HYPER_THREADING_PROC) && (total_threads > 0); n++) { + for (int index = node_start; (index < node_end) && (total_threads > 0); index++) { + if (((n_mode == 1) && ((socket_id < 0) || (socket_id == one_proc_table[index][PROC_SOCKET_ID]))) || + ((n_mode == 2) && (current_socket_id != one_proc_table[index][PROC_SOCKET_ID]) && + ((socket_id < 0) || (socket_id == one_proc_table[index][PROC_SOCKET_ID]))) || + ((n_mode == 3) && (current_socket_id == one_proc_table[index][PROC_SOCKET_ID]) && + ((socket_id < 0) || (socket_id == one_proc_table[index][PROC_SOCKET_ID])))) { + if ((0 != one_proc_table[index][n]) && ((ALL_PROC == target_proc) || (n == target_proc))) { + stream_info[PROC_TYPE] = n; stream_info[STREAM_NUMA_NODE_ID] = one_proc_table[index][PROC_NUMA_NODE_ID]; stream_info[STREAM_SOCKET_ID] = one_proc_table[index][PROC_SOCKET_ID]; - streams_info_table.push_back(stream_info); - return; - } else { - stream_info[THREADS_PER_STREAM] = one_proc_table[index][n]; - stream_info[STREAM_NUMA_NODE_ID] = one_proc_table[index][PROC_NUMA_NODE_ID]; - stream_info[STREAM_SOCKET_ID] = one_proc_table[index][PROC_SOCKET_ID]; - streams_info_table.push_back(stream_info); - total_threads -= one_proc_table[index][n]; + if (total_threads <= one_proc_table[index][n]) { + stream_info[THREADS_PER_STREAM] = total_threads; + streams_info_table.push_back(stream_info); + total_threads -= stream_info[THREADS_PER_STREAM]; + return; + } else { + stream_info[THREADS_PER_STREAM] = one_proc_table[index][n]; + streams_info_table.push_back(stream_info); + total_threads -= stream_info[THREADS_PER_STREAM]; + } } } } @@ -85,20 +94,24 @@ std::vector> get_streams_info_table(const int input_streams, }; auto update_streams_per_node = [&](const int& proc_type, const std::vector& one_proc_info) { - if (0 != one_proc_info[proc_type]) { - if (n_threads_per_stream == -1) { - stream_info[THREADS_PER_STREAM] = (proc_type == EFFICIENT_CORE_PROC) ? 2 : 1; - } - stream_info[PROC_TYPE] = proc_type; - update_ids_method(one_proc_info); - stream_info[NUMBER_OF_STREAMS] = - static_cast(one_proc_info[proc_type] / stream_info[THREADS_PER_STREAM]); - if (n_streams < stream_info[NUMBER_OF_STREAMS]) { - stream_info[NUMBER_OF_STREAMS] = n_streams; - } - if (stream_info[NUMBER_OF_STREAMS] > 0) { - streams_info_table.push_back(stream_info); - n_streams -= stream_info[NUMBER_OF_STREAMS]; + if ((one_proc_info[PROC_NUMA_NODE_ID] < 0) && (stream_info[NUMBER_OF_STREAMS] == 1)) { + update_mix_stream_info(one_proc_info, proc_type_table, proc_type); + } else { + if (0 != one_proc_info[proc_type]) { + if (n_threads_per_stream == -1) { + stream_info[THREADS_PER_STREAM] = (proc_type == EFFICIENT_CORE_PROC) ? 2 : 1; + } + stream_info[PROC_TYPE] = proc_type; + update_ids_method(one_proc_info); + stream_info[NUMBER_OF_STREAMS] = + static_cast(one_proc_info[proc_type] / stream_info[THREADS_PER_STREAM]); + if (n_streams < stream_info[NUMBER_OF_STREAMS]) { + stream_info[NUMBER_OF_STREAMS] = n_streams; + } + if (stream_info[NUMBER_OF_STREAMS] > 0) { + streams_info_table.push_back(stream_info); + n_streams -= stream_info[NUMBER_OF_STREAMS]; + } } } }; @@ -149,21 +162,22 @@ std::vector> get_streams_info_table(const int input_streams, if (((input_streams_changed == false) && (input_perf_hint == ov::util::to_string(ov::hint::PerformanceMode::LATENCY))) || ((input_streams_changed == true) && (input_streams == 1))) { + n_streams = 1; + stream_info[NUMBER_OF_STREAMS] = n_streams; if (input_threads > 0) { - n_streams = 1; n_threads_per_stream = std::min(input_threads, proc_type_table[0][ALL_PROC]); if (proc_type_table.size() == 1) { if ((n_threads_per_stream > proc_type_table[0][MAIN_CORE_PROC]) && (proc_type_table[0][MAIN_CORE_PROC] > 0)) { stream_info[PROC_TYPE] = ALL_PROC; } + } else { + current_socket_id = input_current_socket_id == -1 ? get_current_socket_id() : input_current_socket_id; } } else if ((((input_streams_changed == false) || ((input_streams_changed == true) && (input_streams == 1))) && (latencyThreadingMode == Config::LatencyThreadingMode::PER_PLATFORM)) || (proc_type_table.size() == 1)) { - n_streams = 1; if ((proc_type_table.size() == 1) && (model_prefer_threads > 0)) { - stream_info[NUMBER_OF_STREAMS] = n_streams; if ((model_prefer_threads == proc_type_table[0][MAIN_CORE_PROC]) && (proc_type_table[0][MAIN_CORE_PROC] > 0)) { stream_info[PROC_TYPE] = MAIN_CORE_PROC; @@ -185,15 +199,19 @@ std::vector> get_streams_info_table(const int input_streams, } } else if (((input_streams_changed == false) || ((input_streams_changed == true) && (input_streams == 1))) && (latencyThreadingMode == Config::LatencyThreadingMode::PER_SOCKET)) { + current_socket_id = input_current_socket_id == -1 ? get_current_socket_id() : input_current_socket_id; for (auto& row : proc_socket_table) { - n_threads_per_stream = std::max(n_threads_per_stream, row[ALL_PROC]); + if (row[PROC_SOCKET_ID] == current_socket_id) { + n_threads_per_stream = std::max(n_threads_per_stream, row[ALL_PROC]); + } } - n_streams = 1; } else { + current_socket_id = input_current_socket_id == -1 ? get_current_socket_id() : input_current_socket_id; for (size_t i = 1; i < proc_type_table.size(); i++) { - n_threads_per_stream = std::max(n_threads_per_stream, proc_type_table[i][ALL_PROC]); + if (proc_type_table[i][PROC_SOCKET_ID] == current_socket_id) { + n_threads_per_stream = std::max(n_threads_per_stream, proc_type_table[i][ALL_PROC]); + } } - n_streams = 1; } } else { n_threads = @@ -283,23 +301,25 @@ std::vector> get_streams_info_table(const int input_streams, } } else { for (size_t n_node = 1; (n_node < proc_type_table.size()) && (n_streams > 0); n_node++) { - if (proc_type_table[n_node][n_type] >= stream_info[THREADS_PER_STREAM]) { + if ((proc_type_table[n_node][n_type] >= stream_info[THREADS_PER_STREAM]) && + ((current_socket_id < 0) || (proc_type_table[n_node][PROC_SOCKET_ID] == current_socket_id))) { update_streams_per_node(n_type, proc_type_table[n_node]); } } } } - if ((total_streams == n_streams) && (input_threads == 0)) { + if (total_streams == n_streams) { if (proc_type_table.size() == 1) { if (proc_type_table[0][ALL_PROC] >= stream_info[THREADS_PER_STREAM]) { - update_mix_stream_info(proc_type_table[0], proc_type_table); + update_mix_stream_info(proc_type_table[0], proc_type_table, ALL_PROC); n_streams--; } } else { for (size_t n_node = 0; (n_node < proc_socket_table.size()) && (n_streams > 0); n_node++) { - if (proc_socket_table[n_node][ALL_PROC] >= stream_info[THREADS_PER_STREAM]) { - update_mix_stream_info(proc_socket_table[n_node], proc_type_table); + if ((proc_socket_table[n_node][ALL_PROC] >= stream_info[THREADS_PER_STREAM]) && + ((current_socket_id < 0) || (proc_socket_table[n_node][PROC_SOCKET_ID] == current_socket_id))) { + update_mix_stream_info(proc_socket_table[n_node], proc_type_table, ALL_PROC); n_streams--; } } @@ -307,7 +327,7 @@ std::vector> get_streams_info_table(const int input_streams, } if (total_streams == n_streams) { - update_mix_stream_info(proc_type_table[0], proc_type_table); + update_mix_stream_info(proc_type_table[0], proc_type_table, ALL_PROC); n_streams--; } @@ -331,7 +351,7 @@ std::vector> get_streams_info_table(const int input_streams, } while (n_streams > 0) { - update_mix_stream_info(proc_type_table[0], remain_proc_type_table); + update_mix_stream_info(proc_type_table[0], remain_proc_type_table, ALL_PROC); if (stream_table_size == streams_info_table.size()) { break; @@ -359,7 +379,7 @@ std::vector> get_streams_info_table(const int input_streams, } } else { if (stream_info[PROC_TYPE] == ALL_PROC) { - update_mix_stream_info(proc_type_table[0], proc_type_table); + update_mix_stream_info(proc_type_table[0], proc_type_table, ALL_PROC); } else if (stream_info[PROC_TYPE] == MAIN_CORE_PROC) { if (stream_info[THREADS_PER_STREAM] == proc_socket_table[0][MAIN_CORE_PROC]) { streams_info_table.push_back(stream_info); @@ -502,46 +522,55 @@ int get_model_prefer_threads(const int num_streams, } std::vector> generate_stream_info(const int streams, + const int input_current_socket_id, const std::shared_ptr& model, Config& config, std::vector>& proc_type_table, int preferred_nthreads_per_stream) { int model_prefer_threads = preferred_nthreads_per_stream; - IStreamsExecutor::Config& executor_config = config.streamExecutorConfig; proc_type_table = apply_scheduling_core_type(config.schedulingCoreType, proc_type_table); proc_type_table = apply_hyper_threading(config.enableHyperThreading, config.changedHyperThreading, ov::util::to_string(config.hintPerfMode), proc_type_table); - executor_config._cpu_reservation = get_cpu_pinning(config.enableCpuPinning, - config.changedCpuPinning, - streams, - config.latencyThreadingMode, - proc_type_table); + auto cpu_reservation = get_cpu_pinning(config.enableCpuPinning, + config.changedCpuPinning, + streams, + config.latencyThreadingMode, + proc_type_table); if (-1 == preferred_nthreads_per_stream) { model_prefer_threads = get_model_prefer_threads(streams, proc_type_table, model, config); } - executor_config._streams_info_table = get_streams_info_table(executor_config._streams, - executor_config._streams_changed, - executor_config._threads, - config.hintNumRequests, - model_prefer_threads, - ov::util::to_string(config.hintPerfMode), - config.latencyThreadingMode, - proc_type_table); + auto streams_info_table = get_streams_info_table(config.streams, + config.streamsChanged, + config.threads, + config.hintNumRequests, + model_prefer_threads, + input_current_socket_id, + ov::util::to_string(config.hintPerfMode), + config.latencyThreadingMode, + proc_type_table); + + config.streamExecutorConfig = IStreamsExecutor::Config{"CPUStreamsExecutor", + config.streams, + config.threadsPerStream, + config.threadBindingType, + 1, + 0, + config.threads, + IStreamsExecutor::Config::PreferredCoreType::ANY, + streams_info_table, + cpu_reservation}; + return proc_type_table; } void get_num_streams(const int streams, const std::shared_ptr& model, Config& config) { - IStreamsExecutor::Config& executor_config = config.streamExecutorConfig; std::vector> proc_type_table = get_proc_type_table(); - generate_stream_info(streams, model, config, proc_type_table); - - executor_config = IStreamsExecutor::Config::reserve_cpu_threads(executor_config); - executor_config._threadsPerStream = executor_config._streams_info_table[0][THREADS_PER_STREAM]; + generate_stream_info(streams, -1, model, config, proc_type_table); } int get_default_latency_streams(Config::LatencyThreadingMode latency_threading_mode) { diff --git a/src/plugins/intel_cpu/src/cpu_streams_calculation.hpp b/src/plugins/intel_cpu/src/cpu_streams_calculation.hpp index dcf79b3bd835e0..a33cdd1b2ce942 100644 --- a/src/plugins/intel_cpu/src/cpu_streams_calculation.hpp +++ b/src/plugins/intel_cpu/src/cpu_streams_calculation.hpp @@ -35,6 +35,8 @@ namespace intel_cpu { * function. * - input "0" indicates that the function generates the optimal number of threads per stream based on * processors type information. + * @param[in] input_current_socket_id is the socket ID in cpu mapping table of the currently running thread + * - input "-1" indicates that the function get_streams_info_table will query this id internally. * @param[in] input_perf_hint is performance hint set by user via ov::hint::performance_mode or the default value. * @param[in] latencyThreadingMode is the scope of candidate processors per stream for latency hint * - user can select all processors per numa node, per socket, or per platform. @@ -48,6 +50,7 @@ std::vector> get_streams_info_table(const int input_streams, const int input_threads, const int input_infer_requests, const int model_prefer_threads, + const int input_current_socket_id, const std::string input_perf_hint, const Config::LatencyThreadingMode latencyThreadingMode, const std::vector>& proc_type_table); @@ -70,6 +73,8 @@ int get_model_prefer_threads(const int num_streams, /** * @brief Generate streams information according to processors type table * @param[in] streams number of streams + * @param[in] input_current_socket_id is the socket ID in cpu mapping table of the currently running thread + * - input "-1" indicates that the function get_streams_info_table will query this id internally. * @param[in] model graph handle * @param[in] config intel cpu configuration * @param[in] proc_type_table candidate processors available at current platform @@ -78,21 +83,12 @@ int get_model_prefer_threads(const int num_streams, * ov::hint::enable_hyper_threading */ std::vector> generate_stream_info(const int streams, + const int input_current_socket_id, const std::shared_ptr& model, Config& config, std::vector>& proc_type_table, int preferred_nthreads_per_stream = -1); -struct StreamCfg { - int num_streams; // Number of streams - int num_threads; // Number of threads - int big_core_streams; // Number of streams in Performance-core(big core) - int small_core_streams; // Number of streams in Efficient-core(small core) - int threads_per_stream_big; // Threads per stream in big cores - int threads_per_stream_small; // Threads per stream in small cores - int small_core_offset; -}; - /** * @brief Get information about number of streams, threads and pinning threads on different processors * @param[in] streams number of streams diff --git a/src/plugins/intel_cpu/src/cpu_tensor.cpp b/src/plugins/intel_cpu/src/cpu_tensor.cpp index eaaeee81e522e0..593ac7907f3814 100644 --- a/src/plugins/intel_cpu/src/cpu_tensor.cpp +++ b/src/plugins/intel_cpu/src/cpu_tensor.cpp @@ -3,7 +3,10 @@ // #include "cpu_tensor.h" + +#include "memory_desc/blocked_memory_desc.h" #include "utils/debug_capabilities.h" +#include "utils/general_utils.h" namespace ov { namespace intel_cpu { @@ -94,4 +97,4 @@ std::shared_ptr make_tensor(MemoryPtr mem) { } } // namespace intel_cpu -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/src/dnnl_extension_utils.h b/src/plugins/intel_cpu/src/dnnl_extension_utils.h index 8798e6a9ab244a..489ed798cfff28 100644 --- a/src/plugins/intel_cpu/src/dnnl_extension_utils.h +++ b/src/plugins/intel_cpu/src/dnnl_extension_utils.h @@ -10,15 +10,18 @@ #include +#include "cpu_types.h" #include "onednn/dnnl.h" -#include "memory_desc/cpu_memory_desc.h" #include "onednn/iml_type_mapper.h" +#include "openvino/core/type/element_type.hpp" #include namespace ov { namespace intel_cpu { class DnnlMemoryDesc; +class DnnlBlockedMemoryDesc; +class Shape; class DnnlExtensionUtils { public: diff --git a/src/plugins/intel_cpu/src/dnnl_postops_composer.cpp b/src/plugins/intel_cpu/src/dnnl_postops_composer.cpp index ad9b547f7b6cd1..bf7ff2bb4b69f5 100644 --- a/src/plugins/intel_cpu/src/dnnl_postops_composer.cpp +++ b/src/plugins/intel_cpu/src/dnnl_postops_composer.cpp @@ -3,52 +3,387 @@ // #include "dnnl_postops_composer.h" + #include #include +#include +#include +#include + +#include "memory_desc/dnnl_blocked_memory_desc.h" +#include "openvino/core/type/element_type.hpp" #include "utils/debug_capabilities.h" namespace ov { namespace intel_cpu { -DnnlPostOpsComposer::DnnlPostOpsComposer(const dnnl::engine& engine, - dnnl::primitive_attr& attr, - dnnl::post_ops& ops, - std::unordered_map& args, - const VectorDims& outputDims, - int indexOfOutputChannelDim, - bool isInt8, - const int weiScaleMaskPerChannel, - const std::vector& DQScales, - bool hasBias) +DnnlPostOpsComposer::DnnlPostOpsComposer(const PostOps& postOps, + const dnnl::engine& engine, + const VectorDims& outputDims, + const size_t indexOfOutputChannelDim, + const bool isInt8, + const int weiScaleMaskPerChannel, + const std::vector& DQScales, + const bool hasBias, + const dnnl::memory::data_type outDataType) : engine(engine), - attr(attr), - ops(ops), - args(args), + postOps(postOps), outputDims(outputDims), idxOC(indexOfOutputChannelDim), isINT8(isInt8), - weightScaleMaskPerChannel(weiScaleMaskPerChannel) { + weightScaleMaskPerChannel(weiScaleMaskPerChannel), + outDataType(outDataType) { OPENVINO_ASSERT(idxOC >= 0 && static_cast(idxOC) < outputDims.size()); OC = outputDims[idxOC]; dimsPerOC = dimsPerTensor = VectorDims(outputDims.size(), 1); dimsPerOC[idxOC] = OC; + // generalise dq scales, so extra logic is necessary here. if (isINT8) { wei_scale_values = DQScales.empty() ? std::vector{1.0} : DQScales; wei_scale_mask = wei_scale_values.size() > 1 ? weiScaleMaskPerChannel : 0; dst_scale_val = 1.0; - //set the DQscale into attr weight scale before appending any post-ops. + // set the DQscale into attr weight scale before appending any post-ops. updateWeiScales(); - //If having the bias, attr weight scale can't be updated for further ops-ops optimization. - //ONEDNN 3.x quantization for scheme: QuantizedInput * QuantizedWeight * DQScale + Bias. + // If having the bias, attr weight scale can't be updated for further ops-ops optimization. + // ONEDNN 3.x quantization for scheme: QuantizedInput * QuantizedWeight * DQScale + Bias. weightScaleAvailable = !hasBias; } else if (!DQScales.empty()) { // DQ scale is fused but swiching back to non-INT8 for execution in some cases. DEBUG_LOG("Set DQ scales for None-INT8, scale size ", DQScales.size()); appendScale(DQScales, false, true); } + // @todo does not look good to set scratchpad mode here + // but the reason is that oneDNN's primitive_attr structure is basically huge config structure + // which hold everything + attr.set_scratchpad_mode(dnnl::scratchpad_mode::user); +} + +static dnnl::algorithm convertToOneDnn(const ActivationPostOp::Type type) { + switch (type) { + case ActivationPostOp::Type::relu: + return dnnl::algorithm::eltwise_relu; + case ActivationPostOp::Type::tanh: + return dnnl::algorithm::eltwise_tanh; + case ActivationPostOp::Type::elu: + return dnnl::algorithm::eltwise_elu; + case ActivationPostOp::Type::square: + return dnnl::algorithm::eltwise_square; + case ActivationPostOp::Type::abs: + return dnnl::algorithm::eltwise_abs; + case ActivationPostOp::Type::sqrt: + return dnnl::algorithm::eltwise_sqrt; + case ActivationPostOp::Type::soft_relu: + return dnnl::algorithm::eltwise_soft_relu; + case ActivationPostOp::Type::logistic: + return dnnl::algorithm::eltwise_logistic; + case ActivationPostOp::Type::exp: + return dnnl::algorithm::eltwise_exp; + case ActivationPostOp::Type::gelu_erf: + return dnnl::algorithm::eltwise_gelu_erf; + case ActivationPostOp::Type::gelu_tanh: + return dnnl::algorithm::eltwise_gelu_tanh; + case ActivationPostOp::Type::clip: + return dnnl::algorithm::eltwise_clip; + case ActivationPostOp::Type::swish: + return dnnl::algorithm::eltwise_swish; + case ActivationPostOp::Type::hardswish: + return dnnl::algorithm::eltwise_hardswish; + case ActivationPostOp::Type::mish: + return dnnl::algorithm::eltwise_mish; + case ActivationPostOp::Type::hsigmoid: + return dnnl::algorithm::eltwise_hsigmoid; + case ActivationPostOp::Type::round_half_to_even: + return dnnl::algorithm::eltwise_round_half_to_even; + case ActivationPostOp::Type::round_half_away_from_zero: + return dnnl::algorithm::eltwise_round_half_away_from_zero; + case ActivationPostOp::Type::linear: + return dnnl::algorithm::eltwise_linear; + } + + return dnnl::algorithm::undef; +} + +bool DnnlPostOpsComposer::appendAttrPostOps(const ActivationPostOp& postOp, bool isLastPostOp, bool allowBinary) { + if (postOp.type() == ActivationPostOp::Type::linear) { + appendLinear({postOp.alpha()}, {postOp.beta()}, isLastPostOp); + } else { + const dnnl::algorithm alg = convertToOneDnn(postOp.type()); + appendEltwise(alg, postOp.alpha(), postOp.beta()); + } + + return true; +} + +bool DnnlPostOpsComposer::appendAttrPostOps(const ScaleShiftPostOp& postOp, bool isLastPostOp, bool allowBinary) { + const auto& shifts = postOp.shifts(); + const auto& scales = postOp.scales(); + + switch (postOp.type()) { + case ScaleShiftPostOp::Type::add: + case ScaleShiftPostOp::Type::subtract: + return appendShift(shifts, allowBinary); + case ScaleShiftPostOp::Type::divide: + case ScaleShiftPostOp::Type::multiply: + return appendScale(scales, isLastPostOp, allowBinary); + case ScaleShiftPostOp::Type::muladd: + return appendLinear(scales, shifts, isLastPostOp, allowBinary); + case ScaleShiftPostOp::Type::powerstatic: + if (scales[0] != 1.0f && shifts[0] != 0.0f) { + return appendLinear(scales, shifts, isLastPostOp, allowBinary); + } else if (scales[0] != 1.0f) { // Multiply if has scales + return appendScale(scales, isLastPostOp, allowBinary); + } else if (shifts[0] != 0.0f) { // Add only if has shifts + return appendShift(shifts, allowBinary); + } + break; + case ScaleShiftPostOp::Type::prelu: + if (!allowBinary) + return false; + appendBinary(dnnl::algorithm::binary_prelu, scales); + break; + default: + OPENVINO_THROW(postOp.type(), " as post operation is not supported"); + } + + return true; +} + +static float roundHalfToEven(float f) { + const float RHAFZ = std::round(f); // r is round-half-away-from-zero + const float d = RHAFZ - f; // f + d -> RHAFZ + if ((d != 0.5f) && (d != -0.5f)) + return RHAFZ; + + // already even +/-1.5 -> +/-2 + if (std::fmod(RHAFZ, 2.0f) == 0.0f) + return RHAFZ; + + // +/-2.5 -> +/-3, but we need it to to +/-2 + // RHAFZ (f+d) goes the wrong way, should be (f-d) + return f - d; +} + +struct OptimizedFormula { + std::vector isc; + std::vector ish; + std::vector osc; + std::vector osh; + std::vector clo; + std::vector chi; + + void shrinkLength() { + auto _do_shrink = [](std::vector& v) { + if (v.size() <= 1) + return; + auto ref = v[0]; + if (std::all_of(v.cbegin(), v.cend(), [&](float val) { + return val == ref; + })) { + v.resize(1); + } + }; + _do_shrink(isc); + _do_shrink(ish); + _do_shrink(clo); + _do_shrink(chi); + _do_shrink(osc); + _do_shrink(osh); + } +}; + +static OptimizedFormula updateOptimizedFormula(const FakeQuantizePostOp& postOp, bool do_rounding) { + OptimizedFormula f; + const auto& inputScale = postOp.inputScale(); + const auto& inputShift = postOp.inputShift(); + const auto& cropLow = postOp.cropLow(); + const auto& cropHigh = postOp.cropHigh(); + const auto& outputScale = postOp.outputScale(); + const auto& outputShift = postOp.outputShift(); + + DEBUG_LOG("\t ---- Original formula ----"); + DEBUG_LOG("\t cropLow =[", printable(cropLow), "]"); + DEBUG_LOG("\t cropHigh =[", printable(cropHigh), "]"); + DEBUG_LOG("\t inputScale =[", printable(inputScale), "]"); + DEBUG_LOG("\t inputShift =[", printable(inputShift), "]"); + DEBUG_LOG("\t outputScale=[", printable(outputScale), "]"); + DEBUG_LOG("\t outputShift=[", printable(outputShift), "]"); + + auto isPerTensor = + [](const std::vector& v, float ref, const float zero_thr = std::numeric_limits::min()) { + return std::all_of(v.cbegin(), v.cend(), [&](float val) { + return abs(val - ref) < zero_thr; + }); + }; + size_t OC = std::max({inputScale.size(), + inputShift.size(), + cropLow.size(), + cropHigh.size(), + outputScale.size(), + outputShift.size()}); + + OPENVINO_ASSERT(inputScale.size() == 1 || inputScale.size() == OC); + OPENVINO_ASSERT(inputShift.size() == 1 || inputShift.size() == OC); + OPENVINO_ASSERT(cropLow.size() == 1 || cropLow.size() == OC); + OPENVINO_ASSERT(cropHigh.size() == 1 || cropHigh.size() == OC); + OPENVINO_ASSERT(outputScale.size() == 1 || outputScale.size() == OC); + OPENVINO_ASSERT(outputShift.size() == 1 || outputShift.size() == OC); + + // WA: a per-Tensor input shift may little drift away randomly + // from it's orginal value when FQ was fused with any + // preceding per-channel multiply and create a false + // per-channel input shift, this threshold was chosen carefully + // to recorver the per-Tensor nature w/o mistaking a real + // per-channel FQ. + if (isPerTensor(inputShift, inputShift[0], 0.00005f)) { + f.ish.resize(OC); + for (auto& v : f.ish) + v = inputShift[0]; + } else { + f.ish = inputShift; + } + f.clo = cropLow; + f.chi = cropHigh; + f.isc = inputScale; + f.osc = outputScale; + f.osh = outputShift; + + if (f.clo.size() == 1) + f.clo.resize(OC, f.clo[0]); + if (f.chi.size() == 1) + f.chi.resize(OC, f.chi[0]); + if (f.isc.size() == 1) + f.isc.resize(OC, f.isc[0]); + if (f.ish.size() == 1) + f.ish.resize(OC, f.ish[0]); + + for (size_t i = 0; i < OC; i++) { + auto& clo = f.clo[i]; + auto& chi = f.chi[i]; + auto& isc = f.isc[i]; + auto& ish = f.ish[i]; + const auto& osc = f.osc[f.osc.size() == 1 ? 0 : i]; + const auto& osh = f.osh[f.osh.size() == 1 ? 0 : i]; + + clo = roundHalfToEven(clo * isc + ish); + chi = roundHalfToEven(chi * isc + ish); + if (clo > chi) + std::swap(clo, chi); + + if (!do_rounding) { + // when no rounding is needed, outputScale/outputShift can be + // merged with inputScale/inputShift with updated cropLow/cropHigh + clo = clo * osc + osh; + chi = chi * osc + osh; + if (clo > chi) + std::swap(clo, chi); + + // crop(x*isc + ish, a, b)*osc + osh + // crop(x*isc*osc + ish*osc + osh, a', b') + isc = isc * osc; + ish = ish * osc + osh; + } + } + + if (!do_rounding) { + f.osc.clear(); + f.osh.clear(); + } + + f.shrinkLength(); + + if (f.osc.size() == 1 && f.osc[0] == 1.0f && f.osh.size() == 1 && f.osh[0] == std::trunc(f.osh[0])) { + // if outputScale == 1.0f and outputShift is interger, it can be further optimized + // x = clip2(round(x * inputScale + ish),c2lo,c2hi)*osc + osh + // = clip2(round(x * inputScale + ish),c2lo,c2hi) + osh + // = clip2(round(x * inputScale + ish) + osh, c2lo+osh,c2hi+osh) + // = clip2(round(x * inputScale + ish + osh), c2lo+osh,c2hi+osh) + for (auto& v : f.ish) { + v += f.osh[0]; + } + for (auto& v : f.clo) { + v += f.osh[0]; + } + for (auto& v : f.chi) { + v += f.osh[0]; + } + f.osc.clear(); + f.osh.clear(); + } + + // we can save an additional eltwise linear for negligible shift + if (f.ish.size() == 1 && f.clo.size() == 1 && f.chi.size() == 1) { + auto range = (f.chi[0] - f.clo[0]); + if (abs(f.ish[0]) < range * 0.00001f) { + f.ish[0] = 0.0f; + } + } + + return f; +} + +bool DnnlPostOpsComposer::appendAttrPostOps(const FakeQuantizePostOp& postOp, + bool isLastPostOp, + bool doRounding, + bool allowBinary) { + DEBUG_LOG("isLastPostOp=", + isLastPostOp, + ", outDataType=", + outDataType, + ", allowBinary=", + allowBinary, + ", doRounding=", + doRounding); + + const auto f = updateOptimizedFormula(postOp, doRounding); + + DEBUG_LOG("\t ---- Optimized formula ----"); + DEBUG_LOG("\t inputScale =[", printable(f.isc), "]"); + DEBUG_LOG("\t inputShift =[", printable(f.ish), "]"); + DEBUG_LOG("\t cropLow =[", printable(f.clo), "]"); + DEBUG_LOG("\t cropHigh =[", printable(f.chi), "]"); + DEBUG_LOG("\toutputScale =[", printable(f.osc), "]"); + DEBUG_LOG("\toutputShift =[", printable(f.osh), "]"); + + // when FQ is last postOps and output data type is u8/s8 + // round & clip2 can be further optimized since saturation will be performed by oneDNN by default + bool skipRoundClipOutputLinear = false; + if (isLastPostOp && (postOp.levels() == 256) && f.clo.size() == 1 && f.chi.size() == 1 && f.osc.empty() && + f.osh.empty()) { + if (outDataType == dnnl::memory::data_type::u8 && f.clo[0] <= 0.0f && f.chi[0] >= 255.0f) { + skipRoundClipOutputLinear = true; + } + if (outDataType == dnnl::memory::data_type::s8 && f.clo[0] <= -128.0f && f.chi[0] >= 127.0f) { + skipRoundClipOutputLinear = true; + } + } + + // return false before committing any change to DnnlPostOpsComposer + if (!allowBinary) { + if (f.ish.size() > 1) + return false; + if (!skipRoundClipOutputLinear) { + if (f.clo.size() > 1 || f.chi.size() > 1) + return false; + if (f.osc.size() > 1 || f.osh.size() > 1) + return false; + } + } + + if (!appendLinear(f.isc, f.ish, isLastPostOp && skipRoundClipOutputLinear, allowBinary)) + return false; + + if (skipRoundClipOutputLinear) + return true; + + if (doRounding) + appendRoundHTE(); + appendClip(f.clo, f.chi); + appendLinear(f.osc, f.osh, isLastPostOp, allowBinary); + + return true; } void DnnlPostOpsComposer::updateWeiScales() { @@ -61,7 +396,8 @@ void DnnlPostOpsComposer::updateWeiScales() { DnnlBlockedMemoryDesc memoryDesc(ov::element::f32, Shape({wei_scale_values.size()})); auto mem = std::make_shared(engine, memoryDesc); memcpy(mem->getData(), wei_scale_values.data(), wei_scale_values.size() * sizeof(float)); - args[DNNL_ARG_ATTR_SCALES | DNNL_ARG_WEIGHTS] = mem; + cpuArgs[DNNL_ARG_ATTR_SCALES | DNNL_ARG_WEIGHTS] = mem; + dnnlArgs[DNNL_ARG_ATTR_SCALES | DNNL_ARG_WEIGHTS] = mem->getPrimitive(); } void DnnlPostOpsComposer::updateDestScales() { @@ -74,7 +410,8 @@ void DnnlPostOpsComposer::updateDestScales() { DnnlBlockedMemoryDesc memoryDesc(ov::element::f32, Shape({1})); auto mem = std::make_shared(engine, memoryDesc); memcpy(mem->getData(), &dst_scale_val, sizeof(float)); - args[DNNL_ARG_ATTR_SCALES | DNNL_ARG_DST] = mem; + cpuArgs[DNNL_ARG_ATTR_SCALES | DNNL_ARG_DST] = mem; + dnnlArgs[DNNL_ARG_ATTR_SCALES | DNNL_ARG_DST] = mem->getPrimitive(); } void DnnlPostOpsComposer::appendBinary(const dnnl::algorithm alg, const std::vector& data) { @@ -84,7 +421,7 @@ void DnnlPostOpsComposer::appendBinary(const dnnl::algorithm alg, const std::vec pdims = &dimsPerOC; } - DEBUG_LOG("Append binary post op with algorithm: ", convert_to_c(alg)); + DEBUG_LOG("Append binary post op with algorithm: ", convert_to_c(alg), " Shape: ", Shape(*pdims)); DnnlBlockedMemoryDesc memoryDesc(ov::element::f32, Shape(*pdims)); ops.append_binary(alg, memoryDesc.getDnnlDesc()); @@ -92,11 +429,12 @@ void DnnlPostOpsComposer::appendBinary(const dnnl::algorithm alg, const std::vec // copy the data as args auto mem = std::make_shared(engine, memoryDesc); memcpy(mem->getData(), data.data(), data.size() * sizeof(float)); - args[DNNL_ARG_ATTR_MULTIPLE_POST_OP(ops.len() - 1) | DNNL_ARG_SRC_1] = mem; + cpuArgs[DNNL_ARG_ATTR_MULTIPLE_POST_OP(ops.len() - 1) | DNNL_ARG_SRC_1] = mem; + dnnlArgs[DNNL_ARG_ATTR_MULTIPLE_POST_OP(ops.len() - 1) | DNNL_ARG_SRC_1] = mem->getPrimitive(); } void DnnlPostOpsComposer::appendEltwise(const dnnl::algorithm alg, float alpha, float beta) { - DEBUG_LOG("Append eltwise post op with algorithm: ", convert_to_c(alg)); + DEBUG_LOG("Append eltwise post op with algorithm: ", convert_to_c(alg), " alpha: ", alpha, " beta: ", beta); ops.append_eltwise(alg, alpha, beta); } @@ -110,27 +448,27 @@ bool DnnlPostOpsComposer::appendScale(const std::vector& scale, bool isLa bool fuseIntoWeiScale = false; // Use dest scale when last post-ops is per-tensor quantization. if ((isINT8 && isLastPostOp && scale.size() == 1)) { - dst_scale_val = 1.0 / scale[0]; + dst_scale_val = 1.0f / scale[0]; updateDestScales(); return true; } if (weightScaleAvailable) { - //oneDNN v3.* weight scale can also be used in the further optimization patterns. - // there are so many possible optimizations can be done, for example: + // oneDNN v3.* weight scale can also be used in the further optimization patterns. + // there are so many possible optimizations can be done, for example: // - // we can switch the existing postOps's order to take - // advantage of output scale if it's available: - // relu(x)*scale = relu(x*scale) - // or we can fuse it into previous one as long as they are - // compatible in shape - // x*A*s = x*(A*s) - // or even with add: - // (x*A + B)*s = x*(A*s) + (B*s) - // or we can combine these two tricks: - // relu(x*A)*s = relu(x*(A*s)) + // we can switch the existing postOps's order to take + // advantage of output scale if it's available: + // relu(x)*scale = relu(x*scale) + // or we can fuse it into previous one as long as they are + // compatible in shape + // x*A*s = x*(A*s) + // or even with add: + // (x*A + B)*s = x*(A*s) + (B*s) + // or we can combine these two tricks: + // relu(x*A)*s = relu(x*(A*s)) // - // we cannot implement all of them, so we just add the one - // that we observed in real models. + // we cannot implement all of them, so we just add the one + // that we observed in real models. if ((ops.len() == 0)) fuseIntoWeiScale = true; @@ -171,7 +509,9 @@ bool DnnlPostOpsComposer::appendScale(const std::vector& scale, bool isLa wei_scale_mask = 0; else wei_scale_mask = weightScaleMaskPerChannel; + updateWeiScales(); + return true; } @@ -201,9 +541,9 @@ bool DnnlPostOpsComposer::appendShift(const std::vector& shift, bool allo } bool DnnlPostOpsComposer::appendLinear(const std::vector& scale, - const std::vector& shift, - bool isLastPostOp, - bool allowBinary) { + const std::vector& shift, + bool isLastPostOp, + bool allowBinary) { if (scale.size() == 1 && shift.size() == 1) { if (shift[0] == 0.0f) return appendScale(scale, isLastPostOp, allowBinary); @@ -251,7 +591,9 @@ void DnnlPostOpsComposer::appendClip(const std::vector& low, const std::v } } -MemoryPtr DnnlPostOpsComposer::prepackDecompressionParams(const MemoryCPtr& params_ptr, bool needTranspose) { +static MemoryPtr prepackDecompressionParams(const MemoryCPtr& params_ptr, + bool needTranspose, + const dnnl::engine& engine) { const auto shape = params_ptr->getShape().getStaticDims(); MemoryPtr mem; @@ -291,18 +633,60 @@ void DnnlPostOpsComposer::appendDecompressionScales(const MemoryCPtr& scales_ptr if (scales_ptr == nullptr) return; - auto scalesMem = prepackDecompressionParams(scales_ptr, needTranspose); + auto scalesMem = prepackDecompressionParams(scales_ptr, needTranspose, engine); attr.set_scales_dims(DNNL_ARG_WEIGHTS, DnnlExtensionUtils::convertToDnnlDims(scalesMem->getStaticDims())); - args[DNNL_ARG_ATTR_SCALES | DNNL_ARG_WEIGHTS] = scalesMem; + cpuArgs[DNNL_ARG_ATTR_SCALES | DNNL_ARG_WEIGHTS] = std::move(scalesMem); + dnnlArgs[DNNL_ARG_ATTR_SCALES | DNNL_ARG_WEIGHTS] = + cpuArgs[DNNL_ARG_ATTR_SCALES | DNNL_ARG_WEIGHTS]->getPrimitive(); } void DnnlPostOpsComposer::appendDecompressionZeroPoints(const MemoryCPtr& zero_points_ptr, bool needTranspose) { if (zero_points_ptr == nullptr) return; - auto zeroPointsMem = prepackDecompressionParams(zero_points_ptr, needTranspose); + auto zeroPointsMem = prepackDecompressionParams(zero_points_ptr, needTranspose, engine); attr.set_zero_points_dims(DNNL_ARG_WEIGHTS, DnnlExtensionUtils::convertToDnnlDims(zeroPointsMem->getStaticDims())); - args[DNNL_ARG_ATTR_ZERO_POINTS | DNNL_ARG_WEIGHTS] = zeroPointsMem; + cpuArgs[DNNL_ARG_ATTR_ZERO_POINTS | DNNL_ARG_WEIGHTS] = zeroPointsMem; + dnnlArgs[DNNL_ARG_ATTR_ZERO_POINTS | DNNL_ARG_WEIGHTS] = zeroPointsMem->getPrimitive(); +} + +DnnlPrimitiveAttrs DnnlPostOpsComposer::compose() { + for (size_t i = 0; i < postOps.size(); ++i) { + const auto& postOp = postOps[i]; + bool isLastPostOp = (i == (postOps.size() - 1)); + // @todo replace dynamic cast with an interface for appending to DNNL postops + if (const auto activation = std::dynamic_pointer_cast(postOp)) { + appendAttrPostOps(*activation, isLastPostOp); + continue; + } + + if (const auto ss = std::dynamic_pointer_cast(postOp)) { + appendAttrPostOps(*ss, isLastPostOp); + continue; + } + + if (const auto fq = std::dynamic_pointer_cast(postOp)) { + // drop rounding one special residual pattern + // TODO: validate this unsafe optimization + auto doRounding = [&]() { + return true; + }; + + auto round = i == 0 ? doRounding() : true; + appendAttrPostOps(*fq, isLastPostOp, round); + continue; + } + + OPENVINO_THROW("Fusing of operation to postOp is not implemented"); + } + + attr.set_post_ops(ops); + + for (const auto& args : cpuArgs) { + dnnlArgs[args.first] = args.second->getPrimitive(); + } + + return {attr, dnnlArgs, cpuArgs}; } } // namespace intel_cpu diff --git a/src/plugins/intel_cpu/src/dnnl_postops_composer.h b/src/plugins/intel_cpu/src/dnnl_postops_composer.h index 7ba99a174a89b7..4a1e01288957fb 100644 --- a/src/plugins/intel_cpu/src/dnnl_postops_composer.h +++ b/src/plugins/intel_cpu/src/dnnl_postops_composer.h @@ -8,14 +8,12 @@ */ #pragma once -#include "dnnl_types.h" - -#include +#include #include "cpu_memory.h" -#include "memory_desc/cpu_memory_desc.h" -#include "memory_desc/dnnl_blocked_memory_desc.h" -#include "onednn/dnnl.h" +#include "nodes/executors/dnnl/dnnl_aliases.hpp" +#include "post_ops.hpp" +#include "nodes/executors/dnnl/dnnl_post_op_data.hpp" namespace ov { namespace intel_cpu { @@ -23,42 +21,49 @@ namespace intel_cpu { // so far the API only support per-Tensor or per-OC class DnnlPostOpsComposer { public: - DnnlPostOpsComposer(const dnnl::engine& engine, - dnnl::primitive_attr& attr, - dnnl::post_ops& ops, - std::unordered_map& args, + DnnlPostOpsComposer(const PostOps& postOps, + const dnnl::engine& engine, const VectorDims& outputDims, - int indexOfOutputChannelDim, - bool isINT8, - int weiScaleMaskPerChannel, + const size_t indexOfOutputChannelDim, + const bool isINT8, + const int weiScaleMaskPerChannel, const std::vector& DQScales, - bool hasBias); + const bool hasBias, + const dnnl::memory::data_type outDataType); + DnnlPrimitiveAttrs compose(); + void appendDecompressionScales(const MemoryCPtr& scales_ptr, bool needTranspose); + void appendDecompressionZeroPoints(const MemoryCPtr& zero_points_ptr, bool needTranspose); +private: + bool appendAttrPostOps(const ActivationPostOp& postOp, bool isLastPostOp, bool allowBinary = true); + bool appendAttrPostOps(const ScaleShiftPostOp& postOp, bool isLastPostOp, bool allowBinary = true); + bool appendAttrPostOps(const FakeQuantizePostOp& postOp, + bool isLastPostOp, + bool doRounding, + bool allowBinary = true); void appendBinary(const dnnl::algorithm alg, const std::vector& data); void appendEltwise(const dnnl::algorithm alg, float alpha, float beta); void appendRoundHTE(); bool appendScale(const std::vector& scale, bool isLastPostOp, bool allowBinary = true); bool appendShift(const std::vector& shift, bool allowBinary = true); - bool appendLinear(const std::vector& scale, const std::vector& shift, bool isLastPostOp, bool allowBinary = true); + bool appendLinear(const std::vector& scale, + const std::vector& shift, + bool isLastPostOp, + bool allowBinary = true); void appendClip(const std::vector& low, const std::vector& high); - void appendDecompressionScales(const MemoryCPtr& scales_ptr, bool needTranspose); - void appendDecompressionZeroPoints(const MemoryCPtr& zero_points_ptr, bool needTranspose); - - const VectorDims& getOutputDims() { - return outputDims; - } - -private: const dnnl::engine& engine; - dnnl::primitive_attr& attr; - dnnl::post_ops& ops; - std::unordered_map& args; + const PostOps& postOps; const VectorDims outputDims; - int idxOC; + size_t idxOC; const bool isINT8; // only INT8 primitive support scales const int weightScaleMaskPerChannel; bool weightScaleAvailable = false; + const dnnl::memory::data_type outDataType; + + dnnl::primitive_attr attr; + MemoryArgs cpuArgs; + dnnl_primitive_args dnnlArgs; VectorDims dimsPerTensor; VectorDims dimsPerOC; @@ -66,10 +71,10 @@ class DnnlPostOpsComposer { int wei_scale_mask = -1; std::vector wei_scale_values; float dst_scale_val; + dnnl::post_ops ops; void updateWeiScales(); void updateDestScales(); - MemoryPtr prepackDecompressionParams(const MemoryCPtr& params_ptr, bool needTranspose); }; } // namespace intel_cpu diff --git a/src/plugins/intel_cpu/src/dnnl_postops_composer_legacy.cpp b/src/plugins/intel_cpu/src/dnnl_postops_composer_legacy.cpp new file mode 100644 index 00000000000000..734073e561ea3f --- /dev/null +++ b/src/plugins/intel_cpu/src/dnnl_postops_composer_legacy.cpp @@ -0,0 +1,309 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "dnnl_postops_composer_legacy.h" +#include + +#include +#include "utils/debug_capabilities.h" + +namespace ov { +namespace intel_cpu { + +DnnlPostOpsComposerLegacy::DnnlPostOpsComposerLegacy(const dnnl::engine& engine, + dnnl::primitive_attr& attr, + dnnl::post_ops& ops, + std::unordered_map& args, + const VectorDims& outputDims, + int indexOfOutputChannelDim, + bool isInt8, + const int weiScaleMaskPerChannel, + const std::vector& DQScales, + bool hasBias) + : engine(engine), + attr(attr), + ops(ops), + args(args), + outputDims(outputDims), + idxOC(indexOfOutputChannelDim), + isINT8(isInt8), + weightScaleMaskPerChannel(weiScaleMaskPerChannel) { + OPENVINO_ASSERT(idxOC >= 0 && static_cast(idxOC) < outputDims.size()); + OC = outputDims[idxOC]; + dimsPerOC = dimsPerTensor = VectorDims(outputDims.size(), 1); + dimsPerOC[idxOC] = OC; + + if (isINT8) { + wei_scale_values = DQScales.empty() ? std::vector{1.0} : DQScales; + wei_scale_mask = wei_scale_values.size() > 1 ? weiScaleMaskPerChannel : 0; + dst_scale_val = 1.0; + + //set the DQscale into attr weight scale before appending any post-ops. + updateWeiScales(); + //If having the bias, attr weight scale can't be updated for further ops-ops optimization. + //ONEDNN 3.x quantization for scheme: QuantizedInput * QuantizedWeight * DQScale + Bias. + weightScaleAvailable = !hasBias; + } else if (!DQScales.empty()) { + // DQ scale is fused but swiching back to non-INT8 for execution in some cases. + DEBUG_LOG("Set DQ scales for None-INT8, scale size ", DQScales.size()); + appendScale(DQScales, false, true); + } +} + +void DnnlPostOpsComposerLegacy::updateWeiScales() { + if (wei_scale_mask == 0 && wei_scale_values[0] == 1.0f) + return; + + DEBUG_LOG("Set weight scales mask ", "DNNL_ARG: ", DNNL_ARG_WEIGHTS, " mask: ", wei_scale_mask); + attr.set_scales_mask(DNNL_ARG_WEIGHTS, wei_scale_mask); + + DnnlBlockedMemoryDesc memoryDesc(ov::element::f32, Shape({wei_scale_values.size()})); + auto mem = std::make_shared(engine, memoryDesc); + memcpy(mem->getData(), wei_scale_values.data(), wei_scale_values.size() * sizeof(float)); + args[DNNL_ARG_ATTR_SCALES | DNNL_ARG_WEIGHTS] = mem; +} + +void DnnlPostOpsComposerLegacy::updateDestScales() { + if (dst_scale_val == 1.0f) + return; + + DEBUG_LOG("Set dest scale mask ", "DNNL_ARG: ", DNNL_ARG_DST, " mask: ", 0); + attr.set_scales_mask(DNNL_ARG_DST, 0); + + DnnlBlockedMemoryDesc memoryDesc(ov::element::f32, Shape({1})); + auto mem = std::make_shared(engine, memoryDesc); + memcpy(mem->getData(), &dst_scale_val, sizeof(float)); + args[DNNL_ARG_ATTR_SCALES | DNNL_ARG_DST] = mem; +} + +void DnnlPostOpsComposerLegacy::appendBinary(const dnnl::algorithm alg, const std::vector& data) { + VectorDims* pdims = &dimsPerTensor; + if (data.size() > 1) { + OPENVINO_ASSERT(data.size() == OC); + pdims = &dimsPerOC; + } + + DEBUG_LOG("Append binary post op with algorithm: ", convert_to_c(alg)); + + DnnlBlockedMemoryDesc memoryDesc(ov::element::f32, Shape(*pdims)); + ops.append_binary(alg, memoryDesc.getDnnlDesc()); + + // copy the data as args + auto mem = std::make_shared(engine, memoryDesc); + memcpy(mem->getData(), data.data(), data.size() * sizeof(float)); + args[DNNL_ARG_ATTR_MULTIPLE_POST_OP(ops.len() - 1) | DNNL_ARG_SRC_1] = mem; +} + +void DnnlPostOpsComposerLegacy::appendEltwise(const dnnl::algorithm alg, float alpha, float beta) { + DEBUG_LOG("Append eltwise post op with algorithm: ", convert_to_c(alg)); + ops.append_eltwise(alg, alpha, beta); +} + +void DnnlPostOpsComposerLegacy::appendRoundHTE() { + appendEltwise(dnnl::algorithm::eltwise_round_half_to_even, 0, 0); +} + +bool DnnlPostOpsComposerLegacy::appendScale(const std::vector& scale, bool isLastPostOp, bool allowBinary) { + OPENVINO_ASSERT(scale.size() == OC || scale.size() == 1); + + bool fuseIntoWeiScale = false; + // Use dest scale when last post-ops is per-tensor quantization. + if ((isINT8 && isLastPostOp && scale.size() == 1)) { + dst_scale_val = 1.0 / scale[0]; + updateDestScales(); + return true; + } + if (weightScaleAvailable) { + //oneDNN v3.* weight scale can also be used in the further optimization patterns. + // there are so many possible optimizations can be done, for example: + // + // we can switch the existing postOps's order to take + // advantage of output scale if it's available: + // relu(x)*scale = relu(x*scale) + // or we can fuse it into previous one as long as they are + // compatible in shape + // x*A*s = x*(A*s) + // or even with add: + // (x*A + B)*s = x*(A*s) + (B*s) + // or we can combine these two tricks: + // relu(x*A)*s = relu(x*(A*s)) + // + // we cannot implement all of them, so we just add the one + // that we observed in real models. + if ((ops.len() == 0)) + fuseIntoWeiScale = true; + + // relu(x)*s = relu(x*s) + // prelu(x)*s = prelu(x*s) + if (ops.len() == 1) { + auto& cur_op = ops.get()->entry_[0]; + if ((cur_op.kind == dnnl::impl::primitive_kind::eltwise && cur_op.eltwise.alg == dnnl_eltwise_relu) || + (cur_op.kind == dnnl::impl::primitive_kind::binary && cur_op.binary.alg == dnnl_binary_prelu)) { + fuseIntoWeiScale = true; + } + } + + // (x + dst[:])*s = (x*s + s*dst[:]) + if (scale.size() == 1 && ops.len() == 1) { + auto& cur_op = ops.get()->entry_.back(); + if (cur_op.kind == dnnl::impl::primitive_kind::sum) { + cur_op.sum.scale *= scale[0]; + fuseIntoWeiScale = true; + } + } + } + if (fuseIntoWeiScale) { + if (scale.size() > 1) { + if (wei_scale_mask == 0) + wei_scale_values.resize(scale.size(), wei_scale_values[0]); + else + OPENVINO_ASSERT(wei_scale_values.size() == OC); + + for (Dim j = 0; j < OC; j++) + wei_scale_values[j] *= scale[j]; + } else { + for (size_t j = 0; j < wei_scale_values.size(); j++) + wei_scale_values[j] *= scale[0]; + } + + if (wei_scale_values.size() == 1) + wei_scale_mask = 0; + else + wei_scale_mask = weightScaleMaskPerChannel; + updateWeiScales(); + return true; + } + + // final fallback + if (scale.size() == 1) { + appendEltwise(dnnl::algorithm::eltwise_linear, scale[0], 0); + } else { + // this check returns before committing any changes + if (!allowBinary) + return false; + appendBinary(dnnl::algorithm::binary_mul, scale); + } + return true; +} + +bool DnnlPostOpsComposerLegacy::appendShift(const std::vector& shift, bool allowBinary) { + if (shift.size() == 1) { + if (shift[0] != 0.0f) { + appendEltwise(dnnl::algorithm::eltwise_linear, 1.0f, shift[0]); + } + } else { + if (!allowBinary) + return false; + appendBinary(dnnl::algorithm::binary_add, shift); + } + return true; +} + +bool DnnlPostOpsComposerLegacy::appendLinear(const std::vector& scale, + const std::vector& shift, + bool isLastPostOp, + bool allowBinary) { + if (scale.size() == 1 && shift.size() == 1) { + if (shift[0] == 0.0f) + return appendScale(scale, isLastPostOp, allowBinary); + else + appendEltwise(dnnl::algorithm::eltwise_linear, scale[0], shift[0]); + } else { + // return before committing any changes + if (!allowBinary && shift.size() > 1) + return false; + + if (!scale.empty()) { + if (!appendScale(scale, isLastPostOp && shift.empty(), allowBinary)) + return false; + } + if (!shift.empty()) { + if (!appendShift(shift, allowBinary)) + return false; + } + } + return true; +} + +void DnnlPostOpsComposerLegacy::appendClip(const std::vector& low, const std::vector& high) { + if (low.size() == 1 && high.size() == 1) { + appendEltwise(dnnl::algorithm::eltwise_clip, low[0], high[0]); + } else if (low.size() == 1) { + OPENVINO_ASSERT(high.size() == OC); + appendEltwise(dnnl::algorithm::eltwise_clip, low[0], std::numeric_limits::max()); + if (high.size() > 0) + appendBinary(dnnl::algorithm::binary_min, high); + } else if (high.size() == 1) { + OPENVINO_ASSERT(low.size() == OC); + appendEltwise(dnnl::algorithm::eltwise_clip, -std::numeric_limits::max(), high[0]); + if (low.size() > 0) + appendBinary(dnnl::algorithm::binary_max, low); + } else { + if (low.size() > 0) { + OPENVINO_ASSERT(low.size() == OC); + appendBinary(dnnl::algorithm::binary_max, low); + } + if (high.size() > 0) { + OPENVINO_ASSERT(high.size() == OC); + appendBinary(dnnl::algorithm::binary_min, high); + } + } +} + +MemoryPtr DnnlPostOpsComposerLegacy::prepackDecompressionParams(const MemoryCPtr& params_ptr, bool needTranspose) { + const auto shape = params_ptr->getShape().getStaticDims(); + MemoryPtr mem; + + auto params_data = static_cast(params_ptr->getData()); + + if (needTranspose) { + VectorDims dnnlShape = {shape[0], shape[1]}; + DnnlBlockedMemoryDesc memoryDesc(ov::element::f32, Shape(dnnlShape)); + mem = std::make_shared(engine, memoryDesc); + auto memory_buf = static_cast(mem->getData()); + + // oi -> io + for (size_t oc = 0; oc < dnnlShape[0]; oc++) { + for (size_t ic = 0; ic < dnnlShape[1]; ic++) { + memory_buf[ic * dnnlShape[0] + oc] = params_data[oc * dnnlShape[1] + ic]; + } + } + } else { + VectorDims dnnlShape = {shape[shape.size() - 1], shape[0]}; + DnnlBlockedMemoryDesc memoryDesc(ov::element::f32, Shape(dnnlShape)); + mem = std::make_shared(engine, memoryDesc); + auto memory_buf = static_cast(mem->getData()); + const size_t elements_count = std::accumulate(shape.begin(), shape.end(), 1, std::multiplies()); + + // io -> io + size_t dstIdx = 0; + for (size_t oc = 0; oc < elements_count; oc++) { + memory_buf[dstIdx] = params_data[oc]; + dstIdx++; + } + } + + return mem; +} + +void DnnlPostOpsComposerLegacy::appendDecompressionScales(const MemoryCPtr& scales_ptr, bool needTranspose) { + if (scales_ptr == nullptr) + return; + + auto scalesMem = prepackDecompressionParams(scales_ptr, needTranspose); + attr.set_scales_dims(DNNL_ARG_WEIGHTS, DnnlExtensionUtils::convertToDnnlDims(scalesMem->getStaticDims())); + args[DNNL_ARG_ATTR_SCALES | DNNL_ARG_WEIGHTS] = scalesMem; +} + +void DnnlPostOpsComposerLegacy::appendDecompressionZeroPoints(const MemoryCPtr& zero_points_ptr, bool needTranspose) { + if (zero_points_ptr == nullptr) + return; + + auto zeroPointsMem = prepackDecompressionParams(zero_points_ptr, needTranspose); + attr.set_zero_points_dims(DNNL_ARG_WEIGHTS, DnnlExtensionUtils::convertToDnnlDims(zeroPointsMem->getStaticDims())); + args[DNNL_ARG_ATTR_ZERO_POINTS | DNNL_ARG_WEIGHTS] = zeroPointsMem; +} + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/dnnl_postops_composer_legacy.h b/src/plugins/intel_cpu/src/dnnl_postops_composer_legacy.h new file mode 100644 index 00000000000000..f4140a57843cce --- /dev/null +++ b/src/plugins/intel_cpu/src/dnnl_postops_composer_legacy.h @@ -0,0 +1,76 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +/** + * @brief Convinience wrapper class for handling OneDNN attributes & post ops. + * @file dnnl_postops_composer.h + */ +#pragma once + +#include "dnnl_types.h" + +#include + +#include "cpu_memory.h" +#include "memory_desc/cpu_memory_desc.h" +#include "memory_desc/dnnl_blocked_memory_desc.h" +#include "onednn/dnnl.h" + +namespace ov { +namespace intel_cpu { + +// so far the API only support per-Tensor or per-OC +class DnnlPostOpsComposerLegacy { +public: + DnnlPostOpsComposerLegacy(const dnnl::engine& engine, + dnnl::primitive_attr& attr, + dnnl::post_ops& ops, + std::unordered_map& args, + const VectorDims& outputDims, + int indexOfOutputChannelDim, + bool isINT8, + int weiScaleMaskPerChannel, + const std::vector& DQScales, + bool hasBias); + + void appendBinary(const dnnl::algorithm alg, const std::vector& data); + void appendEltwise(const dnnl::algorithm alg, float alpha, float beta); + void appendRoundHTE(); + bool appendScale(const std::vector& scale, bool isLastPostOp, bool allowBinary = true); + bool appendShift(const std::vector& shift, bool allowBinary = true); + bool appendLinear(const std::vector& scale, const std::vector& shift, bool isLastPostOp, bool allowBinary = true); + void appendClip(const std::vector& low, const std::vector& high); + + void appendDecompressionScales(const MemoryCPtr& scales_ptr, bool needTranspose); + void appendDecompressionZeroPoints(const MemoryCPtr& zero_points_ptr, bool needTranspose); + + const VectorDims& getOutputDims() { + return outputDims; + } + +private: + const dnnl::engine& engine; + dnnl::primitive_attr& attr; + dnnl::post_ops& ops; + std::unordered_map& args; + const VectorDims outputDims; + int idxOC; + const bool isINT8; // only INT8 primitive support scales + const int weightScaleMaskPerChannel; + bool weightScaleAvailable = false; + + VectorDims dimsPerTensor; + VectorDims dimsPerOC; + Dim OC; + int wei_scale_mask = -1; + std::vector wei_scale_values; + float dst_scale_val; + + void updateWeiScales(); + void updateDestScales(); + MemoryPtr prepackDecompressionParams(const MemoryCPtr& params_ptr, bool needTranspose); +}; + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/dnnl_scratch_pad.h b/src/plugins/intel_cpu/src/dnnl_scratch_pad.h index 552ede454e659d..a52d97e15d6081 100644 --- a/src/plugins/intel_cpu/src/dnnl_scratch_pad.h +++ b/src/plugins/intel_cpu/src/dnnl_scratch_pad.h @@ -6,9 +6,8 @@ #include -#include "common/memory.hpp" #include "cpu_memory.h" -#include "dnnl_extension_utils.h" +#include "utils/general_utils.h" namespace ov { namespace intel_cpu { @@ -23,8 +22,7 @@ class DnnlScratchPad { } MemoryPtr createScratchPadMem(const MemoryDescPtr& md) { - auto mem = std::make_shared(eng, md, mgrPtr); - return mem; + return std::make_shared(eng, md, mgrPtr); } }; diff --git a/src/plugins/intel_cpu/src/edge.cpp b/src/plugins/intel_cpu/src/edge.cpp index b9d262fcc77281..21f40511baaf25 100644 --- a/src/plugins/intel_cpu/src/edge.cpp +++ b/src/plugins/intel_cpu/src/edge.cpp @@ -70,7 +70,7 @@ void Edge::collectConsumers(std::vector& result) const { if (auto peerChildSPD = childNode->getSelectedPrimitiveDescriptor()) { auto peerOutputNum = this->getOutputNum(); auto peerInPlacePort = peerChildSPD->getConfig().inConfs[peerOutputNum].inPlace(); - auto& vecChildEdges = childNode->getChildEdgesAtPort(peerInPlacePort); + auto vecChildEdges = getChild()->getChildEdgesAtPort(peerInPlacePort); for (auto childEdge : vecChildEdges) { childEdge->collectConsumers(result); } @@ -510,7 +510,7 @@ EdgePtr Edge::getBaseEdge(int look) { } return next_ch_edge; } else if (parentInPlacePort >= 0 && (look & LOOK_UP)) { - return getParent()->getParentEdgesAtPort(parentInPlacePort)[0]; + return getParent()->getParentEdgeAt(parentInPlacePort); } auto edgesForSamePort = getParent()->getChildEdgesAtPort(inputNum); diff --git a/src/plugins/intel_cpu/src/emitters/plugin/x64/jit_dnnl_ext_emitters.hpp b/src/plugins/intel_cpu/src/emitters/plugin/x64/jit_dnnl_ext_emitters.hpp index e33d0576b68697..835605756f9014 100644 --- a/src/plugins/intel_cpu/src/emitters/plugin/x64/jit_dnnl_ext_emitters.hpp +++ b/src/plugins/intel_cpu/src/emitters/plugin/x64/jit_dnnl_ext_emitters.hpp @@ -7,6 +7,7 @@ #include "openvino/opsets/opset5.hpp" #include "transformations/cpu_opset/common/op/swish_cpu.hpp" #include "jit_dnnl_emitters.hpp" +#include "utils/ngraph_utils.hpp" namespace ov { namespace intel_cpu { diff --git a/src/plugins/intel_cpu/src/graph.cpp b/src/plugins/intel_cpu/src/graph.cpp index 1520512aa2a870..a4c7477a5a04bb 100644 --- a/src/plugins/intel_cpu/src/graph.cpp +++ b/src/plugins/intel_cpu/src/graph.cpp @@ -210,15 +210,15 @@ void Graph::Replicate(const std::shared_ptr &model) { for (auto &output : outputNodesMap) { const auto& outputNode = output.second; const auto precToSet = outputNode->getOriginalInputPrecisionAtPort(0); - const auto parentEdges = outputNode->getParentEdgesAtPort(0); - for (size_t i = 0; i < parentEdges.size(); i++) { - const auto parent = parentEdges[i]->getParent(); - parent->setOriginalOutputPrecisionAtPort(parentEdges[i]->getInputNum(), precToSet); - } + const auto parentEdge = outputNode->getParentEdgeAt(0); + const auto parent = parentEdge->getParent(); + parent->setOriginalOutputPrecisionAtPort(parentEdge->getInputNum(), precToSet); } } -void Graph::InitGraph() { +void Graph::InitGraph(bool optimize) { + DEBUG_LOG("Initializing graph with name: ", GetName()); + GraphOptimizer optimizer; SortTopologically(); @@ -238,7 +238,7 @@ void Graph::InitGraph() { optimizer.ApplyImplSpecificGraphOptimizations(*this); SortTopologically(); - const bool hasDynNodes = ProcessDynNodes(); + const auto hasDynNodes = ProcessDynNodes(); Allocate(); @@ -254,6 +254,8 @@ void Graph::InitGraph() { SearchInternalStateNodes(); status = hasDynNodes ? Status::ReadyDynamic : Status::ReadyStatic; + + CPU_DEBUG_CAP_ENABLE(serialize(*this)); } void Graph::InitNodes() { @@ -304,7 +306,7 @@ void Graph::InitDescriptors() { } void Graph::ResolveInplaceDirections() { - OV_ITT_SCOPED_TASK(itt::domains::intel_cpu, "Graph::ResolveInplaceDirections"); + OV_ITT_SCOPED_TASK(itt::domains::intel_cpu, "Graph::ResolveInplaceDirections"); for (auto& node : graphNodes) { resolveInPlaceDirection(node); @@ -473,7 +475,7 @@ void Graph::ResolveEdgeConflicts() { inDesc.getPrecision().get_type_name() + "_" + outDesc.getPrecision().get_type_name(); auto convertNode = std::make_shared(inDesc.getShape(), inDesc.getPrecision(), outDesc.getPrecision(), - convertName, context); + convertName, context); convertNode->setDescs(inDesc, outDesc); InsertNode(edge, convertNode, true); @@ -1284,6 +1286,7 @@ inline void Graph::ExecuteNode(const NodePtr& node, const dnnl::stream& stream) } void Graph::Infer(SyncInferRequest* request) { + DEBUG_LOG("Starting inference of the graph: ", GetName(), ". Status: ", static_cast(status)); if (!IsReady()) { OPENVINO_THROW("Wrong state of the ov::intel_cpu::Graph. Topology is not ready."); } @@ -1336,41 +1339,21 @@ void Graph::SortTopologically() { for (size_t i = 0; i < graphNodes.size(); i++) graphNodes[i]->execIndex = static_cast(i); - // TODO: Sort in/out edges by port index because of backward compatibility - // A lot of plugin logic are build on top of assumption that index in - // vector childEdges/parentEdges is port number. But that is not - // truth anymore. But to keep old logic correct need to simulate ordering. - // - // Make first N (N == port_num) edge indexes are matched with port index + // Sort in / out child edges by port index + // Make first N (N == port_num) edge indexes match with port index for (auto &node : graphNodes) { - { - int port_num = node->inputShapes.size(); - std::vector res(port_num); - - for (size_t i = 0; i < node->parentEdges.size(); i++) { - auto edge = node->getParentEdgeAt(i); - int port = edge->getOutputNum(); - if (port < port_num && !res[port]) - res[port] = edge; - else - res.push_back(edge); - } - node->parentEdges = {res.begin(), res.end()}; - } - { - int port_num = node->outputShapes.size(); - std::vector res(port_num); - - for (size_t i = 0; i < node->childEdges.size(); i++) { - auto edge = node->getChildEdgeAt(i); - int port = edge->getInputNum(); - if (port < port_num && !res[port]) - res[port] = edge; - else - res.push_back(edge); - } - node->childEdges = {res.begin(), res.end()}; + int port_num = node->outputShapes.size(); + std::vector res(port_num); + + for (size_t i = 0; i < node->childEdges.size(); i++) { + auto edge = node->getChildEdgeAt(i); + int port = edge->getInputNum(); + if (port < port_num && !res[port]) + res[port] = edge; + else + res.push_back(edge); } + node->childEdges = {res.begin(), res.end()}; } } @@ -1408,10 +1391,6 @@ void Graph::CreateEdge(const NodePtr& parent, int parentPort, int childPort) { assert(parentPort >= 0 && childPort >= 0); - assert(std::none_of(child->getParentEdges().begin(), child->getParentEdges().end(), - [&childPort](const EdgeWeakPtr& edge){ - return edge.lock()->getOutputNum() == childPort; - })); auto edge = std::make_shared(parent, child, parentPort, childPort); @@ -1521,31 +1500,30 @@ void Graph::RemoveDroppedEdges() { graphEdges.end()); } -NodePtr Graph::InsertReorder(EdgePtr edge, std::string layerName, const MemoryDesc& inDesc, const MemoryDesc& outDesc, - bool isOptimized, const std::vector & src_perm) { - NodePtr newReorder(new node::Reorder(layerName, context)); - auto *reorderPtr = dynamic_cast(newReorder.get()); - if (reorderPtr == nullptr) { - OPENVINO_THROW("Graph::InsertReorder: Cannot cast to Reorder"); - } - reorderPtr->setDescs(inDesc, outDesc); - reorderPtr->setOptimized(isOptimized); - reorderPtr->setSrcPermutation(src_perm); - - DEBUG_LOG(reorderPtr->getName(), " edge=", edge->name(), " isOptimized=", isOptimized); +NodePtr Graph::InsertReorder(EdgePtr edge, + std::string layerName, + const MemoryDesc& inDesc, + const MemoryDesc& outDesc, + bool isOptimized, + const std::vector & src_perm) { + auto reorder = std::make_shared(inDesc, outDesc, layerName, context); + reorder->setOptimized(isOptimized); + reorder->setSrcPermutation(src_perm); + + DEBUG_LOG(reorder->getName(), " edge=", edge->name(), " isOptimized=", isOptimized); DEBUG_LOG(" inDesc: ", inDesc.getShape().toString(), inDesc.getPrecision().get_type_name(), " ", inDesc.serializeFormat()); DEBUG_LOG(" outDesc: ", outDesc.getShape().toString(), outDesc.getPrecision().get_type_name(), " ", outDesc.serializeFormat()); - InsertNode(edge, newReorder, true); + InsertNode(edge, reorder, true); // Using the method Edge::getDesc() we can check that input and output tensor descriptors are equal. // Due to the specificity of GraphOptimizer::MergeTransposeAndReorder() that isOptimized flag uses, we shouldn't do these checks. if (!isOptimized) { - newReorder->getParentEdgeAt(0)->getDesc(); - newReorder->getChildEdgeAt(0)->getDesc(); + reorder->getParentEdgeAt(0)->getDesc(); + reorder->getChildEdgeAt(0)->getDesc(); } - return newReorder; + return reorder; } bool Graph::InsertNode(EdgePtr edge, NodePtr node, bool initNode) { @@ -1584,7 +1562,7 @@ bool Graph::InsertNode(NodePtr parent, NodePtr child, NodePtr node, int parentPo // Apply inference precision configuration void Graph::EnforceInferencePrecision() { - CPU_DEBUG_CAP_ENABLE(static EnforceInferPrcDebug inferPrecDebug); + CPU_DEBUG_CAP_ENABLE(EnforceInferPrcDebug inferPrecDebug); const auto inferPrec = getConfig().inferencePrecision; @@ -1598,7 +1576,6 @@ void Graph::EnforceInferencePrecision() { searchForNodesToSkip = [&](const NodePtr& node, std::unordered_set& skipNodes) -> void { for (size_t i = 0; i < node->getParentEdges().size(); i++) { const auto& parent = node->getParentEdgeAt(i)->getParent(); - if (inferPrec == ov::element::bf16) { /* list of node types that must be forced to be executed in BF16 precision * because of performance gains */ @@ -1609,7 +1586,7 @@ void Graph::EnforceInferencePrecision() { Type::RNNSeq, // recurent nets Type::MatMul, // bert nets Type::ROIPooling, // object detection nets - Type::Interpolate)) // super resolution nets + Type::Interpolate)) // super resolution nets continue; // stop at significant nodes } else if (inferPrec == ov::element::f16) { /* list of node types that must be forced to be executed in FP16 precision @@ -1625,6 +1602,7 @@ void Graph::EnforceInferencePrecision() { } const auto res = skipNodes.insert(parent); + if (res.second) // node not visited yet searchForNodesToSkip(parent, skipNodes); } @@ -1650,12 +1628,12 @@ void Graph::EnforceInferencePrecision() { if (one_of(node->getType(), Type::Input, Type::Output, Type::MemoryInput, Type::MemoryOutput)) continue; - + if (node->keepOrigPrecision()) + continue; #ifdef CPU_DEBUG_CAPS - if (!inferPrecDebug.enabled(NameFromType(node->getType()), node->getName())) + if (!inferPrecDebug.enabled(NameFromType(node->getType()), node->getName(), node->getOriginalLayers())) continue; #endif - DEBUG_LOG("#", node->getExecIndex(), " ", node->getName(), " is enforced to use", inferPrec); for (size_t i = 0; i < node->getOriginalInputsNumber(); i++) { auto keepOriginalInputPrecisionAtPort = [](const NodePtr& node, const size_t inPort) { @@ -1663,7 +1641,7 @@ void Graph::EnforceInferencePrecision() { if (node->getOriginalInputPrecisionAtPort(inPort) != ov::element::f32) return true; - const auto &parent = node->getParentEdgesAtPort(inPort)[0]->getParent(); + const auto &parent = node->getParentEdgeAt(inPort)->getParent(); /* Skip BF16 enforcement for nodes after Constant Inputs for maintaining precision for fusing. * Element type conversion to bf16 is done automatically, if convolution follows up after Constant Inputs * and activation is bf16 */ @@ -1675,12 +1653,27 @@ void Graph::EnforceInferencePrecision() { if (parent->getType() == Type::Input && one_of(node->getType(), Type::Eltwise, Type::Subgraph)) return true; + // exclude Convert after Range since it may cause precision loss when integter type to LP. + if (parent->getType() == Type::Range && node->getType() == Type::Convert) { + return true; + } + return false; }; if (keepOriginalInputPrecisionAtPort(node, i)) continue; + DEBUG_LOG("#", + node->getExecIndex(), + " ", + node->getTypeStr(), + " : ", + node->getName(), + " input[", + i, + "] is enforced to use", + inferPrec); node->setOriginalInputPrecisionAtPort(i, inferPrec); } @@ -1691,10 +1684,20 @@ void Graph::EnforceInferencePrecision() { // exclude Convert before Range since it may cause precision loss when integter type to LP. // TODO: Incorrect subgraph is generated by ONNX FE + ticket 117861. - const auto &child = node->getChildEdgesAtPort(i)[0]->getChild(); + const auto &child = node->getChildEdgeAt(i)->getChild(); if (child->getType() == Type::Range && node->getType() == Type::Convert) continue; + DEBUG_LOG("#", + node->getExecIndex(), + " ", + node->getTypeStr(), + " : ", + node->getName(), + " output[", + i, + "] is enforced to use", + inferPrec); node->setOriginalOutputPrecisionAtPort(i, inferPrec); } } @@ -1794,7 +1797,7 @@ void Graph::resolveInPlaceDirection(const NodePtr& node) const { // the parent node does not use inPlace memory, let's check children std::function searchNonCyclicDirection; searchNonCyclicDirection = [&](const NodePtr& node, int portIdx) -> InplaceDirectionType { - auto& childEdges = node->getChildEdgesAtPort(portIdx); + auto childEdges = node->getChildEdgesAtPort(portIdx); for (auto& edge : childEdges) { auto pChild = edge->getChild(); auto result = inPlaceDirection(pChild, PortType::INPUT, edge->getOutputNum()); diff --git a/src/plugins/intel_cpu/src/graph.h b/src/plugins/intel_cpu/src/graph.h index 035c1b817e9129..4c19e2c20443ec 100644 --- a/src/plugins/intel_cpu/src/graph.h +++ b/src/plugins/intel_cpu/src/graph.h @@ -6,9 +6,10 @@ #include "config.h" #include "cpu_memory.h" +#include "openvino/runtime/profiling_info.hpp" +#include "node.h" #include "edge.h" #include "graph_context.h" -#include "node.h" #include "openvino/runtime/profiling_info.hpp" #include @@ -16,6 +17,7 @@ #include #include +#include "openvino/runtime/so_ptr.hpp" #include "proxy_mem_mgr.h" namespace ov { @@ -37,6 +39,7 @@ class Graph { }; Graph() = default; + ~Graph(); bool IsReady() { @@ -189,6 +192,7 @@ class Graph { getInternalStateNodes() const { return internalStateNodes; } + void InitGraph(bool optimize = true); protected: void ForgetGraphData() { @@ -218,7 +222,6 @@ class Graph { bool graphHasDynamicInput = false; void Replicate(const std::shared_ptr &subgraph); - void InitGraph(); void InitNodes(); void InitDescriptors(); void ResolveInplaceDirections(); @@ -259,5 +262,7 @@ class Graph { void resolveInPlaceDirection(const NodePtr& node) const; }; +using GraphPtr = std::shared_ptr; + } // namespace intel_cpu } // namespace ov diff --git a/src/plugins/intel_cpu/src/graph_dumper.h b/src/plugins/intel_cpu/src/graph_dumper.h index d0c5262c9dc0ec..c2b9aa5a69dfea 100644 --- a/src/plugins/intel_cpu/src/graph_dumper.h +++ b/src/plugins/intel_cpu/src/graph_dumper.h @@ -5,7 +5,6 @@ #pragma once #include "graph.h" -#include "utils/debug_capabilities.h" #include diff --git a/src/plugins/intel_cpu/src/graph_optimizer.cpp b/src/plugins/intel_cpu/src/graph_optimizer.cpp index cf40705d92ddce..b0fa76a845e5b4 100644 --- a/src/plugins/intel_cpu/src/graph_optimizer.cpp +++ b/src/plugins/intel_cpu/src/graph_optimizer.cpp @@ -12,6 +12,7 @@ #include "nodes/eltwise.h" #include "nodes/fake_quantize.h" #include "nodes/fullyconnected.h" +#include "nodes/gather.h" #include "nodes/input.h" #include "nodes/interpolate.h" #include "nodes/memory.hpp" @@ -71,6 +72,10 @@ void GraphOptimizer::ApplyCommonGraphOptimizations(Graph &graph) { FuseFCAndWeightsDecompression(graph); graph.RemoveDroppedNodes(); + OV_ITT_SCOPE_NEXT(FIRST_INFERENCE, taskChain, "FuseGatherAndWeightsDecompression"); + FuseGatherAndWeightsDecompression(graph); + graph.RemoveDroppedNodes(); + OV_ITT_SCOPE_NEXT(FIRST_INFERENCE, taskChain, "FuseConvolutionAndBias"); FuseConvolutionMatMulDeconvAndBias(graph); graph.RemoveDroppedNodes(); @@ -206,8 +211,8 @@ void GraphOptimizer::FuseConvMatmulFCDeconvAndDQScales(Graph &graph) { if (node->getType() != Type::Eltwise || node->getAlgorithm() != Algorithm::EltwiseMultiply) { return false; } - auto parentNode = node->getParentEdgesAtPort(0)[0]->getParent(); - auto scaleNode = node->getParentEdgesAtPort(1)[0]->getParent(); + auto parentNode = node->getParentEdgeAt(0)->getParent(); + auto scaleNode = node->getParentEdgeAt(1)->getParent(); if (!(parentNode->getType() == Type::Convolution || parentNode->getType() == Type::MatMul || parentNode->getType() == Type::Deconvolution @@ -271,14 +276,14 @@ void GraphOptimizer::FuseConvMatmulFCDeconvAndDQScales(Graph &graph) { CPU_GRAPH_OPTIMIZER_SCOPE(FuseConvMatmulFCDeconvAndDQScales); - auto node = mul->getParentEdgesAtPort(0)[0]->getParent(); - auto scales = mul->getParentEdgesAtPort(1)[0]->getParent(); + auto node = mul->getParentEdgeAt(0)->getParent(); + auto scales = mul->getParentEdgeAt(1)->getParent(); if (!scaleDimsCheck(node, scales)) continue; if (initializeDeQuantizedScales(node, scales)) { DEBUG_LOG("GraphOptimizer##FusingDQ: Node ##", mul->getName(), " optimized as DQ scales of Node ##", node->getName()); node->addOriginalLayer(mul->getOriginalLayers()); - auto p_edge = mul->getParentEdgesAtPort(1)[0]; + auto p_edge = mul->getParentEdgeAt(1); graph.RemoveEdge(p_edge); graph.DropNode(mul); } @@ -301,16 +306,16 @@ void GraphOptimizer::FuseFCAndWeightsDecompression(Graph &graph) { if (fcNode == nullptr) continue; - auto parent = fcNode->getParentEdgesAtPort(1)[0]->getParent(); + auto parent = fcNode->getParentEdgeAt(1)->getParent(); const bool withTranspose = parent->getType() == Type::Transpose; const NodePtr transposeNode = withTranspose ? parent : nullptr; if (transposeNode) - parent = transposeNode->getParentEdgesAtPort(0)[0]->getParent(); + parent = transposeNode->getParentEdgeAt(0)->getParent(); const bool withReshape = parent->getType() == Type::Reshape; const auto reshapeNode = withReshape ? parent : nullptr; if (reshapeNode) { - parent = reshapeNode->getParentEdgesAtPort(0)[0]->getParent(); + parent = reshapeNode->getParentEdgeAt(0)->getParent(); } const auto multiplyNode = parent; @@ -319,21 +324,21 @@ void GraphOptimizer::FuseFCAndWeightsDecompression(Graph &graph) { continue; CPU_GRAPH_OPTIMIZER_SCOPE(FuseFCAndWeightsDecompression); - const auto multiplyConstNode = multiplyNode->getParentEdgesAtPort(1)[0]->getParent(); + const auto multiplyConstNode = multiplyNode->getParentEdgeAt(1)->getParent(); if (!expectedNode(multiplyConstNode, Type::Input)) continue; - const auto mulParent = multiplyNode->getParentEdgesAtPort(0)[0]->getParent(); + const auto mulParent = multiplyNode->getParentEdgeAt(0)->getParent(); const bool withSubtract = mulParent->getAlgorithm() == Algorithm::EltwiseSubtract; NodePtr subtractNode, subtractConvertNode, subtractConstNode; if (withSubtract) { subtractNode = mulParent; if (!expectedNode(subtractNode, Type::Eltwise)) continue; - auto subtractParent = subtractNode->getParentEdgesAtPort(1)[0]->getParent(); + auto subtractParent = subtractNode->getParentEdgeAt(1)->getParent(); if (expectedNode(subtractParent, Type::Convert)) { subtractConvertNode = subtractParent; - subtractParent = subtractConvertNode->getParentEdgesAtPort(0)[0]->getParent(); + subtractParent = subtractConvertNode->getParentEdgeAt(0)->getParent(); } subtractConstNode = subtractParent; if (!expectedNode(subtractConstNode, Type::Input)) @@ -359,13 +364,13 @@ void GraphOptimizer::FuseFCAndWeightsDecompression(Graph &graph) { auto convertNode = mulParent; if (withSubtract) - convertNode = subtractNode->getParentEdgesAtPort(0)[0]->getParent(); + convertNode = subtractNode->getParentEdgeAt(0)->getParent(); if (withPowerStatic) - convertNode = powerStaticNode->getParentEdgesAtPort(0)[0]->getParent(); + convertNode = powerStaticNode->getParentEdgeAt(0)->getParent(); if (!expectedNode(convertNode, Type::Convert)) continue; - const auto weightsNode = convertNode->getParentEdgesAtPort(0)[0]->getParent(); + const auto weightsNode = convertNode->getParentEdgeAt(0)->getParent(); if (!expectedNode(weightsNode, Type::Input)) continue; @@ -507,6 +512,103 @@ void GraphOptimizer::FuseFCAndWeightsDecompression(Graph &graph) { } } +void GraphOptimizer::FuseGatherAndWeightsDecompression(Graph &graph) { + std::set supportedWeightsPrecisions{ov::element::u8}; + auto expectedNode = [](NodePtr node, Type expectedType) { + return node->getType() == expectedType && node->getChildEdges().size() == 1; + }; + + auto& graphNodes = graph.GetNodes(); + for (size_t i = 0; i < graphNodes.size(); i++) { + const auto gatherNode = dynamic_cast(graphNodes[i].get()); + if (gatherNode == nullptr) + continue; + + // Multiply + const auto multiplyNode = gatherNode->getParentEdgeAt(0)->getParent(); + if (!expectedNode(multiplyNode, Type::Eltwise) || multiplyNode->getAlgorithm() != Algorithm::EltwiseMultiply || + !multiplyNode->isConstant()) + continue; + + CPU_GRAPH_OPTIMIZER_SCOPE(FuseGatherAndWeightsDecompression); + const auto multiplyConstNode = multiplyNode->getParentEdgeAt(1)->getParent(); + if (!expectedNode(multiplyConstNode, Type::Input)) + continue; + + const auto mulParent = multiplyNode->getParentEdgeAt(0)->getParent(); + NodePtr subtractNode = mulParent; + if (!expectedNode(subtractNode, Type::Eltwise)) + continue; + auto subtractConstNode = subtractNode->getParentEdgeAt(1)->getParent(); + if (!expectedNode(subtractConstNode, Type::Input)) + continue; + + auto convertNode = subtractNode->getParentEdgeAt(0)->getParent(); + if (!expectedNode(convertNode, Type::Convert)) + continue; + const auto weightsNode = convertNode->getParentEdgeAt(0)->getParent(); + if (!expectedNode(weightsNode, Type::Input)) + continue; + + // Precision limitations + if (supportedWeightsPrecisions.find(weightsNode->getOriginalOutputPrecisionAtPort(0)) == supportedWeightsPrecisions.end()) + continue; + + // Shape limitations + const auto weightsShape = weightsNode->getOutputShapeAtPort(0); + if (weightsShape != multiplyNode->getOutputShapeAtPort(0)) + continue; + + // Get decompressionConstShape + VectorDims decompressionConstShape; + const auto gatherInputWeightsShape = gatherNode->getInputShapeAtPort(0); + if (gatherInputWeightsShape.getRank() != 2u || weightsShape.getRank() != 2u) + continue; + // Should be [vocab_size, 1] + decompressionConstShape = VectorDims{gatherInputWeightsShape.getDims()[0], 1}; + + auto check_decompression_shape = [&decompressionConstShape](const VectorDims& shape_to_check) { + if (shape_to_check.size() != decompressionConstShape.size()) + return false; + return std::equal(shape_to_check.begin(), shape_to_check.end(), decompressionConstShape.begin()); + }; + if (!check_decompression_shape(multiplyConstNode->getOutputShapeAtPort(0).getDims())) + continue; + if (!check_decompression_shape(subtractConstNode->getOutputShapeAtPort(0).getDims())) + continue; + + // Fusion processing + auto *multiplyInputNode = dynamic_cast(multiplyConstNode.get()); + if (!multiplyInputNode) { + OPENVINO_THROW("Cannot cast ", multiplyInputNode->getName(), " to Input node."); + } + gatherNode->fuseDecompressionMultiply(multiplyInputNode->getMemoryPtr()); + + auto *subtractInputNode = dynamic_cast(subtractConstNode.get()); + if (!subtractInputNode) { + OPENVINO_THROW("Cannot cast ", subtractInputNode->getName(), " to Input node."); + } + gatherNode->fuseDecompressionSubtract(subtractInputNode->getMemoryPtr()); + + gatherNode->addOriginalLayer(multiplyNode->getOriginalLayers()); + gatherNode->addOriginalLayer(convertNode->getOriginalLayers()); + + gatherNode->addOriginalLayer(subtractNode->getOriginalLayers()); + auto subtractConstEdge = subtractConstNode->getChildEdges()[0].lock(); + graph.RemoveEdge(subtractConstEdge); + + auto multiplyConstEdge = multiplyConstNode->getChildEdges()[0].lock(); + graph.RemoveEdge(multiplyConstEdge); + + graph.DropNode(convertNode); + graph.DropNode(subtractNode); + graph.DropNode(multiplyNode); + + const auto& weightsPrecision = weightsNode->getOriginalOutputPrecisionAtPort(0); + gatherNode->setOriginalInputPrecisionAtPort(0, weightsPrecision); + } +} + void GraphOptimizer::FuseConvolutionMatMulDeconvAndBias(Graph &graph) { auto& graphNodes = graph.GetNodes(); @@ -532,8 +634,8 @@ void GraphOptimizer::FuseConvolutionMatMulDeconvAndBias(Graph &graph) { || childNode->getParentEdges().size() != 2) return false; - auto biasPort = childNode->getParentEdgesAtPort(0)[0]->getParent() == parentNode ? 1 : 0; - const auto biasNode = childNode->getParentEdgesAtPort(biasPort)[0]->getParent(); + auto biasPort = childNode->getParentEdgeAt(0)->getParent() == parentNode ? 1 : 0; + const auto biasNode = childNode->getParentEdgeAt(biasPort)->getParent(); if (biasNode->getType() != Type::Input || !biasNode->isConstant() || biasNode->getChildEdges().size() != 1) return false; @@ -573,7 +675,7 @@ void GraphOptimizer::FuseConvolutionMatMulDeconvAndBias(Graph &graph) { auto childs = childNode->childEdges; auto parents = childNode->parentEdges; - const auto biasPort = childNode->getParentEdgesAtPort(0)[0]->getParent() == parentNode ? 1 : 0; + const auto biasPort = childNode->getParentEdgeAt(0)->getParent() == parentNode ? 1 : 0; for (size_t i = 0; i < parents.size(); i++) { auto p_edge = parents[i].lock(); @@ -755,14 +857,14 @@ void GraphOptimizer::FuseMultiplyAndAdd(Graph &graph) { node->getParentEdges().size() != 2 || node->getChildEdges().size() != 1) return false; - return isSuitableSecondInput(node->getParentEdgesAtPort(1)[0]->getParent(), node->getInputShapeAtPort(0).getDims()); + return isSuitableSecondInput(node->getParentEdgeAt(1)->getParent(), node->getInputShapeAtPort(0).getDims()); }; auto isSuitableChildNode = [&](const NodePtr& parentNode, const NodePtr& childNode) { if (childNode->getAlgorithm() != Algorithm::EltwiseAdd || !childNode->getFusedWith().empty() || childNode->getParentEdges().size() != 2) return false; - return isSuitableSecondInput(childNode->getParentEdgesAtPort(1)[0]->getParent(), childNode->getInputShapeAtPort(0).getDims()) && + return isSuitableSecondInput(childNode->getParentEdgeAt(1)->getParent(), childNode->getInputShapeAtPort(0).getDims()) && parentNode->canFuse(childNode); }; @@ -1001,7 +1103,7 @@ void GraphOptimizer::FuseConvolutionAndZeroPoints(Graph &graph) { if (parent0->getParentEdges().size() != 2) return false; - auto subtractArg1 = parent0->getParentEdgesAtPort(1)[0]->getParent(); + auto subtractArg1 = parent0->getParentEdgeAt(1)->getParent(); if (subtractArg1->getType() != Type::Input || !subtractArg1->isConstant()) return false; @@ -1057,7 +1159,7 @@ void GraphOptimizer::FuseConvolutionAndZeroPoints(Graph &graph) { if (convNode->legacyOutputCompensation.empty()) convNode->legacyOutputCompensation.resize(convNode->getOutputShapeAtPort(0).getDims()[1]); - auto weightsConstant = dynamic_cast(convNode->getParentEdgesAtPort(1)[0]->getParent().get()); + auto weightsConstant = dynamic_cast(convNode->getParentEdgeAt(1)->getParent().get()); if (!weightsConstant || !weightsConstant->isConstant()) return; @@ -1116,10 +1218,10 @@ void GraphOptimizer::FuseConvolutionAndZeroPoints(Graph &graph) { CPU_GRAPH_OPTIMIZER_SCOPE(FuseConvolutionAndZeroPoints_ConvNode); - auto dataEltwise = conv->getParentEdgesAtPort(0)[0]->getParent(); - auto weightsEltwise = conv->getParentEdgesAtPort(1)[0]->getParent(); + auto dataEltwise = conv->getParentEdgeAt(0)->getParent(); + auto weightsEltwise = conv->getParentEdgeAt(1)->getParent(); if (initializeInputZeroPoints(conv, dataEltwise, weightsEltwise)) { - auto p_edge = dataEltwise->getParentEdgesAtPort(1)[0]; + auto p_edge = dataEltwise->getParentEdgeAt(1); DEBUG_LOG("[GraphOptimizer##FusingZeorPoint]:Eltwise Subtract Node ##", dataEltwise->getName(), " is optimized as zeropoint of Conv ##", conv->getName()); graph.RemoveEdge(p_edge); @@ -1312,7 +1414,7 @@ void GraphOptimizer::FuseConvolutionAndDWConvolution(Graph &graph) { auto outDims = childNode->outputShapes[0].getStaticDims(); int elemSize = childNode->getOriginalOutputPrecisionAtPort(0).size(); - int L3_cache_size = utils::get_cache_size(3, false); + int L3_cache_size = dnnl::utils::get_cache_size(3, false); int dw_conv_input_size = inDims[0] * inDims[1] * inDims[2] * inDims[3] * elemSize; int dw_conv_output_size = outDims[0] * outDims[1]* outDims[2] * outDims[3] * elemSize; @@ -1376,6 +1478,13 @@ void GraphOptimizer::FuseConvolutionAndSimpleOperationThroughMaxPool(Graph &grap parent++; continue; } +//Disable ACL post-ops in fp16 to avoid performance degradation +#if defined(OPENVINO_ARCH_ARM64) + if (parentNode->getOriginalInputPrecisionAtPort(0) == ov::element::f16) { + parent++; + continue; + } +#endif auto fuseCandidate = childNode->getChildEdgeAt(0)->getChild(); if (parentNode->getType() == Type::BinaryConvolution && !parentNode->canFuse(fuseCandidate)) { @@ -1425,6 +1534,13 @@ void GraphOptimizer::FuseConvolutionAndSimpleOperation(Graph &graph) { parent++; continue; } +//Disable ACL post-ops in fp16 to avoid performance degradation +#if defined(OPENVINO_ARCH_ARM64) + if (parentNode->getOriginalInputPrecisionAtPort(0) == ov::element::f16) { + parent++; + continue; + } +#endif childNode->fuseInto(parentNode); @@ -1570,8 +1686,8 @@ void GraphOptimizer::FuseConvolutionSumAndConvolutionSumActivation(Graph &graph) if (!isSuitableNode) continue; - auto parent1 = graphNode->getParentEdgesAtPort(0)[0]->getParent(); - auto parent2 = graphNode->getParentEdgesAtPort(1)[0]->getParent(); + auto parent1 = graphNode->getParentEdgeAt(0)->getParent(); + auto parent2 = graphNode->getParentEdgeAt(1)->getParent(); bool isSuitableParent1 = parent1->getType() == Type::Convolution || parent1->getType() == Type::BinaryConvolution; @@ -1650,8 +1766,8 @@ void GraphOptimizer::FuseConvolutionSumAndConvolutionSumActivation(Graph &graph) return (branchPrecision == ov::element::i8) || (branchPrecision == ov::element::u8); }; - const auto isBranch1Quantized = isBranchQuantized(graphNode->getParentEdgesAtPort(0)[0]->getParent()); - const auto isBranch2Quantized = isBranchQuantized(graphNode->getParentEdgesAtPort(1)[0]->getParent()); + const auto isBranch1Quantized = isBranchQuantized(graphNode->getParentEdgeAt(0)->getParent()); + const auto isBranch2Quantized = isBranchQuantized(graphNode->getParentEdgeAt(1)->getParent()); if (isBranch1Quantized || isBranch2Quantized) { // INT8 const auto parent1CanBeMerged = parent1->getChildEdges().size() == 1ul; @@ -1683,6 +1799,11 @@ void GraphOptimizer::FuseConvolutionSumAndConvolutionSumActivation(Graph &graph) if (mergedConv->isConstant() && !sum->isConstant()) continue; +//Disable ACL post-ops in fp16 to avoid performance degradation +#if defined(OPENVINO_ARCH_ARM64) + if (mergedConv->getOriginalInputPrecisionAtPort(0) == ov::element::f16) + continue; +#endif // Disable fusing for Add with broadcasing in case of known data ranges. Add with brodcasting triggers // non-optimal code path inside Convolution node, so better to avoid fusing at all. auto shape1 = sum->getInputShapeAtPort(0); @@ -1704,7 +1825,7 @@ void GraphOptimizer::FuseConvolutionSumAndConvolutionSumActivation(Graph &graph) bool fuse_allowed = mergedConv->getChildEdges().size() == 1; for (size_t j = 0; fuse_allowed && j < mergedConv->getParentEdges().size(); j++) - if (mergedConv->getParentEdgesAtPort(j)[0]->getParent() == peerNode) + if (mergedConv->getParentEdgeAt(j)->getParent() == peerNode) fuse_allowed = false; // Fused Conv+Sum prim will be used inplace. That's mean that input blob will @@ -2106,10 +2227,10 @@ void GraphOptimizer::DropDoubleReorders(Graph &graph) { if (nn == nullptr) OPENVINO_THROW("Cannot get reorder layer ", nextNode->getName()); - NodePtr p = n->getParentEdgesAtPort(0)[0]->getParent(); - NodePtr c = nn->getChildEdgesAtPort(0)[0]->getChild(); + NodePtr p = n->getParentEdgeAt(0)->getParent(); + NodePtr c = nn->getChildEdgeAt(0)->getChild(); - auto oldEdgeNum = n->getParentEdgesAtPort(0)[0]->getInputNum(); + auto oldEdgeNum = n->getParentEdgeAt(0)->getInputNum(); graph.DropNode(node); graph.DropNode(nextNode); @@ -2369,7 +2490,7 @@ void GraphOptimizer::MergeTransposeAndReorder(Graph &graph) { auto isSuitableParentNode = [](NodePtr node) { // WA: to avoid broken memory pointer for conv + sum auto prevNodeIsConvSum = [](NodePtr node) -> bool { - const auto parent = node->getParentEdgesAtPort(0)[0]->getParent(); + const auto parent = node->getParentEdgeAt(0)->getParent(); if (parent->getType() == Type::Convolution) { for (const auto& fusedNode : parent->getFusedWith()) { if (fusedNode->getAlgorithm() == Algorithm::EltwiseAdd) { @@ -2469,11 +2590,11 @@ void GraphOptimizer::MergeTransposeAndReorder(Graph &graph) { // Additionally, we insert another Reorder that performs the conversion from the input precision (inPrec) // to the output precision (outPrec) auto mergeTransposeAndReorder = [&](std::shared_ptr& parentNode, std::shared_ptr& childNode) { - auto parentParentNode = parentNode->getParentEdgesAtPort(0)[0]->getParent(); - auto parentParentConstNode = parentNode->getParentEdgesAtPort(1)[0]->getParent(); + auto parentParentNode = parentNode->getParentEdgeAt(0)->getParent(); + auto parentParentConstNode = parentNode->getParentEdgeAt(1)->getParent(); auto childChildNode = childNode->getChildEdgeAt(0)->getChild(); - auto remEdge = parentNode->getParentEdgesAtPort(1)[0]; + auto remEdge = parentNode->getParentEdgeAt(1); graph.RemoveEdge(remEdge); // to prevent inPlace conflict we must check that the memory reference is unidirectional or diff --git a/src/plugins/intel_cpu/src/graph_optimizer.h b/src/plugins/intel_cpu/src/graph_optimizer.h index 45254aca36304d..0716bedc802c73 100644 --- a/src/plugins/intel_cpu/src/graph_optimizer.h +++ b/src/plugins/intel_cpu/src/graph_optimizer.h @@ -20,6 +20,7 @@ class GraphOptimizer { private: void FuseConvMatmulFCDeconvAndDQScales(Graph &graph); void FuseFCAndWeightsDecompression(Graph &graph); + void FuseGatherAndWeightsDecompression(Graph &graph); void FuseConvolutionMatMulDeconvAndBias(Graph &graph); void FuseDeconvolutionAndSimpleOperation(Graph &graph); void FuseMultiplyAndAdd(Graph &graph); diff --git a/src/plugins/intel_cpu/src/hash_builder.hpp b/src/plugins/intel_cpu/src/hash_builder.hpp new file mode 100644 index 00000000000000..c295e3f2a4beea --- /dev/null +++ b/src/plugins/intel_cpu/src/hash_builder.hpp @@ -0,0 +1,58 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include +#include +#include +namespace ov { +namespace intel_cpu { +namespace hash { + +// The following code is derived from Boost C++ library +// Copyright 2005-2014 Daniel James. +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt) +template ::value, int>::type = 0> +size_t combine(size_t seed, const T& v) { + return seed ^= std::hash{}(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); +} + +template ::value, int>::type = 0> +size_t combine(size_t seed, const T& v) { + using underlying_t = typename std::underlying_type::type; + return combine(seed, static_cast(v)); +} + +template +size_t combine(size_t seed, const std::vector& v) { + for (const auto& elem : v) + seed = combine(seed, elem); + return seed; +} + +struct Builder { + Builder(size_t seed) : m_seed(seed) {} + + // todo add specializations / sfinae + template + Builder& combine(T v) { + m_seed = ov::intel_cpu::hash::combine(m_seed, v); + return *this; + } + + size_t generate() { + return m_seed; + } + +private: + size_t m_seed; +}; + +} // namespace hash +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/infer_request.cpp b/src/plugins/intel_cpu/src/infer_request.cpp index 7537c0f1f915d7..53b2bec418c0fc 100644 --- a/src/plugins/intel_cpu/src/infer_request.cpp +++ b/src/plugins/intel_cpu/src/infer_request.cpp @@ -8,20 +8,16 @@ #include "compiled_model.h" #include "dnnl_extension_utils.h" #include "itt.h" -#include "memory_desc/dnnl_blocked_memory_desc.h" #include "memory_state.h" #include "nodes/common/cpu_convert.h" #include "nodes/common/cpu_memcpy.h" -#include "nodes/concat.h" #include "nodes/memory.hpp" -#include "nodes/split.h" #include "openvino/core/shape.hpp" #include "openvino/runtime/make_tensor.hpp" #include "openvino/runtime/tensor.hpp" #include "proxy_mem_mgr.h" -#include "transformations/utils/utils.hpp" -#include "utils/cpu_utils.hpp" #include "utils/general_utils.h" +#include "utils/ngraph_utils.hpp" using OvString = ov::element_type_traits::value_type; @@ -452,7 +448,7 @@ void SyncInferRequest::set_tensor(const ov::Output& in_port, con " are different."); } - const auto& desc = m_graph->getOutputNodeByName(name)->getParentEdgesAtPort(0)[0]->getMemory().getDesc(); + const auto& desc = m_graph->getOutputNodeByName(name)->getParentEdgeAt(0)->getMemory().getDesc(); if (!isDynamic && mem_desc_ptr->isCompatible(desc)) { m_external_ptr[name] = tensor; } else if (m_external_ptr.find(name) != m_external_ptr.end()) { @@ -513,7 +509,7 @@ void SyncInferRequest::init_tensor(const std::string& name) { if (!isDynamic) { auto mem_desc_ptr = MemoryDescUtils::generateCpuBlockedMemoryDesc(tensor); if (mem_desc_ptr->isCompatible( - m_graph->getInputNodeByName(name)->getChildEdgesAtPort(0)[0]->getMemory().getDesc())) { + m_graph->getInputNodeByName(name)->getChildEdgeAt(0)->getMemory().getDesc())) { m_external_ptr[name] = tensor; } } @@ -560,7 +556,7 @@ void SyncInferRequest::init_tensor(const std::string& name) { tensor = std::make_shared(memory); } else { const auto graph_prec = - output->second->getParentEdgesAtPort(0)[0]->getMemory().getDesc().getPrecision(); + output->second->getParentEdgeAt(0)->getMemory().getDesc().getPrecision(); OutputControlBlock control_block{model_prec, Shape{shape}}; DEBUG_LOG(name, @@ -614,7 +610,7 @@ void SyncInferRequest::init_tensor(const std::string& name) { m_outputs[name] = tensor; if (!port_shape.is_dynamic() && !m_external_ptr.count(name)) { auto desc = MemoryDescUtils::generateCpuBlockedMemoryDesc(tensor); - if (desc->isCompatible(output->second->getParentEdgesAtPort(0)[0]->getMemory().getDesc())) { + if (desc->isCompatible(output->second->getParentEdgeAt(0)->getMemory().getDesc())) { m_external_ptr[name] = tensor; } } diff --git a/src/plugins/intel_cpu/src/memory_desc/cpu_memory_desc.h b/src/plugins/intel_cpu/src/memory_desc/cpu_memory_desc.h index d6a6d65762fb5a..faecefc6cf95cc 100644 --- a/src/plugins/intel_cpu/src/memory_desc/cpu_memory_desc.h +++ b/src/plugins/intel_cpu/src/memory_desc/cpu_memory_desc.h @@ -29,6 +29,7 @@ class MemoryDesc; using MemoryDescPtr = std::shared_ptr; using MemoryDescCPtr = std::shared_ptr; +using VecMemoryDescs = std::vector; enum MemoryDescType { Undef = 0, diff --git a/src/plugins/intel_cpu/src/memory_desc/cpu_memory_desc_utils.cpp b/src/plugins/intel_cpu/src/memory_desc/cpu_memory_desc_utils.cpp index 4acdce0bd0b36e..b8078eeaed965c 100644 --- a/src/plugins/intel_cpu/src/memory_desc/cpu_memory_desc_utils.cpp +++ b/src/plugins/intel_cpu/src/memory_desc/cpu_memory_desc_utils.cpp @@ -2,17 +2,16 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "memory_desc/cpu_memory_desc_utils.h" -#include "cpu_memory.h" -#include "cpu_memory_desc.h" +#include +#include "memory_desc/cpu_blocked_memory_desc.h" #include "memory_desc/dnnl_blocked_memory_desc.h" -#include "openvino/runtime/itensor.hpp" -#include "openvino/runtime/so_ptr.hpp" -#include "utils/cpu_utils.hpp" -#include "utils/general_utils.h" - -#include "dnnl_types.h" -#include +#include "cpu_memory_desc.h" +#include "memory_desc/cpu_memory_desc_utils.h" +#include +#include +#include +#include +#include #include #include diff --git a/src/plugins/intel_cpu/src/memory_desc/dnnl_blocked_memory_desc.cpp b/src/plugins/intel_cpu/src/memory_desc/dnnl_blocked_memory_desc.cpp index 59aa22a28d2494..96a4a42e6b8b8a 100644 --- a/src/plugins/intel_cpu/src/memory_desc/dnnl_blocked_memory_desc.cpp +++ b/src/plugins/intel_cpu/src/memory_desc/dnnl_blocked_memory_desc.cpp @@ -6,11 +6,10 @@ #include #include -#include "dnnl_types.h" #include "cpu_types.h" #include "dnnl_extension_utils.h" -#include "memory_desc/dnnl_memory_desc.h" -#include "nodes/common/dnnl_executor.h" +#include "memory_desc/cpu_blocked_memory_desc.h" +#include "utils/general_utils.h" #include #include diff --git a/src/plugins/intel_cpu/src/memory_desc/dnnl_blocked_memory_desc.h b/src/plugins/intel_cpu/src/memory_desc/dnnl_blocked_memory_desc.h index dd83cfc34a71e2..ac012dbdc334e8 100644 --- a/src/plugins/intel_cpu/src/memory_desc/dnnl_blocked_memory_desc.h +++ b/src/plugins/intel_cpu/src/memory_desc/dnnl_blocked_memory_desc.h @@ -4,6 +4,7 @@ #pragma once +#include "dnnl_memory_desc.h" #include "blocked_memory_desc.h" #include "openvino/util/util.hpp" #include "cpu_memory.h" diff --git a/src/plugins/intel_cpu/src/memory_desc/dnnl_memory_desc.h b/src/plugins/intel_cpu/src/memory_desc/dnnl_memory_desc.h index b5eddaa91beba8..9e8703b01661ec 100644 --- a/src/plugins/intel_cpu/src/memory_desc/dnnl_memory_desc.h +++ b/src/plugins/intel_cpu/src/memory_desc/dnnl_memory_desc.h @@ -4,10 +4,11 @@ #pragma once -#include "cpu_blocked_memory_desc.h" #include "dnnl_extension_utils.h" #include #include +#include "memory_desc/cpu_memory_desc.h" +#include "dnnl_extension_utils.h" namespace ov { namespace intel_cpu { diff --git a/src/plugins/intel_cpu/src/memory_state.cpp b/src/plugins/intel_cpu/src/memory_state.cpp index eaf715a9fcc052..44b87a082fab3d 100644 --- a/src/plugins/intel_cpu/src/memory_state.cpp +++ b/src/plugins/intel_cpu/src/memory_state.cpp @@ -1,12 +1,13 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // -#include #include "memory_state.h" +#include +#include "cpu_memory.h" +#include "memory_desc/cpu_blocked_memory_desc.h" #include "dnnl_extension_utils.h" -#include "blob_factory.hpp" #include "cpu_tensor.h" #include "utils/plain_tensor.hpp" #include "openvino/core/parallel.hpp" @@ -229,7 +230,7 @@ void VariableStateKVcache::set_state_impl(const ov::SoPtr& state) { std::make_shared(ov::element::i32, Shape{size_B, size_L}); m_hidden_state = std::make_shared(get_engine(), mem_desc); - auto buff = reinterpret_cast(m_hidden_state->getData()); + auto buff = m_hidden_state->getDataAs(); for (size_t i = 0; i < size_B; ++i) { for (size_t j = 0; j < size_L; ++j) { buff[i * size_L + j] = i; diff --git a/src/plugins/intel_cpu/src/memory_state.h b/src/plugins/intel_cpu/src/memory_state.h index 3cfc413d74753a..c762c4afa2f142 100644 --- a/src/plugins/intel_cpu/src/memory_state.h +++ b/src/plugins/intel_cpu/src/memory_state.h @@ -5,10 +5,8 @@ #pragma once #include "cpu_memory.h" -#include "memory_desc/cpu_memory_desc_utils.h" -#include "nodes/common/cpu_memcpy.h" +#include "memory_desc/blocked_memory_desc.h" #include "openvino/runtime/ivariable_state.hpp" -#include "openvino/runtime/make_tensor.hpp" #include "openvino/runtime/tensor.hpp" namespace ov { diff --git a/src/plugins/intel_cpu/src/node.cpp b/src/plugins/intel_cpu/src/node.cpp index 85e6817c5a112b..fbefc74a076d65 100644 --- a/src/plugins/intel_cpu/src/node.cpp +++ b/src/plugins/intel_cpu/src/node.cpp @@ -3,62 +3,39 @@ // #include "node.h" - -#include "common/primitive_desc.hpp" -#include "common/primitive_desc_iface.hpp" -#include "dnnl_debug.h" -#include "dnnl_extension_utils.h" -#include "dnnl_types.h" +#include "cpu_types.h" #include "edge.h" -#include "itt.h" -#include "memory_desc/cpu_memory_desc_utils.h" -#include "memory_desc/dnnl_blocked_memory_desc.h" -#include "nodes/common/cpu_convert.h" -#include "nodes/common/cpu_memcpy.h" -#include "nodes/concat.h" -#include "nodes/conv.h" -#include "nodes/deconv.h" -#include "nodes/depth_to_space.h" -#include "nodes/eltwise.h" -#include "nodes/fake_quantize.h" -#include "nodes/fullyconnected.h" -#include "nodes/if.h" -#include "nodes/input.h" -#include "nodes/interpolate.h" -#include "nodes/lrn.h" -#include "nodes/matmul.h" -#include "nodes/memory.hpp" -#include "nodes/mvn.h" -#include "nodes/normalize.h" -#include "nodes/pad.h" -#include "nodes/pooling.h" -#include "nodes/reduce.h" -#include "nodes/reference.h" -#include "nodes/reorder.h" -#include "nodes/reshape.h" -#include "nodes/scatter_update.h" -#include "nodes/shuffle_channels.h" -#include "nodes/softmax.h" -#include "nodes/space_to_depth.h" -#include "nodes/split.h" -#include "nodes/strided_slice.h" -#include "nodes/tensoriterator.h" -#include "nodes/tile.h" -#include "nodes/transpose.h" -#include "openvino/opsets/opset1.hpp" #include "partitioned_mem_mgr.h" -#include "utils/cpu_utils.hpp" -#include "utils/general_utils.h" -#include "utils/rt_info/memory_formats_attribute.hpp" -#include "utils/verbose.h" -#include -#include #include #include +#include #include +#include #include -#include + +#include "nodes/conv.h" +#include "nodes/eltwise.h" +#include "nodes/input.h" +#include "nodes/reorder.h" +#include "nodes/reference.h" +#include "dnnl_extension_utils.h" + +#include "utils/debug_capabilities.h" +#include "utils/ngraph_utils.hpp" +#include "utils/rt_info/memory_formats_attribute.hpp" +#include + +#include +#include +#include +#include "utils/general_utils.h" +#include "utils/cpu_utils.hpp" +#include "nodes/common/cpu_convert.h" +#include "memory_desc/cpu_memory_desc_utils.h" +#include "memory_desc/dnnl_blocked_memory_desc.h" +#include +#include using namespace dnnl; using namespace openvino; @@ -99,6 +76,8 @@ Node::Node(const std::shared_ptr& op, originalInputPrecisions.emplace_back(op->get_input_element_type(i)); } + parentEdges.reserve(inputShapes.size()); + if (typeStr != "Result" && typeStr != "Assign") { if (op->get_output_size() == 0) { OPENVINO_THROW("Node with type '", typeStr, "' and name '", name, "' does not have any outputs."); @@ -116,6 +95,8 @@ Node::Node(const std::shared_ptr& op, outputShapes.emplace_back(isScalar ? ov::PartialShape{1} : shape); originalOutputPrecisions.emplace_back(op->get_output_element_type(i)); } + + childEdges.reserve(outputShapes.size()); } isDynamic = std::any_of(inputShapes.begin(), inputShapes.end(), [](const Shape& shape){ return shape.isDynamic(); }) || @@ -134,7 +115,7 @@ Node::Node(const std::shared_ptr& op, addOriginalLayer(name); } - auto primitivesPriority = getImplPriorityValue(op); + primitivesPriority = getImplPriorityValue(op); if (!primitivesPriority.empty()) { std::istringstream stream(primitivesPriority); std::string str; @@ -176,19 +157,32 @@ Node::Node(const std::shared_ptr& op, if (it != rtInfo.end()) { enforceBF16evenForGraphTail = it->second.as(); } + if (ov::fp16_compression_is_disabled(op)) + keepOriginalPrecision = true; } -Node::Node(const std::string& type, const std::string& name, const GraphContext::CPtr ctx) - : selectedPrimitiveDescriptorIndex(-1), +Node::Node(const std::string& type, + std::vector inShapes, + std::vector outShapes, + std::vector inputPrecisions, + std::vector outputPrecisions, + const std::string& name, + const GraphContext::CPtr ctx) + : inputShapes(std::move(inShapes)), + outputShapes(std::move(outShapes)), + selectedPrimitiveDescriptorIndex(-1), constant(ConstantType::NoConst), context(ctx), + originalInputPrecisions(std::move(inputPrecisions)), + originalOutputPrecisions(std::move(outputPrecisions)), fusingPort(-1), engine(ctx->getEngine()), name(name), typeStr(type), type(TypeFromName(type)), profiling(name) { - // TODO [NM]: What about filling inDims and outDims? + parentEdges.reserve(inputShapes.size()); + childEdges.reserve(outputShapes.size()); } void Node::addEdge(const EdgePtr& edge) { @@ -381,7 +375,7 @@ void Node::resolveInPlaceEdges(Edge::LOOK look) { if (inplaceInpIndx < 0) continue; - auto baseMemMngr = getParentEdgesAtPort(inplaceInpIndx).front()->getMemory().getMemoryMngr(); + auto baseMemMngr = getParentEdgeAt(inplaceInpIndx)->getMemory().getMemoryMngr(); auto memMngr = std::make_shared(baseMemMngr); const auto& childEdges = getChildEdgesAtPort(i); @@ -492,7 +486,7 @@ std::string Node::getPrimitiveDescriptorType() const { return str_type; } -const EdgePtr Node::getParentEdgeAt(size_t idx) const { +EdgePtr Node::getParentEdgeAt(size_t idx) const { if (idx >= parentEdges.size()) OPENVINO_THROW("Node ", getName(), " contains less parent edges than ", idx); auto parentEdgePtr = parentEdges[idx].lock(); @@ -501,7 +495,7 @@ const EdgePtr Node::getParentEdgeAt(size_t idx) const { return parentEdgePtr; } -const EdgePtr Node::getChildEdgeAt(size_t idx) const { +EdgePtr Node::getChildEdgeAt(size_t idx) const { if (idx >= childEdges.size()) OPENVINO_THROW("Node ", getName(), " contains less child edges than ", idx); auto childEdgePtr = childEdges[idx].lock(); @@ -510,35 +504,24 @@ const EdgePtr Node::getChildEdgeAt(size_t idx) const { return childEdgePtr; } -const std::vector Node::getParentEdgesAtPort(size_t idx) const { - if (idx >= inputShapes.size()) - OPENVINO_THROW("Node ", getName(), " contains less input ports than ", idx); +std::vector Node::getChildEdgesAtPort(int inputNum) const { + if (inputNum < 0) + OPENVINO_THROW("Node ", getName(), ". negative input number is not supported ", inputNum); - std::vector res; - for (auto &edge_w : parentEdges) { - auto edge = edge_w.lock(); - if (!edge) - OPENVINO_THROW("Node ", getName(), " contains dead weak ptr"); - if (edge->getOutputNum() == static_cast(idx)) res.push_back(edge); - } - return res; -} - -const std::vector Node::getChildEdgesAtPort(size_t idx) const { - if (idx >= outputShapes.size()) - OPENVINO_THROW("Node ", getName(), " contains less output ports than ", idx); + if (static_cast(inputNum) >= outputShapes.size()) + OPENVINO_THROW("Node ", getName(), " contains less output ports than ", inputNum); std::vector res; for (auto &edge_w : childEdges) { auto edge = edge_w.lock(); if (!edge) OPENVINO_THROW("Node ", getName(), " contains dead weak ptr"); - if (edge->getInputNum() == static_cast(idx)) res.push_back(edge); + if (edge->getInputNum() == inputNum) + res.push_back(edge); } return res; } - std::vector Node::getAvailableFormatsForDims(const Shape &dims) const { if (dims.getRank() == 0) return {memory::format_tag::x}; @@ -875,7 +858,7 @@ void Node::prepareMemory(dnnl::primitive_desc_iterator& itpd) { MemoryPtr Node::prepareWeightMemory(DnnlMemoryDescPtr dstWeightDesc, DnnlMemoryDescPtr srcWeightDesc) { if (!getParentEdgeAt(1)->getParent()->isConstant()) OPENVINO_THROW("Weight input is not const for node ", getName(), "."); - auto edgeMem = getParentEdgeAt(1)->getMemoryPtr(); + auto edgeMem = getSrcMemoryAtPort(1); if (!edgeMem) OPENVINO_THROW("Cannot get const weights edgeMem for node ", getName(), "."); @@ -896,23 +879,27 @@ MemoryPtr Node::prepareWeightMemory(DnnlMemoryDescPtr dstWeightDesc, DnnlMemoryD MemoryPtr ptr; const auto& format = dstWeightDesc->serializeFormat(); - auto itr = privateWeightCache.find(format); - if (privateWeightCache.end() != itr) { - ptr = itr->second; - } else { - auto weightCache = context->getWeightsCache(); - if (weightCache != nullptr) { - const std::string string_hash = getName() + "_" + format - + "_" + std::to_string(edgeMem->getSize()) - + "_" + std::to_string(reinterpret_cast(edgeMem->getData())); - ptr = *weightCache->findOrCreate(string_hash, create); - } else { - ptr = create(); - } - privateWeightCache[format] = ptr; + assert(privateWeightCache); + + auto itr = privateWeightCache->find(format); + if (privateWeightCache->end() != itr) { + return itr->second; + } + + auto weightCache = context->getWeightsCache(); + if (weightCache != nullptr) { + const std::string string_hash = getName() + "_" + format + + "_" + std::to_string(edgeMem->getSize()) + + "_" + std::to_string(*edgeMem->getDataAs()); + + ptr = *weightCache->findOrCreate(string_hash, create); + } else { + ptr = create(); } + (*privateWeightCache)[format] = ptr; + return ptr; } @@ -1129,7 +1116,7 @@ void Node::initOptimalPrimitiveDescriptor() { auto selected_pd = getSelectedPrimitiveDescriptor(); if (selected_pd == nullptr) - OPENVINO_THROW("Preferable primitive descriptor is not set."); + OPENVINO_THROW("Preferable primitive descriptor is not set for ", getName()); auto config = selected_pd->getConfig(); for (size_t i = 0; i < config.inConfs.size(); i++) { @@ -1275,7 +1262,7 @@ Node* Node::NodesFactory::create(const std::shared_ptr& op, const Grap // Note that the op type and its friendly name will also be provided if we fail to create the node. auto getExceptionDescWithoutStatus = [](const ov::Exception& ex) { std::string desc = ex.what(); - size_t pos = desc.find("]"); + size_t pos = desc.find(']'); if (pos != std::string::npos) { if (desc.size() == pos + 1) { desc.erase(0, pos + 1); @@ -1340,7 +1327,7 @@ bool Node::canBePerformedAsScaleShift(const Node *parentNode) const { const auto channelAxis = parentNode->getFusingAxis(); for (size_t i = 0; i < getParentEdges().size(); i++) { - Node *node = getParentEdgesAtPort(i)[0]->getParent().get(); + Node *node = getParentEdgeAt(i)->getParent().get(); if (node == nullptr) { OPENVINO_THROW("Cannot get parent node for ", getName(), " on ", i, " port"); } @@ -1359,7 +1346,7 @@ bool Node::canBePerformedAsScaleShift(const Node *parentNode) const { if (i == fusingPort) continue; auto& weightShape = getInputShapeAtPort(i).getDims(); - if (getParentEdgesAtPort(i)[0]->getParent()->getChildEdges().size() != 1 || + if (getParentEdgeAt(i)->getParent()->getChildEdges().size() != 1 || !isPerTensorOrPerChannelBroadcastable(dataShape, weightShape, channelAxis, true)) return false; } @@ -1411,15 +1398,15 @@ std::pair, std::vector> Node::getScalesAndShifts(const elementsCount); }; - const auto constPort = getParentEdgesAtPort(0)[0]->getParent().get() == parentNode ? 1 : 0; + const auto constPort = getParentEdgeAt(0)->getParent().get() == parentNode ? 1 : 0; if (one_of(getAlgorithm(), Algorithm::EltwiseMultiply, Algorithm::EltwiseDivide, Algorithm::EltwisePrelu)) { - fillValuesFrom(getParentEdgesAtPort(constPort)[0]->getParent(), scales); + fillValuesFrom(getParentEdgeAt(constPort)->getParent(), scales); } else if (one_of(getAlgorithm(), Algorithm::EltwiseAdd, Algorithm::EltwiseSubtract)) { - fillValuesFrom(getParentEdgesAtPort(constPort)[0]->getParent(), shifts); + fillValuesFrom(getParentEdgeAt(constPort)->getParent(), shifts); } else if (one_of(getAlgorithm(), Algorithm::EltwiseMulAdd)) { - fillValuesFrom(getParentEdgesAtPort(1)[0]->getParent(), scales); - fillValuesFrom(getParentEdgesAtPort(2)[0]->getParent(), shifts); + fillValuesFrom(getParentEdgeAt(1)->getParent(), scales); + fillValuesFrom(getParentEdgeAt(2)->getParent(), shifts); } else if (one_of(getAlgorithm(), Algorithm::EltwisePowerStatic)) { const auto power = dynamic_cast(this); if (!power) { @@ -1464,7 +1451,7 @@ bool Node::isInputTensorAtPortEmpty(size_t port) const { if (inputShapes[port].hasZeroDims()) { return true; } - auto edge = getParentEdgesAtPort(port)[0]; + auto edge = getParentEdgeAt(port); if (one_of(edge->getStatus(), Edge::Status::Allocated, Edge::Status::Validated)) { auto&& mem = edge->getMemory(); if (mem.isAllocated()) { @@ -1481,7 +1468,7 @@ bool Node::isOutputTensorAtPortEmpty(size_t port) const { if (outputShapes[port].isStatic()) { return outputShapes[port].hasZeroDims(); } - auto&& mem = getChildEdgesAtPort(port)[0]->getMemory(); + auto&& mem = getChildEdgeAt(port)->getMemory(); if (mem.isAllocated()) { return mem.getShape().hasZeroDims(); } @@ -1506,7 +1493,7 @@ bool Node::hasEmptyOutputTensors() const { bool Node::inputShapesDefined() const { for (size_t i = 0; i < getParentEdges().size(); i++) { - if (!getParentEdgesAtPort(i)[0]->getMemory().getDesc().isDefined()) { + if (!getParentEdgeAt(i)->getMemory().getDesc().isDefined()) { return false; } } @@ -1515,7 +1502,7 @@ bool Node::inputShapesDefined() const { bool Node::outputShapesDefined() const { for (size_t i = 0; i < outputShapes.size(); i++) { - if (!getChildEdgesAtPort(i)[0]->getMemory().getDesc().isDefined()) { + if (!getChildEdgeAt(i)->getMemory().getDesc().isDefined()) { return false; } } @@ -1538,7 +1525,7 @@ bool Node::inputShapesModified() const { } for (size_t i = 0; i < lastInputDims.size(); i++) { - if (lastInputDims[i] != getParentEdgesAtPort(i)[0]->getMemory().getStaticDims()) + if (lastInputDims[i] != getParentEdgeAt(i)->getMemory().getStaticDims()) return true; } return false; @@ -1561,7 +1548,7 @@ std::vector Node::shapeInferGeneric(const std::vector& shapes if (input_value_port_mask) { for (size_t port = 0; port < inputShapes.size(); ++port) { if (input_value_port_mask & (1 << port)) { - input_values[port] = getParentEdgesAtPort(port)[0]->getMemoryPtr(); + input_values[port] = getSrcMemoryAtPort(port); } } } @@ -1572,9 +1559,8 @@ std::vector Node::shapeInferGeneric(const std::vector& shapes } return std::move(result.dims); - } - catch (const std::runtime_error& exp) { - OPENVINO_THROW("Shape inference of ", getTypeStr() , " node with name ", getName(), " failed: ", exp.what()); + } catch (const std::runtime_error& exp) { + OPENVINO_THROW("Shape inference of ", getTypeStr(), " node with name ", getName(), " failed: ", exp.what()); } } @@ -1585,13 +1571,13 @@ IShapeInfer::Result Node::shapeInfer() const { input_shapes.reserve(inputShapes.size()); for (size_t port = 0; port < inputShapes.size(); ++port) - input_shapes.emplace_back(std::ref(getParentEdgesAtPort(port)[0]->getMemory().getStaticDims())); + input_shapes.emplace_back(std::ref(getParentEdgeAt(port)->getMemory().getStaticDims())); std::unordered_map input_values; if (input_value_port_mask) { for (size_t port = 0; port < inputShapes.size(); ++port) { if (input_value_port_mask & (1 << port)) { - input_values[port] = getParentEdgesAtPort(port)[0]->getMemoryPtr(); + input_values[port] = getSrcMemoryAtPort(port); } } } @@ -1611,14 +1597,14 @@ void Node::updateLastInputDims() { } for (size_t i = 0; i < lastInputDims.size(); i++) - lastInputDims[i] = getParentEdgesAtPort(i)[0]->getMemory().getDesc().getShape().getDims(); + lastInputDims[i] = getParentEdgeAt(i)->getMemory().getDesc().getShape().getDims(); } bool Node::canFuseSimpleOperation(const NodePtr& node) const { if (node->getType() == Type::FakeQuantize) { bool ret = node->getAlgorithm() != Algorithm::FQBinarization; for (size_t i = 1; i < node->getParentEdges().size(); i++) { - ret &= node->getParentEdgesAtPort(i)[0]->getParent()->getChildEdges().size() == 1; + ret &= node->getParentEdgeAt(i)->getParent()->getChildEdges().size() == 1; } return ret; } else if (node->getType() == Type::Eltwise) { diff --git a/src/plugins/intel_cpu/src/node.h b/src/plugins/intel_cpu/src/node.h index 1a8cecf9b112f1..e80800086dec2b 100644 --- a/src/plugins/intel_cpu/src/node.h +++ b/src/plugins/intel_cpu/src/node.h @@ -4,35 +4,36 @@ #pragma once -#include "cache/multi_cache.h" -#include "config.h" +#include +#include +#include #include "cpu_memory.h" #include "cpu_shape.h" #include "cpu_types.h" -#include "dnnl_postops_composer.h" -#include "dnnl_scratch_pad.h" #include "edge.h" -#include "nodes/common/blocked_desc_creator.h" -#include "nodes/executors/executor.hpp" -#include "nodes/executors/mvn_list.hpp" -#include "nodes/node_config.h" -#include "oneapi/dnnl/dnnl.hpp" +#include "selective_build.h" +#include "memory_desc/dnnl_memory_desc.h" #include "onednn/dnnl.h" #include "onednn/iml_type_mapper.h" +#include +#include "openvino/cc/factory.h" #include "openvino/core/node.hpp" -#include "openvino/itt.hpp" -#include "selective_build.h" -#include "shape_inference/shape_inference_cpu.hpp" +#include +#include "cpu_types.h" +#include "cpu_shape.h" +#include "nodes/node_config.h" +#include +#include "perf_count.h" +#include "utils/debug_capabilities.h" #include "utils/bit_util.hpp" #include "utils/debug_capabilities.h" -#include "utils/ngraph_utils.hpp" -#include "weights_cache.hpp" -#include -#include +#include "graph_context.h" +#include "nodes/executors/executor.hpp" + #include -#include #include +#include #define THROW_CPU_NODE_ERR(...) OPENVINO_THROW(getTypeStr(), " node with name '", getName(), "' ", __VA_ARGS__) #define CPU_NODE_ASSERT(condition, ...) OPENVINO_ASSERT(condition, getTypeStr(), " node with name '", getName(), "' ", __VA_ARGS__) @@ -75,7 +76,7 @@ class NodeDesc { NodeDesc(NodeConfig conf, impl_desc_type type): config(std::move(conf)), implementationType(type), executorFactory(nullptr) {} - NodeDesc(NodeConfig conf, impl_desc_type type, ExecutorFactoryPtr factory): + NodeDesc(NodeConfig conf, impl_desc_type type, ExecutorFactoryLegacyPtr factory): config(std::move(conf)), implementationType(type), executorFactory(factory) {} const NodeConfig& getConfig() const { @@ -94,13 +95,13 @@ class NodeDesc { implementationType = type; } - ExecutorFactoryPtr getExecutorFactory() const { + ExecutorFactoryLegacyPtr getExecutorFactory() const { return executorFactory; } template ::value && !std::is_reference::value, int>::type = 0, - typename std::enable_if::value, int>::type = 0> + typename std::enable_if::value, int>::type = 0> std::shared_ptr getExecutorFactoryAs() { auto casted = std::dynamic_pointer_cast(executorFactory); if (!casted) @@ -108,14 +109,14 @@ class NodeDesc { return casted; } - void setExecutorFactory(ExecutorFactoryPtr factory) { + void setExecutorFactory(ExecutorFactoryLegacyPtr factory) { executorFactory = factory; } private: NodeConfig config; impl_desc_type implementationType; - ExecutorFactoryPtr executorFactory; + ExecutorFactoryLegacyPtr executorFactory; }; class Node { @@ -172,7 +173,15 @@ class Node { void remove(); void addParentEdge(const EdgePtr& edge) { - parentEdges.push_back(edge); + assert(std::none_of(parentEdges.begin(), parentEdges.end(), + [&edge](const EdgeWeakPtr& _edge){ + return _edge.lock()->getOutputNum() == edge->getOutputNum(); + })); + parentEdges.insert(std::upper_bound(parentEdges.begin(), parentEdges.end(), edge, + [](const EdgeWeakPtr& lhs, const EdgeWeakPtr& rhs) { + return lhs.lock()->getOutputNum() < rhs.lock()->getOutputNum(); + }), + edge); updateConstantType(); } @@ -197,11 +206,53 @@ class Node { return childEdges; } - const EdgePtr getParentEdgeAt(size_t idx) const; - virtual const EdgePtr getChildEdgeAt(size_t idx) const; + EdgePtr getParentEdgeAt(size_t idx) const; + + /** + * Returns all the child edges by input port number. + * + * Safe way of getting all the child edges at port. + * Does not require a vector of the child edges to be sorted. + * Allocates a storage (vector) to collect the child edges. + */ + std::vector getChildEdgesAtPort(int inputNum) const; - const std::vector getParentEdgesAtPort(size_t idx) const; - const std::vector getChildEdgesAtPort(size_t idx) const; + /** + * Returns a child edge by index. + * + * @attention !!! Can only be used after Graph::SortTopologically is performed !!! + * Optimized way of accessing a child edge at port. + * If node contains multiple child edges at port, a random one is returned. + * Has less overhead in comparison with calling getChildEdgesAtPort(idx)[0]. + * The main use case is accessing Memory from edge with less overhead. + */ + EdgePtr getChildEdgeAt(size_t idx) const; + + MemoryPtr getSrcMemoryAtPort(size_t idx) const { + return getParentEdgeAt(idx)->getMemoryPtr(); + } + + MemoryPtr getDstMemoryAtPort(size_t idx) const { + return getChildEdgeAt(idx)->getMemoryPtr(); + } + + void* getSrcDataAtPort(size_t idx) const { + return getSrcMemoryAtPort(idx)->getData(); + } + + template + T* getSrcDataAtPortAs(size_t idx) const { + return getSrcMemoryAtPort(idx)->getDataAs(); + } + + void* getDstDataAtPort(size_t idx) const { + return getDstMemoryAtPort(idx)->getData(); + } + + template + T* getDstDataAtPortAs(size_t idx) const { + return getDstMemoryAtPort(idx)->getDataAs(); + } int inPlaceInputPort(int portIdx) const; int inPlaceOutPort(int portIdx) const; @@ -246,7 +297,7 @@ class Node { virtual void fuseInto(NodePtr& parentNode) { // The graph supports fusing only of consecutive nodes and some graph logic requires to know through which input port a node was fused into parent one. for (size_t i = 0; i < getParentEdges().size(); i++) { - if (getParentEdgesAtPort(i)[0]->getParent().get() == parentNode.get()) { + if (getParentEdgeAt(i)->getParent().get() == parentNode.get()) { setFusingPort(i); break; } @@ -255,7 +306,7 @@ class Node { auto parentFusedNodes = parentNode->getFusedWith(); if (getFusingPort() < 0 && !parentFusedNodes.empty()) { for (size_t i = 0; i < getParentEdges().size(); i++) { - if (getParentEdgesAtPort(i)[0]->getParent().get() == parentFusedNodes[parentFusedNodes.size() - 1].get()) { + if (getParentEdgeAt(i)->getParent().get() == parentFusedNodes[parentFusedNodes.size() - 1].get()) { setFusingPort(i); break; } @@ -266,7 +317,7 @@ class Node { OPENVINO_THROW("Cannot determine fusing port between nodes: ", parentNode->getName(), " and ", getName()); } - parentNode->addFusedNode(getParentEdgesAtPort(getFusingPort())[0]->getChild()); + parentNode->addFusedNode(getParentEdgeAt(getFusingPort())->getChild()); parentNode->addOriginalLayer(getOriginalLayers()); } @@ -574,6 +625,9 @@ class Node { NameFromType(getType())); return false; } + const bool keepOrigPrecision() const { + return keepOriginalPrecision; + } protected: bool canFuseSimpleOperation(const NodePtr& node) const; @@ -589,7 +643,7 @@ class Node { virtual AttrPtr initPrimitiveAttr() { return nullptr; } - typedef std::function + typedef std::function GetPrimitiveMemoryFormatFunc; std::vector internalBlobDesc; @@ -598,15 +652,23 @@ class Node { std::vector fusedWith; std::vector mergedWith; + std::string primitivesPriority; std::vector customImplPriorities; std::vector inputMemoryFormatsFilter; std::vector outputMemoryFormatsFilter; bool enforceBF16evenForGraphTail = false; + bool keepOriginalPrecision = false; std::string originalLayers; // contains names of the original layers separated by comma Node(const std::shared_ptr& op, const GraphContext::CPtr ctx, const ShapeInferFactory& shapeInferFactory); - Node(const std::string& type, const std::string& name, const GraphContext::CPtr ctx); + Node(const std::string& type, + std::vector inputShapes, + std::vector outputShapes, + std::vector originalInputPrecisions, + std::vector originalOutputPrecisions, + const std::string& name, + const GraphContext::CPtr ctx); int selectedPrimitiveDescriptorIndex = -1; @@ -709,6 +771,15 @@ class Node { std::shared_ptr shapeInference; + // we cannot rely on per-NUMA weightCache for caching weights because: + // 1.it may not exist(in single stream configuration) + // 2.it only holds weak references, the life-cycle of cached item + // is still under control of strong references outside of cache. + // privateWeightCache is for holding strong references to constant weight + // copies of same content with different layouts. + std::shared_ptr> privateWeightCache + = std::make_shared>(); + private: static void removeEdge(const EdgePtr edge, std::vector &edges) { edges.erase(std::remove_if(edges.begin(), edges.end(), @@ -744,13 +815,6 @@ class Node { // Hold output scales std::vector DQScales; - // we cannot rely on per-NUMA weightCache for caching weights because: - // 1.it may not exist(in single stream configuration) - // 2.it only holds weak references, the life-cycle of cached item - // is still under control of strong references outside of cache. - // privateWeightCache is for holding strong references to constant weight - // copies of same content with different layouts. - std::unordered_map privateWeightCache; CPU_DEBUG_CAP_ENABLE(friend class Verbose); }; diff --git a/src/plugins/intel_cpu/src/nodes/adaptive_pooling.cpp b/src/plugins/intel_cpu/src/nodes/adaptive_pooling.cpp index 9e66c9f31ce05a..7c2af831c4acd2 100644 --- a/src/plugins/intel_cpu/src/nodes/adaptive_pooling.cpp +++ b/src/plugins/intel_cpu/src/nodes/adaptive_pooling.cpp @@ -85,7 +85,7 @@ void AdaptivePooling::getSupportedDescriptors() { } bool AdaptivePooling::needShapeInfer() const { - const auto newSpatialDimsPtr = reinterpret_cast(getParentEdgesAtPort(1)[0]->getMemoryPtr()->getData()); + const auto newSpatialDimsPtr = getSrcDataAtPortAs(1); for (int i = 0; i < spatialDimsCount; i++) { if (static_cast(spatialDimsValue[i]) != newSpatialDimsPtr[i]) { for (size_t j = 0; j < spatialDimsValue.size(); j++) { @@ -139,7 +139,7 @@ void AdaptivePooling::execute(dnnl::stream strm) { int *indexDst = nullptr; if (algorithm == Algorithm::AdaptivePoolingMax) { - indexDst = reinterpret_cast(getChildEdgeAt(1)->getMemoryPtr()->getData()); + indexDst = getDstDataAtPortAs(1); } auto isPlainFmt = srcMemory0.getDesc().hasLayoutType(LayoutType::ncsp); @@ -149,9 +149,9 @@ void AdaptivePooling::execute(dnnl::stream strm) { auto srcBlockDesc = srcMemory0.getDescWithType(); int blockSize = isBlkFmt ? srcBlockDesc->getBlockDims().back() : 1; - const auto *src = reinterpret_cast(getParentEdgeAt(0)->getMemoryPtr()->getData()); - const auto *srcPooledSpatialShapes = reinterpret_cast(getParentEdgeAt(1)->getMemoryPtr()->getData()); - auto *dst = reinterpret_cast(getChildEdgeAt(0)->getMemoryPtr()->getData()); + const auto *src = getSrcDataAtPortAs(0); + const auto *srcPooledSpatialShapes = getSrcDataAtPortAs(1); + auto *dst = getDstDataAtPortAs(0); if (static_cast(srcMemory1.getShape().getElementsCount()) != spatialDimsCount) OPENVINO_THROW(errorPrefix, @@ -182,7 +182,7 @@ void AdaptivePooling::execute(dnnl::stream strm) { OPENVINO_THROW(errorPrefix, "doesn't have primitive descriptors."); auto config = selectedPrimitiveDescriptor->getConfig(); auto srcStrides = srcBlockDesc->getStrides(); - auto dstStrides = getChildEdgesAtPort(0)[0]->getMemory().getDescWithType()->getStrides(); + auto dstStrides = getChildEdgeAt(0)->getMemory().getDescWithType()->getStrides(); // unified strides array const size_t tailDimsOffset = (isTailCFmt ? -1 : 0); diff --git a/src/plugins/intel_cpu/src/nodes/batch_to_space.cpp b/src/plugins/intel_cpu/src/nodes/batch_to_space.cpp index 9bd499ccf092f7..ade66061ab2238 100644 --- a/src/plugins/intel_cpu/src/nodes/batch_to_space.cpp +++ b/src/plugins/intel_cpu/src/nodes/batch_to_space.cpp @@ -100,24 +100,24 @@ static std::vector getShape5D(const VectorDims &shape) { template void BatchToSpace::batchToSpaceKernel() { - const auto *srcData = reinterpret_cast(getParentEdgeAt(0)->getMemoryPtr()->getData()); - const auto *blockShapesPtr = reinterpret_cast(getParentEdgeAt(1)->getMemoryPtr()->getData()); - size_t dataRank = getParentEdgesAtPort(0)[0]->getMemoryPtr()->getShape().getRank(); + const auto *srcData = getSrcDataAtPortAs(0); + const auto *blockShapesPtr = getSrcDataAtPortAs(1); + size_t dataRank = getSrcMemoryAtPort(0)->getShape().getRank(); blockShapeIn.clear(); for (size_t i = 0; i < dataRank; i++) { blockShapeIn.push_back(*(blockShapesPtr + i)); } - const auto *padsBeginPtr = reinterpret_cast(getParentEdgeAt(2)->getMemoryPtr()->getData()); + const auto *padsBeginPtr = getSrcDataAtPortAs(2); cropsBeginIn.clear(); for (size_t i = 0; i < dataRank; i++) { cropsBeginIn.push_back(*(padsBeginPtr + i)); } - auto *dstData = reinterpret_cast(getChildEdgeAt(0)->getMemoryPtr()->getData()); + auto *dstData = getDstDataAtPortAs(0); - const auto &inDims = getParentEdgesAtPort(0)[0]->getMemory().getStaticDims(); - const auto &outDims = getChildEdgesAtPort(0)[0]->getMemory().getStaticDims(); + const auto &inDims = getParentEdgeAt(0)->getMemory().getStaticDims(); + const auto &outDims = getChildEdgeAt(0)->getMemory().getStaticDims(); auto srcDesc = getParentEdgeAt(0)->getMemory().getDescWithType(); diff --git a/src/plugins/intel_cpu/src/nodes/bin_conv.cpp b/src/plugins/intel_cpu/src/nodes/bin_conv.cpp index 3b745f2c2ca008..b08ee6a3d85e19 100644 --- a/src/plugins/intel_cpu/src/nodes/bin_conv.cpp +++ b/src/plugins/intel_cpu/src/nodes/bin_conv.cpp @@ -3,8 +3,6 @@ // #include "bin_conv.h" -#include "reorder.h" -#include "input.h" #include "eltwise.h" #include "fake_quantize.h" #include "conv.h" @@ -20,7 +18,7 @@ #include "cpu/x64/cpu_isa_traits.hpp" #include "utils/general_utils.h" #include "openvino/opsets/opset1.hpp" -#include "utils/cpu_utils.hpp" +#include "utils/ngraph_utils.hpp" // WA for xbyak.h #ifdef _WIN32 @@ -1021,9 +1019,9 @@ void BinaryConvolution::createPrimitive() { if (!selectedPrimitiveDescriptor) OPENVINO_THROW("CPU binary convolution with name '", getName(), "' doesn't have primitive descriptors."); - auto srcDims = getParentEdgesAtPort(0)[0]->getMemory().getStaticDims(); - auto weiDims = getParentEdgesAtPort(1)[0]->getMemory().getStaticDims(); - auto dstDims = getChildEdgesAtPort(0)[0]->getMemory().getStaticDims(); + auto srcDims = getParentEdgeAt(0)->getMemory().getStaticDims(); + auto weiDims = getParentEdgeAt(1)->getMemory().getStaticDims(); + auto dstDims = getChildEdgeAt(0)->getMemory().getStaticDims(); auto implType = selectedPrimitiveDescriptor->getImplementationType(); @@ -1116,7 +1114,7 @@ bool BinaryConvolution::canFuse(const NodePtr& node) const { if (node->getType() == Type::FakeQuantize) { bool ret = node->getAlgorithm() == Algorithm::FQBinarization; for (size_t i = 1; i < node->getParentEdges().size(); i++) { - ret &= node->getParentEdgesAtPort(i)[0]->getParent()->getChildEdges().size() == 1; + ret &= node->getParentEdgeAt(i)->getParent()->getChildEdges().size() == 1; } return ret; } else { @@ -1302,13 +1300,13 @@ void BinaryConvolution::executeReference(const uint8_t* src, const uint8_t* weig } void BinaryConvolution::execute(dnnl::stream strm) { - auto srcMemory = getParentEdgeAt(0)->getMemoryPtr(); - auto weightsMemory = getParentEdgeAt(1)->getMemoryPtr(); - auto dstMemory = getChildEdgeAt(0)->getMemoryPtr(); + auto srcMemory = getSrcMemoryAtPort(0); + auto weightsMemory = getSrcMemoryAtPort(1); + auto dstMemory = getDstMemoryAtPort(0); - auto src = reinterpret_cast(srcMemory->getData()); - auto weights = reinterpret_cast(weightsMemory->getData()); - auto dst = reinterpret_cast(dstMemory->getData()); + auto src = srcMemory->getDataAs(); + auto weights = weightsMemory->getDataAs(); + auto dst = dstMemory->getDataAs(); auto srcDesc = getParentEdgeAt(0)->getMemory().getDescWithType(); std::vector srcStride(srcDesc->getStrides().size()); diff --git a/src/plugins/intel_cpu/src/nodes/broadcast.cpp b/src/plugins/intel_cpu/src/nodes/broadcast.cpp index da35c38169a8d0..6f749411e2b209 100644 --- a/src/plugins/intel_cpu/src/nodes/broadcast.cpp +++ b/src/plugins/intel_cpu/src/nodes/broadcast.cpp @@ -2,17 +2,16 @@ // SPDX-License-Identifier: Apache-2.0 // -#include #include #include #include "dnnl_types.h" #include "openvino/core/parallel.hpp" -#include "utils/bfloat16.hpp" -#include "selective_build.h" +#include #include "broadcast.h" #include "nodes/common/blocked_desc_creator.h" #include "openvino/opsets/opset1.hpp" #include "common/cpu_memcpy.h" +#include "utils/ngraph_utils.hpp" namespace ov { namespace intel_cpu { @@ -114,17 +113,17 @@ bool Broadcast::needPrepareParams() const { void Broadcast::prepareParams() { if (!constMap[TARGET_SHAPE_IDX]) { - const auto& targetShapeMem = getParentEdgesAtPort(TARGET_SHAPE_IDX)[0]->getMemory(); - const int32_t* targetShapeData = reinterpret_cast(targetShapeMem.getData()); + const auto& targetShapeMem = getParentEdgeAt(TARGET_SHAPE_IDX)->getMemory(); + const int32_t* targetShapeData = targetShapeMem.getDataAs(); targetShape.assign(targetShapeData, targetShapeData + targetShapeMem.getStaticDims()[0]); } if (broadcastType == EXPLICIT && !constMap[AXES_MAPPING_IDX]) { - const auto& axesMapMem = getParentEdgesAtPort(AXES_MAPPING_IDX)[0]->getMemory(); - const int32_t* axesMapData = reinterpret_cast(axesMapMem.getData()); + const auto& axesMapMem = getParentEdgeAt(AXES_MAPPING_IDX)->getMemory(); + const int32_t* axesMapData = axesMapMem.getDataAs(); axesMapping.assign(axesMapData, axesMapData + axesMapMem.getStaticDims()[0]); } - const auto& srcDims = getParentEdgesAtPort(INPUT_DATA_IDX)[0]->getMemory().getShape().getStaticDims(); + const auto& srcDims = getParentEdgeAt(INPUT_DATA_IDX)->getMemory().getShape().getStaticDims(); repeats.assign(targetShape.begin(), targetShape.end()); const auto ndims = repeats.size(); @@ -160,7 +159,7 @@ bool Broadcast::needShapeInfer() const { if (targetShape.empty()) { return true; } - const int32_t* targetShapeData = reinterpret_cast(getParentEdgesAtPort(TARGET_SHAPE_IDX)[0]->getMemory().getData()); + const int32_t* targetShapeData = getParentEdgeAt(TARGET_SHAPE_IDX)->getMemory().getDataAs(); for (size_t i = 0lu; i < targetShape.size(); i++) { if (targetShape[i] != targetShapeData[i]) { return true; @@ -171,7 +170,7 @@ bool Broadcast::needShapeInfer() const { if (axesMapping.empty()) { return true; } - const int32_t* axesMappingData = reinterpret_cast(getParentEdgesAtPort(AXES_MAPPING_IDX)[0]->getMemory().getData()); + const int32_t* axesMappingData = getParentEdgeAt(AXES_MAPPING_IDX)->getMemory().getDataAs(); for (size_t i = 0lu; i < axesMapping.size(); i++) { if (axesMapping[i] != axesMappingData[i]) { return true; @@ -192,7 +191,7 @@ void Broadcast::executeDynamicImpl(dnnl::stream strm) { void Broadcast::execute(dnnl::stream strm) { if (optimizedCase) { - optimizedExecute(getParentEdgeAt(INPUT_DATA_IDX)->getMemoryPtr(), getChildEdgeAt(0)->getMemoryPtr()); + optimizedExecute(getSrcMemoryAtPort(INPUT_DATA_IDX), getDstMemoryAtPort(0)); } else { plainExecute(strm); } @@ -229,8 +228,8 @@ void Broadcast::plainExecute(dnnl::stream strm) { } const size_t workAmountDst = dstStrides[0] * dstDims[0]; - const auto *srcData = reinterpret_cast(getParentEdgeAt(INPUT_DATA_IDX)->getMemoryPtr()->getData()); - auto *dstData = reinterpret_cast(getChildEdgeAt(0)->getMemoryPtr()->getData()); + const auto *srcData = getSrcDataAtPortAs(INPUT_DATA_IDX); + auto *dstData = getDstDataAtPortAs(0); parallel_nt(0, [&](const int ithr, const int nthr) { size_t i = 0lu, srcIdx = 0lu, start = 0lu, end = 0lu; diff --git a/src/plugins/intel_cpu/src/nodes/bucketize.cpp b/src/plugins/intel_cpu/src/nodes/bucketize.cpp index 4f7a685432b337..2281bdab3592a6 100644 --- a/src/plugins/intel_cpu/src/nodes/bucketize.cpp +++ b/src/plugins/intel_cpu/src/nodes/bucketize.cpp @@ -186,9 +186,9 @@ void Bucketize::execute(dnnl::stream strm) { } void Bucketize::prepareParams() { - auto inputTensorMemPtr = getParentEdgeAt(INPUT_TENSOR_PORT)->getMemoryPtr(); - auto inputBinsMemPtr = getParentEdgeAt(INPUT_BINS_PORT)->getMemoryPtr(); - auto dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); + auto inputTensorMemPtr = getSrcMemoryAtPort(INPUT_TENSOR_PORT); + auto inputBinsMemPtr = getSrcMemoryAtPort(INPUT_BINS_PORT); + auto dstMemPtr = getDstMemoryAtPort(0); if (!dstMemPtr || !dstMemPtr->isAllocated()) OPENVINO_THROW("Destination memory didn't allocate."); if (!inputTensorMemPtr || !inputTensorMemPtr->isAllocated()) @@ -222,9 +222,9 @@ bool Bucketize::isExecutable() const { template void Bucketize::bucketize() { - const auto *input_data = reinterpret_cast(getParentEdgeAt(0)->getMemoryPtr()->getData()); - const auto *boundaries_data = reinterpret_cast(getParentEdgeAt(1)->getMemoryPtr()->getData()); - auto *output_data = reinterpret_cast(getChildEdgesAtPort(0)[0]->getMemoryPtr()->getData()); + const auto *input_data = getSrcDataAtPortAs(0); + const auto *boundaries_data = getSrcDataAtPortAs(1); + auto *output_data = getDstDataAtPortAs(0); if (!with_bins) { memset(output_data, 0, num_values * sizeof(T_IND)); diff --git a/src/plugins/intel_cpu/src/nodes/color_convert.cpp b/src/plugins/intel_cpu/src/nodes/color_convert.cpp index f3c5f8ae460ee3..9aaa3204d280e3 100644 --- a/src/plugins/intel_cpu/src/nodes/color_convert.cpp +++ b/src/plugins/intel_cpu/src/nodes/color_convert.cpp @@ -979,23 +979,23 @@ ColorConvert::Converter::Converter(Node *node, const ColorFormat & colorFormat) } ov::element::Type ColorConvert::Converter::inputPrecision(size_t idx) const { - return _node->getParentEdgesAtPort(idx)[0]->getMemory().getDesc().getPrecision(); + return _node->getParentEdgeAt(idx)->getMemory().getDesc().getPrecision(); } ov::element::Type ColorConvert::Converter::outputPrecision(size_t idx) const { - return _node->getChildEdgesAtPort(idx)[0]->getMemory().getDesc().getPrecision(); + return _node->getChildEdgeAt(idx)->getMemory().getDesc().getPrecision(); } const void * ColorConvert::Converter::input(size_t idx) const { - return _node->getParentEdgeAt(idx)->getMemoryPtr()->getData(); + return _node->getSrcDataAtPort(idx); } void * ColorConvert::Converter::output(size_t idx) const { - return _node->getChildEdgeAt(idx)->getMemoryPtr()->getData(); + return _node->getDstDataAtPort(idx); } const VectorDims & ColorConvert::Converter::inputDims(size_t idx) const { - return _node->getParentEdgesAtPort(idx)[0]->getMemory().getStaticDims(); + return _node->getParentEdgeAt(idx)->getMemory().getStaticDims(); } bool ColorConvert::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { diff --git a/src/plugins/intel_cpu/src/nodes/common/dnnl_executor.h b/src/plugins/intel_cpu/src/nodes/common/dnnl_executor.h index 282b38567ab272..8e29d78217d9dd 100644 --- a/src/plugins/intel_cpu/src/nodes/common/dnnl_executor.h +++ b/src/plugins/intel_cpu/src/nodes/common/dnnl_executor.h @@ -6,6 +6,7 @@ #include #include +#include "memory_desc/dnnl_memory_desc.h" namespace ov { namespace intel_cpu { diff --git a/src/plugins/intel_cpu/src/nodes/common/tile_broadcast_utils.cpp b/src/plugins/intel_cpu/src/nodes/common/tile_broadcast_utils.cpp index ec8a0a3ff368ef..282a9d339c6640 100644 --- a/src/plugins/intel_cpu/src/nodes/common/tile_broadcast_utils.cpp +++ b/src/plugins/intel_cpu/src/nodes/common/tile_broadcast_utils.cpp @@ -253,8 +253,8 @@ void TileBroadcastCommon::broadcastScalar(const char *srcData, char *dstData, si } void TileBroadcastCommon::optimizedExecute(const MemoryPtr& srcMemory, const MemoryPtr& dstMemory) { - auto srcData = reinterpret_cast(srcMemory->getData()); - auto dstData = reinterpret_cast(dstMemory->getData()); + auto srcData = srcMemory->getDataAs(); + auto dstData = dstMemory->getDataAs(); if (srcMemory->getStaticDims() == dstMemory->getStaticDims()) { const auto prc = dstMemory->getDesc().getPrecision(); @@ -266,7 +266,7 @@ void TileBroadcastCommon::optimizedExecute(const MemoryPtr& srcMemory, const Mem if (optimizedParams.dstStrides[0] == optimizedParams.dims[5] * optimizedParams.dstStrides[5]) { size_t data_size = optimizedParams.dstStrides[5]; size_t elt_cnt = optimizedParams.dims[5]; - auto srcData_i32 = reinterpret_cast(srcMemory->getData()); + auto srcData_i32 = srcMemory->getDataAs(); if (data_size == 1) { memset(dstData, srcData[0], elt_cnt); } else if (data_size == 4 && srcData_i32[0] == 0) { diff --git a/src/plugins/intel_cpu/src/nodes/concat.cpp b/src/plugins/intel_cpu/src/nodes/concat.cpp index b50cfb13949bcd..0b2fa32a2ae0e4 100644 --- a/src/plugins/intel_cpu/src/nodes/concat.cpp +++ b/src/plugins/intel_cpu/src/nodes/concat.cpp @@ -4,6 +4,8 @@ #include "concat.h" +#include "openvino/op/concat.hpp" + #include #include #include @@ -14,11 +16,6 @@ #include #include #include "openvino/core/parallel.hpp" -#include "conv.h" -#include "fake_quantize.h" -#include "pooling.h" -#include "eltwise.h" -#include #include "common/cpu_memcpy.h" #include "common/blocked_desc_creator.h" #include @@ -318,7 +315,7 @@ void Concat::prepareParams() { if (canOptimizeNspc || isInPlace()) return; - const auto& dstMemPtr = getChildEdgesAtPort(0)[0]->getMemoryPtr(); + const auto& dstMemPtr = getDstMemoryAtPort(0); if (!dstMemPtr || !dstMemPtr->isAllocated()) OPENVINO_THROW("Destination memory didn't allocate."); auto dstMemDesc = dstMemPtr->getDescWithType(); @@ -328,7 +325,7 @@ void Concat::prepareParams() { const auto& outputStrides = dstMemDesc->getStrides(); size_t curConcatOffset = 0; const size_t elemSize = DnnlExtensionUtils::sizeOfDataType(dstMemPtr->getDataType()); - const auto& src0BlkMemDesc = getParentEdgesAtPort(0)[0]->getMemoryPtr()->getDescPtr()->as(); + const auto& src0BlkMemDesc = getSrcMemoryAtPort(0)->getDescPtr()->as(); const auto& outputOrder = src0BlkMemDesc->getOrder(); for (size_t i = 0; i < outputOrder.size(); i++) { if (outputOrder[i] == axis) { @@ -349,7 +346,7 @@ void Concat::prepareParams() { // in this case, inputs are also small 1d vector and single thread naive impl is faster canOptimize1DCase = true; for (size_t i = 0; i < getParentEdges().size(); i++) { - const auto& srcMemPtr = getParentEdgesAtPort(i)[0]->getMemoryPtr(); + const auto& srcMemPtr = getSrcMemoryAtPort(i); const auto srcMemDesc = srcMemPtr->getDescPtr()->as(); const auto& inputShape = srcMemDesc->getBlockDims(); const auto& strides = srcMemDesc->getStrides(); @@ -364,7 +361,7 @@ void Concat::prepareParams() { std::vector srcs_d; for (size_t i = 0; i < getParentEdges().size(); i++) { - const auto& srcMemPtr = getParentEdgesAtPort(i)[0]->getMemoryPtr(); + const auto& srcMemPtr = getSrcMemoryAtPort(i); if (!srcMemPtr || !srcMemPtr->isAllocated()) { auto parent = getParentEdgeAt(i)->getParent(); OPENVINO_THROW("Source memory from ", parent->getName(), " didn't allocate for node ", getName(), "."); @@ -489,7 +486,7 @@ void Concat::execute(dnnl::stream strm) { std::unordered_map mem_ags {{DNNL_ARG_DST, dst_memory.getPrimitive()}}; size_t nonZeroInShapes = 0; for (size_t i = 0; i < num_src; i++) { - const auto& srcMem = getParentEdgesAtPort(i)[0]->getMemory(); + const auto& srcMem = getParentEdgeAt(i)->getMemory(); if (srcMem.getShape().hasZeroDims()) { continue; } @@ -520,7 +517,7 @@ void Concat::exec1DCase() { void Concat::execNspcSpecCase() { const auto& dst_memory = getChildEdgeAt(0)->getMemory(); const size_t num_src = getParentEdges().size(); - uint8_t* dst_ptr = reinterpret_cast(dst_memory.getData()); + uint8_t* dst_ptr = dst_memory.getDataAs(); const size_t dataSize = DnnlExtensionUtils::sizeOfDataType(dst_memory.getDataType()); std::vector channelsDataSize; @@ -531,14 +528,14 @@ void Concat::execNspcSpecCase() { size_t nonZeroInShapes = 0; int firstNonZeroEdge = -1; for (size_t i = 0; i < num_src; i++) { - const auto& src_mem = getParentEdgesAtPort(i)[0]->getMemory(); + const auto& src_mem = getParentEdgeAt(i)->getMemory(); if (src_mem.getShape().hasZeroDims()) { continue; } const size_t num_channels = src_mem.getStaticDims()[channelAxis]; channelsDataSize.push_back(num_channels * dataSize); - src_ptrs.push_back(reinterpret_cast(src_mem.getData())); + src_ptrs.push_back(src_mem.getDataAs()); dst_ptrs.push_back(dst_ptr + channels_size); channels_size += num_channels * dataSize; @@ -565,10 +562,10 @@ void Concat::execRef() { const size_t elemSize = DnnlExtensionUtils::sizeOfDataType(dstMemory.getDataType()); const auto dstMemBlkDesc = dstMemory.getDescPtr()->as(); const auto& outputShape = dstMemBlkDesc->getBlockDims(); - uint8_t* dstPtr = reinterpret_cast(dstMemory.getData()); + uint8_t* dstPtr = dstMemory.getDataAs(); for (size_t i = 0; i < numSrc; i++) { - const auto& srcMem = getParentEdgesAtPort(i)[0]->getMemory(); - srcPtrs[i] = reinterpret_cast(srcMem.getData()); + const auto& srcMem = getParentEdgeAt(i)->getMemory(); + srcPtrs[i] = srcMem.getDataAs(); } size_t outputStrides[MAX_RANK_REF] = {0}; @@ -679,7 +676,7 @@ void Concat::resolveInPlaceEdges(Edge::LOOK look) { getName(), " can't use inPlace memory with concatenation on dynamic dimension"); - auto& edges = getChildEdgesAtPort(inplaceOutIndx); + auto edges = getChildEdgesAtPort(inplaceOutIndx); auto itr = std::find_if(edges.begin(), edges.end(), [](const EdgePtr& edge) { return edge->getStatus() == Edge::Status::Allocated; }); OPENVINO_ASSERT(itr != edges.end(), " Could not find allocated child edge for concat node: " , getName()); diff --git a/src/plugins/intel_cpu/src/nodes/conv.cpp b/src/plugins/intel_cpu/src/nodes/conv.cpp index a1eb6f49e9900f..a70d2525f68a93 100644 --- a/src/plugins/intel_cpu/src/nodes/conv.cpp +++ b/src/plugins/intel_cpu/src/nodes/conv.cpp @@ -4,6 +4,8 @@ #include "conv.h" +#include "openvino/op/convolution.hpp" +#include "openvino/op/group_conv.hpp" #include "common/c_types_map.hpp" #include "common/cpu_convert.h" #include "common/primitive_desc.hpp" @@ -330,60 +332,65 @@ ov::element::Type Convolution::fusedEltwisePrecision(const NodePtr& fusingNode) } const std::vector& Convolution::getDefaultImplPriority() { - static std::vector priorities = { - impl_desc_type::unknown, - impl_desc_type::dw_acl, - impl_desc_type::winograd_acl, - impl_desc_type::gemm_acl, - impl_desc_type::acl, - impl_desc_type::brgconv_avx512_amx_1x1, - impl_desc_type::brgconv_avx512_amx, - impl_desc_type::jit_avx512_amx_dw, - impl_desc_type::jit_avx512_amx_1x1, - impl_desc_type::jit_avx512_amx, - impl_desc_type::brgconv_avx512_1x1, - impl_desc_type::brgconv_avx512, - impl_desc_type::jit_uni_dw, - impl_desc_type::jit_uni_1x1, - impl_desc_type::jit_uni, - impl_desc_type::jit_avx512_dw, - impl_desc_type::jit_avx512_1x1, - impl_desc_type::jit_avx512, - impl_desc_type::brgconv_avx2_1x1, - impl_desc_type::brgconv_avx2, - impl_desc_type::jit_avx2_dw, - impl_desc_type::jit_avx2_1x1, - impl_desc_type::jit_avx2, - impl_desc_type::jit_avx_dw, - impl_desc_type::jit_avx_1x1, - impl_desc_type::jit_avx, - impl_desc_type::jit_sse42_dw, - impl_desc_type::jit_sse42_1x1, - impl_desc_type::jit_sse42, - impl_desc_type::gemm_any, - impl_desc_type::gemm_blas, - impl_desc_type::gemm_avx512, - impl_desc_type::gemm_avx2, - impl_desc_type::gemm_avx, - impl_desc_type::gemm_sse42, - impl_desc_type::jit_gemm, - impl_desc_type::ref_any, - impl_desc_type::ref, - }; + static const auto priorities = [] { + std::vector priorities = { + impl_desc_type::unknown, + impl_desc_type::dw_acl, + impl_desc_type::winograd_acl, + impl_desc_type::gemm_acl, + impl_desc_type::acl, + impl_desc_type::brgconv_avx512_amx_1x1, + impl_desc_type::brgconv_avx512_amx, + impl_desc_type::jit_avx512_amx_dw, + impl_desc_type::jit_avx512_amx_1x1, + impl_desc_type::jit_avx512_amx, + impl_desc_type::brgconv_avx512_1x1, + impl_desc_type::brgconv_avx512, + impl_desc_type::jit_avx512_dw, + impl_desc_type::jit_avx512_1x1, + impl_desc_type::jit_avx512, + impl_desc_type::brgconv_avx2_1x1, + impl_desc_type::brgconv_avx2, + impl_desc_type::jit_uni_dw, + impl_desc_type::jit_uni_1x1, + impl_desc_type::jit_uni, + impl_desc_type::jit_avx2_dw, + impl_desc_type::jit_avx2_1x1, + impl_desc_type::jit_avx2, + impl_desc_type::jit_avx_dw, + impl_desc_type::jit_avx_1x1, + impl_desc_type::jit_avx, + impl_desc_type::jit_sse42_dw, + impl_desc_type::jit_sse42_1x1, + impl_desc_type::jit_sse42, + impl_desc_type::gemm_any, + impl_desc_type::gemm_blas, + impl_desc_type::gemm_avx512, + impl_desc_type::gemm_avx2, + impl_desc_type::gemm_avx, + impl_desc_type::gemm_sse42, + impl_desc_type::jit_gemm, + impl_desc_type::ref_any, + impl_desc_type::ref, + }; + if (!isBrgConvAvailable()) { + priorities.erase(std::remove_if(priorities.begin(), + priorities.end(), + [](impl_desc_type type) { + return type & impl_desc_type::brgconv; + }), + priorities.end()); + } - priorities.erase(std::remove_if(priorities.begin(), - priorities.end(), - [](impl_desc_type type) { - return !isBrgConvAvailable() && (type & impl_desc_type::brgconv); - }), - priorities.end()); + return priorities; + }(); return priorities; } const bool Convolution::isBrgConvAvailable() { static const bool isBrgConvAvailable = dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx512_core) || - dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx2_vnni_2); + dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx2); return isBrgConvAvailable; } @@ -559,7 +566,6 @@ void Convolution::getSupportedDescriptors() { outputDataType = memory::data_type::f32; eltwisePrecision = ov::element::f32; } - SetPostOpsAndZeroPoints(attrs); if (!one_of(ndims, 3, 4, 5)) @@ -627,7 +633,7 @@ void Convolution::setPostOps(dnnl::primitive_attr& attr, bool isINT8 = canBeExecutedInInt8(); // Weight dims in NON-Group CONV: [OC, IC, KH, KW], perchannel weight scale applied on OC DIM, weiScaleMaskPerChannel = 1 << 0 // Weight dims in Group CONV:[Group, OC, IC, KH, KW], perchannel weight scale applied on GROUP and OC DIM, weiScaleMaskPerChannel = ( 1 << 0 | 1<< 1) = 0x03 - DnnlPostOpsComposer dnnlpoc(getEngine(), attr, ops, args, dims, 1, isINT8, isGrouped ? 3 : 1 << 0, getDQScales(), withBiases); + DnnlPostOpsComposerLegacy dnnlpoc(getEngine(), attr, ops, args, dims, 1, isINT8, isGrouped ? 3 : 1 << 0, getDQScales(), withBiases); DEBUG_LOG(getName(), " useLegacyPostOps=", useLegacyPostOps, " initWeights=", initWeights); @@ -706,8 +712,8 @@ void Convolution::setPostOps(dnnl::primitive_attr& attr, auto* convolutionNode = dynamic_cast(node.get()); if (convolutionNode) { if (initWeights) { - args[DNNL_ARG_ATTR_POST_OP_DW | DNNL_ARG_WEIGHTS] = getParentEdgeAt(getOriginalInputsNumber() + 0)->getMemoryPtr(); - args[DNNL_ARG_ATTR_POST_OP_DW | DNNL_ARG_BIAS] = getParentEdgeAt(getOriginalInputsNumber() + 1)->getMemoryPtr(); + args[DNNL_ARG_ATTR_POST_OP_DW | DNNL_ARG_WEIGHTS] = getSrcMemoryAtPort(getOriginalInputsNumber() + 0); + args[DNNL_ARG_ATTR_POST_OP_DW | DNNL_ARG_BIAS] = getSrcMemoryAtPort(getOriginalInputsNumber() + 1); DEBUG_LOG(getName(), ": Append ", node->getName(), " as DW convolution"); // todo: rewrite onto append_dw_k3s2p1 @@ -1205,8 +1211,8 @@ bool Convolution::isNspcAvailable() const { } void Convolution::prepareParams() { - auto srcMemPtr = getParentEdgesAtPort(0)[0]->getMemoryPtr(); - auto wghMemPtr = getParentEdgesAtPort(1)[0]->getMemoryPtr(); + auto srcMemPtr = getSrcMemoryAtPort(0); + auto wghMemPtr = getSrcMemoryAtPort(1); auto dstMemPtr = getOutputMemory(); if (!dstMemPtr || !dstMemPtr->isAllocated()) OPENVINO_THROW("Destination memory was not allocated."); @@ -1216,7 +1222,7 @@ void Convolution::prepareParams() { OPENVINO_THROW("Weight memory was not allocated."); MemoryPtr biasMemPtr = nullptr; if (withBiases) { - biasMemPtr = getParentEdgesAtPort(2)[0]->getMemoryPtr(); + biasMemPtr = getSrcMemoryAtPort(2); if (!biasMemPtr || !biasMemPtr->isAllocated()) OPENVINO_THROW("Input memory didn't allocate."); } @@ -1505,16 +1511,16 @@ void Convolution::executeDynamicImpl(dnnl::stream strm) { getName()); } const size_t sumPortNum = getParentEdges().size() - 1; - const auto& sumInpMem = getParentEdgesAtPort(sumPortNum).front()->getMemory(); + const auto& sumInpMem = getParentEdgeAt(sumPortNum)->getMemory(); auto inp1 = subgraph->getInput(1); - auto inp1Mem = inp1->getChildEdgesAtPort(0).front()->getMemoryPtr(); + auto inp1Mem = inp1->getDstMemoryAtPort(0); inp1Mem->getMemoryMngr()->setExtBuff(sumInpMem.getData(), sumInpMem.getSize()); subgraph->infer(); auto out = subgraph->getOutput(0); - const auto& outMem = out->getParentEdgesAtPort(0).front()->getMemory(); - auto convOutMem = getChildEdgesAtPort(0).front()->getMemoryPtr(); + const auto& outMem = out->getParentEdgeAt(0)->getMemory(); + auto convOutMem = getDstMemoryAtPort(0); Node::redefineOutputMemory({outMem.getStaticDims()}); convOutMem->load(outMem); } @@ -1531,7 +1537,7 @@ void Convolution::updatePadding() { void Convolution::redefineOutputMemory(const std::vector &newOutputShapes) { if (withSum) { const size_t sumPortNum = getParentEdges().size() - 1; - const auto& sumInpMem = getParentEdgesAtPort(sumPortNum).front()->getMemory(); + const auto& sumInpMem = getParentEdgeAt(sumPortNum)->getMemory(); if (newOutputShapes.front() != sumInpMem.getStaticDims()) { withSumBroadcast = true; if (!subgraph) { @@ -1588,9 +1594,9 @@ MemoryPtr Convolution::getOutputMemory() const { getName()); } auto inp0 = subgraph->getInput(0); - return inp0->getChildEdgesAtPort(0).front()->getMemoryPtr(); + return inp0->getDstMemoryAtPort(0); } else { - return getChildEdgesAtPort(0).front()->getMemoryPtr(); + return getDstMemoryAtPort(0); } } @@ -1604,7 +1610,7 @@ void Convolution::addFusedNode(const NodePtr &fusingNode) { } if (withSum && isDynamicNode()) { for (size_t i = 0; i < fusingNode->getParentEdges().size(); ++i) { - auto edge = fusingNode->getParentEdgesAtPort(i).front(); + auto edge = fusingNode->getParentEdgeAt(i); auto parent = edge->getParent(); if ("Constant" == parent->getTypeStr()) { fusedConstNodes[fusingNode].push_back(parent); @@ -1645,6 +1651,7 @@ void Convolution::initializeInputZeroPoints(const uint8_t* inputZpData, const si inputZeroPointType = zpType::PerChannel; } // Only enable per-tensor zero point on avx512-amx and avx512-core-vnni, avx2_vnni_2. + // avx2_vnni is not enabled per-tensor z because of perf regression brgconv with per-tensor zpcompared with jit per-channel zp // If zero point is pertensor, both legacy zp and stock zp // would be passed into conv node. The conv node would determine how to create // post-ops attribute and prioritize to choose final onednn kernel. diff --git a/src/plugins/intel_cpu/src/nodes/convert.cpp b/src/plugins/intel_cpu/src/nodes/convert.cpp index 1f7f0b2f0d43a3..7251e19f0f1acf 100644 --- a/src/plugins/intel_cpu/src/nodes/convert.cpp +++ b/src/plugins/intel_cpu/src/nodes/convert.cpp @@ -43,12 +43,8 @@ Convert::Convert(const std::shared_ptr& op, const GraphContext::CPtr c Convert::Convert(const Shape &shape, const ov::element::Type &inPrc, const ov::element::Type &outPrc, const std::string &nodeName, const GraphContext::CPtr context) - : Node("Convert", nodeName, context) { + : Node("Convert", {shape}, {shape}, {inPrc}, {outPrc}, nodeName, context) { convertParams.origPrc = outPrc; - inputShapes.push_back(shape); - addOriginalInputPrecision(inPrc); - outputShapes.push_back(shape); - addOriginalOutputPrecision(outPrc); isDynamic = shape.isDynamic(); if (isDynamicNode()) { @@ -154,13 +150,13 @@ void Convert::prepareParams() { convertParams.size = parentMem.getDescWithType()->getPaddedElementsCount(); auto selectedPD = getSelectedPrimitiveDescriptor(); - MemoryDescPtr srcDesc = getParentEdgeAt(0)->getMemoryPtr()->getDescPtr(); - MemoryDescPtr dstDesc = getChildEdgeAt(0)->getMemoryPtr()->getDescPtr(); + MemoryDescPtr srcDesc = getSrcMemoryAtPort(0)->getDescPtr(); + MemoryDescPtr dstDesc = getDstMemoryAtPort(0)->getDescPtr(); execPtr = selectedPD->getExecutorFactoryAs()->makeExecutor(convertParams, srcDesc, dstDesc, {}); - selectedPD->setImplementationType(execPtr->getImplType()); + selectedPD->setImplementationType(execPtr->implType()); } void Convert::executeDynamicImpl(dnnl::stream strm) { @@ -177,9 +173,9 @@ void Convert::execute(dnnl::stream strm) { if (parentPaddElemCount != childPaddElemCount) OPENVINO_THROW(errorPrefix, " has different elements number in input and output buffers"); - MemoryCPtr srcMemory = getParentEdgeAt(0)->getMemoryPtr(); - MemoryPtr dstMemory = getChildEdgeAt(0)->getMemoryPtr(); - execPtr->exec(srcMemory, dstMemory); + MemoryCPtr srcMemory = getSrcMemoryAtPort(0); + MemoryPtr dstMemory = getDstMemoryAtPort(0); + execPtr->exec({srcMemory}, {dstMemory}); } bool Convert::created() const { diff --git a/src/plugins/intel_cpu/src/nodes/convert.h b/src/plugins/intel_cpu/src/nodes/convert.h index 568326f5983834..82a059a36ddbbb 100644 --- a/src/plugins/intel_cpu/src/nodes/convert.h +++ b/src/plugins/intel_cpu/src/nodes/convert.h @@ -15,7 +15,7 @@ class Convert : public Node { public: Convert(const std::shared_ptr& op, const GraphContext::CPtr context); Convert(const Shape &shape, const ov::element::Type &inPrc, const ov::element::Type &outPrc, - const std::string &nodeName, const GraphContext::CPtr context); + const std::string &nodeName, const GraphContext::CPtr context); void getSupportedDescriptors() override; void initSupportedPrimitiveDescriptors() override; diff --git a/src/plugins/intel_cpu/src/nodes/ctc_greedy_decoder.cpp b/src/plugins/intel_cpu/src/nodes/ctc_greedy_decoder.cpp index ce4419b0a749df..b391e038e69dbd 100644 --- a/src/plugins/intel_cpu/src/nodes/ctc_greedy_decoder.cpp +++ b/src/plugins/intel_cpu/src/nodes/ctc_greedy_decoder.cpp @@ -68,9 +68,9 @@ void CTCGreedyDecoder::initSupportedPrimitiveDescriptors() { } void CTCGreedyDecoder::execute(dnnl::stream strm) { - const float* probabilities = reinterpret_cast(getParentEdgeAt(DATA_INDEX)->getMemoryPtr()->getData()); - const float* sequenceMask = reinterpret_cast(getParentEdgeAt(SEQUENCE_LENGTH_INDEX)->getMemoryPtr()->getData()); - float* outputSequences = reinterpret_cast(getChildEdgesAtPort(0)[0]->getMemoryPtr()->getData()); + const float* probabilities = getSrcDataAtPortAs(DATA_INDEX); + const float* sequenceMask = getSrcDataAtPortAs(SEQUENCE_LENGTH_INDEX); + float* outputSequences = getDstDataAtPortAs(0); const size_t T = getParentEdgeAt(DATA_INDEX)->getMemory().getStaticDims()[0]; const size_t B = getParentEdgeAt(DATA_INDEX)->getMemory().getStaticDims()[1]; diff --git a/src/plugins/intel_cpu/src/nodes/ctc_greedy_decoder_seq_len.cpp b/src/plugins/intel_cpu/src/nodes/ctc_greedy_decoder_seq_len.cpp index c67707fc347987..c2eba1d3fe1251 100644 --- a/src/plugins/intel_cpu/src/nodes/ctc_greedy_decoder_seq_len.cpp +++ b/src/plugins/intel_cpu/src/nodes/ctc_greedy_decoder_seq_len.cpp @@ -73,10 +73,10 @@ void CTCGreedyDecoderSeqLen::initSupportedPrimitiveDescriptors() { } void CTCGreedyDecoderSeqLen::execute(dnnl::stream strm) { - const float* probabilities = reinterpret_cast(getParentEdgeAt(DATA_INDEX)->getMemoryPtr()->getData()); - const int* sequenceLengths = reinterpret_cast(getParentEdgeAt(SEQUENCE_LENGTH_INDEX)->getMemoryPtr()->getData()); - int* decodedClasses = reinterpret_cast(getChildEdgesAtPort(DECODED_CLASSES_INDEX)[0]->getMemoryPtr()->getData()); - int* decodedClassesLength = reinterpret_cast(getChildEdgesAtPort(DECODED_CLASSES_LENGTH_INDEX)[0]->getMemoryPtr()->getData()); + const float* probabilities = getSrcDataAtPortAs(DATA_INDEX); + const int* sequenceLengths = getSrcDataAtPortAs(SEQUENCE_LENGTH_INDEX); + int* decodedClasses = getDstDataAtPortAs(DECODED_CLASSES_INDEX); + int* decodedClassesLength = getDstDataAtPortAs(DECODED_CLASSES_LENGTH_INDEX); const size_t B = getParentEdgeAt(DATA_INDEX)->getMemory().getStaticDims()[0];; const size_t T = getParentEdgeAt(DATA_INDEX)->getMemory().getStaticDims()[1];; @@ -85,7 +85,7 @@ void CTCGreedyDecoderSeqLen::execute(dnnl::stream strm) { int blankIndex = C - 1; if (inputShapes.size() > BLANK_INDEX) - blankIndex = (reinterpret_cast(getParentEdgeAt(BLANK_INDEX)->getMemoryPtr()->getData()))[0]; + blankIndex = (getSrcDataAtPortAs(BLANK_INDEX))[0]; size_t workAmount = 0; for (size_t b = 0; b < B; b++) { @@ -93,7 +93,7 @@ void CTCGreedyDecoderSeqLen::execute(dnnl::stream strm) { std::string errorMsg = errorPrefix + ". Sequence length " + std::to_string(sequenceLengths[b]) + " cannot be greater than according decoded classes dimension size " - + std::to_string(getChildEdgesAtPort(DECODED_CLASSES_INDEX)[0]->getMemory().getStaticDims()[1]); + + std::to_string(getChildEdgeAt(DECODED_CLASSES_INDEX)->getMemory().getStaticDims()[1]); OPENVINO_THROW(errorMsg); } workAmount += sequenceLengths[b]; diff --git a/src/plugins/intel_cpu/src/nodes/ctc_loss.cpp b/src/plugins/intel_cpu/src/nodes/ctc_loss.cpp index 928eeaf33e3cef..88e1a08c8e7da9 100644 --- a/src/plugins/intel_cpu/src/nodes/ctc_loss.cpp +++ b/src/plugins/intel_cpu/src/nodes/ctc_loss.cpp @@ -65,11 +65,11 @@ void CTCLoss::executeDynamicImpl(dnnl::stream strm) { void CTCLoss::execute(dnnl::stream strm) { int32_t returnCode = 0; - const float* logits = reinterpret_cast(getParentEdgeAt(0)->getMemoryPtr()->getData()); - const int* logitsLength = reinterpret_cast(getParentEdgeAt(1)->getMemoryPtr()->getData()); - const int* labels = reinterpret_cast(getParentEdgeAt(2)->getMemoryPtr()->getData()); - const int* labelsLength = reinterpret_cast(getParentEdgeAt(3)->getMemoryPtr()->getData()); - float* dstData = reinterpret_cast(getChildEdgesAtPort(0)[0]->getMemoryPtr()->getData()); + const float* logits = getSrcDataAtPortAs(0); + const int* logitsLength = getSrcDataAtPortAs(1); + const int* labels = getSrcDataAtPortAs(2); + const int* labelsLength = getSrcDataAtPortAs(3); + float* dstData = getDstDataAtPortAs(0); const auto &inDims = getParentEdgeAt(0)->getMemory().getStaticDims(); const size_t batchNum = inDims[0]; @@ -78,7 +78,7 @@ void CTCLoss::execute(dnnl::stream strm) { int blankIndex = classesNum - 1; if (inputShapes.size() > 4) { - blankIndex = reinterpret_cast(getParentEdgeAt(4)->getMemoryPtr()->getData())[0]; + blankIndex = getSrcDataAtPortAs(4)[0]; } std::vector decodedTargetLenB(batchNum, 0); diff --git a/src/plugins/intel_cpu/src/nodes/cum_sum.cpp b/src/plugins/intel_cpu/src/nodes/cum_sum.cpp index d447da61de6754..946eab1ba223d3 100644 --- a/src/plugins/intel_cpu/src/nodes/cum_sum.cpp +++ b/src/plugins/intel_cpu/src/nodes/cum_sum.cpp @@ -109,8 +109,8 @@ void CumSum::execute(dnnl::stream strm) { template void CumSum::exec() { - const auto *input = reinterpret_cast(getParentEdgeAt(CUM_SUM_DATA)->getMemoryPtr()->getData()); - auto *output = reinterpret_cast(getChildEdgesAtPort(0)[0]->getMemoryPtr()->getData()); + const auto *input = getSrcDataAtPortAs(CUM_SUM_DATA); + auto *output = getDstDataAtPortAs(0); const VectorDims strides = getParentEdgeAt(CUM_SUM_DATA)->getMemory().getDescWithType()->getStrides(); if (reverse) { @@ -132,7 +132,7 @@ template void CumSum::cumSum(const dataType *input, dataType *output, const VectorDims &strides) { VectorDims iterationRange(numOfDims - 1); size_t j = 0; - const auto &shape = getParentEdgesAtPort(CUM_SUM_DATA)[0]->getMemory().getStaticDims(); + const auto &shape = getParentEdgeAt(CUM_SUM_DATA)->getMemory().getStaticDims(); for (size_t i = 0; i < shape.size(); i++) { if (i == axis) continue; @@ -232,12 +232,12 @@ size_t CumSum::getAxis(const IMemory& _axis, const IMemory& _data) const { int64_t axisValueFromBlob = 0; switch (axisPrecision) { case ov::element::i32 : { - const auto *axisPtr = reinterpret_cast(_axis.getData()); + const auto *axisPtr = _axis.getDataAs(); axisValueFromBlob = static_cast(axisPtr[0]); break; } case ov::element::i64 : { - const auto *axisPtr = reinterpret_cast(_axis.getData()); + const auto *axisPtr = _axis.getDataAs(); axisValueFromBlob = axisPtr[0]; break; } diff --git a/src/plugins/intel_cpu/src/nodes/deconv.cpp b/src/plugins/intel_cpu/src/nodes/deconv.cpp index cf52ba0e0ff6e3..3e92fbcd7112f0 100644 --- a/src/plugins/intel_cpu/src/nodes/deconv.cpp +++ b/src/plugins/intel_cpu/src/nodes/deconv.cpp @@ -481,11 +481,13 @@ void Deconvolution::getSupportedDescriptors() { config.outConfs.resize(getOriginalOutputsNumber()); for (size_t i = 0; i < getParentEdges().size(); ++i) { + //force f32 precision to avoid reference inference (CVS-114087) config.inConfs[i].setMemDesc( - creatorsMap.at(format)->createSharedDesc(getOriginalInputPrecisionAtPort(i), getInputShapeAtPort(i))); + creatorsMap.at(format)->createSharedDesc(ov::element::f32, getInputShapeAtPort(i))); } + //force f32 precision to avoid reference inference (CVS-114087) config.outConfs[0].setMemDesc( - creatorsMap.at(format)->createSharedDesc(getOriginalOutputPrecisionAtPort(0), getOutputShapeAtPort(0))); + creatorsMap.at(format)->createSharedDesc(ov::element::f32, getOutputShapeAtPort(0))); std::vector srcMemoryDescs; for (size_t i = 0; i < config.inConfs.size(); i++) { @@ -555,7 +557,7 @@ void Deconvolution::setPostOps(dnnl::primitive_attr& attr, const VectorDims& dim // weiScaleMaskPerChannel = 1 << 0 // Weight dims in Group deconv: [Group, Deconv_OC, Deconv_IC, KH, KW], perchannel weight scale is applied on GROUP and Deconv_OC, // weiScaleMaskPerChannel = ( 1 << 0 | 1 << 1) = 0x03 - DnnlPostOpsComposer dnnlpoc(getEngine(), attr, ops, postOpsArgs, dims, 1, isInt8, withGroups ? 3 : 1 << 0, getDQScales(), withBiases); + DnnlPostOpsComposerLegacy dnnlpoc(getEngine(), attr, ops, postOpsArgs, dims, 1, isInt8, withGroups ? 3 : 1 << 0, getDQScales(), withBiases); for (size_t i = 0; i < fusedWith.size(); ++i) { auto& node = fusedWith[i]; @@ -644,11 +646,11 @@ void Deconvolution::execute(dnnl::stream strm) { if (useACL) { std::vector srcMemory; for (size_t i = 0; i < getOriginalInputsNumber(); i++) { - srcMemory.push_back(getParentEdgeAt(i)->getMemoryPtr()); + srcMemory.push_back(getSrcMemoryAtPort(i)); } std::vector dstMemory; for (size_t i = 0; i < getOriginalOutputsNumber(); i++) { - dstMemory.push_back(getChildEdgeAt(i)->getMemoryPtr()); + dstMemory.push_back(getDstMemoryAtPort(i)); } //TODO: need to pass post ops data execPtrDeconv->exec(srcMemory, dstMemory, nullptr); @@ -751,14 +753,14 @@ dnnl::primitive_desc createDescriptorInternalInt8(const dnnl::memory::desc& in_c } DefaultDeconvDescs createDefaultMkldnnDeconvDesc(const dnnl::memory::desc& srcDesc, - const dnnl::memory::desc& wghDesc, - const dnnl::memory::desc& dstDesc, - const std::vector& stride, - const std::vector& dilation, - const ov::CoordinateDiff& paddingL, - const ov::CoordinateDiff& paddingR, - const dnnl::primitive_attr& attr, - const dnnl::engine& engine) { + const dnnl::memory::desc& wghDesc, + const dnnl::memory::desc& dstDesc, + const std::vector& stride, + const std::vector& dilation, + const ov::CoordinateDiff& paddingL, + const ov::CoordinateDiff& paddingR, + const dnnl::primitive_attr& attr, + const dnnl::engine& engine) { dnnl::algorithm alg = dnnl::algorithm::convolution_direct; convolution_backward_data::primitive_desc deconv_desc; convolution_forward::primitive_desc fwd_conv_pd; @@ -823,13 +825,13 @@ void Deconvolution::createPrimitive() { inDims = getInputShapeAtPort(0).getStaticDims(); outDims = getOutputShapeAtPort(0).getStaticDims(); - inDesc = getParentEdgesAtPort(0).front()->getMemory().getDescWithType(); - outDesc = getChildEdgesAtPort(0).front()->getMemory().getDescWithType(); + inDesc = getParentEdgeAt(0)->getMemory().getDescWithType(); + outDesc = getChildEdgeAt(0)->getMemory().getDescWithType(); } dnnl::memory::desc dnnlBiasDesc; if (withBiases) { - DnnlMemoryDescPtr biasDesc = getParentEdgesAtPort(biasPort).front()->getMemory().getDescWithType(); + DnnlMemoryDescPtr biasDesc = getParentEdgeAt(biasPort)->getMemory().getDescWithType(); dnnlBiasDesc = biasDesc->getDnnlDesc(); } @@ -854,9 +856,9 @@ void Deconvolution::createPrimitive() { } void Deconvolution::prepareParams() { - auto srcMemPtr = getParentEdgesAtPort(0)[0]->getMemoryPtr(); - auto wghMemPtr = getParentEdgesAtPort(1)[0]->getMemoryPtr(); - auto dstMemPtr = getChildEdgesAtPort(0)[0]->getMemoryPtr(); + auto srcMemPtr = getSrcMemoryAtPort(0); + auto wghMemPtr = getSrcMemoryAtPort(1); + auto dstMemPtr = getDstMemoryAtPort(0); if (!dstMemPtr || !dstMemPtr->isAllocated()) OPENVINO_THROW("Destination memory has not been allocated."); if (!srcMemPtr || !srcMemPtr->isAllocated()) @@ -870,11 +872,11 @@ void Deconvolution::prepareParams() { if (useACL) { std::vector srcMemoryDescs; for (size_t i = 0; i < getOriginalInputsNumber(); i++) { - srcMemoryDescs.push_back(getParentEdgesAtPort(i).front()->getMemory().getDescWithType()); + srcMemoryDescs.push_back(getParentEdgeAt(i)->getMemory().getDescWithType()); } std::vector dstMemoryDescs; for (size_t i = 0; i < getOriginalOutputsNumber(); i++) { - dstMemoryDescs.push_back(getChildEdgesAtPort(i).front()->getMemory().getDescWithType()); + dstMemoryDescs.push_back(getChildEdgeAt(i)->getMemory().getDescWithType()); } execPtrDeconv = selected_pd->getExecutorFactoryAs()->makeExecutor(deconvAttrs, srcMemoryDescs, @@ -883,8 +885,8 @@ void Deconvolution::prepareParams() { return; } - auto inMemoryDesc = getParentEdgesAtPort(0).front()->getMemory().getDescWithType(); - auto outMemoryDesc = getChildEdgesAtPort(0).front()->getMemory().getDescWithType(); + auto inMemoryDesc = getParentEdgeAt(0)->getMemory().getDescWithType(); + auto outMemoryDesc = getChildEdgeAt(0)->getMemory().getDescWithType(); AttrPtr pAttrLocal; if (isDynamicNode()) { @@ -909,13 +911,13 @@ void Deconvolution::prepareParams() { if (isInt8) { wghDesc = internalBlobMemory.front()->getDescWithType(); if (withBiases) { - biasMemPtr = getParentEdgesAtPort(biasPort)[0]->getMemoryPtr(); + biasMemPtr = getSrcMemoryAtPort(biasPort); if (!biasMemPtr || !biasMemPtr->isAllocated()) OPENVINO_THROW("Bias memory memory didn't allocate."); biasDesc = biasMemPtr->getDescWithType(); } } else { - wghDesc = getParentEdgesAtPort(1).front()->getMemory().getDescWithType(); + wghDesc = getParentEdgeAt(1)->getMemory().getDescWithType(); } DeconvKey key = {inMemoryDesc, @@ -1096,8 +1098,8 @@ void Deconvolution::createDescriptor(const std::vector &inputDesc convolution_backward_data::primitive_desc deconv_desc; convolution_forward::primitive_desc fwd_conv_pd; std::tie(deconv_desc, fwd_conv_pd) = createDescriptorInternalDefault(in_candidate, wgh_candidate, out_candidate, dnnl::algorithm::convolution_direct, - deconvAttrs.stride, deconvAttrs.dilation, deconvAttrs.paddingL, - deconvAttrs.paddingR, *attr, getEngine()); + deconvAttrs.stride, deconvAttrs.dilation, deconvAttrs.paddingL, + deconvAttrs.paddingR, *attr, getEngine()); if (fwd_conv_pd && deconv_desc && deconv_desc.get(true) != nullptr) { fwdConvPD.push_back(fwd_conv_pd); // oneDNN requires forward pd to exists until primitive is created descs.push_back(deconv_desc); @@ -1183,7 +1185,7 @@ std::vector Deconvolution::readOutputSpatialDims() const { if (getParentEdges().size() < 3) { OPENVINO_THROW("Can't get output spatial dims. Inputs number = ", getParentEdges().size()); } - const auto &shapeMemPtr = getParentEdgesAtPort(2)[0]->getMemoryPtr(); + const auto &shapeMemPtr = getSrcMemoryAtPort(2); if (!shapeMemPtr || !shapeMemPtr->isAllocated()) { OPENVINO_THROW("'output_shape' input memory is not allocated."); } @@ -1191,7 +1193,7 @@ std::vector Deconvolution::readOutputSpatialDims() const { if (shapeMemPtr->getStaticDims()[0] != spDimsNum) { OPENVINO_THROW("Can't read output spatial dims, beause 'output_shape' input has incorrect number of elements"); } - const int32_t *outShapePtr = reinterpret_cast(shapeMemPtr->getData()); + const int32_t *outShapePtr = shapeMemPtr->getDataAs(); std::vector outSpDims(outShapePtr, outShapePtr + shapeMemPtr->getStaticDims()[0]); return outSpDims; } @@ -1218,12 +1220,12 @@ void Deconvolution::initSupportedPrimitiveDescriptors() { for (size_t i = 0; i < getParentEdges().size(); ++i) { config.inConfs[i].setMemDesc( - // ACL expected equal precision - creatorsMap.at(format)->createSharedDesc(getOriginalInputPrecisionAtPort(0), getInputShapeAtPort(i))); + // force f32 precision to avoid reference inference (CVS-114087) + creatorsMap.at(format)->createSharedDesc(ov::element::f32, getInputShapeAtPort(i))); } config.outConfs[0].setMemDesc( - // ACL expected equal precision - creatorsMap.at(format)->createSharedDesc(getOriginalInputPrecisionAtPort(0), getOutputShapeAtPort(0))); + // force f32 precision to avoid reference inference (CVS-114087) + creatorsMap.at(format)->createSharedDesc(ov::element::f32, getOutputShapeAtPort(0))); std::vector srcMemoryDescs; for (size_t i = 0; i < config.inConfs.size(); i++) { diff --git a/src/plugins/intel_cpu/src/nodes/def_conv.cpp b/src/plugins/intel_cpu/src/nodes/def_conv.cpp index 1222c36003f646..d921cffb76c05c 100644 --- a/src/plugins/intel_cpu/src/nodes/def_conv.cpp +++ b/src/plugins/intel_cpu/src/nodes/def_conv.cpp @@ -4,6 +4,8 @@ #include "def_conv.h" +#include + #include #include #include @@ -1176,10 +1178,10 @@ void DeformableConvolution::DefConvRefExecutor::exec(const float* src, const flo } void DeformableConvolution::prepareParams() { - auto dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); - auto srcMemPtr = getParentEdgeAt(DATA_ID)->getMemoryPtr(); - auto offMemPtr = getParentEdgeAt(OFF_ID)->getMemoryPtr(); - auto weiMemPtr = getParentEdgeAt(WEI_ID)->getMemoryPtr(); + auto dstMemPtr = getDstMemoryAtPort(0); + auto srcMemPtr = getSrcMemoryAtPort(DATA_ID); + auto offMemPtr = getSrcMemoryAtPort(OFF_ID); + auto weiMemPtr = getSrcMemoryAtPort(WEI_ID); if (!dstMemPtr || !dstMemPtr->isAllocated()) OPENVINO_THROW(errorPrefix, " did not allocate destination memory"); @@ -1191,7 +1193,7 @@ void DeformableConvolution::prepareParams() { OPENVINO_THROW(errorPrefix, " did not allocate weights memory"); if (getOriginalInputsNumber() > 3) { - auto modMemPtr = getParentEdgeAt(MOD_ID)->getMemoryPtr(); + auto modMemPtr = getSrcMemoryAtPort(MOD_ID); if (!modMemPtr || !modMemPtr->isAllocated()) OPENVINO_THROW(errorPrefix, " did not allocate modulations memory"); } @@ -1214,7 +1216,7 @@ void DeformableConvolution::prepareParams() { if (withModulation) { descVector.push_back(getParentEdgeAt(MOD_ID)->getMemory().getDescWithType()); } - descVector.push_back(getChildEdgesAtPort(0)[0]->getMemory().getDescWithType()); + descVector.push_back(getChildEdgeAt(0)->getMemory().getDescWithType()); DefConvKey key = { descVector, @@ -1223,8 +1225,8 @@ void DeformableConvolution::prepareParams() { }; const int MB = getParentEdgeAt(DATA_ID)->getMemory().getStaticDims()[0]; - const int OH = getChildEdgesAtPort(0)[0]->getMemory().getStaticDims()[2]; - const int OW = getChildEdgesAtPort(0)[0]->getMemory().getStaticDims()[3]; + const int OH = getChildEdgeAt(0)->getMemory().getStaticDims()[2]; + const int OW = getChildEdgeAt(0)->getMemory().getStaticDims()[3]; const int KH = getParentEdgeAt(WEI_ID)->getMemory().getStaticDims()[2]; const int KW = getParentEdgeAt(WEI_ID)->getMemory().getStaticDims()[3]; @@ -1294,15 +1296,15 @@ void DeformableConvolution::execute(dnnl::stream strm) { auto &srcMemory2 = getParentEdgeAt(2)->getMemory(); auto &dstMemory = getChildEdgeAt(0)->getMemory(); - const auto *src = reinterpret_cast(srcMemory0.getData()); - const auto *offsets = reinterpret_cast(srcMemory1.getData()); - const auto *weights = reinterpret_cast(srcMemory2.getData()); + const auto *src = srcMemory0.getDataAs(); + const auto *offsets = srcMemory1.getDataAs(); + const auto *weights = srcMemory2.getDataAs(); float* modulation = nullptr; if (inputsNumber > 3) { - modulation = reinterpret_cast(getParentEdgeAt(3)->getMemory().getData()); + modulation = getParentEdgeAt(3)->getMemory().getDataAs(); } - float *dst = reinterpret_cast(dstMemory.getData()); + float *dst = dstMemory.getDataAs(); auto selectedPrimitiveDescriptor = getSelectedPrimitiveDescriptor(); if (!selectedPrimitiveDescriptor) diff --git a/src/plugins/intel_cpu/src/nodes/depth_to_space.cpp b/src/plugins/intel_cpu/src/nodes/depth_to_space.cpp index 9a5159b08419a1..57d13213e957a5 100644 --- a/src/plugins/intel_cpu/src/nodes/depth_to_space.cpp +++ b/src/plugins/intel_cpu/src/nodes/depth_to_space.cpp @@ -160,8 +160,8 @@ void DepthToSpace::initSupportedPrimitiveDescriptors() { } void DepthToSpace::createPrimitive() { - auto dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); - auto srcMemPtr = getParentEdgeAt(0)->getMemoryPtr(); + auto dstMemPtr = getDstMemoryAtPort(0); + auto srcMemPtr = getSrcMemoryAtPort(0); if (!dstMemPtr || !dstMemPtr->isAllocated()) THROW_ERROR("has not allocated destination memory"); if (!srcMemPtr || !srcMemPtr->isAllocated()) @@ -184,7 +184,7 @@ void DepthToSpace::createPrimitive() { } void DepthToSpace::prepareParams() { - attrs.srcBlockedDims = getParentEdgeAt(0)->getMemoryPtr()->getDescWithType()->getBlockDims(); + attrs.srcBlockedDims = getSrcMemoryAtPort(0)->getDescWithType()->getBlockDims(); auto builder = [](const DepthToSpaceAttrs& key) -> std::shared_ptr { return std::make_shared(key); }; @@ -291,8 +291,8 @@ void DepthToSpace::DepthToSpaceExecutor::exec(const MemoryPtr& srcMemPtr, const if (!permuteKernel) OPENVINO_THROW("Could not execute. Kernel for Transpose node was not compiled."); - const uint8_t* srcData = reinterpret_cast(srcMemPtr->getData()); - uint8_t* dstData = reinterpret_cast(dstMemPtr->getData()); + const uint8_t* srcData = srcMemPtr->getDataAs(); + uint8_t* dstData = dstMemPtr->getDataAs(); permuteKernel->execute(srcData, dstData, MB); } @@ -302,8 +302,8 @@ void DepthToSpace::execute(dnnl::stream strm) { THROW_ERROR("doesn't have a compiled executor."); } - int MB = getParentEdgeAt(0)->getMemoryPtr()->getStaticDims()[0]; - execPtr->exec(getParentEdgeAt(0)->getMemoryPtr(), getChildEdgeAt(0)->getMemoryPtr(), MB); + int MB = getSrcMemoryAtPort(0)->getStaticDims()[0]; + execPtr->exec(getSrcMemoryAtPort(0), getDstMemoryAtPort(0), MB); } void DepthToSpace::executeDynamicImpl(dnnl::stream strm) { diff --git a/src/plugins/intel_cpu/src/nodes/detection_output.cpp b/src/plugins/intel_cpu/src/nodes/detection_output.cpp index 32184acbf16cf5..3336f3749eb8c0 100644 --- a/src/plugins/intel_cpu/src/nodes/detection_output.cpp +++ b/src/plugins/intel_cpu/src/nodes/detection_output.cpp @@ -171,15 +171,15 @@ void DetectionOutput::executeDynamicImpl(dnnl::stream strm) { } void DetectionOutput::execute(dnnl::stream strm) { - float *dstData = reinterpret_cast(getChildEdgesAtPort(0)[0]->getMemoryPtr()->getData()); + float *dstData = getDstDataAtPortAs(0); - const float *locData = reinterpret_cast(getParentEdgeAt(ID_LOC)->getMemoryPtr()->getData()); - const float *confData = reinterpret_cast(getParentEdgeAt(ID_CONF)->getMemoryPtr()->getData()); - const float *priorData = reinterpret_cast(getParentEdgeAt(ID_PRIOR)->getMemoryPtr()->getData()); + const float *locData = getSrcDataAtPortAs(ID_LOC); + const float *confData = getSrcDataAtPortAs(ID_CONF); + const float *priorData = getSrcDataAtPortAs(ID_PRIOR); const float *ARMConfData = inputShapes.size() > 3 ? - reinterpret_cast(getParentEdgeAt(ID_ARM_CONF)->getMemoryPtr()->getData()) : nullptr; + getSrcDataAtPortAs(ID_ARM_CONF) : nullptr; const float *ARMLocData = inputShapes.size() > 4 ? - reinterpret_cast(getParentEdgeAt(ID_ARM_LOC)->getMemoryPtr()->getData()) : nullptr; + getSrcDataAtPortAs(ID_ARM_LOC) : nullptr; float *reorderedConfData = reorderedConf.data(); int *reorderedConfDataIndices = reinterpret_cast(reorderedConf.data()); @@ -827,7 +827,7 @@ inline void DetectionOutput::NMSMX(int* indicesIn, inline void DetectionOutput::generateOutput(float* reorderedConfData, int* indicesData, int* detectionsData, float* decodedBboxesData, float* dstData) { - const auto& outDims = getChildEdgesAtPort(0)[0]->getMemory().getStaticDims(); + const auto& outDims = getChildEdgeAt(0)->getMemory().getStaticDims(); const int numResults = outDims[2]; const int DETECTION_SIZE = outDims[3]; if (DETECTION_SIZE != 7) { @@ -842,7 +842,7 @@ inline void DetectionOutput::generateOutput(float* reorderedConfData, int* indic else dstDataSize = imgNum * classesNum * priorsNum * DETECTION_SIZE * sizeof(float); - if (static_cast(dstDataSize) > getChildEdgesAtPort(0)[0]->getMemory().getSize()) { + if (static_cast(dstDataSize) > getChildEdgeAt(0)->getMemory().getSize()) { OPENVINO_THROW(errorPrefix, ": OUT_OF_BOUNDS"); } memset(dstData, 0, dstDataSize); diff --git a/src/plugins/intel_cpu/src/nodes/dft.cpp b/src/plugins/intel_cpu/src/nodes/dft.cpp index 6d2004e858c7bf..259fa763827745 100644 --- a/src/plugins/intel_cpu/src/nodes/dft.cpp +++ b/src/plugins/intel_cpu/src/nodes/dft.cpp @@ -5,7 +5,6 @@ #include "dft.h" #include -#include #include #include #include "dnnl_extension_utils.h" @@ -14,6 +13,7 @@ #include "onednn/dnnl.h" #include "utils/general_utils.h" #include "common/cpu_memcpy.h" +#include "utils/ngraph_utils.hpp" #include using namespace dnnl::impl; @@ -234,13 +234,13 @@ void copyDataToOutputWithSignalSize(const float* input, const std::vectorgetMemory().getStaticDims(); + const auto& outputShape = getChildEdgeAt(0)->getMemory().getStaticDims(); const auto inputDataEdge = getParentEdgeAt(DATA_INDEX); const auto outputDataEdge = getChildEdgeAt(0); - const auto src = reinterpret_cast(inputDataEdge->getMemoryPtr()->getData()); - auto dst = reinterpret_cast(outputDataEdge->getMemoryPtr()->getData()); + const auto src = inputDataEdge->getMemoryPtr()->getDataAs(); + auto dst = outputDataEdge->getMemoryPtr()->getDataAs(); const auto inputRank = inputDataEdge->getMemory().getShape().getRank(); @@ -525,7 +525,7 @@ void DFT::prepareParams() { bool hasFFT = false; axes = getAxes(); - const auto outputShape = getChildEdgesAtPort(0)[0]->getMemory().getStaticDims(); + const auto outputShape = getChildEdgeAt(0)->getMemory().getStaticDims(); for (size_t axis : axes) { size_t nComplex = outputShape[axis]; @@ -542,7 +542,7 @@ void DFT::prepareParams() { std::vector DFT::getAxes() const { auto axesEdge = getParentEdgeAt(AXES_INDEX); - const auto* axesStartPtr = reinterpret_cast(axesEdge->getMemoryPtr()->getData()); + const auto* axesStartPtr = axesEdge->getMemoryPtr()->getDataAs(); auto axes = std::vector(axesStartPtr, axesStartPtr + axesEdge->getMemory().getStaticDims()[0]); for (auto& axis : axes) { if (axis < 0) { diff --git a/src/plugins/intel_cpu/src/nodes/eltwise.cpp b/src/plugins/intel_cpu/src/nodes/eltwise.cpp index 4ed4174b750aad..0395909450236a 100644 --- a/src/plugins/intel_cpu/src/nodes/eltwise.cpp +++ b/src/plugins/intel_cpu/src/nodes/eltwise.cpp @@ -17,6 +17,7 @@ #include "fake_quantize.h" #include "input.h" #include "memory_desc/dnnl_blocked_memory_desc.h" +#include "nodes/executors/eltwise_list.hpp" #include "onednn/dnnl.h" #include "openvino/core/except.hpp" #include "openvino/core/parallel.hpp" @@ -33,6 +34,7 @@ #include "utils/bfloat16.hpp" #include "utils/cpu_utils.hpp" #include "utils/general_utils.h" +#include "utils/ngraph_utils.hpp" #include #include @@ -2273,8 +2275,8 @@ void Eltwise::initSupportedPrimitiveDescriptors() { // WA is needed to handle bug in LPT that produces wrong precision after average pooling (I8/U8 instead of FP32) if ((getAlgorithm() == Algorithm::EltwiseMulAdd || getAlgorithm() == Algorithm::EltwisePowerStatic) && (inputPrecisions[0] == ov::element::u8 || inputPrecisions[0] == ov::element::i8)) { - auto parentNode = getParentEdgesAtPort(0)[0]->getParent(); - if (getParentEdgesAtPort(0)[0]->getParent()->getAlgorithm() == Algorithm::PoolingAvg) { + auto parentNode = getParentEdgeAt(0)->getParent(); + if (getParentEdgeAt(0)->getParent()->getAlgorithm() == Algorithm::PoolingAvg) { inputPrecisions[0] = ov::element::f32; } } @@ -2450,8 +2452,8 @@ void Eltwise::initSupportedPrimitiveDescriptors() { void Eltwise::createPrimitive() { if (memPtrs.empty()) { for (size_t i = 0; i < inputNum; i++) - memPtrs.push_back(getParentEdgeAt(i)->getMemoryPtr()); - memPtrs.push_back(getChildEdgeAt(0)->getMemoryPtr()); + memPtrs.push_back(getSrcMemoryAtPort(i)); + memPtrs.push_back(getDstMemoryAtPort(0)); } start_offset_in.resize(inputNum); @@ -2474,10 +2476,10 @@ void Eltwise::prepareParams() { if (canUseAclExecutor) { std::vector srcMemoryDescs; for (size_t i = 0; i < getParentEdges().size(); i++) { - srcMemoryDescs.push_back(getParentEdgeAt(i)->getMemoryPtr()->getDescPtr()); + srcMemoryDescs.push_back(getSrcMemoryAtPort(i)->getDescPtr()); } std::vector dstMemoryDescs; - dstMemoryDescs.push_back(getChildEdgeAt(0)->getMemoryPtr()->getDescPtr()); + dstMemoryDescs.push_back(getDstMemoryAtPort(0)->getDescPtr()); auto selectedPD = getSelectedPrimitiveDescriptor(); aclExecPtr = selectedPD->getExecutorFactoryAs()->makeExecutor(eltwiseAttrs, srcMemoryDescs, dstMemoryDescs, {}); @@ -2620,7 +2622,7 @@ void Eltwise::prepareParams() { bool Eltwise::needPrepareParams() const { for (size_t i = 0; i < getParentEdges().size(); i++) { - if (getParentEdgesAtPort(i)[0]->getMemory().getDescWithType()->getBlockDims() != currentInBlkDims[i]) + if (getParentEdgeAt(i)->getMemory().getDescWithType()->getBlockDims() != currentInBlkDims[i]) return true; } return false; @@ -2635,8 +2637,8 @@ void Eltwise::execute(dnnl::stream strm) { jit_eltwise_call_args_ptrs args_ptrs = {}; VectorDims dims_out = implType == EltwiseImplType::optimizedShapeAgnostic ? execParams.outDims : execPtr->getOutDims(); for (size_t i = 0; i < memPtrs.size() - 1; i++) - args_ptrs.src_ptr[i] = reinterpret_cast(memPtrs[i]->getData()) + start_offset_in[i]; - args_ptrs.dst_ptr = reinterpret_cast(memPtrs.back()->getData()) + start_offset_out; + args_ptrs.src_ptr[i] = memPtrs[i]->getDataAs() + start_offset_in[i]; + args_ptrs.dst_ptr = memPtrs.back()->getDataAs() + start_offset_out; args_ptrs.post_op_data = fqDataPtrs.data(); @@ -2653,10 +2655,10 @@ void Eltwise::execute(dnnl::stream strm) { } else if (aclExecPtr) { std::vector srcMemory; for (size_t i = 0; i < getParentEdges().size(); i++) { - srcMemory.push_back(getParentEdgeAt(i)->getMemoryPtr()); + srcMemory.push_back(getSrcMemoryAtPort(i)); } std::vector dstMemory; - dstMemory.push_back(getChildEdgeAt(0)->getMemoryPtr()); + dstMemory.push_back(getDstMemoryAtPort(0)); aclExecPtr->exec(srcMemory, dstMemory, fqDataPtrs.data()); } else { @@ -2673,7 +2675,7 @@ bool Eltwise::created() const { } bool Eltwise::canBeInPlace() const { - if (getParentEdgesAtPort(0)[0]->getParent()->getType() == Type::Input) { + if (getParentEdgeAt(0)->getParent()->getType() == Type::Input) { return false; } @@ -2839,7 +2841,7 @@ void Eltwise::appendPostOps(dnnl::post_ops& ops, const VectorDims &postOpDims, s appendPostOpsImpl(ops, postOpDims, postOpsMem, channelAxis); } -bool Eltwise::appendAttrPostOps(DnnlPostOpsComposer& dnnlpoc, bool isLastPostOp, dnnl::memory::data_type outDataType, bool allowBinary) { +bool Eltwise::appendAttrPostOps(DnnlPostOpsComposerLegacy& dnnlpoc, bool isLastPostOp, dnnl::memory::data_type outDataType, bool allowBinary) { const std::string errorPrefix = "Appending Eltwise node with name '" + getName() + "' as binary post op "; if (getOneDnnAlgorithm() != dnnl::algorithm::undef) { @@ -2960,7 +2962,7 @@ bool Eltwise::canFuse(const NodePtr& node) const { return false; } - if (node->getParentEdgesAtPort(0)[0]->getParent().get() != this) { + if (node->getParentEdgeAt(0)->getParent().get() != this) { // Eltwise jitter doesn't respect commutative property, so fusing is disabled in case it applied not for 0-th port. if (one_of(node->getAlgorithm(), Algorithm::EltwiseSubtract, Algorithm::EltwiseDivide, diff --git a/src/plugins/intel_cpu/src/nodes/eltwise.h b/src/plugins/intel_cpu/src/nodes/eltwise.h index d910c255b9d8d0..0cf8fa13284908 100644 --- a/src/plugins/intel_cpu/src/nodes/eltwise.h +++ b/src/plugins/intel_cpu/src/nodes/eltwise.h @@ -4,8 +4,13 @@ #pragma once -#include "executors/eltwise_list.hpp" -#include "node.h" +#include +#include +#include +#include + +#include "dnnl_postops_composer_legacy.h" +#include "nodes/executors/eltwise.hpp" namespace ov { namespace intel_cpu { @@ -109,13 +114,15 @@ class Eltwise : public Node { bool canFuse(const NodePtr& node) const override; void appendPostOps(dnnl::post_ops& ops, const VectorDims &postOpDims, std::unordered_map& postOpsMem, const int channelAxis = 1) override; void appendPostOps(dnnl::post_ops& ops, const VectorDims &postOpDims, std::vector& postOpsMem, const int channelAxis = 1) override; - bool appendAttrPostOps(DnnlPostOpsComposer& dnnlpoc, bool isLastPostOp, dnnl::memory::data_type outDataType, bool allowBinary = true); + bool appendAttrPostOps(DnnlPostOpsComposerLegacy& dnnlpoc, bool isLastPostOp, dnnl::memory::data_type outDataType, bool allowBinary = true); void fuseInto(NodePtr& parentNode) override; ov::element::Type getRuntimePrecision() const override; float getAlpha() const { return alpha; } float getBeta() const { return beta; } float getGamma() const { return gamma; } + const std::vector& getScales() const { return scales; } + const std::vector& getShifts() const { return shifts; } dnnl::algorithm getOneDnnAlgorithm() const { return onednnAlgorithm; } @@ -210,4 +217,4 @@ class eltwise_precision_helper { } // namespace node } // namespace intel_cpu -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/embedding_bag_offset_sum.cpp b/src/plugins/intel_cpu/src/nodes/embedding_bag_offset_sum.cpp index b415393bf6d234..d3da16e38522c2 100644 --- a/src/plugins/intel_cpu/src/nodes/embedding_bag_offset_sum.cpp +++ b/src/plugins/intel_cpu/src/nodes/embedding_bag_offset_sum.cpp @@ -75,17 +75,17 @@ void EmbeddingBagOffsetSum::initSupportedPrimitiveDescriptors() { } void EmbeddingBagOffsetSum::prepareParams() { - _indicesLen = getParentEdgesAtPort(INDICES_IDX)[0]->getMemory().getStaticDims()[0]; - _offsetsLen = getParentEdgesAtPort(OFFSETS_IDX)[0]->getMemory().getStaticDims()[0]; - EmbeddingBagSum::prepareParams(getParentEdgesAtPort(EMB_TABLE_IDX)[0]->getMemory().getStaticDims()); + _indicesLen = getParentEdgeAt(INDICES_IDX)->getMemory().getStaticDims()[0]; + _offsetsLen = getParentEdgeAt(OFFSETS_IDX)->getMemory().getStaticDims()[0]; + EmbeddingBagSum::prepareParams(getParentEdgeAt(EMB_TABLE_IDX)->getMemory().getStaticDims()); } void EmbeddingBagOffsetSum::initFromInputs() { - indicesData_ = reinterpret_cast(getParentEdgeAt(INDICES_IDX)->getMemoryPtr()->getData()); - offsetsData_ = reinterpret_cast(getParentEdgeAt(OFFSETS_IDX)->getMemoryPtr()->getData()); + indicesData_ = getSrcDataAtPortAs(INDICES_IDX); + offsetsData_ = getSrcDataAtPortAs(OFFSETS_IDX); if (getParentEdges().size() > DEFAULT_INDEX_IDX) { - defaultIndices_ = reinterpret_cast(getParentEdgeAt(DEFAULT_INDEX_IDX)->getMemoryPtr()->getData()); + defaultIndices_ = getSrcDataAtPortAs(DEFAULT_INDEX_IDX); } } @@ -131,14 +131,14 @@ bool EmbeddingBagOffsetSum::isExecutable() const { } void EmbeddingBagOffsetSum::execute(dnnl::stream strm) { - const auto *srcData = reinterpret_cast(getParentEdgeAt(0)->getMemoryPtr()->getData()); + const auto *srcData = getSrcDataAtPortAs(0); const uint8_t* weightsData = nullptr; if (_withWeights) - weightsData = reinterpret_cast(getParentEdgeAt(PER_SAMPLE_WEIGHTS_IDX)->getMemoryPtr()->getData()); + weightsData = getSrcDataAtPortAs(PER_SAMPLE_WEIGHTS_IDX); const auto &inputMem = getParentEdgeAt(0)->getMemory(); EmbeddingBagSum::execute(srcData, weightsData, inputMem.getDesc().getPrecision(), - inputMem.getStaticDims(), getChildEdgesAtPort(0)[0]->getMemoryPtr()); + inputMem.getStaticDims(), getDstMemoryAtPort(0)); } bool EmbeddingBagOffsetSum::created() const { diff --git a/src/plugins/intel_cpu/src/nodes/embedding_bag_packed_sum.cpp b/src/plugins/intel_cpu/src/nodes/embedding_bag_packed_sum.cpp index b796ad17f8c4ca..5bd78016dc2592 100644 --- a/src/plugins/intel_cpu/src/nodes/embedding_bag_packed_sum.cpp +++ b/src/plugins/intel_cpu/src/nodes/embedding_bag_packed_sum.cpp @@ -67,13 +67,13 @@ void EmbeddingBagPackedSum::initSupportedPrimitiveDescriptors() { } void EmbeddingBagPackedSum::prepareParams() { - _batch = getParentEdgesAtPort(INDICES_IDX)[0]->getMemory().getStaticDims()[0]; - _indicesPerBag = getParentEdgesAtPort(INDICES_IDX)[0]->getMemory().getStaticDims()[1]; - EmbeddingBagSum::prepareParams(getParentEdgesAtPort(EMB_TABLE_IDX)[0]->getMemory().getStaticDims()); + _batch = getParentEdgeAt(INDICES_IDX)->getMemory().getStaticDims()[0]; + _indicesPerBag = getParentEdgeAt(INDICES_IDX)->getMemory().getStaticDims()[1]; + EmbeddingBagSum::prepareParams(getParentEdgeAt(EMB_TABLE_IDX)->getMemory().getStaticDims()); } void EmbeddingBagPackedSum::initFromInputs() { - _indices = reinterpret_cast(getParentEdgeAt(INDICES_IDX)->getMemoryPtr()->getData()); + _indices = getSrcDataAtPortAs(INDICES_IDX); } void EmbeddingBagPackedSum::getIndices(size_t embIndex, const int*& indices, size_t& size, int& weightsIdx, bool& withWeight) { @@ -97,14 +97,14 @@ bool EmbeddingBagPackedSum::isExecutable() const { } void EmbeddingBagPackedSum::execute(dnnl::stream strm) { - const auto *srcData = reinterpret_cast(getParentEdgeAt(0)->getMemoryPtr()->getData()); + const auto *srcData = getSrcDataAtPortAs(0); const uint8_t* weightsData = nullptr; if (_withWeights) - weightsData = reinterpret_cast(getParentEdgeAt(PER_SAMPLE_WEIGHTS_IDX)->getMemoryPtr()->getData()); + weightsData = getSrcDataAtPortAs(PER_SAMPLE_WEIGHTS_IDX); const auto &inputMem = getParentEdgeAt(0)->getMemory(); EmbeddingBagSum::execute(srcData, weightsData, inputMem.getDesc().getPrecision(), - inputMem.getStaticDims(), getChildEdgesAtPort(0)[0]->getMemoryPtr()); + inputMem.getStaticDims(), getDstMemoryAtPort(0)); } bool EmbeddingBagPackedSum::created() const { diff --git a/src/plugins/intel_cpu/src/nodes/embedding_bag_sum.cpp b/src/plugins/intel_cpu/src/nodes/embedding_bag_sum.cpp index e82a86fbd9907d..9f7641e015d7f2 100644 --- a/src/plugins/intel_cpu/src/nodes/embedding_bag_sum.cpp +++ b/src/plugins/intel_cpu/src/nodes/embedding_bag_sum.cpp @@ -52,7 +52,7 @@ void EmbeddingBagSum::processData(const T* srcData, const T* weightsData, initFromInputs(); const size_t outputBagsNum = outMemory->getShape().getStaticDims()[0]; - auto *dstData = reinterpret_cast(outMemory->getData()); + auto *dstData = outMemory->getDataAs(); auto threadBody = [&](const int ithr, const int nthr) { size_t start(0lu), end(0lu); diff --git a/src/plugins/intel_cpu/src/nodes/embedding_segments_sum.cpp b/src/plugins/intel_cpu/src/nodes/embedding_segments_sum.cpp index 172a20420e0c2f..735d73d2384d5a 100644 --- a/src/plugins/intel_cpu/src/nodes/embedding_segments_sum.cpp +++ b/src/plugins/intel_cpu/src/nodes/embedding_segments_sum.cpp @@ -75,18 +75,18 @@ void EmbeddingSegmentsSum::initSupportedPrimitiveDescriptors() { } void EmbeddingSegmentsSum::prepareParams() { - EmbeddingBagSum::prepareParams(getParentEdgesAtPort(EMB_TABLE_IDX)[0]->getMemory().getStaticDims()); + EmbeddingBagSum::prepareParams(getParentEdgeAt(EMB_TABLE_IDX)->getMemory().getStaticDims()); } void EmbeddingSegmentsSum::initFromInputs() { - indices_ = reinterpret_cast(getParentEdgeAt(INDICES_IDX)->getMemoryPtr()->getData()); + indices_ = getSrcDataAtPortAs(INDICES_IDX); indicesSize_ = getParentEdgeAt(INDICES_IDX)->getMemory().getShape().getElementsCount(); - segmentIds_ = reinterpret_cast(getParentEdgeAt(SEGMENT_ID_IDX)->getMemoryPtr()->getData()); + segmentIds_ = getSrcDataAtPortAs(SEGMENT_ID_IDX); lastNumSegments_ = getNumSegments(); if (getParentEdges().size() > DEFAULT_INDEX_IDX) { - defaultIndices_ = reinterpret_cast(getParentEdgeAt(DEFAULT_INDEX_IDX)->getMemoryPtr()->getData()); + defaultIndices_ = getSrcDataAtPortAs(DEFAULT_INDEX_IDX); } } @@ -119,7 +119,7 @@ void EmbeddingSegmentsSum::getIndices(size_t embIndex, const int*& indices, size } int32_t EmbeddingSegmentsSum::getNumSegments() const { - return reinterpret_cast(getParentEdgesAtPort(NUM_SEGMENTS_IDX)[0]->getMemory().getData())[0]; + return getParentEdgeAt(NUM_SEGMENTS_IDX)->getMemory().getDataAs()[0]; } bool EmbeddingSegmentsSum::needShapeInfer() const { @@ -143,14 +143,14 @@ bool EmbeddingSegmentsSum::isExecutable() const { } void EmbeddingSegmentsSum::execute(dnnl::stream strm) { - const auto *srcData = reinterpret_cast(getParentEdgeAt(0)->getMemoryPtr()->getData()); + const auto *srcData = getSrcDataAtPortAs(0); const uint8_t* weightsData = nullptr; if (_withWeights) - weightsData = reinterpret_cast(getParentEdgeAt(PER_SAMPLE_WEIGHTS_IDX)->getMemoryPtr()->getData()); + weightsData = getSrcDataAtPortAs(PER_SAMPLE_WEIGHTS_IDX); const auto &inputMem = getParentEdgeAt(0)->getMemory(); EmbeddingBagSum::execute(srcData, weightsData, inputMem.getDesc().getPrecision(), - inputMem.getStaticDims(), getChildEdgesAtPort(0)[0]->getMemoryPtr()); + inputMem.getStaticDims(), getDstMemoryAtPort(0)); } bool EmbeddingSegmentsSum::created() const { diff --git a/src/plugins/intel_cpu/src/nodes/executors/acl/acl_convert.cpp b/src/plugins/intel_cpu/src/nodes/executors/acl/acl_convert.cpp index 5d9fdefb916f34..4061535c2624df 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/acl/acl_convert.cpp +++ b/src/plugins/intel_cpu/src/nodes/executors/acl/acl_convert.cpp @@ -60,9 +60,12 @@ bool ACLConvertExecutor::init(const ConvertParams& convertParams, return true; } -void ACLConvertExecutor::exec(const MemoryCPtr& src, const MemoryPtr& dst) { - srcTensor.allocator()->import_memory(src->getData()); - dstTensor.allocator()->import_memory(dst->getData()); +void ACLConvertExecutor::exec(const std::vector& src, const std::vector& dst) { + assert(src.size() == 1); + assert(dst.size() == 1); + + srcTensor.allocator()->import_memory(src[0]->getData()); + dstTensor.allocator()->import_memory(dst[0]->getData()); if (isCopyOp) { acl_copy->run(); @@ -130,4 +133,4 @@ bool ACLConvertExecutorBuilder::isSupported(const ConvertParams& convertParams, } } // namespace intel_cpu -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/acl/acl_convert.hpp b/src/plugins/intel_cpu/src/nodes/executors/acl/acl_convert.hpp index 6d442c2f65d87c..f0f171ff74254f 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/acl/acl_convert.hpp +++ b/src/plugins/intel_cpu/src/nodes/executors/acl/acl_convert.hpp @@ -18,12 +18,11 @@ class ACLConvertExecutor : public ConvertExecutor { const MemoryDescPtr& srcDesc, const MemoryDescPtr& dstDesc, const dnnl::primitive_attr &attr) override; - void exec(const MemoryCPtr& src, const MemoryPtr& dst) override; - impl_desc_type getImplType() const override { return implDescType; }; + void exec(const std::vector& src, const std::vector& dst) override; + impl_desc_type implType() const override { return impl_desc_type::acl; }; protected: ConvertParams aclConvertParams; bool isCopyOp; - static const impl_desc_type implDescType = impl_desc_type::acl; arm_compute::Tensor srcTensor, dstTensor; std::unique_ptr acl_copy; std::unique_ptr acl_cast; @@ -40,4 +39,4 @@ class ACLConvertExecutorBuilder : public ConvertExecutorBuilder { }; } // namespace intel_cpu -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/acl/acl_deconv.cpp b/src/plugins/intel_cpu/src/nodes/executors/acl/acl_deconv.cpp index 692d9d8f370d49..0df85c49adfd70 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/acl/acl_deconv.cpp +++ b/src/plugins/intel_cpu/src/nodes/executors/acl/acl_deconv.cpp @@ -91,7 +91,7 @@ bool AclDeconvExecutor::init(const DeconvAttrs& deconvAttrs, } static void transpose_to_1023(const MemoryCPtr& srcMemPtr, std::vector& dst_data) { - const auto src_data = reinterpret_cast(srcMemPtr->getData()); + const auto src_data = srcMemPtr->getDataAs(); const int DIM0 = srcMemPtr->getStaticDims()[0]; const int DIM1 = srcMemPtr->getStaticDims()[1]; diff --git a/src/plugins/intel_cpu/src/nodes/executors/acl/acl_interpolate.hpp b/src/plugins/intel_cpu/src/nodes/executors/acl/acl_interpolate.hpp index 3285d64ca04cb2..b349fafebb3043 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/acl/acl_interpolate.hpp +++ b/src/plugins/intel_cpu/src/nodes/executors/acl/acl_interpolate.hpp @@ -5,6 +5,8 @@ #pragma once #include "../interpolate.hpp" +#include "arm_compute/runtime/NEON/functions/NEScale.h" +#include "arm_compute/runtime/Tensor.h" namespace ov { namespace intel_cpu { @@ -48,4 +50,4 @@ class ACLInterpolateExecutorBuilder : public InterpolateExecutorBuilder { const std::vector& dstDescs); }; } // namespace intel_cpu -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/acl/acl_transpose.cpp b/src/plugins/intel_cpu/src/nodes/executors/acl/acl_transpose.cpp index 4031e174b65481..5ab6b855db52d2 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/acl/acl_transpose.cpp +++ b/src/plugins/intel_cpu/src/nodes/executors/acl/acl_transpose.cpp @@ -55,8 +55,7 @@ bool ov::intel_cpu::ACLTransposeExecutor::init(const ov::intel_cpu::TransposePar return true; } -void ov::intel_cpu::ACLTransposeExecutor::exec(const std::vector &src, const std::vector &dst, - const int MB) { +void ov::intel_cpu::ACLTransposeExecutor::exec(const std::vector &src, const std::vector &dst) { srcTensor.allocator()->import_memory(src[0]->getData()); dstTensor.allocator()->import_memory(dst[0]->getData()); diff --git a/src/plugins/intel_cpu/src/nodes/executors/acl/acl_transpose.hpp b/src/plugins/intel_cpu/src/nodes/executors/acl/acl_transpose.hpp index b94cc2f3a4a279..6984c59d8cb244 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/acl/acl_transpose.hpp +++ b/src/plugins/intel_cpu/src/nodes/executors/acl/acl_transpose.hpp @@ -5,6 +5,9 @@ #pragma once #include "nodes/executors/transpose.hpp" + +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/NEON/functions/NEPermute.h" #include "utils/debug_capabilities.h" namespace ov { @@ -18,10 +21,9 @@ class ACLTransposeExecutor : public TransposeExecutor { const std::vector& srcDescs, const std::vector& dstDescs, const dnnl::primitive_attr &attr) override; - void exec(const std::vector& src, const std::vector& dst, const int MB) override; - impl_desc_type getImplType() const override { return implType; } + void exec(const std::vector& src, const std::vector& dst) override; + impl_desc_type implType() const override { return impl_desc_type::acl; } private: - static const impl_desc_type implType = impl_desc_type::acl; arm_compute::Tensor srcTensor, dstTensor; std::unique_ptr acl_permute; }; @@ -63,4 +65,4 @@ class ACLTransposeExecutorBuilder : public TransposeExecutorBuilder { }; } // namespace intel_cpu -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/common/ref_convert.cpp b/src/plugins/intel_cpu/src/nodes/executors/common/ref_convert.cpp index 4e1eec0294543f..91f83607ccb790 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/common/ref_convert.cpp +++ b/src/plugins/intel_cpu/src/nodes/executors/common/ref_convert.cpp @@ -13,9 +13,12 @@ bool ov::intel_cpu::CommonConvertExecutor::init(const ov::intel_cpu::ConvertPara return true; } -void ov::intel_cpu::CommonConvertExecutor::exec(const MemoryCPtr& src, const MemoryPtr& dst) { - cpu_convert(src->getData(), - dst->getData(), +void ov::intel_cpu::CommonConvertExecutor::exec(const std::vector& src, const std::vector& dst) { + assert(src.size() == 1); + assert(dst.size() == 1); + + cpu_convert(src[0]->getData(), + dst[0]->getData(), commonConvertParams.srcPrc, commonConvertParams.origPrc, commonConvertParams.dstPrc, diff --git a/src/plugins/intel_cpu/src/nodes/executors/common/ref_convert.hpp b/src/plugins/intel_cpu/src/nodes/executors/common/ref_convert.hpp index 902251a8945343..d95a2b820b06b9 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/common/ref_convert.hpp +++ b/src/plugins/intel_cpu/src/nodes/executors/common/ref_convert.hpp @@ -16,8 +16,8 @@ class CommonConvertExecutor : public ConvertExecutor { const MemoryDescPtr& srcDesc, const MemoryDescPtr& dstDesc, const dnnl::primitive_attr &attr) override; - void exec(const MemoryCPtr& src, const MemoryPtr& dst) override; - impl_desc_type getImplType() const override { return implDescType; }; + void exec(const std::vector& src, const std::vector& dst) override; + impl_desc_type implType() const override { return implDescType; }; protected: ConvertParams commonConvertParams; static const impl_desc_type implDescType = impl_desc_type::ref; @@ -39,4 +39,4 @@ class CommonConvertExecutorBuilder : public ConvertExecutorBuilder { }; } // namespace intel_cpu -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/common/ref_opt_transpose.cpp b/src/plugins/intel_cpu/src/nodes/executors/common/ref_opt_transpose.cpp index 4cc32133c466cf..ce8b284efb3d21 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/common/ref_opt_transpose.cpp +++ b/src/plugins/intel_cpu/src/nodes/executors/common/ref_opt_transpose.cpp @@ -17,8 +17,8 @@ struct TransposeContext { template void transpose_to_0312(const int MB, const MemoryCPtr& srcMemPtr, MemoryPtr& dstMemPtr) { - const auto src_data = reinterpret_cast(srcMemPtr->getData()); - auto dst_data = reinterpret_cast(dstMemPtr->getData()); + const auto src_data = srcMemPtr->getDataAs(); + auto dst_data = dstMemPtr->getDataAs(); const int DIM1 = srcMemPtr->getStaticDims()[1]; const int DIM2 = srcMemPtr->getStaticDims()[2]; @@ -42,8 +42,8 @@ void transpose_to_0312(const int MB, const MemoryCPtr& srcMemPtr, MemoryPtr& dst template void transpose_to_04123(const int MB, const MemoryCPtr& srcMemPtr, MemoryPtr& dstMemPtr) { - const auto src_data = reinterpret_cast(srcMemPtr->getData()); - auto dst_data = reinterpret_cast(dstMemPtr->getData()); + const auto src_data = srcMemPtr->getDataAs(); + auto dst_data = dstMemPtr->getDataAs(); const int DIM1 = srcMemPtr->getStaticDims()[1]; const int DIM2 = srcMemPtr->getStaticDims()[2]; @@ -70,8 +70,8 @@ void transpose_to_04123(const int MB, const MemoryCPtr& srcMemPtr, MemoryPtr& ds template void transpose_to_051234(const int MB, const MemoryCPtr& srcMemPtr, MemoryPtr& dstMemPtr) { - const auto src_data = reinterpret_cast(srcMemPtr->getData()); - auto dst_data = reinterpret_cast(dstMemPtr->getData()); + const auto src_data = srcMemPtr->getDataAs(); + auto dst_data = dstMemPtr->getDataAs(); const int DIM1 = srcMemPtr->getStaticDims()[1]; const int DIM2 = srcMemPtr->getStaticDims()[2]; @@ -118,8 +118,9 @@ struct TransposeOptimizedEmitter { } }; } // namespace -void RefOptimizedTransposeExecutor::exec(const std::vector& src, const std::vector& dst, const int MB) { +void RefOptimizedTransposeExecutor::exec(const std::vector& src, const std::vector& dst) { const size_t dataSize = src[0]->getDesc().getPrecision().size(); + const int MB = src[0]->getStaticDims()[0]; TransposeContext ctx = {src[0], dst[0], MB}; OV_SWITCH(intel_cpu, TransposeOptimizedEmitter, ctx, dataSize, OV_CASE(1u, element_type_traits::value_type), @@ -135,4 +136,4 @@ bool RefOptimizedTransposeExecutor::init(const TransposeParams &transposeParams, } } // namespace intel_cpu -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/common/ref_opt_transpose.hpp b/src/plugins/intel_cpu/src/nodes/executors/common/ref_opt_transpose.hpp index 90d8e6e8d83a85..23d4841741bc57 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/common/ref_opt_transpose.hpp +++ b/src/plugins/intel_cpu/src/nodes/executors/common/ref_opt_transpose.hpp @@ -17,10 +17,8 @@ class RefOptimizedTransposeExecutor : public TransposeExecutor { const std::vector &srcDescs, const std::vector &dstDescs, const dnnl::primitive_attr &attr) override; - void exec(const std::vector &src, const std::vector &dst, const int MB) override; - impl_desc_type getImplType() const override { return implType; } -private: - static const impl_desc_type implType = impl_desc_type::ref; + void exec(const std::vector &src, const std::vector &dst) override; + impl_desc_type implType() const override { return impl_desc_type::ref; } }; class RefOptimizedTransposeExecutorBuilder : public TransposeExecutorBuilder { @@ -47,4 +45,4 @@ class RefOptimizedTransposeExecutorBuilder : public TransposeExecutorBuilder { }; } // namespace intel_cpu -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/common/ref_transpose.cpp b/src/plugins/intel_cpu/src/nodes/executors/common/ref_transpose.cpp index d3a5d79cd50b31..3b3e17daabb0b4 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/common/ref_transpose.cpp +++ b/src/plugins/intel_cpu/src/nodes/executors/common/ref_transpose.cpp @@ -63,9 +63,10 @@ void RefTransposeExecutor::referenceExecute(const uint8_t* src_data, uint8_t* ds }); } -void RefTransposeExecutor::exec(const std::vector& src, const std::vector& dst, const int MB) { - const uint8_t* src_data = reinterpret_cast(src[0]->getData()); - uint8_t* dst_data = reinterpret_cast(dst[0]->getData()); +void RefTransposeExecutor::exec(const std::vector& src, const std::vector& dst) { + const uint8_t* src_data = src[0]->getDataAs(); + uint8_t* dst_data = dst[0]->getDataAs(); + const int MB = src[0]->getStaticDims()[0]; referenceExecute(src_data, dst_data, jcp, MB); } @@ -78,4 +79,4 @@ bool RefTransposeExecutor::init(const TransposeParams &transposeParams, } } // namespace intel_cpu -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/common/ref_transpose.hpp b/src/plugins/intel_cpu/src/nodes/executors/common/ref_transpose.hpp index 07910df06892dc..ec0c37c53074fd 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/common/ref_transpose.hpp +++ b/src/plugins/intel_cpu/src/nodes/executors/common/ref_transpose.hpp @@ -16,10 +16,9 @@ class RefTransposeExecutor : public TransposeExecutor { const std::vector &srcDescs, const std::vector &dstDescs, const dnnl::primitive_attr &attr) override; - void exec(const std::vector &src, const std::vector &dst, const int MB) override; - impl_desc_type getImplType() const override { return implType; } + void exec(const std::vector &src, const std::vector &dst) override; + impl_desc_type implType() const override { return impl_desc_type::ref; } private: - static const impl_desc_type implType = impl_desc_type::ref; jit_permute_config_params jcp; }; diff --git a/src/plugins/intel_cpu/src/nodes/executors/convert.hpp b/src/plugins/intel_cpu/src/nodes/executors/convert.hpp index 323768a0b20836..ce766663a0b653 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/convert.hpp +++ b/src/plugins/intel_cpu/src/nodes/executors/convert.hpp @@ -18,15 +18,13 @@ struct ConvertParams { size_t size; }; -class ConvertExecutor { +class ConvertExecutor : public Executor { public: explicit ConvertExecutor(const ExecutorContext::CPtr context); virtual bool init(const ConvertParams& convertParams, const MemoryDescPtr& srcDesc, const MemoryDescPtr& dstDesc, const dnnl::primitive_attr &attr) = 0; - virtual void exec(const MemoryCPtr& src, const MemoryPtr& dst) = 0; - virtual impl_desc_type getImplType() const = 0; virtual ~ConvertExecutor() = default; protected: ConvertParams convertParams; @@ -48,4 +46,4 @@ using ConvertExecutorBuilderPtr = std::shared_ptr; using ConvertExecutorBuilderCPtr = std::shared_ptr; } // namespace intel_cpu -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/convert_list.hpp b/src/plugins/intel_cpu/src/nodes/executors/convert_list.hpp index bbbc992111363e..a7ed05ceb634e4 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/convert_list.hpp +++ b/src/plugins/intel_cpu/src/nodes/executors/convert_list.hpp @@ -26,12 +26,12 @@ struct ConvertExecutorDesc { const std::vector& getConvertExecutorsList(); -class ConvertExecutorFactory : public ExecutorFactory { +class ConvertExecutorFactory : public ExecutorFactoryLegacy { public: ConvertExecutorFactory(const ConvertParams& convertParams, const MemoryDescPtr& srcDesc, const MemoryDescPtr& dstDesc, - const ExecutorContext::CPtr context) : ExecutorFactory(context) { + const ExecutorContext::CPtr context) : ExecutorFactoryLegacy(context) { for (auto& desc : getConvertExecutorsList()) { if (desc.builder->isSupported(convertParams, srcDesc, dstDesc)) { supportedDescs.push_back(desc); @@ -54,4 +54,4 @@ using ConvertExecutorFactoryPtr = std::shared_ptr; using ConvertExecutorFactoryCPtr = std::shared_ptr; } // namespace intel_cpu -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/convolution_config.hpp b/src/plugins/intel_cpu/src/nodes/executors/convolution_config.hpp new file mode 100644 index 00000000000000..124b512eaa85e9 --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/convolution_config.hpp @@ -0,0 +1,23 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "executor_config.hpp" + +namespace ov { +namespace intel_cpu { + +/** + * @todo only attributes necessary for 1x1 convlution as fullyconnected fallback + * are currently listed + */ +struct ConvAttrs { + bool withBias; +}; + +using ConvConfig = executor::Config; + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/debug_messages.hpp b/src/plugins/intel_cpu/src/nodes/executors/debug_messages.hpp new file mode 100644 index 00000000000000..2ee407564bf957 --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/debug_messages.hpp @@ -0,0 +1,26 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#define UNSUPPORTED_SPARSE_WEIGHTS " sparse weights are not supported" +#define UNSUPPORTED_WEIGHTS_DECOMPRESSION " weights decompression is not supported" +#define UNSUPPORTED_POST_OPS " post ops are not supported" +#define UNSUPPORTED_SRC_PRECISIONS " unsupported src precisions" +#define UNSUPPORTED_WEI_PRECISIONS " unsupported wei precisions" +#define UNSUPPORTED_DST_PRECISIONS " unsupported dst precisions" +#define UNSUPPORTED_ISA " unsupported isa" +#define UNSUPPORTED_SRC_RANK " unsupported src rank" +#define UNSUPPORTED_WEI_RANK " unsupported wei rank" +#define UNSUPPORTED_DST_RANK " unsupported dst rank" +#define UNSUPPORTED_DST_STRIDES " unsupported dst strides" +#define HEURISTICS_MISMATCH " heuristics mismatch" + +#define VERIFY(condition, ...) \ + do { \ + if (!(condition)) { \ + DEBUG_LOG(__VA_ARGS__); \ + return false; \ + } \ + } while (0) diff --git a/src/plugins/intel_cpu/src/nodes/executors/deconv_list.hpp b/src/plugins/intel_cpu/src/nodes/executors/deconv_list.hpp index 58a188fc598f10..4c63a565aac2e0 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/deconv_list.hpp +++ b/src/plugins/intel_cpu/src/nodes/executors/deconv_list.hpp @@ -24,12 +24,12 @@ struct DeconvExecutorDesc { const std::vector& getDeconvExecutorsList(); -class DeconvExecutorFactory : public ExecutorFactory { +class DeconvExecutorFactory : public ExecutorFactoryLegacy { public: DeconvExecutorFactory(const DeconvAttrs& deconvAttrs, const std::vector& srcDescs, const std::vector& dstDescs, - const ExecutorContext::CPtr context) : ExecutorFactory(context) { + const ExecutorContext::CPtr context) : ExecutorFactoryLegacy(context) { for (auto& desc : getDeconvExecutorsList()) { if (desc.builder->isSupported(deconvAttrs, srcDescs, dstDescs)) { supportedDescs.push_back(desc); diff --git a/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_aliases.hpp b/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_aliases.hpp new file mode 100644 index 00000000000000..a611e94f617e44 --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_aliases.hpp @@ -0,0 +1,16 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include + +namespace ov { +namespace intel_cpu { + +using dnnl_primitive_args = std::unordered_map; + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_convolution_primitive.cpp b/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_convolution_primitive.cpp new file mode 100644 index 00000000000000..11309c408da0ae --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_convolution_primitive.cpp @@ -0,0 +1,191 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "nodes/executors/dnnl/dnnl_convolution_primitive.hpp" + +#include +#include + +#include "dnnl_extension_utils.h" +#include "memory_desc/cpu_memory_desc.h" +#include "memory_desc/cpu_memory_desc_utils.h" +#include "memory_desc/dnnl_memory_desc.h" +#include "nodes/executors/convolution_config.hpp" +#include "nodes/executors/dnnl/dnnl_aliases.hpp" +#include "nodes/executors/dnnl/dnnl_shape_agnostic_data.hpp" +#include "nodes/executors/executor.hpp" +#include "nodes/executors/memory_arguments.hpp" +#include "onednn/iml_type_mapper.h" + +namespace ov { +namespace intel_cpu { + +using namespace dnnl; +using namespace executor; + +// @todo rewrite using hash_builder +size_t DnnlConvolutionPrimitive::Key::hash() const { + using namespace dnnl::impl; + using namespace dnnl::impl::primitive_hashing; + + size_t seed = 0; + + for (const auto& ptr : {src, wei, bias, dst}) { + if (ptr) { + seed = hash_combine(seed, get_md_hash(*ptr->getDnnlDesc().get())); + } + } + + seed = hash_combine(seed, get_attr_hash(*attr.get())); + + return seed; +} + +bool DnnlConvolutionPrimitive::Key::operator==(const Key& rhs) const { + bool result = true; + + if (src != rhs.src) { + result = result && src && rhs.src && src->getDnnlDesc() == rhs.src->getDnnlDesc(); + } + if (wei != rhs.wei) { + result = result && wei && rhs.wei && wei->getDnnlDesc() == rhs.wei->getDnnlDesc(); + } + if (bias != rhs.bias) { + result = result && bias && rhs.bias && bias->getDnnlDesc() == rhs.bias->getDnnlDesc(); + } + if (dst != rhs.dst) { + result = result && dst && rhs.dst && dst->getDnnlDesc() == rhs.dst->getDnnlDesc(); + } + + result = result && *attr.get() == *rhs.attr.get(); + + return result; +} + +// make a fake shape: N, C, W +static dnnl::memory::dims normalizeDims(const dnnl::memory::dims& dims) { + assert(one_of(static_cast(dims.size()), 2, 3)); + + if (dims.size() == 3) { + return {dims[0], dims[2], dims[1]}; + } + + return {dnnl::memory::dim{1}, dims[1], dims[0]}; +} + +static dnnl::convolution_forward::primitive_desc createDescriptorInternal(const dnnl::memory::desc& inputDesc, + const dnnl::memory::desc& weightDesc, + const dnnl::memory::desc& biasDesc, + const dnnl::memory::desc& outputDesc, + const dnnl::primitive_attr& attr, + const dnnl::engine& engine) { + const auto normalizedInDims = normalizeDims(inputDesc.get_dims()); + const auto convInDesc = dnnl::memory::desc(normalizedInDims, inputDesc.get_data_type(), memory::format_tag::nwc); + const auto normalizedOutDims = normalizeDims(outputDesc.get_dims()); + const auto convOutDesc = dnnl::memory::desc(normalizedOutDims, outputDesc.get_data_type(), memory::format_tag::nwc); + + // @todo create general mapping from node configuration to backend configuration + static const std::map weightsTypeByInputType{ + // input data type weights data type + {memory::data_type::f32, memory::data_type::f32 }, + {memory::data_type::f16, memory::data_type::f16 }, + {memory::data_type::bf16, memory::data_type::bf16}, + {memory::data_type::u8, memory::data_type::s8 }, + {memory::data_type::s8, memory::data_type::s8 }, + }; + + // make a fake shape: OC, IC, 1 + const auto& weightDims = weightDesc.get_dims(); + const dnnl::memory::dims normalizedWeightDims{static_cast(weightDims[0]), + static_cast(weightDims[1]), + dnnl::memory::dim{1}}; + const auto weightDataType = weightsTypeByInputType.at(inputDesc.get_data_type()); + const auto convWeightDescAny = + dnnl::memory::desc(normalizedWeightDims, weightDataType, dnnl::memory::format_tag::any); + + return dnnl::convolution_forward::primitive_desc(engine, + prop_kind::forward_inference, + dnnl::algorithm::convolution_direct, + convInDesc, + convWeightDescAny, + biasDesc, + convOutDesc, + dnnl::memory::dims{1}, // stride + dnnl::memory::dims{0}, // dilation + dnnl::memory::dims{0}, // paddingL + dnnl::memory::dims{0}, // paddingR + attr); +} + +static primitive_desc createPrimitiveDesc(const dnnl::engine& engine, + const dnnl::memory::desc& inputDesc, + const dnnl::memory::desc& weightDesc, + const dnnl::memory::desc& biasDesc, + const dnnl::memory::desc& outputDesc, + const dnnl::primitive_attr& attr, + const std::vector& implPriorities) { + auto prim_desc = createDescriptorInternal(inputDesc, weightDesc, biasDesc, outputDesc, attr, engine); + auto first_desc = dnnl::convolution_forward::primitive_desc(prim_desc.get()); + + for (auto preferredImplType : implPriorities) { + const bool found = DnnlExtensionUtils::find_implementation(prim_desc, preferredImplType); + + if (found) + return std::move(prim_desc); + } + + return std::move(first_desc); +} + +void DnnlConvolutionPrimitive::execute(const dnnl_primitive_args& primArgs) const { + m_prim.execute(m_stream, primArgs); +} + +std::shared_ptr DnnlConvolutionPrimitive::create( + const MemoryArgs& memory, + const ConvAttrs& attrs, + const ExecutorContext::CPtr context, + const DnnlShapeAgnosticDataPtr& shapeAgnosticData) { + const auto& srcDesc = MemoryDescUtils::convertToDnnlMemoryDesc(memory.at(ARG_SRC)->getDescPtr()); + const auto& weiDesc = MemoryDescUtils::convertToDnnlMemoryDesc(memory.at(ARG_WEI)->getDescPtr()); + // @todo remove after empty memory desc is introduced + const DnnlMemoryDescPtr biaDesc = memory.at(ARG_BIAS)->getDescPtr()->getCurrentMemSize() != 0 + ? MemoryDescUtils::convertToDnnlMemoryDesc(memory.at(ARG_BIAS)->getDescPtr()) + : DnnlExtensionUtils::makeDescriptor(dnnl::memory::desc{}); + const auto& dstDesc = MemoryDescUtils::convertToDnnlMemoryDesc(memory.at(ARG_DST)->getDescPtr()); + + const Key dnnlConvKey{srcDesc, weiDesc, biaDesc, dstDesc, shapeAgnosticData->primAttrs.attr}; + + auto builder = [&context](const Key& dnnlKey) { + return std::make_shared(dnnlKey, context->getEngine(), context->getImplPriorities()); + }; + + auto runtimeCache = context->getRuntimeCache(); + const auto result = runtimeCache->getOrCreate(dnnlConvKey, builder); + const auto& primitive = result.first; + assert(primitive); + + return primitive; +} + +DnnlConvolutionPrimitive::DnnlConvolutionPrimitive(const Key& key, + const dnnl::engine& engine, + const std::vector& implPriorities) + : m_stream(dnnl::stream(engine)), + m_primDesc(createPrimitiveDesc(engine, + key.src->getDnnlDesc(), + key.wei->getDnnlDesc(), + key.bias->getDnnlDesc(), + key.dst->getDnnlDesc(), + key.attr, + implPriorities)), + m_implType(parse_impl_name(m_primDesc.impl_info_str())), + m_srcDesc(DnnlExtensionUtils::makeDescriptor(m_primDesc.src_desc())), + m_weiDesc(DnnlExtensionUtils::makeDescriptor(m_primDesc.weights_desc())), + m_dstDesc(DnnlExtensionUtils::makeDescriptor(m_primDesc.dst_desc())), + m_scratchPadDesc(DnnlExtensionUtils::makeDescriptor(m_primDesc.scratchpad_desc())), + m_prim(primitive(m_primDesc)) {} + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_convolution_primitive.hpp b/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_convolution_primitive.hpp new file mode 100644 index 00000000000000..1a7fb3c08b3137 --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_convolution_primitive.hpp @@ -0,0 +1,83 @@ +// Copyright (C) 2018-2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include + +#include "cpu_memory.h" +#include "memory_desc/dnnl_memory_desc.h" +#include "nodes/executors/convolution_config.hpp" +#include "nodes/executors/dnnl/dnnl_aliases.hpp" +#include "nodes/executors/dnnl/dnnl_shape_agnostic_data.hpp" +#include "nodes/executors/dnnl/dnnl_utils.hpp" +#include "nodes/executors/executor.hpp" + +namespace ov { +namespace intel_cpu { + +// @todo executor is not complete and covers only 1x1 fallback case for fullyconnected node +class DnnlConvolutionPrimitive { + // @todo generalize caching for dnnl backend + struct Key { + // @todo shouldn't we have a key representing onednn specific data types only? + const DnnlMemoryDescCPtr src; + const DnnlMemoryDescCPtr wei; + const DnnlMemoryDescCPtr bias; + const DnnlMemoryDescCPtr dst; + + const dnnl::primitive_attr attr; + + size_t hash() const; + bool operator==(const Key& rhs) const; + }; + +public: + DnnlConvolutionPrimitive(const Key& key, + const dnnl::engine& engine, + const std::vector& implPriorities); + + void execute(const dnnl_primitive_args& primArgs) const; + + const DnnlMemoryDescPtr srcDesc() const { + return m_srcDesc; + } + + const DnnlMemoryDescPtr dstDesc() const { + return m_dstDesc; + } + + const DnnlMemoryDescPtr weightsDesc() const { + return m_weiDesc; + } + + const DnnlMemoryDescPtr scratchPadDesc() const { + return m_scratchPadDesc; + } + + impl_desc_type implType() const { + return m_implType; + } + + static std::shared_ptr create(const MemoryArgs& memory, + const ConvAttrs& attrs, + const ExecutorContext::CPtr context, + const DnnlShapeAgnosticDataPtr& shapeAgnosticData); + +private: + dnnl::stream m_stream; + dnnl::primitive_desc m_primDesc; + impl_desc_type m_implType; + DnnlMemoryDescPtr m_srcDesc; + DnnlMemoryDescPtr m_weiDesc; + DnnlMemoryDescPtr m_dstDesc; + DnnlMemoryDescPtr m_scratchPadDesc; + dnnl::primitive m_prim; +}; + +using DnnlConvExecutorPtr = std::shared_ptr; + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_fullyconnected.hpp b/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_fullyconnected.hpp new file mode 100644 index 00000000000000..f50b4edc04f5c9 --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_fullyconnected.hpp @@ -0,0 +1,150 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include + +#include "cpu_memory.h" +#include "memory_desc/cpu_memory_desc.h" +#include "nodes/executors/dnnl/dnnl_fullyconnected_primitive.hpp" +#include "nodes/executors/dnnl/dnnl_aliases.hpp" +#include "nodes/executors/executor.hpp" +#include "nodes/executors/executor_config.hpp" +#include "nodes/executors/memory_arguments.hpp" + +namespace ov { +namespace intel_cpu { + +template +class DefaultInstantiator { +public: + std::shared_ptr operator()(const MemoryArgs& memory, + const Attrs& attrs, + const ExecutorContext::CPtr context, + const std::shared_ptr shapeAgnosticData) { + return ExecutorT::create(memory, attrs, context, shapeAgnosticData); + } +}; + +template > +class DnnlFCExecutor : public Executor { +public: + using PrimitivePtr = std::shared_ptr; + DnnlFCExecutor(const Attrs& attrs, + const PostOps& postOps, + const MemoryArgs& memory, + const ExecutorContext::CPtr context, + const bool cacheWeights) + : m_attrs(attrs), + m_context(context), + m_shapeAgnosticData(DnnlFCPrimitive::createShapeAgnosticData(m_attrs, postOps, memory, m_context, cacheWeights)), + m_primArgs(m_shapeAgnosticData->primAttrs.dnnlArgs) {} + void update(const MemoryArgs& memory) override { + const auto primitive = createPrimitive(memory); + updateMemory(m_primitive, primitive, memory); + m_primitive = primitive; + } + + void execute(const MemoryArgs& memory) override { + if (resetSrcMemoryDataHandle) + m_primArgs[DNNL_ARG_SRC].set_data_handle(memory.at(ARG_SRC)->getData()); + if (resetDstMemoryDataHandle) + m_primArgs[DNNL_ARG_DST].set_data_handle(memory.at(ARG_DST)->getData()); + + m_primitive->execute(m_primArgs); + } + + impl_desc_type implType() const override { + return m_primitive->implType(); + } + +private: + void updateSrcMemory(const DnnlMemoryDescPtr& memDesc, const PrimitivePtr primitive, const MemoryPtr memory) { + const auto& primMemDesc = primitive->srcDesc(); + if (memDesc->isCompatible(*primMemDesc)) { + m_primArgs[DNNL_ARG_SRC] = memory->getPrimitive(); + } else { + resetSrcMemoryDataHandle = true; + // create 2D memory without underlying buffer and reset to the actual memory in scope of 'execute' call + m_primArgs[DNNL_ARG_SRC] = + dnnl::memory(primMemDesc->getDnnlDesc(), m_context->getEngine(), memory->getData()); + } + } + + void updateDstMemory(const DnnlMemoryDescPtr& memDesc, const PrimitivePtr primitive, const MemoryPtr memory) { + const auto& primMemDesc = primitive->dstDesc(); + if (memDesc->isCompatible(*primMemDesc)) { + m_primArgs[DNNL_ARG_DST] = memory->getPrimitive(); + } else { + resetDstMemoryDataHandle = true; + // create 2D memory without underlying buffer and reset to the actual memory in scope of 'execute' call + m_primArgs[DNNL_ARG_DST] = + dnnl::memory(primMemDesc->getDnnlDesc(), m_context->getEngine(), memory->getData()); + } + } + + void updateWeightsMemory(DnnlMemoryDescPtr originalMemDesc, + const PrimitivePtr currentPrimitive, + const PrimitivePtr newPrimitive, + const MemoryPtr memory) { + const auto newPrimMemDesc = newPrimitive->weightsDesc(); + if (currentPrimitive && currentPrimitive->weightsDesc()->isCompatible(*newPrimMemDesc)) + return; + + if (m_attrs.weightsNonTransposed) + originalMemDesc = utils::makeTransposedWeightDescriptor(originalMemDesc, newPrimMemDesc); + + const auto weiMemory = utils::prepareWeightsMemory(originalMemDesc, newPrimMemDesc, memory, m_context); + m_primArgs[DNNL_ARG_WEIGHTS] = weiMemory->getPrimitive(); + } + + void updateBiasMemory(const MemoryPtr memory) { + m_primArgs[DNNL_ARG_BIAS] = memory->getPrimitive(); + } + + void updateScratchPadMem(const PrimitivePtr currentPrimitive, const PrimitivePtr newPrimitive) { + const auto newPrimMemDesc = newPrimitive->scratchPadDesc(); + // @todo should we compare dnnl::memory::desc directly to avoid any overhead? + if (currentPrimitive && currentPrimitive->scratchPadDesc()->isCompatible(*newPrimMemDesc)) + return; + + m_scratchPadMemory = m_context->getScratchPad()->createScratchPadMem(newPrimMemDesc); + m_primArgs[DNNL_ARG_SCRATCHPAD] = m_scratchPadMemory->getPrimitive(); + } + + void updateMemory(const PrimitivePtr currentPrimitive, + const PrimitivePtr newPrimitive, + const MemoryArgs& memory) { + const auto& srcDesc = MemoryDescUtils::convertToDnnlMemoryDesc(memory.at(ARG_SRC)->getDescPtr()); + const auto& weiDesc = MemoryDescUtils::convertToDnnlMemoryDesc(memory.at(ARG_WEI)->getDescPtr()); + const auto& dstDesc = MemoryDescUtils::convertToDnnlMemoryDesc(memory.at(ARG_DST)->getDescPtr()); + + updateSrcMemory(srcDesc, newPrimitive, memory.at(ARG_SRC)); + updateDstMemory(dstDesc, newPrimitive, memory.at(ARG_DST)); + updateWeightsMemory(weiDesc, currentPrimitive, newPrimitive, memory.at(ARG_WEI)); + updateBiasMemory(memory.at(ARG_BIAS)); + updateScratchPadMem(currentPrimitive, newPrimitive); + } + + PrimitivePtr createPrimitive(const MemoryArgs& memory) { + return Instantiator{}(memory, m_attrs, m_context, m_shapeAgnosticData); + } + + const Attrs& m_attrs; + const ExecutorContext::CPtr m_context; + const std::shared_ptr m_shapeAgnosticData; + dnnl_primitive_args& m_primArgs; + bool resetSrcMemoryDataHandle = false; + bool resetDstMemoryDataHandle = false; + MemoryPtr m_scratchPadMemory; + PrimitivePtr m_primitive; +}; + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_fullyconnected_primitive.cpp b/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_fullyconnected_primitive.cpp new file mode 100644 index 00000000000000..a9a852fe32e817 --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_fullyconnected_primitive.cpp @@ -0,0 +1,356 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "dnnl_fullyconnected_primitive.hpp" + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "cpu/x64/cpu_isa_traits.hpp" +#include "cpu_memory.h" +#include "cpu_types.h" +#include "dnnl_extension_utils.h" +#include "dnnl_postops_composer.h" +#include "memory_desc/cpu_memory_desc.h" +#include "memory_desc/cpu_memory_desc_utils.h" +#include "memory_desc/dnnl_memory_desc.h" +#include "nodes/executors/dnnl/dnnl_shape_agnostic_data.hpp" +#include "nodes/executors/executor.hpp" +#include "nodes/executors/fullyconnected_config.hpp" +#include "nodes/executors/memory_arguments.hpp" +#include "utils/debug_capabilities.h" + +namespace ov { +namespace intel_cpu { + +using namespace dnnl; +using namespace ov::element; +using namespace executor; + +// @todo rewrite using hash_builder +size_t DnnlFCPrimitive::Key::hash() const { + using namespace dnnl::impl; + using namespace dnnl::impl::primitive_hashing; + + size_t seed = 0; + + for (const auto& ptr : {src, wei, bias, dst}) { + if (ptr) { + seed = hash_combine(seed, get_md_hash(*ptr->getDnnlDesc().get())); + } + } + + seed = hash_combine(seed, get_attr_hash(*attr.get())); + seed = hash_combine(seed, sparseWeights); + seed = hash_combine(seed, transposedWeights); + + return seed; +} + +bool DnnlFCPrimitive::Key::operator==(const Key& rhs) const { + bool result = true; + + if (src != rhs.src) { + result = result && src && rhs.src && src->getDnnlDesc() == rhs.src->getDnnlDesc(); + } + if (wei != rhs.wei) { + result = result && wei && rhs.wei && wei->getDnnlDesc() == rhs.wei->getDnnlDesc(); + } + if (bias != rhs.bias) { + result = result && bias && rhs.bias && bias->getDnnlDesc() == rhs.bias->getDnnlDesc(); + } + if (dst != rhs.dst) { + result = result && dst && rhs.dst && dst->getDnnlDesc() == rhs.dst->getDnnlDesc(); + } + + result = result && *attr.get() == *rhs.attr.get() && sparseWeights == rhs.sparseWeights && + transposedWeights == rhs.transposedWeights; + + return result; +} + +std::shared_ptr DnnlFCPrimitive::create(const MemoryArgs& memory, + const FCAttrs& attrs, + const ExecutorContext::CPtr context, + const DnnlShapeAgnosticDataPtr& shapeAgnosticData) { + const auto& srcDesc = MemoryDescUtils::convertToDnnlMemoryDesc(memory.at(ARG_SRC)->getDescPtr()); + const auto& weiDesc = MemoryDescUtils::convertToDnnlMemoryDesc(memory.at(ARG_WEI)->getDescPtr()); + const DnnlMemoryDescPtr biaDesc = memory.at(ARG_BIAS)->getDescPtr()->getCurrentMemSize() != 0 + ? MemoryDescUtils::convertToDnnlMemoryDesc(memory.at(ARG_BIAS)->getDescPtr()) + : DnnlExtensionUtils::makeDescriptor(dnnl::memory::desc{}); + const auto& dstDesc = MemoryDescUtils::convertToDnnlMemoryDesc(memory.at(ARG_DST)->getDescPtr()); + + Key dnnlFCKey{ + srcDesc, + weiDesc, + biaDesc, + dstDesc, + shapeAgnosticData->primAttrs.attr, + attrs.sparseWeights, + attrs.weightsNonTransposed, + }; + + auto builder = [&context](const Key& dnnlKey) { + return std::make_shared(dnnlKey, context->getEngine(), context->getImplPriorities()); + }; + + auto runtimeCache = context->getRuntimeCache(); + const auto result = runtimeCache->getOrCreate(dnnlFCKey, builder); + const auto& primitive = result.first; + assert(primitive); + + return primitive; +} + +bool DnnlFCPrimitive::useWeightsDecompressionImpl(const ov::element::Type inputType, + const ov::element::Type weightsType) { + return dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx2) && one_of(inputType, f32, bf16) && + one_of(weightsType, u8, nf4, u4, i4); +} + +template +static std::vector normalizeDimsTo2D(const std::vector& dims) { + return {std::accumulate(dims.begin(), dims.end() - 1, (T)1, std::multiplies()), dims[dims.size() - 1]}; +} + +static DnnlPrimitiveAttrs createPrimitiveAttrs(const FCAttrs& attrs, + const PostOps& postOps, + const MemoryArgs& memory, + ExecutorContext::CPtr context) { + const auto& srcDesc = memory.at(ARG_SRC)->getDescPtr(); + const auto& weiDesc = memory.at(ARG_WEI)->getDescPtr(); + const auto& dstDesc = memory.at(ARG_DST)->getDescPtr(); + + const auto& originalDims = dstDesc->getShape().getMinDims(); + const auto& dims = normalizeDimsTo2D(originalDims); + + auto isINT8 = + one_of(srcDesc->getPrecision(), ov::element::u8, ov::element::i8) && weiDesc->getPrecision() == ov::element::i8; + auto outputDataType = DnnlExtensionUtils::ElementTypeToDataType(dstDesc->getPrecision()); + + DnnlPostOpsComposer dnnlpoc(postOps, + context->getEngine(), + dims, + dims.size() - 1, + isINT8, + 1 << 0, + attrs.dequantizationScales, + attrs.withBias, + outputDataType); + + if (attrs.decompressionMultiplyPtr) + dnnlpoc.appendDecompressionScales(attrs.decompressionMultiplyPtr, !attrs.weightsNonTransposed); + if (attrs.decompressionSubtractPtr) + dnnlpoc.appendDecompressionZeroPoints(attrs.decompressionSubtractPtr, + !attrs.weightsNonTransposed); + + return dnnlpoc.compose(); +} + +static dnnl::memory::desc normalizeDescriptor(const dnnl::memory::desc& desc) { + const auto& dims = desc.get_dims(); + + if (dims.size() > 2) + return desc.reshape(normalizeDimsTo2D(dims)); + + return desc; +} + +static dnnl::inner_product_forward::primitive_desc createDescriptorInternal(const dnnl::memory::desc& inputDesc, + const dnnl::memory::desc& weightDesc, + const dnnl::memory::desc& biasDesc, + const dnnl::memory::desc& outputDesc, + const dnnl::primitive_attr& attr, + const dnnl::engine& engine, + const bool useSparseWeights, + const bool useWeightsDecompression) { + const auto normalizedInputDesc = normalizeDescriptor(inputDesc); + const auto normalizedOutputDesc = normalizeDescriptor(outputDesc); + + const auto indt = normalizedInputDesc.get_data_type(); + auto wdt = indt; + + if (useWeightsDecompression) { + wdt = weightDesc.get_data_type(); + } else if (indt == dnnl::memory::data_type::u8 || indt == dnnl::memory::data_type::s8) { + wdt = memory::data_type::s8; + } + + const dnnl::memory::desc weightsDesc = + useSparseWeights ? dnnl::memory::desc().sparse_desc(weightDesc.get_dims(), wdt) + : dnnl::memory::desc(weightDesc.get_dims(), wdt, memory::format_tag::any); + + return dnnl::inner_product_forward::primitive_desc(engine, + dnnl::prop_kind::forward_inference, + normalizedInputDesc, + weightsDesc, + biasDesc, + normalizedOutputDesc, + attr); +} + +static primitive_desc createPrimitiveDesc(const dnnl::memory::desc& inputDesc, + const dnnl::memory::desc& weightDesc, + const dnnl::memory::desc& biasDesc, + const dnnl::memory::desc& outputDesc, + const dnnl::primitive_attr& attr, + const dnnl::engine& engine, + const std::vector& implPriorities, + const bool useSparseWeights, + const bool useWeightsDecompression) { + auto prim_desc = createDescriptorInternal(inputDesc, + weightDesc, + biasDesc, + outputDesc, + attr, + engine, + useSparseWeights, + useWeightsDecompression); + OPENVINO_ASSERT(prim_desc, "Failed to create inner_product primitive descriptor"); + auto first_desc = dnnl::inner_product_forward::primitive_desc(prim_desc.get()); + + const bool found = DnnlExtensionUtils::find_implementation(prim_desc, [&](impl_desc_type implType) { + return contains(implPriorities, implType); + }); + + if (found) + return std::move(prim_desc); + + return std::move(first_desc); +} + +static VectorDims makeDummyInputDims(const Shape& inShape, const Shape& wShape) { + const auto& weightDims = wShape.getStaticDims(); + + auto inMinDims = inShape.getMinDims(); + auto inMaxDims = inShape.getMaxDims(); + inMinDims.back() = weightDims.back(); + inMaxDims.back() = weightDims.back(); + + return MemoryDescUtils::makeDummyShape(Shape(inMinDims, inMaxDims)).getStaticDims(); +} + +static VectorDims makeDummyOutputDims(const VectorDims& inShape, const VectorDims& wShape, const size_t out_rank) { + size_t activationRank = inShape.size(); + size_t channelRank = wShape.size() - 1; + // activation weight output_shape + // NCHW CoCHW NCo + // TNC CoC TNCo + // NC CoC NCo + VectorDims outputShape(out_rank, 1); + // set Co + outputShape.back() = wShape[0]; + // set batch dims + size_t batchRank = activationRank - channelRank; + size_t startIdx = out_rank - batchRank - 1; + for (size_t i = 0; i < batchRank; i++) { + outputShape[i + startIdx] = inShape[i]; + } + + return outputShape; +} + +DnnlShapeAgnosticDataPtr DnnlFCPrimitive::createShapeAgnosticData(const FCAttrs& attrs, + const PostOps& postOps, + const MemoryArgs& memory, + const ExecutorContext::CPtr context, + const bool cacheWeights) { + DEBUG_LOG("Creating shape agnostic data"); + auto srcDesc = memory.at(ARG_SRC)->getDescPtr(); + const auto& weiDesc = memory.at(ARG_WEI)->getDescPtr(); + auto dstDesc = memory.at(ARG_DST)->getDescPtr(); + + const auto postOpData = createPrimitiveAttrs(attrs, postOps, memory, context); + + if (!cacheWeights) + return std::make_shared(postOpData); + + if (srcDesc->getShape().isDynamic()) { + const auto& inShape = srcDesc->getShape(); + const auto& wShape = weiDesc->getShape(); + const auto& inDymmyDims = makeDummyInputDims(inShape, wShape); + srcDesc = srcDesc->cloneWithNewDims(inDymmyDims); + const auto& outDymmyDims = + makeDummyOutputDims(inDymmyDims, wShape.getStaticDims(), dstDesc->getShape().getRank()); + dstDesc = dstDesc->cloneWithNewDims(outDymmyDims); + } + + const dnnl::memory::desc srcDnnlDesc = MemoryDescUtils::convertToDnnlMemoryDesc(srcDesc)->getDnnlDesc(); + const dnnl::memory::desc weiDnnlDesc = MemoryDescUtils::convertToDnnlMemoryDesc(weiDesc)->getDnnlDesc(); + const dnnl::memory::desc dstDnnlDesc = MemoryDescUtils::convertToDnnlMemoryDesc(dstDesc)->getDnnlDesc(); + const auto useSparseWeights = attrs.sparseWeights; + const auto useWeightsDecompression = useWeightsDecompressionImpl(srcDesc->getPrecision(), weiDesc->getPrecision()); + + const dnnl::memory::desc biaDnnlDesc = + memory.at(ARG_BIAS)->getDescPtr()->getCurrentMemSize() != 0 + ? MemoryDescUtils::convertToDnnlMemoryDesc(memory.at(ARG_BIAS)->getDescPtr())->getDnnlDesc() + : dnnl::memory::desc{}; + + const auto primDesc = createPrimitiveDesc(srcDnnlDesc, + weiDnnlDesc, + biaDnnlDesc, + dstDnnlDesc, + postOpData.attr, + context->getEngine(), + context->getImplPriorities(), + useSparseWeights, + useWeightsDecompression); + + const auto weightsDesc = DnnlExtensionUtils::makeDescriptor(primDesc.weights_desc()); + auto originalWeightsDesc = MemoryDescUtils::convertToDnnlMemoryDesc(weiDesc); + if (attrs.weightsNonTransposed) + originalWeightsDesc = utils::makeTransposedWeightDescriptor(originalWeightsDesc, weightsDesc); + + // ignore the result since we just need to put the packed weights into the cache + (void)utils::prepareWeightsMemory(originalWeightsDesc, + weightsDesc, + memory.at(ARG_WEI), + context); + + return std::make_shared(postOpData); +} + +static impl_desc_type implTypeFromPrimDesc(const dnnl::primitive_desc primDesc) { + const auto implType = parse_impl_name(primDesc.impl_info_str()); + if (implType == ov::intel_cpu::brgemm_avx512_amx && + primDesc.weights_desc().get_format_kind() == memory::format_kind::sparsed) { + return ov::intel_cpu::brgemm_sparse_avx512_amx; + } + + return implType; +} + +DnnlFCPrimitive::DnnlFCPrimitive(const Key& key, + const dnnl::engine& engine, + const std::vector& implPriorities) + : m_stream(dnnl::stream(engine)), + m_primDesc(createPrimitiveDesc(key.src->getDnnlDesc(), + key.wei->getDnnlDesc(), + key.bias->getDnnlDesc(), + key.dst->getDnnlDesc(), + key.attr, + engine, + implPriorities, + key.sparseWeights, + useWeightsDecompressionImpl(key.src->getPrecision(), key.wei->getPrecision()))), + m_implType(implTypeFromPrimDesc(m_primDesc)), + m_srcDesc(DnnlExtensionUtils::makeDescriptor(m_primDesc.src_desc())), + m_weiDesc(DnnlExtensionUtils::makeDescriptor(m_primDesc.weights_desc())), + m_dstDesc(DnnlExtensionUtils::makeDescriptor(m_primDesc.dst_desc())), + m_scratchPadDesc(DnnlExtensionUtils::makeDescriptor(m_primDesc.scratchpad_desc())), + m_prim(primitive(m_primDesc)) {} + +void DnnlFCPrimitive::execute(const dnnl_primitive_args& primArgs) const { + m_prim.execute(m_stream, primArgs); +} + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_fullyconnected_primitive.hpp b/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_fullyconnected_primitive.hpp new file mode 100644 index 00000000000000..479032ebf4c320 --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_fullyconnected_primitive.hpp @@ -0,0 +1,86 @@ +// Copyright (C) 2018-2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include + +#include "cpu_memory.h" +#include "memory_desc/dnnl_memory_desc.h" +#include "nodes/executors/dnnl/dnnl_shape_agnostic_data.hpp" +#include "nodes/executors/dnnl/dnnl_utils.hpp" +#include "nodes/executors/executor.hpp" +#include "nodes/executors/fullyconnected_config.hpp" + +namespace ov { +namespace intel_cpu { + +class DnnlFCPrimitive { + struct Key { + DnnlMemoryDescCPtr src; + DnnlMemoryDescCPtr wei; + DnnlMemoryDescCPtr bias; + DnnlMemoryDescCPtr dst; + dnnl::primitive_attr attr; + bool sparseWeights; + bool transposedWeights; + + size_t hash() const; + bool operator==(const Key& rhs) const; + }; + +public: + DnnlFCPrimitive(const Key& key, const dnnl::engine& engine, const std::vector& implPriorities); + + void execute(const dnnl_primitive_args& primArgs) const; + + const DnnlMemoryDescPtr srcDesc() const { + return m_srcDesc; + } + + const DnnlMemoryDescPtr dstDesc() const { + return m_dstDesc; + } + + const DnnlMemoryDescPtr weightsDesc() const { + return m_weiDesc; + } + + const DnnlMemoryDescPtr scratchPadDesc() const { + return m_scratchPadDesc; + } + + impl_desc_type implType() const { + return m_implType; + } + + static DnnlShapeAgnosticDataPtr createShapeAgnosticData(const FCAttrs& attrs, + const PostOps& postOps, + const MemoryArgs& memory, + const ExecutorContext::CPtr context, + const bool cacheWeights); + + static bool useWeightsDecompressionImpl(const ov::element::Type inputType, const ov::element::Type weightsType); + + static std::shared_ptr create(const MemoryArgs& memory, + const FCAttrs& attrs, + const ExecutorContext::CPtr context, + const DnnlShapeAgnosticDataPtr& shapeAgnosticData); + +private: + dnnl::stream m_stream; + dnnl::primitive_desc m_primDesc; + impl_desc_type m_implType; + DnnlMemoryDescPtr m_srcDesc; + DnnlMemoryDescPtr m_weiDesc; + DnnlMemoryDescPtr m_dstDesc; + DnnlMemoryDescPtr m_scratchPadDesc; + dnnl::primitive m_prim; +}; + +using DnnlFCPrimitivePtr = std::shared_ptr; + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_post_op_data.hpp b/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_post_op_data.hpp new file mode 100644 index 00000000000000..e94733eaffe2d6 --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_post_op_data.hpp @@ -0,0 +1,20 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "dnnl_aliases.hpp" +#include "nodes/executors/memory_arguments.hpp" + +namespace ov { +namespace intel_cpu { + +struct DnnlPrimitiveAttrs { + dnnl::primitive_attr attr; + dnnl_primitive_args dnnlArgs; + MemoryArgs cpuArgs; +}; + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_shape_agnostic_data.hpp b/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_shape_agnostic_data.hpp new file mode 100644 index 00000000000000..d76e1984bd87d9 --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_shape_agnostic_data.hpp @@ -0,0 +1,24 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include + +#include "nodes/executors/dnnl/dnnl_post_op_data.hpp" + +namespace ov { +namespace intel_cpu { + +struct DnnlShapeAgnosticData { + DnnlShapeAgnosticData(DnnlPrimitiveAttrs primAttrs) + : primAttrs(std::move(primAttrs)) {} + + DnnlPrimitiveAttrs primAttrs; +}; + +using DnnlShapeAgnosticDataPtr = std::shared_ptr; + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_utils.cpp b/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_utils.cpp new file mode 100644 index 00000000000000..52081f9050029b --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_utils.cpp @@ -0,0 +1,68 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "nodes/executors/dnnl/dnnl_utils.hpp" + +#include + +#include "cpu_memory.h" +#include "memory_desc/dnnl_memory_desc.h" +#include "nodes/executors/executor.hpp" +#include "nodes/reorder.h" + +namespace ov { +namespace intel_cpu { +namespace utils { + +DnnlMemoryDescPtr makeTransposedWeightDescriptor(const DnnlMemoryDescPtr srcDesc, const DnnlMemoryDescPtr dstDesc) { + const auto& weiDesc = srcDesc->getDnnlDesc(); + const auto reorderedWeiDesc = dnnl::memory::desc{weiDesc.get_dims(), weiDesc.get_data_type(), dnnl::memory::format_tag::ba}; + const auto transposedWeiDesc = reorderedWeiDesc.reshape(dstDesc->getDnnlDesc().get_dims()); + + return DnnlExtensionUtils::makeDescriptor(transposedWeiDesc); +} + +MemoryPtr prepareWeightsMemory(const DnnlMemoryDescPtr srcWeightDesc, + const DnnlMemoryDescPtr dstWeightDesc, + const MemoryCPtr weightsMem, + const ExecutorContext::CPtr context) { + const auto& eng = context->getEngine(); + const auto& format = dstWeightDesc->serializeFormat(); + + const auto privateWeightCache = context->getPrivateWeighCache(); + if (privateWeightCache) { + auto itr = privateWeightCache->find(format); + if (privateWeightCache->end() != itr) { + return itr->second; + } + } + + auto create = [&]() { + Memory srcMemory{eng, srcWeightDesc, weightsMem->getData()}; + MemoryPtr _ptr = std::make_shared(eng, dstWeightDesc); + auto rtCache = context->getRuntimeCache(); + node::Reorder::reorderData(srcMemory, *_ptr, rtCache); + + return _ptr; + }; + + auto globalWeightCache = context->getWeightsCache(); + MemoryPtr ptr; + if (globalWeightCache && + dnnl::memory::format_kind::blocked == dstWeightDesc->getDnnlDesc().get_format_kind()) { + const std::string string_hash = format + "_" + std::to_string(weightsMem->getSize()) + "_" + + std::to_string(reinterpret_cast(weightsMem->getData())); + ptr = *globalWeightCache->findOrCreate(string_hash, create); + } else { + ptr = create(); + } + + (*privateWeightCache)[format] = ptr; + + return ptr; +} + +} // namespace utils +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_utils.hpp b/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_utils.hpp new file mode 100644 index 00000000000000..2cee78428cf3b7 --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_utils.hpp @@ -0,0 +1,24 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// +// @file dnnl_utils.hpp +// Contains utility methods supposed used by oneDNN backend executors +// + +#pragma once + +#include "cpu_memory.h" +#include "memory_desc/dnnl_memory_desc.h" +#include "nodes/executors/executor.hpp" + +namespace ov { +namespace intel_cpu { +namespace utils { +DnnlMemoryDescPtr makeTransposedWeightDescriptor(const DnnlMemoryDescPtr srcDesc, const DnnlMemoryDescPtr dstDesc); +MemoryPtr prepareWeightsMemory(const DnnlMemoryDescPtr srcWeightDesc, + const DnnlMemoryDescPtr dstWeightDesc, + const MemoryCPtr weightsMem, + const ExecutorContext::CPtr context); +} // namespace utils +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/eltwise_list.hpp b/src/plugins/intel_cpu/src/nodes/executors/eltwise_list.hpp index b37c84e2766eb4..456c2d0f5251d2 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/eltwise_list.hpp +++ b/src/plugins/intel_cpu/src/nodes/executors/eltwise_list.hpp @@ -24,12 +24,12 @@ struct EltwiseExecutorDesc { const std::vector& getEltwiseExecutorsList(); -class EltwiseExecutorFactory : public ExecutorFactory { +class EltwiseExecutorFactory : public ExecutorFactoryLegacy { public: EltwiseExecutorFactory(const EltwiseAttrs& eltwiseAttrs, const std::vector& srcDescs, const std::vector& dstDescs, - const ExecutorContext::CPtr context) : ExecutorFactory(context) { + const ExecutorContext::CPtr context) : ExecutorFactoryLegacy(context) { for (auto& desc : getEltwiseExecutorsList()) { if (desc.builder->isSupported(eltwiseAttrs, srcDescs, dstDescs)) { supportedDescs.push_back(desc); @@ -81,4 +81,4 @@ using EltwiseExecutorFactoryPtr = std::shared_ptr; using EltwiseExecutorFactoryCPtr = std::shared_ptr; } // namespace intel_cpu -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/executor.cpp b/src/plugins/intel_cpu/src/nodes/executors/executor.cpp new file mode 100644 index 00000000000000..9696ff8b8e91b7 --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/executor.cpp @@ -0,0 +1,41 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "executor.hpp" + +namespace ov { +namespace intel_cpu { + +std::string ExecutorTypeToString(const ExecutorType type) { +#define CASE(_type) case ExecutorType::_type: return #_type; + switch (type) { + CASE(Undefined); + CASE(Graph); + CASE(Common); + CASE(x64); + CASE(Dnnl); + CASE(Acl); + CASE(Mlas); + } +#undef CASE + return "Undefined"; +} + +ExecutorType ExecutorTypeFromString(const std::string& typeStr) { +#define CASE(_type) if (typeStr == #_type) { return ExecutorType::_type; } + CASE(Undefined); + CASE(Graph); + CASE(Common); + CASE(x64); + CASE(Dnnl); + CASE(Acl); + CASE(Mlas); +#undef CASE + return ExecutorType::Undefined; +} + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/executor.hpp b/src/plugins/intel_cpu/src/nodes/executors/executor.hpp index a74ac434cea0b7..58cfd978723f67 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/executor.hpp +++ b/src/plugins/intel_cpu/src/nodes/executors/executor.hpp @@ -4,46 +4,54 @@ #pragma once +#include "openvino/core/except.hpp" +#include "openvino/core/visibility.hpp" +#include + #include "cache/multi_cache.h" +#include "cpu_memory.h" #include "graph_context.h" #include "onednn/iml_type_mapper.h" +#include "memory_arguments.hpp" namespace ov { namespace intel_cpu { #if defined(OV_CPU_WITH_MLAS) && defined(OPENVINO_ARCH_ARM64) -#define OV_CPU_INSTANCE_MLAS_ARM64(...) \ - {__VA_ARGS__}, +# define OV_CPU_INSTANCE_MLAS_ARM64(...) {__VA_ARGS__}, #else -#define OV_CPU_INSTANCE_MLAS_ARM64(...) +# define OV_CPU_INSTANCE_MLAS_ARM64(...) #endif #if defined(OV_CPU_WITH_ACL) -#define OV_CPU_INSTANCE_ACL(...) \ - {__VA_ARGS__}, +# define OV_CPU_INSTANCE_ACL(...) {__VA_ARGS__}, #else -#define OV_CPU_INSTANCE_ACL(...) +# define OV_CPU_INSTANCE_ACL(...) #endif #if defined(OV_CPU_WITH_DNNL) -#define OV_CPU_INSTANCE_DNNL(...) \ - {__VA_ARGS__}, +# define OV_CPU_INSTANCE_DNNL(...) {__VA_ARGS__}, #else -#define OV_CPU_INSTANCE_DNNL(...) +# define OV_CPU_INSTANCE_DNNL(...) #endif #if defined(OPENVINO_ARCH_X86_64) -#define OV_CPU_INSTANCE_X64(...) \ - {__VA_ARGS__}, +# define OV_CPU_INSTANCE_X64(...) {__VA_ARGS__}, #else -#define OV_CPU_INSTANCE_X64(...) +# define OV_CPU_INSTANCE_X64(...) #endif -#define OV_CPU_INSTANCE_COMMON(...) \ - {__VA_ARGS__}, +#define OV_CPU_INSTANCE_COMMON(...) {__VA_ARGS__}, + +// @todo another option is to determine shape relation by executor type +enum class ShapeTolerance { + Agnostic, + Dependant +}; enum class ExecutorType { Undefined, + Graph, Common, x64, Dnnl, @@ -51,26 +59,46 @@ enum class ExecutorType { Mlas }; +enum class OperationType { + FullyConnected, + MatMul, + Convolution +}; + +std::string ExecutorTypeToString(const ExecutorType type); +ExecutorType ExecutorTypeFromString(const std::string& typeStr); + class ExecutorContext { public: - typedef std::shared_ptr Ptr; - typedef std::shared_ptr CPtr; + using Ptr = std::shared_ptr; + using CPtr = std::shared_ptr; - ExecutorContext(const GraphContext::CPtr graphContext, const std::vector& implPriorities) + ExecutorContext(const GraphContext::CPtr graphContext, + const std::vector& implPriorities, + std::shared_ptr> privateWeighCache = nullptr) : runtimeCache(graphContext->getParamsCache()), scratchPad(graphContext->getScratchPad()), + weightsCache(graphContext->getWeightsCache()), engine(graphContext->getEngine()), - implPriorities(implPriorities) {} - - MultiCacheWeakPtr getRuntimeCache() const { - return runtimeCache; + implPriorities(implPriorities), + privateWeighCache(std::move(privateWeighCache)) + {} + + MultiCachePtr getRuntimeCache() const { + auto runtimeCachePtr = runtimeCache.lock(); + assert(runtimeCachePtr); + return runtimeCachePtr; } DnnlScratchPadPtr getScratchPad() const { return scratchPad; } - dnnl::engine getEngine() const { + std::shared_ptr> getPrivateWeighCache() const { + return privateWeighCache; + } + + const dnnl::engine& getEngine() const { return engine; } @@ -78,25 +106,49 @@ class ExecutorContext { return implPriorities; } + const WeightsSharing::Ptr getWeightsCache() const { + return weightsCache; + } + private: // weak_ptr is required to avoid cycle dependencies with MultiCache // since ExecutorContext is stored in Executor itself MultiCacheWeakPtr runtimeCache; DnnlScratchPadPtr scratchPad; - dnnl::engine engine; + WeightsSharing::Ptr weightsCache; + const dnnl::engine& engine; std::vector implPriorities; + // @todo remove after global cache is used exclusevly + std::shared_ptr> privateWeighCache; }; -class ExecutorFactory { +class ExecutorFactoryLegacy { public: - ExecutorFactory(const ExecutorContext::CPtr context) : context(context) {} - virtual ~ExecutorFactory() = default; + ExecutorFactoryLegacy(const ExecutorContext::CPtr context) : context(context) {} + virtual ~ExecutorFactoryLegacy() = default; const ExecutorContext::CPtr context; }; -using ExecutorFactoryPtr = std::shared_ptr; -using ExecutorFactoryCPtr = std::shared_ptr; +using ExecutorFactoryLegacyPtr = std::shared_ptr; +using ExecutorFactoryLegacyCPtr = std::shared_ptr; + +class Executor { +public: + virtual void update(const MemoryArgs& memory) {} + virtual void execute() const {} + // dnnl_fullyconnected 3D workaround version + virtual void execute(const MemoryArgs& memory) { + OPENVINO_THROW_NOT_IMPLEMENTED("This version of the 'execute' method is not implemented by executor"); + } + // legacy version + virtual void exec(const std::vector& src, const std::vector& dst) { + OPENVINO_THROW_NOT_IMPLEMENTED("This version of the 'execute' method is not implemented by executor"); + } + virtual impl_desc_type implType() const = 0; + virtual ~Executor() = default; +}; +using ExecutorPtr = std::shared_ptr; -} // namespace intel_cpu -} // namespace ov +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/executor_config.hpp b/src/plugins/intel_cpu/src/nodes/executors/executor_config.hpp new file mode 100644 index 00000000000000..497e480af2b78d --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/executor_config.hpp @@ -0,0 +1,26 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "post_ops.hpp" +#include "memory_arguments.hpp" +#include "printers.hpp" + +namespace ov { +namespace intel_cpu { +namespace executor { + +template +struct Config { + MemoryDescArgs descs; + Attrs attrs; + PostOps postOps; + + CPU_DEBUG_CAP_ENABLE(friend std::ostream& operator<< <>(std::ostream& os, const Config& key)); +}; + +} // namespace executor +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/executor_factory.hpp b/src/plugins/intel_cpu/src/nodes/executors/executor_factory.hpp new file mode 100644 index 00000000000000..d5474b927411cd --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/executor_factory.hpp @@ -0,0 +1,267 @@ +// Copyright (C) 2018-2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include + +#include "executor.hpp" +#include "nodes/executors/implementations.hpp" +#include "nodes/executors/executor_config.hpp" +#include "nodes/executors/executor_implementation.hpp" +#include "nodes/executors/graph_emitter.hpp" +#include "nodes/executors/memory_arguments.hpp" +#include "nodes/executors/printers.hpp" +#include "openvino/core/except.hpp" +#include "post_ops.hpp" + +namespace ov { +namespace intel_cpu { +using namespace executor; + +template +static ExecutorPtr fallback(const executor::Config& config, + const executor::Config& fallbackConfig, + const MemoryArgs& memory, + const ExecutorContext::CPtr context, + const std::string& name) { + DEBUG_LOG("Falling back to graph executor for ", + name, + ". Original config: ", + config, + " new config:", + fallbackConfig); + + GraphEmitter graphEmitter(config.descs, config.attrs, config.postOps, memory, context, name); + + const auto& graphExecutor = + graphEmitter.createGraph(fallbackConfig.descs, fallbackConfig.attrs, fallbackConfig.postOps, context) + .ensureAttrsMatch() + .ensureSrcDescsMatch() + .ensureDstDescsMatch() + .ensurePostOpsMatch() + .emit(); + (void)graphExecutor; + + OPENVINO_THROW("Fallback logic is not implemented yet"); // return graphExecutor; +} + +template +class ExecutorFactory { +public: + ExecutorFactory(const Attrs& attrs, + const PostOps& postOps, + const ExecutorContext::CPtr context, + const MemoryDescArgs& descriptors, + const std::string& implementationPriority = {}) + : m_attrs(attrs), + m_postOps(postOps), + m_context(context), + m_suitableImplementations(filter(m_attrs, m_postOps, descriptors, implementationPriority)), + m_implementationRequiresFallback(m_suitableImplementations.size(), true) {} + + /** + * @brief Retrieves the proper memory descriptors based on the provided memory descriptors. + * + * Examines the given executor configuration and determines the appropriate + * memory descriptors to be used. Checks for fallback configurations if necessary and + * returns the corresponding memory descriptors. + * + * @param descriptors memory descriptors. + * @return MemoryDescArgs The proper memory descriptors based on the configuration. + * @todo Create proper memory descriptors for all the implementations + * to fully enable graph's layout propagation functionality + * + * @note The main use case is to avoid a fallback during the creation of an executor + * by passing proper memory descriptors to the make() method + */ + MemoryDescArgs getProperMemoryDescriptors(const MemoryDescArgs& descriptors) const { + DEBUG_LOG("Preconfiguring memory descriptors"); + + const auto& impl = m_suitableImplementations.front(); + executor::Config config{descriptors, m_attrs, m_postOps}; + + if (auto fallbackConfig = impl.get().requiresFallback(config)) { + return fallbackConfig->descs; + } + + return config.descs; + } + + /** + * @brief Preconfigures an executor based on the provided memory arguments. + * + * Preconfigures an executor by selecting an appropriate implementation based on the provided + * memory arguments and by creating an executor using the implementation. + * + * @param memory The memory parameters used for selecting the appropriate executor implementation. + * + * @note The main use case is to offload executor data preparation (i.e. weights packing) + * From the make() call + * @todo Currently supports creating a single executor. + * For some nodes it can be worth to preconfigure all the executors. + */ + void preconfigure(const MemoryArgs& memory) { + executor::Config config{memoryDescsFromMemory(memory), m_attrs, m_postOps}; + std::transform(m_suitableImplementations.begin(), + m_suitableImplementations.end(), + m_implementationRequiresFallback.begin(), + [&config](const std::reference_wrapper>& impl) { + return impl.get().requiresFallback(config); + }); + + const size_t implId = select(memory); + const auto& impl = m_suitableImplementations[implId].get(); + DEBUG_LOG("Preconfiguring executor: ", impl.name()); + + if (m_implementationRequiresFallback[implId]) { + if (auto fallbackConfig = impl.requiresFallback(config)) { + fallback(config, *fallbackConfig, memory, m_context, impl.name()); + } + } + + (void)create(impl, memory, m_context); + } + + /** + * @brief Creates an Executor instance based on provided memory arguments. + * + * Creates an Executor instance using the provided MemoryArgs, selecting an appropriate implementation + * based on the characteristics of the memory. It handles fallback scenarios if necessary and updates the executor + * with the given memory information. + * + * @param memory memory arguments. + * + * @return A shared pointer to the created Executor. + * + * The function follows the steps below: + * - Selects an implementation based on the provided memory using the select() function. + * - Retrieves the selected implementation and checks if fallback is required. + * - If fallback is required, it creates a fallback configuration and returns a fallback executor. + * - Otherwise creates the executor using the selected implementation. + * - Updates the executor with the given memory information. + * + */ + ExecutorPtr make(MemoryArgs& memory) { + const size_t implId = select(memory); + const auto& impl = m_suitableImplementations[implId].get(); + if (m_implementationRequiresFallback[implId]) { + executor::Config config{memoryDescsFromMemory(memory), m_attrs, m_postOps}; + if (auto fallbackConfig = impl.requiresFallback(config)) { + return fallback(config, *fallbackConfig, memory, m_context, impl.name()); + } + } + + const auto executor = create(impl, memory, m_context); + executor->update(memory); + return executor; + } + +private: + static MemoryDescArgs memoryDescsFromMemory(const MemoryArgs& memory) { + MemoryDescArgs memoryDescs; + memoryDescs.reserve(memory.size()); + + for (const auto& mem : memory) { + memoryDescs[mem.first] = mem.second->getDescPtr(); + } + + return memoryDescs; + } + /** + * @brief Filters and retrieves suitable implementations based on the provided executor configuration. + * + * @param attrs The attributes used for filtering implementations. + * @param postOps The post-operations to be applied. + * @param descs The memory descriptor arguments. + * @param implementationPriority Optional. The name of the implementation to prioritize. + * If specified, only the implementation with this name will be considered. + * + * @note If an implementation is shape agnostic, no further implementations with lower + * priority are considered. + */ + static std::vector>> filter( + const Attrs& attrs, + const PostOps& postOps, + const MemoryDescArgs& descs, + const std::string& implementationPriority = {}) { + const auto& implementations = getImplementations(); + std::vector>> suitableImplementations; + const executor::Config config{descs, attrs, postOps}; + + for (const auto& implementation : implementations) { + DEBUG_LOG("Processing implementation: ", implementation.name()); + if (!implementationPriority.empty() && implementation.name() != implementationPriority) { + DEBUG_LOG("Implementation: ", + implementation.name(), + " does not match priority: ", + implementationPriority); + continue; + } + + if (!implementation.supports(config)) { + DEBUG_LOG("Implementation is not supported: ", implementation.name()); + continue; + } + + suitableImplementations.push_back(std::ref(implementation)); + + // implementation is supported and it is shape agnostic, there is no way + // an implementation with a lower priority will be chosen + if (implementation.shapeAgnostic()) { + DEBUG_LOG("Implementation is shape agnostic: ", + implementation.name(), + ". Stop processing implementations"); + break; + } + } + + return suitableImplementations; + } + + size_t select(const MemoryArgs& memory) const { + const auto selectedImplementation = + std::find_if(m_suitableImplementations.begin(), + m_suitableImplementations.end(), + [&memory](const std::reference_wrapper> implementation) { + return implementation.get().shapeAgnostic() || implementation.get().acceptsShapes(memory); + }); + OPENVINO_ASSERT(selectedImplementation != m_suitableImplementations.end(), "Failed to select an implemetation"); + + return std::distance(m_suitableImplementations.begin(), selectedImplementation); + } + + ExecutorPtr create(const ExecutorImplementation& impl, + const MemoryArgs& memory, + const ExecutorContext::CPtr context) { + DEBUG_LOG("Creating executor using implementation: ", impl.name()); + const auto& executorId = std::make_pair(impl.type(), impl.operationType()); + auto factoryIt = m_executors.find(executorId); + if (factoryIt == m_executors.end()) { + factoryIt = + m_executors.insert(std::make_pair(executorId, impl.create(m_attrs, m_postOps, memory, context))).first; + } + + return factoryIt->second; + } + + const Attrs& m_attrs; + const PostOps& m_postOps; + const ExecutorContext::CPtr m_context; + std::vector>> m_suitableImplementations; + // stores fallback status to avoid performing the check for every make() call + std::vector m_implementationRequiresFallback; + std::map, ExecutorPtr> m_executors; +}; + +template +using ExecutorFactoryPtr = std::shared_ptr>; + +template +using ExecutorFactoryCPtr = std::shared_ptr>; + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/executor_implementation.hpp b/src/plugins/intel_cpu/src/nodes/executors/executor_implementation.hpp new file mode 100644 index 00000000000000..d27d6353c78415 --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/executor_implementation.hpp @@ -0,0 +1,111 @@ +// Copyright (C) 2018-2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include + +#include "nodes/executors/executor.hpp" +#include "nodes/executors/executor_config.hpp" +#include "ov_optional.hpp" + +namespace ov { +namespace intel_cpu { + +// @todo Consider alternative of using template arguments instead of std::functions +template +class ExecutorImplementation { +public: + ExecutorImplementation( + const char* name, + const ExecutorType type, + const OperationType operationType, + const ShapeTolerance shapeRelation, + std::function&)> supports, + std::function>(const executor::Config&)> requiresFallback, + std::function acceptsShape, + std::function create) + : m_name(name), + m_type(type), + m_operationType(operationType), + m_shapeRelation(shapeRelation), + m_supports(std::move(supports)), + m_requiresFallback(std::move(requiresFallback)), + m_acceptsShape(std::move(acceptsShape)), + m_create(std::move(create)) {} + + bool supports(const executor::Config& config) const { + if (m_supports) { + return m_supports(config); + } + + return false; + } + + ov::optional> requiresFallback(const executor::Config& config) const { + if (m_requiresFallback) { + return m_requiresFallback(config); + } + + return {}; + } + + bool acceptsShapes(const MemoryArgs& memory) const { + if (m_acceptsShape) { + return m_acceptsShape(memory); + } + + return false; + } + + ExecutorPtr create(const Attrs& attrs, + const PostOps& postOps, + const MemoryArgs& memory, + const ExecutorContext::CPtr context) const { + // @todo require configure to be defined + if (m_create) + return m_create(attrs, postOps, memory, context); + return nullptr; + } + + bool shapeAgnostic() const { + return m_shapeRelation == ShapeTolerance::Agnostic; + } + + const char* name() const { + return m_name; + } + + const ExecutorType type() const { + return m_type; + } + + const OperationType operationType() const { + return m_operationType; + } + +private: + const char* m_name; + const ExecutorType m_type; + const OperationType m_operationType; + const ShapeTolerance m_shapeRelation; + // @todo create aliases for std::functions + const std::function&)> m_supports = {}; + const std::function>(const executor::Config&)> m_requiresFallback = {}; + const std::function m_acceptsShape = {}; + const std::function + m_create = {}; +}; + +template +using ExecutorImplementationPtr = std::shared_ptr>; +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/fullyconnected_config.hpp b/src/plugins/intel_cpu/src/nodes/executors/fullyconnected_config.hpp new file mode 100644 index 00000000000000..5638fc17fd483c --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/fullyconnected_config.hpp @@ -0,0 +1,32 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include + +#include "cpu_memory.h" +#include "executor_config.hpp" + +namespace ov { +namespace intel_cpu { + +// @todo require explicit initialization of all the attributes? +struct FCAttrs { + // @todo probably we don't want with bias flag, since this information is already + // a part of src memory descs + bool withBias = false; + bool weightsNonTransposed = false; + bool sparseWeights = false; + // @todo only memory descriptors should be a part of attributes + // actual memory should be passed into "execute" or "prepareMemory" calls + std::vector dequantizationScales; + // @todo should be passed as an additional memory input? + MemoryCPtr decompressionSubtractPtr; + MemoryCPtr decompressionMultiplyPtr; +}; + +using FCConfig = executor::Config; +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/fullyconnected_implementations.cpp b/src/plugins/intel_cpu/src/nodes/executors/fullyconnected_implementations.cpp new file mode 100644 index 00000000000000..bbfaa09413d734 --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/fullyconnected_implementations.cpp @@ -0,0 +1,306 @@ +// Copyright (C) 2018-2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include +#include + +#include "cpu/x64/cpu_isa_traits.hpp" +#include "debug_messages.hpp" +#include "implementation_utils.hpp" +#include "memory_desc/cpu_memory_desc.h" +#include "nodes/executors/convolution_config.hpp" +#include "nodes/executors/dnnl/dnnl_convolution_primitive.hpp" +#include "nodes/executors/dnnl/dnnl_fullyconnected.hpp" +#include "nodes/executors/dnnl/dnnl_shape_agnostic_data.hpp" +#include "nodes/executors/executor.hpp" +#include "nodes/executors/executor_implementation.hpp" +#include "nodes/executors/implementations.hpp" +#include "nodes/executors/fullyconnected_config.hpp" +#include "nodes/executors/memory_arguments.hpp" +#include "nodes/executors/mlas/mlas_gemm.hpp" +#include "nodes/executors/precision_matcher.hpp" +#include "nodes/executors/precision_translation.hpp" +#include "openvino/core/type/element_type.hpp" +#include "ov_optional.hpp" +#include "utils/cpp/maybe_unused.hpp" + +using namespace InferenceEngine; + +namespace ov { +namespace intel_cpu { + +using namespace ov::element; +using namespace TypeMaskAlias; +using namespace executor; + +static const MappingNotation dnnlFCMappingNotation{ARG_SRC, ARG_WEI, ARG_BIAS, ARG_DST}; + +using LayoutConfig = std::vector; +static const LayoutConfig dnnlFCLayoutConfig{LayoutType::ncsp, LayoutType::ncsp, LayoutType::ncsp, LayoutType::ncsp}; + +// clang-format off +static const TypeMapping dnnlFCTypeMapping { + // {src, wei, bia, dst} pt + {{_bf16, _bf16, _any, _bf16 | _f32}, pt(bypass(), bypass(), use<3>(), use<3>())}, + {{_f16, _f16, _any, _f16 | _f32}, pt(bypass(), bypass(), use<3>(), use<3>())}, + // integer precision outputs are not supported for float precision inputs + {{_f32 | _bf16 | _f16, _any, _any, _i8 | _u8}, pt(bypass(), bypass(), use<0>(), use<0>())}, + // compresses float weights which do not match input data precision + {{_f32, _half_float, _any, _any | _any}, pt(bypass(), bypass(), use<0>(), use<0>())}, + {{_bf16, _f16, _any, _any | _any}, pt(bypass(), bypass(), use<0>(), use<0>())}, + {{_f16, _bf16, _any, _any | _any}, pt(bypass(), bypass(), use<0>(), use<0>())}, + // quantization configuration (@todo more strict requrements for output precision?) + {{_u8 | _i8, _i8, _any, _any}, pt(bypass(), bypass(), bypass(), use<3>())}, + // compresses int weights (@todo more strict requrements for output precision?) + {{_f32 | _bf16, _u8 | _nf4 | _u4 | _i4, _any, _any}, pt(bypass(), bypass(), use<0>(), use<0>())}, + // @todo should we fallback to FPXX instead of _f32? + {{_any, _any, _any, _any}, pt(just(), just(), just(), just())}, + // @todo explicitly cover configuration limitations for oneDNN on ARM +}; + +static const MappingNotation dnnlConvolutionMappingNotation { + ARG_SRC, ARG_WEI, ARG_BIAS, ARG_DST +}; + +static const TypeMapping dnnlConvolutionTypeMapping { + // {src, wei, bia, dst} pt + {{_bf16, _bf16, _any, _bf16 | _f32}, pt(bypass(), bypass(), use<3>(), use<3>())}, + {{_f16, _f16, _any, _f16 | _f32}, pt(bypass(), bypass(), use<3>(), use<3>())}, + // integer precision outputs are not supported for float precision inputs + {{_f32 | _bf16 | _f16, _any, _any, _i8 | _u8}, pt(bypass(), bypass(), use<0>(), use<0>())}, + // compresses float weights which do not match input data precision + {{_f32, _half_float, _any, _any | _any}, pt(bypass(), bypass(), use<0>(), use<0>())}, + {{_bf16, _f16, _any, _any | _any}, pt(bypass(), bypass(), use<0>(), use<0>())}, + {{_f16, _bf16, _any, _any | _any}, pt(bypass(), bypass(), use<0>(), use<0>())}, + // quantization configuration + {{_u8 | _i8, _i8, _any, _any}, pt(bypass(), bypass(), use<3>(), use<3>())}, + // @todo should we fallback to _fxx instead of _f32 (currenly legacy logic is replicated) + {{_any, _any, _any, _any}, pt(just(), just(), just(), just())}, +}; +// clang-format on + +static bool fullyMatchConfiguration(const MemoryDescArgs& currentDescriptors, + const InOutTypes& typeConfig, + const LayoutConfig& layoutConfig, + const MappingNotation& notation) { + for (size_t i = 0; i < typeConfig.size(); i++) { + const auto& type = typeConfig[i]; + const auto& desc = currentDescriptors.at(notation[i]); + if ((!one_of(desc->getPrecision(), type, ov::element::undefined)) || !desc->hasLayoutType(layoutConfig[i])) + return false; + } + + return true; +} + +static MemoryDescArgs createOptimalDescriptors(const MemoryDescArgs& currentDescriptors, + const InOutTypes& typeConfig, + const LayoutConfig& layoutConfig, + const MappingNotation& notation) { + MemoryDescArgs descs = currentDescriptors; + + const auto& creatorsMap = BlockedDescCreator::getCommonCreators(); + for (size_t i = 0; i < typeConfig.size(); i++) { + const auto& desc = currentDescriptors.at(notation[i]); + const auto& descType = desc->getPrecision(); + const auto& type = typeConfig[i]; + const auto& layout = layoutConfig[i]; + + if (one_of(descType, ov::element::undefined, type)) { + continue; + } + + descs[notation[i]] = creatorsMap.at(layout)->createSharedDesc(type, desc->getShape()); + } + + return descs; +} + +template +ov::optional> requiresFallbackCommon(const executor::Config& config, + const TypeMapping& typeMapping, + const LayoutConfig& layoutConfig, + const MappingNotation& notation) { + const auto typeConfig = getTypeConfiguration(config.descs, typeMapping, notation); + + if (fullyMatchConfiguration(config.descs, typeConfig, layoutConfig, notation)) { + return {}; + } + + const auto optimalDescriptors = createOptimalDescriptors(config.descs, typeConfig, layoutConfig, notation); + + return ov::optional>(FCConfig{optimalDescriptors, config.attrs, config.postOps}); +} + +OV_CPU_MAYBE_UNUSED_FUNCTION static inline bool noWeightsDecompression(const FCConfig& config) { + return !DnnlFCPrimitive::useWeightsDecompressionImpl(srcType(config), weiType(config)); +} + +OV_CPU_MAYBE_UNUSED_FUNCTION static inline bool noSparseDecompression(const FCConfig& config) { + return !(config.attrs.sparseWeights); +} + +OV_CPU_MAYBE_UNUSED_FUNCTION static inline bool noPostOps(const FCConfig& config) { + return config.postOps.empty(); +} + +template <> +const std::vector>& getImplementations() { + static const std::vector> fullyconnectedImplementations { + OV_CPU_INSTANCE_X64( + "fullyconnected_mlas", + ExecutorType::Mlas, + OperationType::MatMul, + ShapeTolerance::Agnostic, + // supports + [](const FCConfig& config) -> bool { + // @todo probably there is no need of having implementation name in the debug message + // since it can be distinguished from the context of other logs anyway. + VERIFY(noPostOps(config), UNSUPPORTED_POST_OPS); + VERIFY(noSparseDecompression(config), UNSUPPORTED_SPARSE_WEIGHTS); + VERIFY(noWeightsDecompression(config), UNSUPPORTED_WEIGHTS_DECOMPRESSION); + VERIFY(everyone_is(f32, srcType(config), weiType(config), dstType(config)), UNSUPPORTED_SRC_PRECISIONS); + + return MlasGemmExecutor::supports(config); + }, + // requiresFallback + [](const FCConfig& config) -> ov::optional> { + // @todo Implement proper handling for the cases when fallback is not expected + // throwing exception is not an option, since requiresFallback is used in two contexts: + // 1) getting proper memory descriptors configuration + // 2) actual fallback to subgraph + return {}; + }, + // acceptsShapes + [](const MemoryArgs& memory) -> bool { + // @todo create syntactic sugar (functor) for shape agnostic lambda + return true; + }, + // create + [](const FCAttrs& attrs, + const PostOps& postOps, + const MemoryArgs& memory, + const ExecutorContext::CPtr context) { + return std::make_shared(attrs, postOps, memory, context); + }) + OV_CPU_INSTANCE_X64( + "convolution_1x1_dnnl", + ExecutorType::Dnnl, + OperationType::Convolution, + ShapeTolerance::Dependant, + // supports + [](const FCConfig& config) -> bool { + VERIFY(noSparseDecompression(config), UNSUPPORTED_SPARSE_WEIGHTS); + VERIFY(noWeightsDecompression(config), UNSUPPORTED_WEIGHTS_DECOMPRESSION); + auto getOffset0 = [](const MemoryDescPtr& desc) { + DnnlMemoryDescCPtr dnnlDesc = MemoryDescUtils::convertToDnnlMemoryDesc(desc); + dnnl::impl::memory_desc_wrapper wrapped(dnnlDesc->getDnnlDesc().get()); + return wrapped.offset0(); + }; + + VERIFY(dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx512_core), UNSUPPORTED_ISA); + VERIFY(srcType(config) == ov::element::f32, UNSUPPORTED_SRC_PRECISIONS); + // disable rank=4: + // if layout is nhwc: + // A matrix: N * IC * H * W --> N * (IC*H*W), the M, N', K of matrix multiply will be: + // M = 1, K = (IC*H*W), when M = 1 it should not be efficient since acts as a vector multiply + // if layout is nchw/nChw16c: brg1x1 not support. Although jit supports, it should have similar + // problems with the above. + VERIFY(one_of(srcRank(config), 2u, 3u), UNSUPPORTED_SRC_RANK); + VERIFY(weiRank(config) == 2, UNSUPPORTED_WEI_RANK); + // brg convolution does not support stride + VERIFY(getOffset0(config.descs.at(ARG_DST)) == 0, UNSUPPORTED_DST_STRIDES); + return true; + }, + // requiresFallback + [](const FCConfig& config) -> ov::optional> { + // @todo use dnnlConvolutionLayoutConfig after one is implemented + return requiresFallbackCommon(config, + dnnlConvolutionTypeMapping, + dnnlFCLayoutConfig, + dnnlFCMappingNotation); + }, + // acceptsShapes + [](const MemoryArgs& memory) -> bool { + const auto inRank = memory.at(ARG_SRC)->getShape().getRank(); + const auto& inDims = memory.at(ARG_SRC)->getShape().getDims(); + const auto& weightDims = memory.at(ARG_WEI)->getShape().getDims(); + // for original inner product semantics: + // when input is 2D tensor -> M in oneDNN will map to widthInConv + // when input is 3D tensor -> M in oneDNN will map to widthInConv*minibatch + // currently nwc mapping in brg:: + // when input is 2D tensor -> widthInConv will map to 'w', 'n' will be 1 + // when input is 3D tensor -> widthInConv will map to 'w', 'n' will be minibatch + Dim widthInConv = inDims[inRank - 2]; + Dim K = inDims[inRank - 1]; + Dim N = weightDims[0]; + + const auto& weightsSize = memory.at(ARG_WEI)->getDesc().getCurrentMemSize(); + // Disable Conv1x1 when weight size >= 16M to avoid different weight layout when having different input + // activation shapes. As a consuquence, peak memory consumption in LLM can be decreased. + VERIFY(weightsSize < (16 * 1 << 20), " weights size is to big"); + VERIFY(widthInConv >= 2 && widthInConv <= 3136 && K >= 96 && K <= 4096 && N >= 96 && N <= K * 4, + HEURISTICS_MISMATCH); + + return true; + }, + // create + [](const FCAttrs& attrs, const PostOps& postOps, const MemoryArgs& memory, ExecutorContext::CPtr context) { + struct ConvolutionInstantiator { + std::shared_ptr operator()( + const MemoryArgs& memory, + const FCAttrs& attrs, + const ExecutorContext::CPtr context, + std::shared_ptr shareAgnosticData) const { + ConvAttrs convAttrs{attrs.withBias}; + return DefaultInstantiator{}( + memory, + convAttrs, + context, + shareAgnosticData); + } + }; + + return std::make_shared< + DnnlFCExecutor>( + attrs, + postOps, + memory, + context, + false); + }) + OV_CPU_INSTANCE_DNNL( + "fullyconnected_dnnl", + ExecutorType::Dnnl, + OperationType::FullyConnected, + ShapeTolerance::Dependant, + // supports + [](const FCConfig& config) -> bool { + return true; + }, + // requiresFallback + [](const FCConfig& config) -> ov::optional> { + return requiresFallbackCommon(config, + dnnlFCTypeMapping, + dnnlFCLayoutConfig, + dnnlConvolutionMappingNotation); + }, + // acceptsShapes + [](const MemoryArgs& memory) -> bool { + return true; + }, + // create + [](const FCAttrs& attrs, const PostOps& postOps, const MemoryArgs& memory, ExecutorContext::CPtr context) { + return std::make_shared>(attrs, + postOps, + memory, + context, + false); + }) + }; + + return fullyconnectedImplementations; +} +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/graph_emitter.hpp b/src/plugins/intel_cpu/src/nodes/executors/graph_emitter.hpp new file mode 100644 index 00000000000000..2004242d68523d --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/graph_emitter.hpp @@ -0,0 +1,87 @@ +// Copyright (C) 2018-2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include + +#include "graph.h" +#include "memory_desc/cpu_memory_desc.h" +#include "node.h" +#include "nodes/executors/executor.hpp" +#include "post_ops.hpp" + +namespace ov { +namespace intel_cpu { + +template +class GraphEmitter { +public: + // @todo use template argument instead of passing std::function + using ensureAttrsStrategy = + std::function; + + GraphEmitter(const MemoryDescArgs& descs, + const Attrs& attrs, + const PostOps& postOps, + const MemoryArgs& memory, + const ExecutorContext::CPtr context, + const std::string& name, + ensureAttrsStrategy ensureAttrs = {}) + : descs(descs), + attrs(attrs), + postOps(postOps), + context(context), + name(name), + ensureAttrs(std::move(ensureAttrs)) { + OPENVINO_THROW("Graph emitter is not implemented yet!"); + } + + GraphEmitter& createGraph(const MemoryDescArgs& descs, + const Attrs& attrs, + const PostOps& postOps, + const ExecutorContext::CPtr context) { + OPENVINO_THROW("Not implemented yet!"); + return *this; + } + + GraphEmitter& ensureSrcDescsMatch() { + OPENVINO_THROW("Not implemented yet!"); + return *this; + } + + GraphEmitter& ensureDstDescsMatch() { + OPENVINO_THROW("Not implemented yet!"); + return *this; + } + + GraphEmitter& ensureAttrsMatch() { + OPENVINO_THROW("Not implemented yet!"); + return *this; + } + + GraphEmitter& ensurePostOpsMatch() { + OPENVINO_THROW("Not implemented yet!"); + return *this; + } + + GraphPtr emit() { + graph->InitGraph(false); + return graph; + } + +private: + const MemoryDescArgs& descs; + const Attrs& attrs; + const PostOps& postOps; + const ExecutorContext::CPtr context; + const std::string& name; + const ensureAttrsStrategy ensureAttrs; + NodePtr coreNode; + GraphPtr graph; +}; + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/implementation_utils.hpp b/src/plugins/intel_cpu/src/nodes/executors/implementation_utils.hpp new file mode 100644 index 00000000000000..2382f5e4091a9f --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/implementation_utils.hpp @@ -0,0 +1,87 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include "cpu_types.h" +#include "memory_desc/cpu_memory_desc.h" +#include "nodes/executors/memory_arguments.hpp" +#include "openvino/core/type/element_type.hpp" + +namespace ov { +namespace intel_cpu { + +template +ov::element::Type memoryDescType(const Config& config) { + return config.descs.at(idx)->getPrecision(); +} + +template +ov::element::Type srcType(const Config& config) { + return memoryDescType(config); +} + +template +ov::element::Type weiType(const Config& config) { + return memoryDescType(config); +} + +template +ov::element::Type biaType(const Config& config) { + return memoryDescType(config); +} + +template +ov::element::Type dstType(const Config& config) { + return memoryDescType(config); +} + +template +ov::element::Type dims(const Config& config) { + return config.descs.at(idx)->getShape().getDims(); +} + +template +const VectorDims& srcDims(const Config& config) { + return dims(config); +} + +template +const VectorDims& weiDims(const Config& config) { + return dims(config); +} + +template +size_t rank(const Config& config) { + return config.descs.at(idx)->getShape().getRank(); +} + +template +size_t srcRank(const Config& config) { + return rank(config); +} + +template +size_t weiRank(const Config& config) { + return rank(config); +} + +template +size_t memSize(const Config& config) { + return config.descs.at(idx)->getCurrentMemSize(); +} + +template +size_t srcMemSize(const Config& config) { + return memSize(config); +} + +template +size_t weiMemSize(const Config& config) { + return memSize(config); +} + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/implementations.hpp b/src/plugins/intel_cpu/src/nodes/executors/implementations.hpp new file mode 100644 index 00000000000000..5f0be772ab7b1a --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/implementations.hpp @@ -0,0 +1,32 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include + +#include "nodes/executors/executor_implementation.hpp" +#include "nodes/executors/fullyconnected_config.hpp" + +namespace ov { +namespace intel_cpu { + +// @todo move to separate header file +template +struct always_false : std::false_type {}; + +template +const std::vector>& getImplementations() { + static_assert(always_false::value, "Only specialization instantiations are allowed"); + return {}; +} + +// FullyConnected +template <> +const std::vector>& getImplementations(); + +// ... + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/interpolate.cpp b/src/plugins/intel_cpu/src/nodes/executors/interpolate.cpp index 9766918f51f673..859f17eef4d3e4 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/interpolate.cpp +++ b/src/plugins/intel_cpu/src/nodes/executors/interpolate.cpp @@ -453,7 +453,7 @@ inline VectorDims getBlockND(const VectorDims& shape) { } const uint8_t* ov::intel_cpu::InterpolateExecutor::padPreprocess(const std::vector& src, const std::vector& dst) { - const uint8_t *src_data_origin = reinterpret_cast(src[0]->getData()); + const uint8_t *src_data_origin = src[0]->getDataAs(); const auto &srcDim = src[0]->getStaticDims(); const auto &dstDim = dst[0]->getStaticDims(); diff --git a/src/plugins/intel_cpu/src/nodes/executors/interpolate_list.hpp b/src/plugins/intel_cpu/src/nodes/executors/interpolate_list.hpp index d5b80fd08500e9..2ed16ea04b1852 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/interpolate_list.hpp +++ b/src/plugins/intel_cpu/src/nodes/executors/interpolate_list.hpp @@ -24,12 +24,12 @@ struct InterpolateExecutorDesc { const std::vector& getInterpolateExecutorsList(); -class InterpolateExecutorFactory : public ExecutorFactory { +class InterpolateExecutorFactory : public ExecutorFactoryLegacy { public: InterpolateExecutorFactory(const InterpolateAttrs& InterpolateAttrs, const std::vector& srcDescs, const std::vector& dstDescs, - const ExecutorContext::CPtr context) : ExecutorFactory(context) { + const ExecutorContext::CPtr context) : ExecutorFactoryLegacy(context) { for (auto& desc : getInterpolateExecutorsList()) { if (desc.builder->isSupported(InterpolateAttrs, srcDescs, dstDescs)) { supportedDescs.push_back(desc); @@ -82,4 +82,4 @@ using InterpolateExecutorFactoryPtr = std::shared_ptr; } // namespace intel_cpu -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/memory_arguments.hpp b/src/plugins/intel_cpu/src/nodes/executors/memory_arguments.hpp new file mode 100644 index 00000000000000..51fd52fe44fe23 --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/memory_arguments.hpp @@ -0,0 +1,29 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "cpu_memory.h" +#include "memory_desc/cpu_memory_desc.h" +#include "unordered_map" + +namespace ov { +namespace intel_cpu { + +using MemoryDescArgs = std::unordered_map; +using MemoryArgs = std::unordered_map; + +// @todo add more options +#define ARG_SRC_0 1 +#define ARG_SRC ARG_SRC_0 +#define ARG_SRC_1 2 +#define ARG_SRC_2 3 +#define ARG_DST_0 17 +#define ARG_DST ARG_DST_0 +#define ARG_WEI_0 33 +#define ARG_WEI ARG_WEI_0 +#define ARG_BIAS 41 + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/mlas/mlas_gemm.cpp b/src/plugins/intel_cpu/src/nodes/executors/mlas/mlas_gemm.cpp new file mode 100644 index 00000000000000..6078f84773d91e --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/mlas/mlas_gemm.cpp @@ -0,0 +1,156 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "mlas_gemm.hpp" + +#include +#include + +#include "cpu_memory.h" +#include "memory_desc/cpu_blocked_memory_desc.h" +#include "mlas/sgemm.hpp" +#include "nodes/executors/executor.hpp" +#include "nodes/executors/fullyconnected_config.hpp" +#include "nodes/executors/memory_arguments.hpp" +#include "nodes/executors/mlas/mlas_gemm.hpp" +#include "utils/debug_capabilities.h" + +namespace ov { +namespace intel_cpu { + +using namespace executor; +using namespace dnnl; +using namespace ov::element; + +static MemoryPtr prepareWeightMemory(const MemoryPtr weightsMemory, + const ExecutorContext::CPtr context, + const bool weightsTransposed) { + DEBUG_LOG("MlasGemmExecutor: prepack weights"); + const auto& wgtDims = weightsMemory->getStaticDims(); + // Weights are transposed by MatMulConstTransposesExtraction + // K is the IC of weight + // the weight is reshaped to [-1, K] in ConvertMatMulToFC + const auto K = wgtDims[1]; + const auto N = wgtDims[0]; + + auto packedBsize = mlas_sgemm_pack_get_size(N, K); + + auto create = [&]() { + float* weightPtr = reinterpret_cast(weightsMemory->getData()); + size_t ldb = weightsTransposed ? K : N; + MemoryPtr _ptr = std::make_shared(context->getEngine(), + intel_cpu::CpuBlockedMemoryDesc(i8, intel_cpu::Shape{packedBsize})); + float* prepackedDst = reinterpret_cast(_ptr->getData()); + DEBUG_LOG("MlasGemmExecutor: cache miss, perform packing"); + mlas_sgemm_pack(weightsTransposed ? "T" : "F", N, K, ldb, weightPtr, prepackedDst); + return _ptr; + }; + + auto weightCache = context->getWeightsCache(); + if (weightCache != nullptr) { + std::string format = "gemm_mlas_" + std::to_string(N) + "_" + std::to_string(K); + const std::string string_hash = format + "_" + std::to_string(weightsMemory->getSize()) + "_" + + std::to_string(reinterpret_cast(weightsMemory->getData())); + DEBUG_LOG("MlasGemmExecutor: findOrCreate, string_hash: ", string_hash); + return *weightCache->findOrCreate(string_hash, create); + } + + DEBUG_LOG("MlasGemmExecutor: Weights cache is not available"); + return create(); +} + +// @todo use VERIFY macro for the checks +bool MlasGemmExecutor::supports(const FCConfig& config) { + if (!config.postOps.empty()) { + DEBUG_LOG("MlasGemmExecutor: PostOps are not supported"); + return false; + } + const auto& weiDesc = config.descs.at(ARG_WEI); + const auto& dstDesc = config.descs.at(ARG_DST); + + // MLAS cannot support weight dims > 2, e.g. [1,64,9,9] * [10,64,9,9] + const auto& weightsDims = weiDesc->getShape().getStaticDims(); + if (weightsDims.size() > 2) { + if (!std::all_of(weightsDims.begin() + 2, weightsDims.end(), [](const Dim dim) { + return dim == 1; + })) { + DEBUG_LOG("MlasGemmExecutor: weights dims > 2 are not supported"); + return false; + } + } + + if (config.attrs.withBias) { + const auto& biaDesc = config.descs.at(ARG_BIAS); + const auto& biasDims = biaDesc->getShape().getStaticDims(); + const auto& outDims = dstDesc->getShape().getDims(); + const bool isByChannel = biasDims.back() == outDims.back(); + + if (!isByChannel) { + DEBUG_LOG("MlasGemmExecutor: only 'by channel' bias is supported"); + return false; + } + + if (!std::all_of(biasDims.begin(), biasDims.end() - 1, [](const Dim dim) { + return dim == 1; + })) { + DEBUG_LOG("MlasGemmExecutor: only 'by channel' bias is supported"); + return false; + } + } + + return true; +} + +MlasGemmExecutor::MlasGemmExecutor(const FCAttrs& attrs, + const PostOps& postOps, + const MemoryArgs& memory, + const ExecutorContext::CPtr context) + : packedWeights(prepareWeightMemory(memory.at(ARG_WEI), context, !attrs.weightsNonTransposed)) {} + +void MlasGemmExecutor::update(const MemoryArgs& memory) { + const auto& weiDesc = memory.at(ARG_WEI)->getDescPtr(); + const auto& dstDesc = memory.at(ARG_DST)->getDescPtr(); + const auto& wgtDims = weiDesc->getShape().getStaticDims(); + // Weights are transposed by MatMulConstTransposesExtraction + // K is the IC of weight + // the weight is reshaped to [-1, K] in ConvertMatMulToFC + K = wgtDims[1]; + N = wgtDims[0]; + + const auto& outDims = dstDesc->getShape().getStaticDims(); + if (outDims.size() > 2) { + M = std::accumulate(outDims.begin(), outDims.end() - 1, 1, std::multiplies()); + } else { + M = outDims[0]; + } +} + +void MlasGemmExecutor::execute(const MemoryArgs& memory) { + const auto srcRawMemPtr = memory.at(ARG_SRC)->getDataAs(); + const auto weiRawMemPtr = packedWeights->getDataAs(); + const auto dstRawMemPtr = memory.at(ARG_DST)->getDataAs(); + const auto biasRawMemPtr = memory.at(ARG_BIAS)->getDataAs(); + + const auto lda = K; + const auto ldb = K; + const auto ldc = N; + + mlas_sgemm_compute("N", + "N", + M, + N, + K, + 1.0f, + srcRawMemPtr, + lda, + weiRawMemPtr, + ldb, + 0.0f, + dstRawMemPtr, + ldc, + biasRawMemPtr); +} + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/mlas/mlas_gemm.hpp b/src/plugins/intel_cpu/src/nodes/executors/mlas/mlas_gemm.hpp new file mode 100644 index 00000000000000..1cff70c569962c --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/mlas/mlas_gemm.hpp @@ -0,0 +1,42 @@ +// Copyright (C) 2018-2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// +#pragma once + +#include +#include + +#include "cpu_memory.h" +#include "nodes/executors/fullyconnected_config.hpp" +#include "onednn/iml_type_mapper.h" + +namespace ov { +namespace intel_cpu { + +class MlasGemmExecutor : public Executor { +public: + MlasGemmExecutor(const FCAttrs& attrs, + const PostOps& postOps, + const MemoryArgs& memory, + const ExecutorContext::CPtr context); + + void execute(const MemoryArgs& memory) override; + + impl_desc_type implType() const override { + return impl_desc_type::gemm_mlas; + } + + // offloads execution data preparation from the exec call + void update(const MemoryArgs& memory) override; + + static bool supports(const FCConfig& config); + +private: + const MemoryCPtr packedWeights; + int64_t M, N, K; +}; + +using MlasGemmExecutorPtr = std::shared_ptr; + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/mlas/mlas_transpose.cpp b/src/plugins/intel_cpu/src/nodes/executors/mlas/mlas_transpose.cpp index 404b7bbeaceeb3..678fe5a5c22176 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/mlas/mlas_transpose.cpp +++ b/src/plugins/intel_cpu/src/nodes/executors/mlas/mlas_transpose.cpp @@ -153,8 +153,8 @@ void MlasTransposeExecutor::TransposeSingleAxisOutwards(const MemoryCPtr& input, const auto& input_dims = input_shape.getDims(); const auto element_size = input->getDesc().getPrecision().size(); - const auto* input_data = reinterpret_cast(input->getData()); - auto* output_data = reinterpret_cast(output->getData()); + const auto* input_data = input->getDataAs(); + auto* output_data = output->getDataAs(); auto num_loops = calcShapeSize(input_shape, 0, to); auto num_writers = input_dims[from]; @@ -215,8 +215,8 @@ void MlasTransposeExecutor::TransposeSingleAxisInwards(const MemoryCPtr& input, const auto& input_dims = input_shape.getDims(); const auto element_size = input->getDesc().getPrecision().size(); - const auto* input_data = reinterpret_cast(input->getData()); - auto* output_data = reinterpret_cast(output->getData()); + const auto* input_data = input->getDataAs(); + auto* output_data = output->getDataAs(); auto num_loops = calcShapeSize(input_shape, 0, from); auto num_readers = input_dims[from]; @@ -270,7 +270,7 @@ void MlasTransposeExecutor::TransposeSingleAxisInwards(const MemoryCPtr& input, } } -void MlasTransposeExecutor::exec(const std::vector& src, const std::vector& dst, const int MB) { +void MlasTransposeExecutor::exec(const std::vector& src, const std::vector& dst) { if (from > to) { TransposeSingleAxisOutwards(src[0], dst[0], from, to); } else { @@ -309,4 +309,4 @@ TransposeExecutorPtr MlasTransposeExecutorBuilder::makeExecutor(const ExecutorCo } } // namespace intel_cpu -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/mlas/mlas_transpose.hpp b/src/plugins/intel_cpu/src/nodes/executors/mlas/mlas_transpose.hpp index d4e102eb393c06..d7e0307414aac9 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/mlas/mlas_transpose.hpp +++ b/src/plugins/intel_cpu/src/nodes/executors/mlas/mlas_transpose.hpp @@ -15,16 +15,15 @@ class MlasTransposeExecutor : public TransposeExecutor { const std::vector &srcDescs, const std::vector &dstDescs, const dnnl::primitive_attr &attr) override; - void exec(const std::vector &src, const std::vector &dst, const int MB) override; + void exec(const std::vector &src, const std::vector &dst) override; - impl_desc_type getImplType() const override { return implType; } + impl_desc_type implType() const override { return impl_desc_type::mlas; } private: static int64_t calcShapeSize(const Shape& shape, size_t start, size_t end); static bool IsTransposeMovingSingleAxis(VectorDims permutations, size_t& from, size_t& to); void TransposeSingleAxisOutwards(const MemoryCPtr& input, const MemoryPtr& output, size_t from, size_t to); void TransposeSingleAxisInwards(const MemoryCPtr& input, const MemoryPtr& output, size_t from, size_t to); - static const impl_desc_type implType = impl_desc_type::mlas; size_t from; size_t to; }; @@ -39,4 +38,4 @@ class MlasTransposeExecutorBuilder : public TransposeExecutorBuilder { }; } // namespace intel_cpu -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/mvn_list.hpp b/src/plugins/intel_cpu/src/nodes/executors/mvn_list.hpp index 24a06f4b51d3b5..3a8d3cc61fe585 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/mvn_list.hpp +++ b/src/plugins/intel_cpu/src/nodes/executors/mvn_list.hpp @@ -24,12 +24,12 @@ struct MVNExecutorDesc { const std::vector& getMVNExecutorsList(); -class MVNExecutorFactory : public ExecutorFactory { +class MVNExecutorFactory : public ExecutorFactoryLegacy { public: MVNExecutorFactory(const MVNAttrs& mvnAttrs, const std::vector& srcDescs, const std::vector& dstDescs, - const ExecutorContext::CPtr context) : ExecutorFactory(context) { + const ExecutorContext::CPtr context) : ExecutorFactoryLegacy(context) { for (auto& desc : getMVNExecutorsList()) { if (desc.builder->isSupported(mvnAttrs, srcDescs, dstDescs)) { supportedDescs.push_back(desc); @@ -81,4 +81,4 @@ using MVNExecutorFactoryPtr = std::shared_ptr; using MVNExecutorFactoryCPtr = std::shared_ptr; } // namespace intel_cpu -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/pooling_list.hpp b/src/plugins/intel_cpu/src/nodes/executors/pooling_list.hpp index 5d5e153cd3ca44..d6ce5489105b19 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/pooling_list.hpp +++ b/src/plugins/intel_cpu/src/nodes/executors/pooling_list.hpp @@ -21,12 +21,12 @@ struct PoolingExecutorDesc { const std::vector& getPoolingExecutorsList(); -class PoolingExecutorFactory : public ExecutorFactory { +class PoolingExecutorFactory : public ExecutorFactoryLegacy { public: PoolingExecutorFactory(const PoolingAttrs& poolingAttrs, const std::vector& srcDescs, const std::vector& dstDescs, - const ExecutorContext::CPtr context) : ExecutorFactory(context) { + const ExecutorContext::CPtr context) : ExecutorFactoryLegacy(context) { for (auto& desc : getPoolingExecutorsList()) { if (desc.builder->isSupported(poolingAttrs, srcDescs, dstDescs)) { supportedDescs.push_back(desc); @@ -75,4 +75,4 @@ using PoolingExecutorFactoryPtr = std::shared_ptr; using PoolingExecutorFactoryCPtr = std::shared_ptr; } // namespace intel_cpu -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/precision_matcher.cpp b/src/plugins/intel_cpu/src/nodes/executors/precision_matcher.cpp new file mode 100644 index 00000000000000..95044a9e205595 --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/precision_matcher.cpp @@ -0,0 +1,26 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "precision_matcher.hpp" + +#include + +#include "nodes/executors/precision_translation.hpp" +#include "openvino/core/type/element_type.hpp" + +namespace ov { +namespace intel_cpu { + +bool match(const InOutTypeMask& patterns, const InOutTypes& values) { + assert(patterns.size() == values.size()); + + return std::equal(values.begin(), values.end(), patterns.begin(), [](const ov::element::Type value, const TypeMask pattern) { + return pattern & value; + }); + + return true; +} + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/precision_matcher.hpp b/src/plugins/intel_cpu/src/nodes/executors/precision_matcher.hpp new file mode 100644 index 00000000000000..e7c592b55ea4c5 --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/precision_matcher.hpp @@ -0,0 +1,13 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "nodes/executors/precision_translation.hpp" + +namespace ov { +namespace intel_cpu { + +bool match(const InOutTypeMask& patterns, const InOutTypes& values); + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/precision_translation.cpp b/src/plugins/intel_cpu/src/nodes/executors/precision_translation.cpp new file mode 100644 index 00000000000000..7ab47477f72735 --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/precision_translation.cpp @@ -0,0 +1,38 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "precision_translation.hpp" + +#include + +#include "nodes/executors/memory_arguments.hpp" +#include "openvino/core/except.hpp" +#include "openvino/core/type/element_type.hpp" +#include "precision_matcher.hpp" + +using namespace InferenceEngine; + +namespace ov { +namespace intel_cpu { + +InOutTypes getTypeConfiguration(const MemoryDescArgs& descriptors, const TypeMapping& mapping, const MappingNotation& notation) { + InOutTypes types; + std::transform(notation.begin(), notation.end(), std::back_inserter(types), [&descriptors](int id) { + return descriptors.at(id)->getPrecision(); + }); + + for (const auto& entry : mapping) { + const auto& pattern = entry.first; + if (!match(pattern, types)) + continue; + + const auto& translator = entry.second; + return translator(types); + } + + OPENVINO_THROW("Failed to create a type configuration for the provided memory descriptors"); +} + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/precision_translation.hpp b/src/plugins/intel_cpu/src/nodes/executors/precision_translation.hpp new file mode 100644 index 00000000000000..4e9be3b3dd5691 --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/precision_translation.hpp @@ -0,0 +1,94 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include +#include + +#include "nodes/executors/memory_arguments.hpp" +#include "nodes/executors/type_mask.hpp" +#include "openvino/core/type/element_type.hpp" +#include "utils/precision_support.h" + +namespace ov { +namespace intel_cpu { + +template +struct use { + ov::element::Type operator()(const std::vector& types, + size_t idx) const { + assert(bypassId < types.size()); + return types[bypassId]; + } +}; + +struct bypass { + ov::element::Type operator()(const std::vector& types, + size_t idx) const { + return types[idx]; + } +}; + +template +struct just { + ov::element::Type operator()(const std::vector& types, + size_t idx) const { + // ignore everything + (void)types; + (void)idx; + return type; + } +}; + +template <> +struct just { + ov::element::Type operator()(const std::vector& types, + size_t idx) const { + // ignore everything + (void)types; + (void)idx; + return defaultFloatPrecision(); + } +}; + +using policy = std::function&, size_t idx)>; + +struct PortsTranslation { + template + PortsTranslation(Policies... policies) : + m_policies{policies...} {} + + std::vector operator()( + const std::vector& types) const { + assert(types.size() == m_policies.size()); + + std::vector result; + result.reserve(types.size()); + for (size_t i = 0; i < types.size(); i++) { + result.emplace_back(m_policies[i](types, i)); + } + + return result; + } +private: + std::vector m_policies; +}; + +// @todo vectors can be replaced with arrays, since we know the size beforehand +// pros: should be more efficient and safe +// cons: more template instances (binary size) of the translation utility functions +using InOutTypes = std::vector; +using PortsConfigurationImpl = std::function; +using InOutTypeMask = std::vector; +using TypeMapping = std::vector>; +using MappingNotation = std::vector; +using pt = PortsTranslation; + +InOutTypes getTypeConfiguration(const MemoryDescArgs& descriptors, const TypeMapping& mapping, const MappingNotation& notation); + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/printers.cpp b/src/plugins/intel_cpu/src/nodes/executors/printers.cpp new file mode 100644 index 00000000000000..ac52b25a069541 --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/printers.cpp @@ -0,0 +1,28 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#ifdef CPU_DEBUG_CAPS + +#include +#include "printers.hpp" +#include "post_ops.hpp" +#include "fullyconnected_config.hpp" + +namespace ov { +namespace intel_cpu { + +std::ostream & operator<<(std::ostream & os, const FCAttrs& attrs) { + // @todo print Attrs + return os; +} + +std::ostream & operator<<(std::ostream & os, const PostOps& postOps) { + // @todo print PostOps + return os; +} + +} // namespace intel_cpu +} // namespace ov + +#endif // CPU_DEBUG_CAPS diff --git a/src/plugins/intel_cpu/src/nodes/executors/printers.hpp b/src/plugins/intel_cpu/src/nodes/executors/printers.hpp new file mode 100644 index 00000000000000..d37ab633ba8036 --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/printers.hpp @@ -0,0 +1,40 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#ifdef CPU_DEBUG_CAPS +#pragma once + +#include +#include "executor_config.hpp" + +namespace ov { +namespace intel_cpu { + +namespace executor { +template struct Config; +} + +struct FCAttrs; + +std::ostream & operator<<(std::ostream & os, const FCAttrs& attrs); +std::ostream & operator<<(std::ostream & os, const PostOps& postOps); + +template +std::ostream & operator<<(std::ostream & os, const executor::Config& config) { + for (const auto& desc : config.descs) { + const auto id = desc.first; + const auto descPtr = desc.second; + os << "[" << id << "]" << *descPtr << ";"; + } + + os << config.postOps; + os << config.attrs; + + return os; +} + +} // namespace intel_cpu +} // namespace ov + +#endif // CPU_DEBUG_CAPS diff --git a/src/plugins/intel_cpu/src/nodes/executors/reduce_list.hpp b/src/plugins/intel_cpu/src/nodes/executors/reduce_list.hpp index bce92f7aa1f040..ea2543a495e64c 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/reduce_list.hpp +++ b/src/plugins/intel_cpu/src/nodes/executors/reduce_list.hpp @@ -24,12 +24,12 @@ struct ReduceExecutorDesc { const std::vector& getReduceExecutorsList(); -class ReduceExecutorFactory : public ExecutorFactory { +class ReduceExecutorFactory : public ExecutorFactoryLegacy { public: ReduceExecutorFactory(const ReduceAttrs& reduceAttrs, const std::vector& srcDescs, const std::vector& dstDescs, - const ExecutorContext::CPtr context) : ExecutorFactory(context) { + const ExecutorContext::CPtr context) : ExecutorFactoryLegacy(context) { for (auto& desc : getReduceExecutorsList()) { if (desc.builder->isSupported(reduceAttrs, srcDescs, dstDescs)) { supportedDescs.push_back(desc); @@ -82,4 +82,4 @@ using ReduceExecutorFactoryPtr = std::shared_ptr; using ReduceExecutorFactoryCPtr = std::shared_ptr; } // namespace intel_cpu -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/transpose.hpp b/src/plugins/intel_cpu/src/nodes/executors/transpose.hpp index 0039719a785eeb..15f2d5085cd5ad 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/transpose.hpp +++ b/src/plugins/intel_cpu/src/nodes/executors/transpose.hpp @@ -16,7 +16,7 @@ struct TransposeParams { PermuteParams permuteParams; }; -class TransposeExecutor { +class TransposeExecutor : public Executor { public: static jit_permute_config_params prepareParams(const PermuteParams& params); explicit TransposeExecutor(const ExecutorContext::CPtr context); @@ -24,8 +24,6 @@ class TransposeExecutor { const std::vector& srcDescs, const std::vector& dstDescs, const dnnl::primitive_attr &attr) = 0; - virtual void exec(const std::vector& src, const std::vector& dst, const int MB) = 0; - virtual impl_desc_type getImplType() const = 0; virtual ~TransposeExecutor() = default; protected: PermuteParams permuteParams; @@ -47,4 +45,4 @@ using TransposeExecutorBuilderPtr = std::shared_ptr; using TransposeExecutorBuilderCPtr = std::shared_ptr; } // namespace intel_cpu -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/transpose_list.hpp b/src/plugins/intel_cpu/src/nodes/executors/transpose_list.hpp index 63fa736c4cdd0d..90141a6194592e 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/transpose_list.hpp +++ b/src/plugins/intel_cpu/src/nodes/executors/transpose_list.hpp @@ -29,12 +29,12 @@ struct TransposeExecutorDesc { const std::vector& getTransposeExecutorsList(); -class TransposeExecutorFactory : public ExecutorFactory { +class TransposeExecutorFactory : public ExecutorFactoryLegacy { public: TransposeExecutorFactory(const TransposeParams& transposeParams, const std::vector& srcDescs, const std::vector& dstDescs, - const ExecutorContext::CPtr context) : ExecutorFactory(context) { + const ExecutorContext::CPtr context) : ExecutorFactoryLegacy(context) { for (auto& desc : getTransposeExecutorsList()) { if (desc.builder->isSupported(transposeParams, srcDescs, dstDescs)) { supportedDescs.push_back(desc); @@ -57,4 +57,4 @@ using TransposeExecutorFactoryPtr = std::shared_ptr; using TransposeExecutorFactoryCPtr = std::shared_ptr; } // namespace intel_cpu -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/type_mask.hpp b/src/plugins/intel_cpu/src/nodes/executors/type_mask.hpp new file mode 100644 index 00000000000000..366026070e0cb9 --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/executors/type_mask.hpp @@ -0,0 +1,123 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include + +#include "openvino/core/type/element_type.hpp" + +namespace ov { +namespace intel_cpu { +struct TypeMask { + enum Value : uint64_t { + _undefined = 1 << 0, + _dynamic = 1 << 1, + _boolean = 1 << 2, + _bf16 = 1 << 3, + _f16 = 1 << 4, + _f32 = 1 << 5, + _f64 = 1 << 6, + _i4 = 1 << 7, + _i8 = 1 << 8, + _i16 = 1 << 9, + _i32 = 1 << 10, + _i64 = 1 << 11, + _u1 = 1 << 12, + _u4 = 1 << 13, + _u8 = 1 << 14, + _u16 = 1 << 15, + _u32 = 1 << 16, + _u64 = 1 << 17, + _nf4 = 1 << 18, + _f8e4m3 = 1 << 19, + _f8e5m2 = 1 << 20, + _string = 1 << 21 + }; + + TypeMask(const ov::element::Type precision) : value(generateMask(precision)), precision(precision) {} + + TypeMask(const uint64_t value) : value(value) {} + + // can be treated as uint64_t mask + operator uint64_t() const { + return value; + } + // match + bool operator&(const ov::element::Type precision) const { + return value & TypeMask(precision); + } + + const uint64_t value; + const ov::element::Type precision; + +private: + static Value generateMask(const ov::element::Type type) { +#define CASE(typeM) \ + case ov::element::typeM: \ + return _##typeM; + switch (type) { + CASE(undefined) + CASE(dynamic) + CASE(boolean) + CASE(bf16) + CASE(f16) + CASE(f32) + CASE(f64) + CASE(i4) + CASE(i8) + CASE(i16) + CASE(i32) + CASE(i64) + CASE(u1) + CASE(u4) + CASE(u8) + CASE(u16) + CASE(u32) + CASE(u64) + CASE(nf4) + CASE(f8e4m3) + CASE(f8e5m2) + CASE(string) + } +#undef CASE + return _undefined; + } +}; + +namespace TypeMaskAlias { +constexpr ov::element::Type fxx(ov::element::Type_t::undefined); +#define DEFINE_TYPE_ALIAS(x) constexpr auto x = TypeMask::Value::x +// use underscore for naming to avoid conflicts with Precision aliases +DEFINE_TYPE_ALIAS(_undefined); +DEFINE_TYPE_ALIAS(_dynamic); +DEFINE_TYPE_ALIAS(_boolean); +DEFINE_TYPE_ALIAS(_bf16); +DEFINE_TYPE_ALIAS(_f16); +DEFINE_TYPE_ALIAS(_f32); +DEFINE_TYPE_ALIAS(_f64); +DEFINE_TYPE_ALIAS(_i4); +DEFINE_TYPE_ALIAS(_i8); +DEFINE_TYPE_ALIAS(_i16); +DEFINE_TYPE_ALIAS(_i32); +DEFINE_TYPE_ALIAS(_i64); +DEFINE_TYPE_ALIAS(_u1); +DEFINE_TYPE_ALIAS(_u4); +DEFINE_TYPE_ALIAS(_u8); +DEFINE_TYPE_ALIAS(_u16); +DEFINE_TYPE_ALIAS(_u32); +DEFINE_TYPE_ALIAS(_u64); +DEFINE_TYPE_ALIAS(_nf4); +DEFINE_TYPE_ALIAS(_f8e4m3); +DEFINE_TYPE_ALIAS(_f8e5m2); +DEFINE_TYPE_ALIAS(_string); +constexpr auto _any_float = _f64 | _f32 | _f16 | _bf16; +constexpr auto _half_float = _f16 | _bf16; +constexpr auto _quant = _u8 | _i8; +constexpr auto _any = std::numeric_limits::max(); +} // namespace TypeMaskAlias + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/x64/jit_transpose.cpp b/src/plugins/intel_cpu/src/nodes/executors/x64/jit_transpose.cpp index d8078a30052476..f424e8c8bdb688 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/x64/jit_transpose.cpp +++ b/src/plugins/intel_cpu/src/nodes/executors/x64/jit_transpose.cpp @@ -10,12 +10,13 @@ using namespace dnnl::impl::cpu::x64; namespace ov { namespace intel_cpu { -void JitTransposeExecutor::exec(const std::vector& src, const std::vector& dst, const int MB) { +void JitTransposeExecutor::exec(const std::vector& src, const std::vector& dst) { if (!pKernel) OPENVINO_THROW("Could not execute. Kernel for Transpose node was not compiled."); - const uint8_t* srcData = reinterpret_cast(src[0]->getData()); - uint8_t* dstData = reinterpret_cast(dst[0]->getData()); + const uint8_t* srcData = src[0]->getDataAs(); + uint8_t* dstData = dst[0]->getDataAs(); + const int MB = src[0]->getStaticDims()[0]; pKernel->execute(srcData, dstData, MB); } @@ -39,4 +40,4 @@ bool JitTransposeExecutorBuilder::isSupported(const TransposeParams& transposePa } } // namespace intel_cpu -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/executors/x64/jit_transpose.hpp b/src/plugins/intel_cpu/src/nodes/executors/x64/jit_transpose.hpp index 2e757fef58ce82..02d8172707d697 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/x64/jit_transpose.hpp +++ b/src/plugins/intel_cpu/src/nodes/executors/x64/jit_transpose.hpp @@ -17,11 +17,10 @@ class JitTransposeExecutor : public TransposeExecutor { const std::vector& srcDescs, const std::vector& dstDescs, const dnnl::primitive_attr &attr) override; - void exec(const std::vector& src, const std::vector& dst, const int MB) override; - impl_desc_type getImplType() const override { return implType; } + void exec(const std::vector& src, const std::vector& dst) override; + impl_desc_type implType() const override { return impl_desc_type::jit; } private: std::shared_ptr pKernel; - static const impl_desc_type implType = impl_desc_type::jit; }; class JitTransposeExecutorBuilder : public TransposeExecutorBuilder { @@ -35,4 +34,4 @@ class JitTransposeExecutorBuilder : public TransposeExecutorBuilder { }; } // namespace intel_cpu -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/experimental_detectron_detection_output.cpp b/src/plugins/intel_cpu/src/nodes/experimental_detectron_detection_output.cpp index 70a47d46029375..f8c04fb1383e3d 100644 --- a/src/plugins/intel_cpu/src/nodes/experimental_detectron_detection_output.cpp +++ b/src/plugins/intel_cpu/src/nodes/experimental_detectron_detection_output.cpp @@ -275,14 +275,14 @@ void ExperimentalDetectronDetectionOutput::execute(dnnl::stream strm) { assert(classes_num_ == static_cast(getParentEdgeAt(INPUT_SCORES)->getMemory().getStaticDims()[1])); assert(4 * classes_num_ == static_cast(getParentEdgeAt(INPUT_DELTAS)->getMemory().getStaticDims()[1])); - const auto* boxes = reinterpret_cast(getParentEdgeAt(INPUT_ROIS)->getMemoryPtr()->getData()); - const auto* deltas = reinterpret_cast(getParentEdgeAt(INPUT_DELTAS)->getMemoryPtr()->getData()); - const auto* scores = reinterpret_cast(getParentEdgeAt(INPUT_SCORES)->getMemoryPtr()->getData()); - const auto* im_info = reinterpret_cast(getParentEdgeAt(INPUT_IM_INFO)->getMemoryPtr()->getData()); - - auto* output_boxes = reinterpret_cast(getChildEdgesAtPort(OUTPUT_BOXES)[0]->getMemoryPtr()->getData()); - auto* output_scores = reinterpret_cast(getChildEdgesAtPort(OUTPUT_SCORES)[0]->getMemoryPtr()->getData()); - auto* output_classes = reinterpret_cast(getChildEdgesAtPort(OUTPUT_CLASSES)[0]->getMemoryPtr()->getData()); + const auto* boxes = getSrcDataAtPortAs(INPUT_ROIS); + const auto* deltas = getSrcDataAtPortAs(INPUT_DELTAS); + const auto* scores = getSrcDataAtPortAs(INPUT_SCORES); + const auto* im_info = getSrcDataAtPortAs(INPUT_IM_INFO); + + auto* output_boxes = getDstDataAtPortAs(OUTPUT_BOXES); + auto* output_scores = getDstDataAtPortAs(OUTPUT_SCORES); + auto* output_classes = getDstDataAtPortAs(OUTPUT_CLASSES); const float img_H = im_info[0]; const float img_W = im_info[1]; diff --git a/src/plugins/intel_cpu/src/nodes/experimental_detectron_generate_proposals_single_image.cpp b/src/plugins/intel_cpu/src/nodes/experimental_detectron_generate_proposals_single_image.cpp index be9df09d535c5e..4484d0105cbbd7 100644 --- a/src/plugins/intel_cpu/src/nodes/experimental_detectron_generate_proposals_single_image.cpp +++ b/src/plugins/intel_cpu/src/nodes/experimental_detectron_generate_proposals_single_image.cpp @@ -347,13 +347,13 @@ void ExperimentalDetectronGenerateProposalsSingleImage::execute(dnnl::stream str OPENVINO_THROW("'Deltas' blob size for ONNXProposal is incompatible with 'scores' blob size!"); // Prepare memory - const float *p_deltas_item = reinterpret_cast(getParentEdgeAt(INPUT_DELTAS)->getMemoryPtr()->getData()); - const float *p_scores_item = reinterpret_cast(getParentEdgeAt(INPUT_SCORES)->getMemoryPtr()->getData()); - const float *p_anchors_item = reinterpret_cast(getParentEdgeAt(INPUT_ANCHORS)->getMemoryPtr()->getData()); - const float *p_img_info_cpu = reinterpret_cast(getParentEdgeAt(INPUT_IM_INFO)->getMemoryPtr()->getData()); + const float *p_deltas_item = getSrcDataAtPortAs(INPUT_DELTAS); + const float *p_scores_item = getSrcDataAtPortAs(INPUT_SCORES); + const float *p_anchors_item = getSrcDataAtPortAs(INPUT_ANCHORS); + const float *p_img_info_cpu = getSrcDataAtPortAs(INPUT_IM_INFO); - float *p_roi_item = reinterpret_cast(getChildEdgesAtPort(OUTPUT_ROIS)[0]->getMemoryPtr()->getData()); - float *p_roi_score_item = reinterpret_cast(getChildEdgesAtPort(OUTPUT_SCORES)[0]->getMemoryPtr()->getData()); + float *p_roi_item = getDstDataAtPortAs(OUTPUT_ROIS); + float *p_roi_score_item = getDstDataAtPortAs(OUTPUT_SCORES); const int anchors_num = scoreDims[0]; diff --git a/src/plugins/intel_cpu/src/nodes/experimental_detectron_priorgridgenerator.cpp b/src/plugins/intel_cpu/src/nodes/experimental_detectron_priorgridgenerator.cpp index 470b25712ced70..28cb20d4faa6a4 100644 --- a/src/plugins/intel_cpu/src/nodes/experimental_detectron_priorgridgenerator.cpp +++ b/src/plugins/intel_cpu/src/nodes/experimental_detectron_priorgridgenerator.cpp @@ -68,8 +68,8 @@ void ExperimentalDetectronPriorGridGenerator::execute(dnnl::stream strm) { const float step_w = stride_w_ ? stride_w_ : static_cast(getParentEdgeAt(INPUT_IMAGE)->getMemory().getStaticDims()[3]) / layer_width; const float step_h = stride_h_ ? stride_h_ : static_cast(getParentEdgeAt(INPUT_IMAGE)->getMemory().getStaticDims()[2]) / layer_height; - const auto *bottom_data_0 = reinterpret_cast(getParentEdgeAt(0)->getMemoryPtr()->getData()); - auto *top_data_0 = reinterpret_cast(getChildEdgesAtPort(OUTPUT_ROIS)[0]->getMemoryPtr()->getData()); + const auto *bottom_data_0 = getSrcDataAtPortAs(0); + auto *top_data_0 = getDstDataAtPortAs(OUTPUT_ROIS); for (int h = 0; h < layer_height; ++h) { for (int w = 0; w < layer_width; ++w) { diff --git a/src/plugins/intel_cpu/src/nodes/experimental_detectron_roifeatureextractor.cpp b/src/plugins/intel_cpu/src/nodes/experimental_detectron_roifeatureextractor.cpp index cccda957089bb0..7c3408e7d9a714 100644 --- a/src/plugins/intel_cpu/src/nodes/experimental_detectron_roifeatureextractor.cpp +++ b/src/plugins/intel_cpu/src/nodes/experimental_detectron_roifeatureextractor.cpp @@ -333,11 +333,11 @@ void ExperimentalDetectronROIFeatureExtractor::execute(dnnl::stream strm) { const int channels_num = getParentEdgeAt(INPUT_FEATURES_START)->getMemory().getStaticDims()[1]; const int feaxels_per_roi = pooled_height_ * pooled_width_ * channels_num; - auto *input_rois = reinterpret_cast(getParentEdgeAt(INPUT_ROIS)->getMemoryPtr()->getData()); - auto *output_rois_features = reinterpret_cast(getChildEdgesAtPort(OUTPUT_ROI_FEATURES)[0]->getMemoryPtr()->getData()); + auto *input_rois = getSrcDataAtPortAs(INPUT_ROIS); + auto *output_rois_features = getDstDataAtPortAs(OUTPUT_ROI_FEATURES); float *output_rois = nullptr; if (OUTPUT_ROIS < outputShapes.size()) { - output_rois = reinterpret_cast(getChildEdgesAtPort(OUTPUT_ROIS)[0]->getMemoryPtr()->getData()); + output_rois = getDstDataAtPortAs(OUTPUT_ROIS); } std::vector level_ids(num_rois, 0); @@ -355,7 +355,7 @@ void ExperimentalDetectronROIFeatureExtractor::execute(dnnl::stream strm) { const int level_rois_offset = rois_per_level[i]; const int level_rois_num = rois_per_level[i + 1] - level_rois_offset; if (level_rois_num > 0) { - auto *featuremap = reinterpret_cast(getParentEdgeAt(INPUT_FEATURES_START + i)->getMemoryPtr()->getData()); + auto *featuremap = getSrcDataAtPortAs(INPUT_FEATURES_START + i); const int featuremap_height = getParentEdgeAt(INPUT_FEATURES_START + i)->getMemory().getStaticDims()[2]; const int featuremap_width = getParentEdgeAt(INPUT_FEATURES_START + i)->getMemory().getStaticDims()[3]; ROIAlignForward_cpu_kernel(feaxels_per_roi * level_rois_num, diff --git a/src/plugins/intel_cpu/src/nodes/experimental_detectron_topkrois.cpp b/src/plugins/intel_cpu/src/nodes/experimental_detectron_topkrois.cpp index 7a18f47e9e7d23..88d5f3b9c2b518 100644 --- a/src/plugins/intel_cpu/src/nodes/experimental_detectron_topkrois.cpp +++ b/src/plugins/intel_cpu/src/nodes/experimental_detectron_topkrois.cpp @@ -66,9 +66,9 @@ void ExperimentalDetectronTopKROIs::execute(dnnl::stream strm) { const int input_rois_num = getParentEdgeAt(INPUT_ROIS)->getMemory().getStaticDims()[0]; const int top_rois_num = (std::min)(max_rois_num_, input_rois_num); - auto *input_rois = reinterpret_cast(getParentEdgeAt(INPUT_ROIS)->getMemoryPtr()->getData()); - auto *input_probs = reinterpret_cast(getParentEdgeAt(INPUT_PROBS)->getMemoryPtr()->getData()); - auto *output_rois = reinterpret_cast(getChildEdgesAtPort(OUTPUT_ROIS)[0]->getMemoryPtr()->getData()); + auto *input_rois = getSrcDataAtPortAs(INPUT_ROIS); + auto *input_probs = getSrcDataAtPortAs(INPUT_PROBS); + auto *output_rois = getDstDataAtPortAs(OUTPUT_ROIS); std::vector idx(input_rois_num); iota(idx.begin(), idx.end(), 0); diff --git a/src/plugins/intel_cpu/src/nodes/extract_image_patches.cpp b/src/plugins/intel_cpu/src/nodes/extract_image_patches.cpp index a15740ab503310..426fb5b8790ce7 100644 --- a/src/plugins/intel_cpu/src/nodes/extract_image_patches.cpp +++ b/src/plugins/intel_cpu/src/nodes/extract_image_patches.cpp @@ -370,8 +370,8 @@ ExtractImagePatches::ExtractImagePatches(const std::shared_ptr& op, co } void ExtractImagePatches::prepareParams() { - const auto& srcMemPtr0 = getParentEdgeAt(0)->getMemoryPtr(); - const auto& dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); + const auto& srcMemPtr0 = getSrcMemoryAtPort(0); + const auto& dstMemPtr = getDstMemoryAtPort(0); if (!srcMemPtr0 || !srcMemPtr0->isAllocated()) OPENVINO_THROW("Input memory has not been allocated."); if (!dstMemPtr || !dstMemPtr->isAllocated()) @@ -380,7 +380,7 @@ void ExtractImagePatches::prepareParams() { OPENVINO_THROW("Preferable primitive descriptor is not set."); const auto& in_dims = getParentEdgeAt(0)->getMemory().getStaticDims(); - const auto& out_dims = getChildEdgesAtPort(0)[0]->getMemory().getStaticDims(); + const auto& out_dims = getChildEdgeAt(0)->getMemory().getStaticDims(); const auto prcSize = getOriginalInputPrecisionAtPort(0).size(); ExtractImagePatchesKey key = {in_dims, out_dims, _ksizes, _strides, _rates, _auto_pad, prcSize}; const auto isJit = mayiuse(x64::sse41); @@ -423,10 +423,10 @@ void ExtractImagePatches::initSupportedPrimitiveDescriptors() { void ExtractImagePatches::execute(dnnl::stream strm) { if (execPtr) { - auto src = getParentEdgeAt(0)->getMemoryPtr()->getData(); - auto dst = getChildEdgesAtPort(0)[0]->getMemoryPtr()->getData(); + auto src = getSrcDataAtPort(0); + auto dst = getDstDataAtPort(0); const auto inStrides = getParentEdgeAt(0)->getMemory().getDescWithType()->getStrides(); - const auto outStrides = getChildEdgesAtPort(0)[0]->getMemory().getDescWithType()->getStrides(); + const auto outStrides = getChildEdgeAt(0)->getMemory().getDescWithType()->getStrides(); execPtr->exec(src, dst, inStrides, outStrides); } else { OPENVINO_THROW("Can't execute extract image patches node. Primitive wasn't created"); diff --git a/src/plugins/intel_cpu/src/nodes/eye.cpp b/src/plugins/intel_cpu/src/nodes/eye.cpp index cdded150fe520b..867267de254f04 100644 --- a/src/plugins/intel_cpu/src/nodes/eye.cpp +++ b/src/plugins/intel_cpu/src/nodes/eye.cpp @@ -3,7 +3,9 @@ // #include "eye.h" - +#include "openvino/op/eye.hpp" +#include +#include #include "openvino/core/parallel.hpp" #include "shape_inference/shape_inference_ngraph.hpp" #include "utils/bfloat16.hpp" @@ -73,7 +75,7 @@ struct Eye::EyeExecute { }; void Eye::execute(dnnl::stream strm) { - auto outputPrec = getChildEdgesAtPort(0)[0]->getMemory().getDesc().getPrecision(); + auto outputPrec = getChildEdgeAt(0)->getMemory().getDesc().getPrecision(); OV_SWITCH(intel_cpu, EyeExecute, this, outputPrec, OV_CASE(ov::element::f32, float), OV_CASE(ov::element::bf16, bfloat16_t), @@ -102,10 +104,10 @@ void Eye::executeSpecified() { const size_t rowNum = getRowNum(); const size_t colNum = getColNum(); const int64_t shift = getDiagIndex(); - auto outPtr = getChildEdgeAt(0)->getMemoryPtr(); + auto outPtr = getDstMemoryAtPort(0); if (!outPtr || !outPtr ->isAllocated()) THROW_ERROR(errorPrefix, "Destination memory didn't allocate."); - T *dst = reinterpret_cast(outPtr->getData()); + T *dst = outPtr->getDataAs(); const size_t batchVolume = getBatchVolume(getBatchShape()); const size_t spatialCount = colNum * rowNum; diff --git a/src/plugins/intel_cpu/src/nodes/eye.h b/src/plugins/intel_cpu/src/nodes/eye.h index 1da52c953e687d..7978c45d8a05d1 100644 --- a/src/plugins/intel_cpu/src/nodes/eye.h +++ b/src/plugins/intel_cpu/src/nodes/eye.h @@ -42,34 +42,34 @@ class Eye : public Node { template struct EyeExecute; inline const size_t getRowNum() const { - auto rowMem = getParentEdgeAt(ROWS_NUM)->getMemoryPtr(); + auto rowMem = getSrcMemoryAtPort(ROWS_NUM); if (rowMem == nullptr) OPENVINO_THROW(errorPrefix, " doesn't contain row_count data"); - const int *rowPtr = reinterpret_cast(rowMem->getData()); + const int *rowPtr = rowMem->getDataAs(); return rowPtr[0]; } inline const size_t getColNum() const { - auto colMem = getParentEdgeAt(COLS_NUM)->getMemoryPtr(); + auto colMem = getSrcMemoryAtPort(COLS_NUM); if (colMem == nullptr) OPENVINO_THROW(errorPrefix, " doesn't contain col_count data"); - const int *colPtr = reinterpret_cast(colMem->getData()); + const int *colPtr = colMem->getDataAs(); return colPtr[0]; } inline const int getDiagIndex() const { - auto diagIndMem = getParentEdgeAt(DIAGONAL_INDEX)->getMemoryPtr(); + auto diagIndMem = getSrcMemoryAtPort(DIAGONAL_INDEX); if (diagIndMem == nullptr) OPENVINO_THROW(errorPrefix, " doesn't contain diag_index data"); - const int *diagIndexPtr = reinterpret_cast(diagIndMem->getData()); + const int *diagIndexPtr = diagIndMem->getDataAs(); return diagIndexPtr[0]; } inline const std::vector getBatchShape() const { if (withBatchShape) { - const int batchShapeSize = static_cast(getParentEdgeAt(BATCH_SHAPE)->getMemoryPtr()->getShape().getElementsCount()); + const int batchShapeSize = static_cast(getSrcMemoryAtPort(BATCH_SHAPE)->getShape().getElementsCount()); std::vector batchShape(batchShapeSize); - const int *batchShapePtr = reinterpret_cast(getParentEdgeAt(BATCH_SHAPE)->getMemoryPtr()->getData()); + const int *batchShapePtr = getSrcDataAtPortAs(BATCH_SHAPE); batchShape.assign(batchShapePtr, batchShapePtr + batchShapeSize); return batchShape; } else { diff --git a/src/plugins/intel_cpu/src/nodes/fake_quantize.cpp b/src/plugins/intel_cpu/src/nodes/fake_quantize.cpp index d2ce12478c024d..f98b43c6503d3d 100644 --- a/src/plugins/intel_cpu/src/nodes/fake_quantize.cpp +++ b/src/plugins/intel_cpu/src/nodes/fake_quantize.cpp @@ -1298,11 +1298,6 @@ void FakeQuantize::getSupportedDescriptors() { if (getChildEdges().empty()) OPENVINO_THROW(errorPrefix, "has incorrect number of output edges: ", getChildEdges().size()); - for (size_t i = 0; i < getParentEdges().size(); i++) { - if (getParentEdgesAtPort(i).size() != 1) - OPENVINO_THROW(errorPrefix, "has unsupported number of parent edges at port ", i); - } - if (getInputShapeAtPort(0).getRank() != getInputShapeAtPort(0).getRank()) { OPENVINO_THROW(errorPrefix, "has different ranks for input and output tensors"); } @@ -1390,7 +1385,7 @@ bool FakeQuantize::needPrepareParams() const { return true; } - const auto axisSize = getParentEdgesAtPort(0)[0]->getMemory().getStaticDims()[getAxis()]; + const auto axisSize = getParentEdgeAt(0)->getMemory().getStaticDims()[getAxis()]; const auto newPaddedSize = rnd_up(axisSize, 16); const auto currPaddedSize = rnd_up(currentAxisSize, 16); @@ -1494,10 +1489,10 @@ void FakeQuantize::createPrimitive() { } void FakeQuantize::executeReference() { - auto srcMemory = getParentEdgeAt(0)->getMemoryPtr(); - auto dstMemory = getChildEdgeAt(0)->getMemoryPtr(); + auto srcMemory = getSrcMemoryAtPort(0); + auto dstMemory = getDstMemoryAtPort(0); - auto src = reinterpret_cast(srcMemory->getData()); + auto src = srcMemory->getDataAs(); auto srcDims = srcMemory->getStaticDims(); auto dstDims = dstMemory->getStaticDims(); @@ -1524,13 +1519,13 @@ void FakeQuantize::executeReference() { } d_str[1] = tmp; - auto dst = reinterpret_cast(dstMemory->getData()); + auto dst = dstMemory->getDataAs(); const int nbits = 8; const int CB = impl::utils::div_up(C, nbits); - auto thresholds = reinterpret_cast(internalBlobMemory[0]->getData()); - auto output_mask = reinterpret_cast(internalBlobMemory[1]->getData()); + auto thresholds = internalBlobMemory[0]->getDataAs(); + auto output_mask = internalBlobMemory[1]->getDataAs(); parallel_nd(N, CB, D, H, W, [&](dim_t n, dim_t cb, dim_t d, dim_t h, dim_t w) { uint8_t bin_val = 0x00; @@ -1560,7 +1555,7 @@ void FakeQuantize::executeReference() { dst[dst_off / nbits] = bin_val; }); } else { - auto dst = reinterpret_cast(dstMemory->getData()); + auto dst = dstMemory->getDataAs(); parallel_nd(N, C, D, H, W, [&](dim_t n, dim_t c, dim_t d, dim_t h, dim_t w) { size_t src_off = srcDims.size() == 5 ? @@ -1604,14 +1599,14 @@ void FakeQuantize::executeReference() { } void FakeQuantize::executeBinarization(const std::unique_ptr &pKernel) const { #if defined(OPENVINO_ARCH_X86_64) - auto srcMemory = getParentEdgeAt(0)->getMemoryPtr(); - auto dstMemory = getChildEdgeAt(0)->getMemoryPtr(); + auto srcMemory = getSrcMemoryAtPort(0); + auto dstMemory = getDstMemoryAtPort(0); - auto src = reinterpret_cast(srcMemory->getData()); - auto dst = reinterpret_cast(dstMemory->getData()); + auto src = srcMemory->getDataAs(); + auto dst = dstMemory->getDataAs(); - auto thresholds = reinterpret_cast(internalBlobMemory[0]->getData()); - auto output_mask = reinterpret_cast(internalBlobMemory[1]->getData()); + auto thresholds = internalBlobMemory[0]->getDataAs(); + auto output_mask = internalBlobMemory[1]->getDataAs(); auto src_dims = srcMemory->getStaticDims(); @@ -1646,11 +1641,11 @@ void FakeQuantize::executeBinarization(const std::unique_ptr &pKernel) const { #if defined(OPENVINO_ARCH_X86_64) - auto srcMemory = getParentEdgeAt(0)->getMemoryPtr(); - auto dstMemory = getChildEdgeAt(0)->getMemoryPtr(); + auto srcMemory = getSrcMemoryAtPort(0); + auto dstMemory = getDstMemoryAtPort(0); - auto src = reinterpret_cast(srcMemory->getData()); - auto dst = reinterpret_cast(dstMemory->getData()); + auto src = srcMemory->getDataAs(); + auto dst = dstMemory->getDataAs(); auto& srcDesc = srcMemory->getDesc(); auto srcDims = srcDesc.getShape().getStaticDims(); @@ -2048,7 +2043,7 @@ void FakeQuantize::updateOptimizedFormula(bool do_rounding) { // map FQ to oneDNN's attribuites & postOps // equation: // y = clip2(round(x * inputScale + inputShift))*outputScale + outputShift -bool FakeQuantize::appendAttrPostOps(DnnlPostOpsComposer& dnnlpoc, +bool FakeQuantize::appendAttrPostOps(DnnlPostOpsComposerLegacy& dnnlpoc, bool isLastPostOp, dnnl::memory::data_type outDataType, bool allowBinary, diff --git a/src/plugins/intel_cpu/src/nodes/fake_quantize.h b/src/plugins/intel_cpu/src/nodes/fake_quantize.h index fc899a115c7822..ade6a1d74e8259 100644 --- a/src/plugins/intel_cpu/src/nodes/fake_quantize.h +++ b/src/plugins/intel_cpu/src/nodes/fake_quantize.h @@ -8,6 +8,7 @@ #include "node.h" #include +#include "dnnl_postops_composer_legacy.h" namespace ov { namespace intel_cpu { @@ -100,6 +101,7 @@ class FakeQuantize : public Node { const std::vector& getInputShift() const { return inputShift; } const std::vector& getOutputScale() const { return outputScale; } const std::vector& getOutputShift() const { return outputShift; } + const size_t getLevels() const { return levels; } void setCropLow(std::vector newCropLow) { cropLow = std::move(newCropLow); cropLowSize = cropLow.size(); ++parameterVersion; @@ -132,7 +134,7 @@ class FakeQuantize : public Node { void appendPostOps(dnnl::post_ops& ops, const VectorDims &postOpDims, std::unordered_map& postOpsMem, const int channelAxis = 1) override; void appendPostOps(dnnl::post_ops& ops, const VectorDims &postOpDims, std::vector& postOpsMem, const int channelAxis = 1) override; - bool appendAttrPostOps(DnnlPostOpsComposer& dnnlpoc, + bool appendAttrPostOps(DnnlPostOpsComposerLegacy& dnnlpoc, bool isLastPostOp, dnnl::memory::data_type outDataType, bool allowBinary = true, diff --git a/src/plugins/intel_cpu/src/nodes/fullyconnected.cpp b/src/plugins/intel_cpu/src/nodes/fullyconnected.cpp index 0d6aa56b9d5907..fe55e1a44c491f 100644 --- a/src/plugins/intel_cpu/src/nodes/fullyconnected.cpp +++ b/src/plugins/intel_cpu/src/nodes/fullyconnected.cpp @@ -4,107 +4,45 @@ #include "fullyconnected.h" -#include "eltwise.h" -#include "input.h" -#include "fake_quantize.h" +#include +#include +#include + +#include "common/cpu_convert.h" +#include "dnnl_extension_utils.h" +#include "executors/memory_arguments.hpp" +#include "graph_context.h" #include "input.h" #include "memory_desc/blocked_memory_desc.h" -#include "memory_desc/dnnl_memory_desc.h" -#include "reorder.h" -#include "transformations/cpu_opset/common/op/fully_connected.hpp" -#include "openvino/opsets/opset1.hpp" -#include "dnnl_extension_utils.h" -#include "onednn/dnnl.h" -#include "utils/general_utils.h" +#include "memory_desc/cpu_memory_desc.h" #include "memory_desc/cpu_memory_desc_utils.h" #include "memory_desc/dnnl_blocked_memory_desc.h" -#include "utils/cpu_utils.hpp" - -#include "onednn/dnnl.h" -#include "oneapi/dnnl/dnnl.hpp" -#include "cpu/x64/cpu_isa_traits.hpp" -#include "common/primitive_hashing_utils.hpp" -#include "common/primitive_desc.hpp" -#include "common/primitive_desc_iface.hpp" -#include "common/cpu_convert.h" +#include "nodes/executors/executor.hpp" +#include "nodes/executors/fullyconnected_config.hpp" +#include "openvino/core/type/element_type.hpp" +#include "post_ops.hpp" #include "shape_inference/custom/fullyconnected.hpp" - -#include -#include - -#ifdef OV_CPU_WITH_MLAS -#include "mlas/sgemm.hpp" -#endif +#include "transformations/cpu_opset/common/op/fully_connected.hpp" +#include "utils/debug_capabilities.h" +#include "utils/general_utils.h" using namespace dnnl; +using namespace ov::element; namespace ov { namespace intel_cpu { namespace node { -namespace { - -struct FCKey { - DnnlMemoryDescCPtr inp0; - DnnlMemoryDescCPtr inp1; - DnnlMemoryDescCPtr bias; - DnnlMemoryDescCPtr out; - dnnl::primitive_attr attr; - impl_desc_type implType; - bool useConv1x1; - bool useSparseWeights; - - size_t hash() const; - bool operator==(const FCKey& rhs) const; -}; - -size_t FCKey::hash() const { - using namespace dnnl::impl; - using namespace dnnl::impl::primitive_hashing; - size_t seed = 0; - - for (const auto& ptr : {inp0, inp1, bias, out}) { - if (ptr) { - seed = hash_combine(seed, get_md_hash(*ptr->getDnnlDesc().get())); - } - } - - seed = hash_combine(seed, get_attr_hash(*attr.get())); - seed = hash_combine(seed, implType); - seed = hash_combine(seed, useConv1x1); - seed = hash_combine(seed, useSparseWeights); - return seed; -} - -bool FCKey::operator==(const FCKey &rhs) const { - bool retVal = true; - if (inp0 != rhs.inp0) { - retVal = retVal && inp0 && rhs.inp0 && inp0->getDnnlDesc() == rhs.inp0->getDnnlDesc(); - } - if (inp1 != rhs.inp1) { - retVal = retVal && inp1 && rhs.inp1 && inp1->getDnnlDesc() == rhs.inp1->getDnnlDesc(); - } - if (bias != rhs.bias) { - retVal = retVal && bias && rhs.bias && bias->getDnnlDesc() == rhs.bias->getDnnlDesc(); - } - if (out != rhs.out) { - retVal = retVal && out && rhs.out && out->getDnnlDesc() == rhs.out->getDnnlDesc(); - } - retVal = retVal && *attr.get() == *rhs.attr.get() && - implType == rhs.implType && useConv1x1 == rhs.useConv1x1 && useSparseWeights == rhs.useSparseWeights; - return retVal; -} - -} // namespace - -bool FullyConnected::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { +bool FullyConnected::isSupportedOperation(const std::shared_ptr& op, + std::string& errorMessage) noexcept { try { const auto fc = std::dynamic_pointer_cast(op); if (!fc) { errorMessage = "Only legacy FullyConnected operation is supported"; return false; } - if (fc->get_input_size() == 3 && std::dynamic_pointer_cast(fc->get_input_node_shared_ptr(BIAS_ID)) == nullptr) { + if (fc->get_input_size() == 3 && + std::dynamic_pointer_cast(fc->get_input_node_shared_ptr(BIAS_ID)) == nullptr) { errorMessage = "Only Constant operation on 'bias' input is supported"; return false; } @@ -120,569 +58,43 @@ bool FullyConnected::isSupportedOperation(const std::shared_ptr& } FullyConnected::FullyConnected(const std::shared_ptr& op, const GraphContext::CPtr context) - : Node(op, context, FCShapeInferFactory(op)), withBiases(false) { + : Node(op, context, FCShapeInferFactory(op)), + errorPrefix("FullyConnected node with name '" + getName() + "'") { std::string errorMessage; if (!isSupportedOperation(op, errorMessage)) OPENVINO_THROW_NOT_IMPLEMENTED(errorMessage); - errorPrefix = "FullyConnected node with name '" + getName() + "'"; - if (context->getConfig().fcSparseWeiDecompressionRate < 1.0f) - minSparseRate = context->getConfig().fcSparseWeiDecompressionRate; - - expectedBiasDims = {getInputShapeAtPort(WEIGHTS_ID).getStaticDims()[0]}; -} - -std::vector FullyConnected::getAvailableFormatsForDims(const Shape &dims) const { - if (dims.getRank() == 0) - return {memory::format_tag::x}; - else if (dims.getRank() == 1) - return {memory::format_tag::x}; - else if (dims.getRank() == 2) - return {memory::format_tag::nc}; - else if (dims.getRank() == 3) - return {memory::format_tag::tnc}; - else if (dims.getRank() == 4) - return {memory::format_tag::nChw8c, memory::format_tag::nChw16c, memory::format_tag::nhwc, memory::format_tag::nchw}; - else if (dims.getRank() == 5) - return {memory::format_tag::nCdhw8c, memory::format_tag::nCdhw16c, memory::format_tag::ndhwc, memory::format_tag::ncdhw}; - return {memory::format_tag::any}; -} - -VectorDims FullyConnected::makeDummyInputDims() const { - const auto& inShape = getInputShapeAtPort(DATA_ID); - const auto& weightDims = getInputShapeAtPort(WEIGHTS_ID).getStaticDims(); - - auto inMinDims = inShape.getMinDims(); - auto inMaxDims = inShape.getMaxDims(); - inMinDims.back() = weightDims.back(); - inMaxDims.back() = weightDims.back(); - - return MemoryDescUtils::makeDummyShape(Shape(inMinDims, inMaxDims)).getStaticDims(); -} - -VectorDims FullyConnected::makeDummyOutputDims(const VectorDims& inDims) const { - std::vector inShapes = {Shape(inDims), getInputShapeAtPort(WEIGHTS_ID)}; - if (inputShapes.size() > 2) { - inShapes.emplace_back(getInputShapeAtPort(BIAS_ID)); - } - return shapeInferGeneric(inShapes).front(); -} - -bool FullyConnected::canBeExecutedInInt8() const { - auto firstInputPrecision = getOriginalInputPrecisionAtPort(0); - auto secondInputPrecision = getOriginalInputPrecisionAtPort(1); - - return one_of(firstInputPrecision, ov::element::u8, ov::element::i8) && secondInputPrecision == ov::element::i8; -} - -void FullyConnected::getSupportedDescriptors() { - if (getParentEdges().size() != 2 && getParentEdges().size() != 3) - OPENVINO_THROW(errorPrefix, " has incorrect number of input edges"); - if (getChildEdges().empty()) - OPENVINO_THROW(errorPrefix, " has incorrect number of output edges"); - - auto inputDataType = DnnlExtensionUtils::ElementTypeToDataType(getOriginalInputPrecisionAtPort(DATA_ID)); - outputDataType = DnnlExtensionUtils::ElementTypeToDataType(getOriginalOutputPrecisionAtPort(DATA_ID)); - - if (!fusedWith.empty()) { - outputDataType = DnnlExtensionUtils::ElementTypeToDataType(fusedWith[fusedWith.size() - 1]->getOriginalOutputPrecisionAtPort(0)); - } - auto weightsDataType = DnnlExtensionUtils::ElementTypeToDataType(getOriginalInputPrecisionAtPort(WEIGHTS_ID)); - - withBiases = getOriginalInputsNumber() == 3; - - useSparseWeights = useSparseWeightsDecompression(); - useWeightsDecompressionImpl = dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx2) && - one_of(inputDataType, memory::data_type::f32, memory::data_type::bf16) && - one_of(weightsDataType, memory::data_type::u8, memory::data_type::nf4, - memory::data_type::u4, memory::data_type::s4); - - // revert back outputDataType on special cases - if (inputDataType == memory::data_type::f32) { - // oneDNN only support f32 output when input is f32, even if FQ is fused - outputDataType = memory::data_type::f32; - } else if (inputDataType == memory::data_type::bf16) { - // bf16 input only supports bf16/f32 output, even if FQ is fused as post-ops - if (one_of(outputDataType , memory::data_type::u8, memory::data_type::s8)) { - outputDataType = memory::data_type::bf16; - } - // TODO: Ticket CVS-122347 - support WeightsDecompression with bf16 inputDataType on avx2_vnni_2 - if (useWeightsDecompressionImpl && !dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx512_core_bf16)) { - inputDataType = outputDataType = memory::data_type::f32; - } - } else if (inputDataType == memory::data_type::f16) { -#if defined(OV_CPU_WITH_ACL) - // acl fc does not support precisions conversion - outputDataType = weightsDataType = memory::data_type::f16; -#else - // f16 input only supports f16/f32 output, even if FQ is fused as post-ops - if (!one_of(outputDataType , memory::data_type::f32, memory::data_type::f16)) { - outputDataType = memory::data_type::f16; - } -#endif - } else if (one_of(inputDataType, memory::data_type::u8, memory::data_type::s8)) { - if (weightsDataType != memory::data_type::s8) { - // weight has to be s8 for INT8 mode, otherwise fallback to - // f32 mode - inputDataType = outputDataType = memory::data_type::f32; - } else if (one_of(outputDataType, memory::data_type::f16)) { - // INT8 inner-product only supports u8/s8/s32/f32/bf16, - // other precision needs fallback to f32 - outputDataType = memory::data_type::f32; - } - } else { - // s32/u32/... unsupported input data types, fallback to f32 - inputDataType = outputDataType = memory::data_type::f32; - } - - inDims = isDynamicNode() ? makeDummyInputDims() : getInputShapeAtPort(DATA_ID).getStaticDims(); - outDims = isDynamicNode() ? makeDummyOutputDims(inDims) : getOutputShapeAtPort(0).getStaticDims(); -#if defined(OV_CPU_WITH_MLAS) && (defined(OPENVINO_ARCH_X86) || defined(OPENVINO_ARCH_X86_64)) - // MLAS doesn't support post-ops fusing and only supports FP32. INT8 is not enabled yet - // Disable MLAS when FC could fuse post-ops - useMlas = !useSparseWeights && !useWeightsDecompressionImpl && - (inputDataType == memory::data_type::f32 && weightsDataType == memory::data_type::f32) && - fusedWith.empty(); - auto wgtDims = getInputShapeAtPort(WEIGHTS_ID).getStaticDims(); - // MLAS cannot support weight dims > 2, e.g. [1,64,9,9] * [10,64,9,9] - if (useMlas && wgtDims.size() > 2) { - bool allOnes = true; - for (size_t i = 2; i < wgtDims.size(); i++) { - allOnes = allOnes && wgtDims[i] == 1; - } - useMlas = useMlas && allOnes; - } - if (useMlas && withBiases) { - const auto& biasDims = getInputShapeAtPort(BIAS_ID).getStaticDims(); - bool isByChannel = biasDims.back() == outDims.back(); - for (size_t i = 0; i < biasDims.size() - 1; i++) { - isByChannel = isByChannel && biasDims[i] == 1; - } - useMlas = useMlas && isByChannel; - } -#endif -#ifdef CPU_DEBUG_CAPS - // Select Sgemm type by ENV MLAS/ONEDNN, MLAS is used by default - if (getenv("OV_CPU_FC_EXEC_TYPE")) { - if (std::string(getenv("OV_CPU_FC_EXEC_TYPE")) != "MLAS") { - useMlas = false; - } - } -#endif - if (useMlas) return; - - for (auto format : getAvailableFormatsForDims(getInputShapeAtPort(0))) { - auto in_candidate = dnnl::memory::desc(DnnlExtensionUtils::convertToDnnlDims(inDims), inputDataType, format); - auto out_candidate = dnnl::memory::desc(DnnlExtensionUtils::convertToDnnlDims(outDims), outputDataType, dnnl::memory::format_tag::any); - - createDescriptorInternal(in_candidate, out_candidate); - } -} - -#ifdef OV_CPU_WITH_MLAS -void FullyConnected::prepackMLASWeight() { - auto prepareMLASWeight = [&](const int64_t N, const int64_t K) { - if (!getParentEdgeAt(WEIGHTS_ID)->getParent()->isConstant()) - OPENVINO_THROW("Weight input is not const for node ", getName(), "."); - auto weightsMem = getParentEdgeAt(WEIGHTS_ID)->getMemoryPtr(); - if (!weightsMem) - OPENVINO_THROW("Cannot get const weights edgeMem for node ", getName(), "."); - auto packedBsize = mlas_sgemm_pack_get_size(N, K); - MemoryPtr ptr; - auto create = [&]() { - float* weightPtr = reinterpret_cast(weightsMem->getData()); - size_t ldb = weightsNonTransposed ? N : K; - MemoryPtr _ptr = - std::make_shared(getEngine(), - intel_cpu::CpuBlockedMemoryDesc(ov::element::i8, intel_cpu::Shape{packedBsize})); - float* prepackedDst = reinterpret_cast(_ptr->getData()); - mlas_sgemm_pack(weightsNonTransposed ? "F" : "T", N, K, ldb, weightPtr, prepackedDst); - return _ptr; - }; - - auto weightCache = context->getWeightsCache(); - if (weightCache != nullptr) { - std::string format = "gemm_mlas_" + std::to_string(N) + "_" + std::to_string(K); - const std::string string_hash = getName() + "_" + format + "_" + std::to_string(weightsMem->getSize()) + - "_" + std::to_string(reinterpret_cast(weightsMem->getData())); - - ptr = *weightCache->findOrCreate(string_hash, create); - } else { - ptr = create(); - } - return ptr; + auto createEmptyMemoryDesc = [](const ov::element::Type type) { + return std::make_shared(type, Shape{0}); }; - const auto& wgtDims = getParentEdgeAt(WEIGHTS_ID)->getMemoryPtr()->getStaticDims(); - // Weights are transposed by MatMulConstTransposesExtraction - // K is the IC of weight - // the weight is reshaped to [-1, K] in ConvertMatMulToFC - K = wgtDims[1]; - N = wgtDims[0]; - - mlasPackedPtr = prepareMLASWeight(N, K); -} -#endif - -static dnnl::convolution_forward::primitive_desc -createDescriptorInternalForConv(DnnlMemoryDescCPtr inputDescPtr, - DnnlMemoryDescCPtr weightDescPtr, - DnnlMemoryDescCPtr biasDescPtr, - DnnlMemoryDescCPtr outputDescPtr, - const dnnl::primitive_attr& attr, - const dnnl::engine& engine) { - const dnnl::memory::desc &inputDesc = inputDescPtr->getDnnlDesc(); - const dnnl::memory::desc &outputDesc = outputDescPtr->getDnnlDesc(); - const dnnl::memory::desc &weightDesc = weightDescPtr->getDnnlDesc(); - // make a fake shape: N, IC, W - auto inDims = inputDesc.get_dims(); - dnnl::memory::dims normalizedInDims; - if (inDims.size() == 3) { - normalizedInDims = {inDims[0], inDims[2], inDims[1]}; - } else if (inDims.size() == 2) { - normalizedInDims = {dnnl::memory::dim{1}, inDims[1], inDims[0]}; - } - auto convInDesc = dnnl::memory::desc(normalizedInDims, inputDesc.get_data_type(), memory::format_tag::nwc); - - // make a fake shape: N, OC, W - const auto& outDims = outputDesc.get_dims(); - dnnl::memory::dims normalizedOutDims; - if (outDims.size() == 3) { - normalizedOutDims = { outDims[0], outDims[2], outDims[1]}; - } else if (outDims.size() == 2) { - normalizedOutDims = { dnnl::memory::dim{1}, outDims[1], outDims[0]}; - } - auto convOutDesc = dnnl::memory::desc(normalizedOutDims, outputDesc.get_data_type(), memory::format_tag::nwc); - // make a fake shape: OC, IC, 1 - auto weightDims = weightDesc.get_dims(); - dnnl::memory::dims normalizedWeightDims; - normalizedWeightDims = {static_cast(weightDims[0]), - static_cast(weightDims[1]), - dnnl::memory::dim{1}}; - auto convWeightDescAny = dnnl::memory::desc(normalizedWeightDims, weightDesc.get_data_type(), dnnl::memory::format_tag::any); - - if (biasDescPtr) { - return dnnl::convolution_forward::primitive_desc( - engine, - prop_kind::forward_inference, - dnnl::algorithm::convolution_direct, - convInDesc, convWeightDescAny, biasDescPtr->getDnnlDesc(), convOutDesc, - dnnl::memory::dims{1}, // stride - dnnl::memory::dims{0}, // dilation - dnnl::memory::dims{0}, // paddingL - dnnl::memory::dims{0}, // paddingR - attr); - } else { - return dnnl::convolution_forward::primitive_desc( - engine, - prop_kind::forward_inference, dnnl::algorithm::convolution_direct, - convInDesc, convWeightDescAny, convOutDesc, - dnnl::memory::dims{1}, // stride - dnnl::memory::dims{0}, // dilation - dnnl::memory::dims{0}, // paddingL - dnnl::memory::dims{0}, // paddingR - attr); - } -} + auto createEmptyMemory = [&createEmptyMemoryDesc](const GraphContext::CPtr context, const ov::element::Type type) { + return std::make_shared(context->getEngine(), createEmptyMemoryDesc(type), nullptr); + }; -template -static std::vector normalizeDims(const std::vector& dims) { - return {std::accumulate(dims.begin(), dims.end() - 1, (T)1, std::multiplies()), dims[dims.size() - 1]}; + emptyMemory = createEmptyMemory(context, ov::element::undefined); } -static dnnl::primitive_desc createPrimitiveDesc(const FCKey& key, const dnnl::engine& engine) { - // use conv1x1 primitive for computation - if (key.useConv1x1) { - auto prim_desc = createDescriptorInternalForConv(key.inp0, key.inp1, key.bias, key.out, key.attr, engine); - const bool found = DnnlExtensionUtils::find_implementation(prim_desc, brgconv_avx512_1x1); - - if (found) - return std::move(prim_desc); - } - - // fallback to normal inner product primitive - auto inDesc = key.inp0->getDnnlDesc(); - const auto& inDims = inDesc.get_dims(); // @TODO query + copy might be slow - if (inDims.size() > 2) { - dnnl::memory::dims normalizedInDims = normalizeDims(inDims); - inDesc = inDesc.reshape(normalizedInDims); - } - - auto outDesc = key.out->getDnnlDesc(); - const auto& outDims = outDesc.get_dims(); // @TODO query + copy might be slow - if (outDims.size() > 2) { - dnnl::memory::dims normalizedOutDims = normalizeDims(outDims); - outDesc = outDesc.reshape(normalizedOutDims); - } - - dnnl::memory::desc weiDesc; - if (key.useSparseWeights) { - weiDesc = key.inp1->getDnnlDesc(); - } else { - weiDesc = dnnl::memory::desc(DnnlExtensionUtils::convertToDnnlDims(key.inp1->getShape().getStaticDims()), - key.inp1->getDataType(), memory::format_tag::any); - } - dnnl::inner_product_forward::primitive_desc prim_desc; - if (key.bias) { - prim_desc = dnnl::inner_product_forward::primitive_desc( - engine, - dnnl::prop_kind::forward_inference, - inDesc, - weiDesc, - key.bias->getDnnlDesc(), - outDesc, - key.attr); - } else { - prim_desc = dnnl::inner_product_forward::primitive_desc( - engine, - dnnl::prop_kind::forward_inference, - inDesc, - weiDesc, - outDesc, - key.attr); - } - auto first_desc = dnnl::inner_product_forward::primitive_desc(prim_desc.get()); - const bool found = DnnlExtensionUtils::find_implementation(prim_desc, key.implType); - - if (found) - return std::move(prim_desc); +bool FullyConnected::canBeExecutedInInt8() const { + auto srcType = getOriginalInputPrecisionAtPort(0); + auto weiType = getOriginalInputPrecisionAtPort(1); - return std::move(first_desc); + return one_of(srcType, ov::element::u8, ov::element::i8) && weiType == ov::element::i8; } -#if defined(OV_CPU_WITH_ACL) -/** - * Do not wait till prepareParams to reorder the weights - * Do it in scope of compile_model using dummy shapes - */ -void FullyConnected::prepareWeightsUsingDummyShape() { - NodeDesc *selected_pd = getSelectedPrimitiveDescriptor(); - if (selected_pd == nullptr) - OPENVINO_THROW("Preferable primitive descriptor is not set for node ", getName(), "."); - - auto inDesc = MemoryDescUtils::convertToDnnlMemoryDesc(MemoryDescUtils::makeDummyDesc(*getBaseMemDescAtInputPort(DATA_ID))); - auto weightDesc = MemoryDescUtils::convertToDnnlMemoryDesc(weightDescIP); - auto biasDesc = withBiases ? MemoryDescUtils::convertToDnnlMemoryDesc(getBaseMemDescAtInputPort(BIAS_ID)) : nullptr; - auto outDesc = MemoryDescUtils::convertToDnnlMemoryDesc(MemoryDescUtils::makeDummyDesc(*getBaseMemDescAtOutputPort(0))); +ExecutorPtr FullyConnected::createExecutor() { + const auto& executor = factory->make(memory); + getSelectedPrimitiveDescriptor()->setImplementationType(executor->implType()); - const FCKey key = {inDesc, - weightDesc, - biasDesc, - outDesc, - attr, - selected_pd->getImplementationType(), - false}; - - auto prim_desc = createPrimitiveDesc(key, getEngine()); - auto weights = DnnlExtensionUtils::makeDescriptor(prim_desc.weights_desc()); - // ignore the result since we just need to put the reordered weights into the cache - if (weightsNonTransposed) { - (void) prepareWeightMemory(weights, makeTransposedWeightDescriptor(weights)); - } else { - (void) prepareWeightMemory(weights); - } -} -#endif - -void FullyConnected::createPrimitive() { -#ifdef OV_CPU_WITH_MLAS - if (useMlas) { - Node::createPrimitive(); - prepackMLASWeight(); - return; - } -#endif - setPostOps(attr, outDims); - attr.set_scratchpad_mode(dnnl::scratchpad_mode::user); - Node::createPrimitive(); - appendPostOpArgs(attr, primArgs, postOpsArgs); -#if defined(OV_CPU_WITH_ACL) - prepareWeightsUsingDummyShape(); -#endif + return executor; } void FullyConnected::prepareParams() { - auto srcMemPtr = getParentEdgesAtPort(0)[0]->getMemoryPtr(); - auto dstMemPtr = getChildEdgesAtPort(0)[0]->getMemoryPtr(); - if (!dstMemPtr || !dstMemPtr->isAllocated()) - OPENVINO_THROW("Destination memory hasn't been allocated."); - if (!srcMemPtr || !srcMemPtr->isAllocated()) - OPENVINO_THROW("Input memory hasn't been allocated."); - MemoryPtr biasMemPtr = nullptr; - if (withBiases) { - biasMemPtr = getParentEdgesAtPort(2)[0]->getMemoryPtr(); - if (!biasMemPtr || !biasMemPtr->isAllocated()) - OPENVINO_THROW("Input memory hasn't been allocated."); - } - - NodeDesc *selected_pd = getSelectedPrimitiveDescriptor(); - if (selected_pd == nullptr) - OPENVINO_THROW("Preferable primitive descriptor is not set for node ", getName(), "."); -#ifdef OV_CPU_WITH_MLAS - // M should be normalized and updated - if (useMlas) { - outDims = dstMemPtr->getStaticDims(); - if (outDims.size() > 2) { - M = std::accumulate(outDims.begin(), outDims.end() - 1, 1, std::multiplies()); - } else { - M = outDims[0]; - } - return; - } -#endif - DnnlMemoryDescPtr weightDesc = MemoryDescUtils::convertToDnnlMemoryDesc(weightDescIP); - DnnlMemoryDescCPtr biasDesc = nullptr; - if (biasMemPtr) { - biasDesc = biasMemPtr->getDescWithType(); - } - - DnnlMemoryDescCPtr inDesc = srcMemPtr->getDescWithType(); - DnnlMemoryDescCPtr outDesc = dstMemPtr->getDescWithType(); - - useConv1x1 = canBeExecutedInConv1x1(); - FCKey key = {inDesc, - weightDesc, - biasDesc, - outDesc, - attr, - implementationTypeIP, - useConv1x1, - useSparseWeights}; - - auto& engine = getEngine(); - - auto builder = [&engine](const FCKey& key) -> executorPtr { - return std::make_shared(createPrimitiveDesc(key, engine)); - }; - - auto cache = context->getParamsCache(); - auto result = cache->getOrCreate(key, builder); - - if (!result.first) { - OPENVINO_THROW("Primitive descriptor was not found for node ", getName(), "."); - } - - auto prevExecPtr = execPtr; - execPtr = result.first; - - if (execPtr) { - if (execPtr->getSrcDesc()->isCompatible(*inDesc)) { - primArgs[DNNL_ARG_SRC] = srcMemPtr->getPrimitive(); - } else { - primArgs[DNNL_ARG_SRC] = dnnl::memory(execPtr->getDnnlSrcDesc(), engine, srcMemPtr->getData()); - } - - if (execPtr->getDstDesc()->isCompatible(*outDesc)) { - primArgs[DNNL_ARG_DST] = dstMemPtr->getPrimitive(); - } else { - primArgs[DNNL_ARG_DST] = dnnl::memory(execPtr->getDnnlDstDesc(), engine, dstMemPtr->getData()); - } - - if (!prevExecPtr || !execPtr->getWeightDesc()->isCompatible(*(prevExecPtr->getWeightDesc()))) { -#ifdef CPU_DEBUG_CAPS - // execPtr expects different weight layout. - if (prevExecPtr) { - const Shape weiShape{getParentEdgesAtPort(1)[0]->getMemoryPtr()->getStaticDims()}; - DEBUG_LOG("##", getName(), " weight desc is not compatible with previous inner product execPtr!"); - DEBUG_LOG("#", static_cast(execPtr->getWeightDesc()->getMaxMemSize()) / static_cast(1<<20), - "#", weiShape.toString(), - "#", prevExecPtr->getImplementationType() == brgconv_avx512_1x1 ? "Conv1x1," : "FullyConnnect,", - "#", execPtr->getImplementationType() == brgconv_avx512_1x1 ? "Conv1x1," : "FullyConnnect,", - "#", *prevExecPtr->getWeightDesc(), - "#", *execPtr->getWeightDesc()); - } -#endif - if (weightsNonTransposed) { - primArgs[DNNL_ARG_WEIGHTS] = prepareWeightMemory(execPtr->getWeightDesc(), - makeTransposedWeightDescriptor(execPtr->getWeightDesc()))->getPrimitive(); - } else { - primArgs[DNNL_ARG_WEIGHTS] = prepareWeightMemory(execPtr->getWeightDesc())->getPrimitive(); - } - } - // changed shapes may also cause the kernel type changed - selected_pd->setImplementationType(execPtr->getImplementationType()); - // WA: We update implType to know whether weights decompression was used inside the kernel - if (selected_pd->getImplementationType() == ov::intel_cpu::brgemm_avx512_amx && - execPtr->getDnnlWeightDesc().get_format_kind() == memory::format_kind::sparsed) { - selected_pd->setImplementationType(ov::intel_cpu::brgemm_sparse_avx512_amx); - } - // maybe expected 1x1 conv is not created, update the flag depends on the real type - useConv1x1 = execPtr->getImplementationType() == brgconv_avx512_1x1; - - if (withBiases) { - primArgs[DNNL_ARG_BIAS] = biasMemPtr->getPrimitive(); - } - - auto schratchpadMem = getScratchPadMem(execPtr->getScratchPadDesc()); - primArgs[DNNL_ARG_SCRATCHPAD] = schratchpadMem->getPrimitive(); -#ifdef CPU_DEBUG_CAPS - if (result.second == CacheEntryBase::LookUpStatus::Miss) { - auto pd = execPtr->getPrimitiveDesc(); - DEBUG_LOG("verbose##", getName(), "##", DnnlExtensionUtils::query_pd_info(pd), "\n"); - } -#endif - } else { - OPENVINO_THROW("Executor is not created for node ", getName(), "."); - } -} - -#ifdef OV_CPU_WITH_MLAS -void FullyConnected::executeMLAS() { - const auto dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); - const auto src0MemPtr = getParentEdgeAt(0)->getMemoryPtr(); - const auto biasMemPtr = withBiases ? getParentEdgeAt(BIAS_ID)->getMemoryPtr() : nullptr; - int64_t lda = K; - int64_t ldb = K; - int64_t ldc = N; - mlas_sgemm_compute("N", - "N", - M, - N, - K, - 1.0f, - reinterpret_cast(src0MemPtr->getData()), - lda, - reinterpret_cast(mlasPackedPtr->getData()), - ldb, - 0.0f, - reinterpret_cast(dstMemPtr->getData()), - ldc, - withBiases ? reinterpret_cast(biasMemPtr->getData()) : nullptr); + executor = createExecutor(); } -#endif - void FullyConnected::execute(dnnl::stream strm) { -#ifdef OV_CPU_WITH_MLAS - if (useMlas) { - executeMLAS(); - return; - } -#endif - if (!execPtr) { - OPENVINO_THROW("Can't execute FullyConnected node with name: ", - getName(), - ", because executor is not compiled"); - } - - // in cases parameter -> FullyConnected or dynamic shapes - // we keep old pointer to data in primArgs on second iteration with same input shapes - auto updateMemoryPtr = [this](int argType) { - auto param = primArgs.find(argType); - if (param != primArgs.end()) { - if (argType == DNNL_ARG_SRC && (getInputShapeAtPort(DATA_ID).getRank() > 2 || useConv1x1)) { - primArgs.at(argType).set_data_handle(getParentEdgesAtPort(0)[0]->getMemoryPtr()->getData()); - } - if (argType == DNNL_ARG_DST && (getOutputShapeAtPort(0).getRank() > 2 || useConv1x1)) { - primArgs.at(argType).set_data_handle(getChildEdgesAtPort(0)[0]->getMemoryPtr()->getData()); - } - } - }; - - updateMemoryPtr(DNNL_ARG_SRC); - updateMemoryPtr(DNNL_ARG_DST); - - execPtr->exec(primArgs, strm); + executor->execute(memory); } void FullyConnected::executeDynamicImpl(dnnl::stream strm) { @@ -693,55 +105,6 @@ bool FullyConnected::canFuse(const NodePtr& node) const { return canFuseSimpleOperation(node); } -void FullyConnected::setPostOps(dnnl::primitive_attr& attr, const VectorDims& dims_ext) { - dnnl::post_ops ops; - - // accoridng to https://oneapi-src.github.io/oneDNN/dev_guide_inner_product.html - // oneDNN inner product primitive's input & output tensors are always 2D: - // input: [N, IC] weight: [OC, IC] bias: [OC] output:[N,OC] - // - // when input output tensors have spatial dimensions, they are flattened to 2D. - // and following type of MatMul will be converted into FullyConnected inside CPU plugin: - // 2D: [X,Y] [Y,Z] => [X,Z] with N=X,IC=Y,OC=Z - // 3D: [B,X,Y] [Y,Z] => [B,X,Z] with N=B*X,IC=Y,OC=Z - - VectorDims dims = normalizeDims(dims_ext); - - DnnlPostOpsComposer dnnlpoc(getEngine(), attr, ops, postOpsArgs, dims, dims.size() - 1, canBeExecutedInInt8(), - 1 << 0, getDQScales(), withBiases); - - NodeDesc *selected_pd = getSelectedPrimitiveDescriptor(); - if (selected_pd == nullptr) - OPENVINO_THROW("Preferable primitive descriptor is not set for node ", getName(), "."); - if (decompressionMultiplyPtr) - dnnlpoc.appendDecompressionScales(decompressionMultiplyPtr, !weightsNonTransposed); - if (decompressionSubtractPtr) - dnnlpoc.appendDecompressionZeroPoints(decompressionSubtractPtr, !weightsNonTransposed); - - for (size_t i = 0; i < fusedWith.size(); ++i) { - auto& node = fusedWith[i]; - bool isLastPostOp = (i == (fusedWith.size() - 1)); - - if (auto* fakeQuantizeNode = dynamic_cast(node.get())) { - fakeQuantizeNode->appendAttrPostOps(dnnlpoc, isLastPostOp, outputDataType); - continue; - } - - if (auto* eltwiseNode = dynamic_cast(node.get())) { - eltwiseNode->appendAttrPostOps(dnnlpoc, isLastPostOp, outputDataType); - continue; - } - - OPENVINO_THROW("Fusing of ", - NameFromType(node->getType()), - " operation to ", - NameFromType(this->getType()), - " node is not implemented"); - } - - attr.set_post_ops(ops); -} - bool FullyConnected::created() const { return getType() == Type::FullyConnected; } @@ -783,348 +146,151 @@ const std::vector& FullyConnected::getDefaultImplPriority() { return priorities; } -// WA: creation DnnlMemoryDesc with format == any is prohibited -// so we create dnnl::memory::desc directly -// we need specific method and can't remove createDescriptor from base class because its used into initDescriptor -void FullyConnected::createDescriptorInternal(const dnnl::memory::desc &inputDesc, - const dnnl::memory::desc &outputDesc) { - auto create2Dcandidate = [](const dnnl::memory::desc &desc) { - if (desc.get_dims().size() == 2) // already 2D - return desc; - - auto inDims = desc.get_dims(); - dnnl::memory::dims normalizedInDims = normalizeDims(inDims); - - return dnnl::memory::desc(normalizedInDims, desc.get_data_type(), - DnnlExtensionUtils::GetPlainFormatByRank(normalizedInDims.size())); - }; - - const auto in_candidate = create2Dcandidate(inputDesc); - const auto out_candidate = create2Dcandidate(outputDesc); +// @todo Should be moved to the transformations / optimization stages? +static bool useSparseWeightsDecompression(const NodePtr& weightsInput, + const ov::element::Type inputType, + const float sparseWeiDecompressionRate) { + const auto minSparseRate = sparseWeiDecompressionRate; - const dnnl::memory::data_type indt = inputDesc.get_data_type(); - const dnnl::memory::data_type outdt = outputDesc.get_data_type(); - dnnl::memory::data_type wdt = indt; - dnnl::memory::data_type bdt = outdt; - - if (useWeightsDecompressionImpl) { - // Weights decompression case - wdt = DnnlExtensionUtils::ElementTypeToDataType(getOriginalInputPrecisionAtPort(WEIGHTS_ID)); - } else if (one_of(indt, dnnl::memory::data_type::bf16, dnnl::memory::data_type::f16)) { -#if defined(OPENVINO_ARCH_X86_64) - bdt = dnnl::memory::data_type::f32; -#else - // oneDNN ARM InnerProduct primitive supports only identical in/out data types - bdt = dnnl::memory::data_type::f16; -#endif - } else if (indt == dnnl::memory::data_type::u8 || indt == dnnl::memory::data_type::s8) { - wdt = memory::data_type::s8; - if (withBiases) - bdt = DnnlExtensionUtils::ElementTypeToDataType(getOriginalInputPrecisionAtPort(BIAS_ID)); - } - // We need to explicitly specify the memory descriptor to use sparse weights decompression - dnnl::memory::desc wgh_candidate; - if (useSparseWeights) { - wgh_candidate = wgh_candidate.sparse_desc(DnnlExtensionUtils::convertToDnnlDims(getInputShapeAtPort(WEIGHTS_ID).getStaticDims()), - wdt); - } else { - wgh_candidate = { DnnlExtensionUtils::convertToDnnlDims(getInputShapeAtPort(WEIGHTS_ID).getStaticDims()), - wdt, dnnl::memory::format_tag::any }; + if (minSparseRate == 1.f) { + return false; } - const dnnl::primitive_attr attr; - - if (withBiases) { - dnnl::memory::desc bias_candidate(DnnlExtensionUtils::convertToDnnlDims(expectedBiasDims), bdt, - dnnl::memory::format_tag::any); - auto desc = inner_product_forward::primitive_desc( - getEngine(), - prop_kind::forward_inference, - in_candidate, - wgh_candidate, - bias_candidate, - out_candidate, - attr, - true); + if (!dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx512_core_amx)) + return false; - descs.push_back(desc); - } else { - auto desc = inner_product_forward::primitive_desc( - getEngine(), - prop_kind::forward_inference, - in_candidate, - wgh_candidate, - out_candidate, - attr, - true); + const auto constNode = std::dynamic_pointer_cast(weightsInput); + if (!constNode) + return false; - descs.push_back(desc); - } -} + const auto weiMemory = constNode->getMemoryPtr(); + OPENVINO_ASSERT(weiMemory, "Cannot get const blob"); -void FullyConnected::createDescriptor(const std::vector &inputDesc, - const std::vector &outputDesc) { - MemoryDescPtr inpDesc; - if (inputDesc[0]->isDefined()) { - inpDesc = inputDesc[0]; - } else { - inpDesc = inputDesc[0]->cloneWithNewDims(inDims); + const auto weiDims = weiMemory->getShape().getStaticDims(); + if (weiDims.size() != 2 || weiDims[0] % 64 != 0 || weiDims[1] % 64 != 0) { + return false; } - MemoryDescPtr outDesc; - if (outputDesc[0]->isDefined()) { - outDesc = outputDesc[0]; - } else { - outDesc = outputDesc[0]->cloneWithNewDims(outDims); + const auto weightsType = weiMemory->getPrecision(); + if (!one_of(inputType, u8, i8) || weightsType != i8) { + return false; } - createDescriptorInternal(MemoryDescUtils::convertToDnnlMemoryDesc(inpDesc)->getDnnlDesc(), - MemoryDescUtils::convertToDnnlMemoryDesc(outDesc)->getDnnlDesc()); -} -void FullyConnected::initSupportedPrimitiveDescriptors() { - if (!supportedPrimitiveDescriptors.empty()) - return; - if (useMlas) { - auto dataPrecision = getOriginalInputPrecisionAtPort(0); - if (withBiases) { - addSupportedPrimDesc({{LayoutType::ncsp, dataPrecision}, - {LayoutType::ncsp, dataPrecision}, - {LayoutType::ncsp, dataPrecision}}, - {{LayoutType::ncsp, dataPrecision}}, - impl_desc_type::gemm_mlas); - } else { - addSupportedPrimDesc({{LayoutType::ncsp, dataPrecision}, - {LayoutType::ncsp, dataPrecision}}, - {{LayoutType::ncsp, dataPrecision}}, - impl_desc_type::gemm_mlas); + const auto weightsData = weiMemory->getDataAs(); + auto elementsCount = weiMemory->getDescWithType()->getPaddedElementsCount(); + size_t zerosCount = 0; + for (size_t i = 0; i < elementsCount; i++) { + if (weightsData[i] == 0) { + zerosCount++; } - return; } - // 3D FC requires implicit reshape so strides should be defined - auto supportsUndefStridesAndOffset = [&]() { - return getOutputShapeAtPort(0).getRank() == 2; - }; - - auto addSupportedPrimitiveDescriptor = [&](const dnnl::primitive_desc& prim_desc) { - std::vector inConfs, outConfs; - const int inPlaceOutPort = canBeInPlace() ? 0 : -1; - - for (size_t i = 0; i < descInputNumbers(); i++) { - auto desc = getSrcMemDesc(prim_desc, i); - const auto inputBlockedMask = (supportsUndefStridesAndOffset() && !(i == WEIGHTS_ID && useSparseWeights)) ? - BlockedMemoryDesc::EMPTY_MASK : - BlockedMemoryDesc::FULL_MASK; - - inConfs.emplace_back(desc, inputBlockedMask); - } - const auto outputBlockedMask = supportsUndefStridesAndOffset() ? BlockedMemoryDesc::EMPTY_MASK : BlockedMemoryDesc::FULL_MASK; + DEBUG_LOG("elementsCount = ", + elementsCount, + ", zerosCount = ", + zerosCount, + ", nnzCount = ", + elementsCount - zerosCount); - for (size_t i = 0; i < descOutputNumbers(); i++) { - auto desc = getDstMemDesc(prim_desc, i); + auto sparseRate = static_cast(zerosCount) / static_cast(elementsCount); - outConfs.emplace_back(desc, outputBlockedMask, inPlaceOutPort); - } + DEBUG_LOG("Sparse rate = ", + sparseRate * 100, + "%, min sparse rate = ", + minSparseRate * 100, + "%, use sparse weights = ", + sparseRate >= minSparseRate); - const NodeConfig config(inConfs, outConfs); - const impl_desc_type impl_type = parse_impl_name(prim_desc.impl_info_str()); + return sparseRate >= minSparseRate; +} - supportedPrimitiveDescriptors.emplace_back(config, impl_type); +void FullyConnected::initSupportedPrimitiveDescriptors() { + attrs.withBias = getOriginalInputsNumber() == 3; + attrs.dequantizationScales = getDQScales(); + attrs.sparseWeights = useSparseWeightsDecompression(getParentEdgeAt(WEIGHTS_ID)->getParent(), + getOriginalInputPrecisionAtPort(DATA_ID), + context->getConfig().fcSparseWeiDecompressionRate); + postOps = getPostOps(fusedWith); + + const auto& srcTypes = getOriginalInputPrecisions(); + auto dstTypes = getOriginalOutputPrecisions(); + // @todo graph optimizer should update original output precisions instead + if (!fusedWith.empty()) + dstTypes = fusedWith.back()->getOriginalOutputPrecisions(); + + VecMemoryDescs srcDescs; + const auto& creatorsMap = BlockedDescCreator::getCommonCreators(); + for (size_t i = 0; i < srcTypes.size(); i++) { + const auto srcDesc = creatorsMap.at(LayoutType::ncsp)->createSharedDesc(srcTypes[i], getInputShapeAtPort(i)); + srcDescs.push_back(srcDesc); + } + + VecMemoryDescs dstDescs; + for (size_t i = 0; i < dstTypes.size(); i++) { + const auto dstDesc = creatorsMap.at(LayoutType::ncsp)->createSharedDesc(dstTypes[i], getOutputShapeAtPort(i)); + dstDescs.push_back(dstDesc); + } + + auto createEmptyMemoryDesc = [](const ov::element::Type type) { + return std::make_shared(type, Shape{0}); }; - for (auto& desc : descs) { - auto first_desc = dnnl::primitive_desc(DnnlExtensionUtils::clone_primitive_desc(desc.get())); - const bool first_match = customImplPriorities.empty(); - DnnlExtensionUtils::for_each_implementation(desc, - first_match, - [&](impl_desc_type implType) { - return contains(getImplPriority(), implType); - }, - [&](dnnl::primitive_desc& desc) { - addSupportedPrimitiveDescriptor(desc); - }); - - // fallback. if none of the primitive types is present in the priority list just add first implementation - // @todo this fallback is not necessary if primitive priority list is filled correctly - if (supportedPrimitiveDescriptors.empty()) - addSupportedPrimitiveDescriptor(first_desc); - } -} + MemoryDescArgs descs{ + {ARG_SRC, srcDescs[0]}, + {ARG_WEI, srcDescs[1]}, + {ARG_BIAS, attrs.withBias ? srcDescs[2] : createEmptyMemoryDesc(ov::element::undefined)}, + {ARG_DST, dstDescs[0]}, + }; -std::shared_ptr FullyConnected::getSrcMemDesc(const dnnl::primitive_desc &prim_desc, size_t idx) const { - auto desc = idx > 0 ? prim_desc.weights_desc(idx - 1) : prim_desc.src_desc(idx); + auto executionContext = std::make_shared(context, getImplPriority(), privateWeightCache); + factory = std::make_shared>(attrs, postOps, executionContext, descs); + const auto nodeDescriptors = factory->getProperMemoryDescriptors(descs); - if (getInputShapeAtPort(idx).getRank() != 2 - // report original plain layout for weight since it needs to be reordered dynamically at runtime - || (idx == 1 && !useSparseWeights)) { - return std::make_shared( - DnnlExtensionUtils::DataTypeToElementType(desc.get_data_type()), getInputShapeAtPort(idx)); - } + NodeConfig nodeConfig; + nodeConfig.inConfs.emplace_back(nodeDescriptors.at(ARG_SRC)); + nodeConfig.inConfs.emplace_back(nodeDescriptors.at(ARG_WEI)); + if (attrs.withBias) nodeConfig.inConfs.emplace_back(nodeDescriptors.at(ARG_BIAS)); - if (getInputShapeAtPort(idx).isDynamic()) { - return DnnlExtensionUtils::makeUndefinedDesc(desc, getInputShapeAtPort(idx)); - } + const int inPlace = canBeInPlace() ? 0 : -1; + nodeConfig.outConfs.emplace_back(nodeDescriptors.at(ARG_DST), BlockedMemoryDesc::FULL_MASK, inPlace); - return DnnlExtensionUtils::makeDescriptor(desc); + supportedPrimitiveDescriptors.emplace_back(nodeConfig, impl_desc_type::undef); } -std::shared_ptr FullyConnected::getDstMemDesc(const dnnl::primitive_desc &prim_desc, size_t idx) const { - auto desc = prim_desc.dst_desc(idx); - - if (getOutputShapeAtPort(idx).getRank() != 2) { - return std::make_shared( - DnnlExtensionUtils::DataTypeToElementType(desc.get_data_type()), getOutputShapeAtPort(idx)); - } - - if (getOutputShapeAtPort(idx).isDynamic()) { - return DnnlExtensionUtils::makeUndefinedDesc(desc, getOutputShapeAtPort(idx)); - } +void FullyConnected::createPrimitive() { + memory[ARG_SRC] = getSrcMemoryAtPort(DATA_ID); + memory[ARG_WEI] = getSrcMemoryAtPort(WEIGHTS_ID); + memory[ARG_BIAS] = attrs.withBias ? getSrcMemoryAtPort(BIAS_ID) : emptyMemory; + memory[ARG_DST] = getDstMemoryAtPort(0); + // @todo should we preconfigure only for dynamic shapes? + // Since for static shapes primitive is created in scope of compile_model() anyway + factory->preconfigure(memory); - return DnnlExtensionUtils::makeDescriptor(desc); + Node::createPrimitive(); } ov::element::Type FullyConnected::getRuntimePrecision() const { - std::vector inputPrecisions; + std::vector srcTypes; // Don't take bias precision into account - size_t inputsNumLimit = 2; - for (size_t i = 0; i < std::min(getParentEdges().size(), inputsNumLimit); i++) { + const size_t inputsNumLimit = 2; + const auto inputSize = std::min(getParentEdges().size(), inputsNumLimit); + + for (size_t i = 0; i < inputSize; i++) { auto parentEdge = getParentEdgeAt(i); if (parentEdge && parentEdge->getStatus() == Edge::Status::Validated) { - inputPrecisions.emplace_back(DnnlExtensionUtils::DataTypeToElementType((parentEdge->getMemoryPtr()->getDataType()))); + srcTypes.emplace_back(parentEdge->getMemoryPtr()->getPrecision()); } } - return getMaxPrecision(inputPrecisions); -} - -void FullyConnected::initOptimalPrimitiveDescriptor() { - Node::initOptimalPrimitiveDescriptor(); - auto selectedPD = getSelectedPrimitiveDescriptor(); - implementationTypeIP = selectedPD->getImplementationType(); - // if convolution selected the reorder for ip is useless. Will do the reoder for ip in prepareParams - auto constParent = getParentEdgeAt(1)->getParent(); - auto selectedParentPD = constParent->getSelectedPrimitiveDescriptor(); - auto config = selectedPD->getConfig(); - weightDescIP = config.inConfs[1].getMemDesc(); - config.inConfs[1].setMemDesc(selectedParentPD->getConfig().outConfs[0].getMemDesc()); - selectedPD->setConfig(config); -} - -bool FullyConnected::canBeExecutedInConv1x1() const { - bool retVal = false; - const auto inRank = getInputShapeAtPort(DATA_ID).getRank(); - const auto weightRank = getInputShapeAtPort(WEIGHTS_ID).getRank(); - if (useWeightsDecompressionImpl) { - return false; - } - // disable rank=4: - // if layout is nhwc: - // A matrix: N * IC * H * W --> N * (IC*H*W), the M, N', K of matrix multiply will be: - // M = 1, K = (IC*H*W), when M = 1 it should not be efficient since acts as a vector multiply - // if layout is nchw/nChw16c: brg1x1 not support. Although jit supports, it should have similar - // problems with the above. - if (dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx512_core) && - getOriginalInputPrecisionAtPort(DATA_ID) == ov::element::f32 && - one_of(inRank, 2u, 3u) && weightRank == 2) { - auto dstMemPtr = getChildEdgesAtPort(0)[0]->getMemoryPtr(); - DnnlMemoryDescCPtr outDesc = dstMemPtr->getDescWithType(); - // brg convolution does not support stride - dnnl::impl::memory_desc_wrapper wrapped(outDesc->getDnnlDesc().get()); - if (wrapped.offset0() == 0) - retVal = true; - } - - if (retVal) { - auto srcMemPtr = getParentEdgesAtPort(0)[0]->getMemoryPtr(); - const auto& srcDims = srcMemPtr->getStaticDims(); - auto weightMemPtr = getParentEdgesAtPort(1)[0]->getMemoryPtr(); - const auto& weightDims = weightMemPtr->getStaticDims(); - // for original inner product semantics: - // when input is 2D tensor - // M in oneDNN will map to widthInConv - // when input is 3D tensor - // M in oneDNN will map to widthInConv*minibatch - // currently nwc mapping in brg: - // when input is 2D tensor - // widthInConv will map to 'w', 'n' will be 1 - // when input is 3D tensor - // widthInConv will map to 'w', 'n' will be minibatch - Dim widthInConv, N, K; - widthInConv = srcDims[inRank - 2]; - K = srcDims[inRank - 1]; - N = weightDims[0]; - // Disable Conv1x1 when weight size >= 16M to avoid different weight layout when having different input activation shapes. - // As a consuquence, peak memory consumption in LLM can be decreased. - if (weightMemPtr->getSize() >= (16 * 1 << 20)) - retVal = false; - if (!(widthInConv >= 2 && widthInConv <= 3136 && - K >= 96 && K <= 4096 && - N >= 96 && N <= K * 4)) - retVal = false; - } - - return retVal; -} - -bool FullyConnected::useSparseWeightsDecompression() { - // minSparseRate == 1 means that sparse feature is switched off - if (minSparseRate == 1.f) { - return false; - } - - if (!impl::cpu::x64::mayiuse(impl::cpu::x64::avx512_core_amx)) - return false; - - auto weiDims = getInputShapeAtPort(WEIGHTS_ID).getStaticDims(); - if (weiDims.size() != 2 || weiDims[0] % 64 != 0 || weiDims[1] % 64 != 0) { - return false; - } - - auto inputPrecision = getOriginalInputPrecisionAtPort(DATA_ID); - auto weightsPrecision = getOriginalInputPrecisionAtPort(WEIGHTS_ID); - if (!one_of(inputPrecision , ov::element::u8, ov::element::i8) || weightsPrecision != ov::element::i8) { - return false; - } - - // calculate sparse rate - const auto constNode = std::dynamic_pointer_cast(getParentEdgeAt(WEIGHTS_ID)->getParent()); - if (!constNode) { - return false; - } - auto blb = constNode->getMemoryPtr(); - if (blb == nullptr) - OPENVINO_THROW("Cannot get const blob for node ", getName(), "."); - - auto weightsData = reinterpret_cast(blb->getData()); - auto elementsCount = blb->getDescWithType()->getPaddedElementsCount(); - size_t zerosCounts = 0; - for (size_t i = 0; i < elementsCount; i++) { - if (weightsData[i] == 0) { - zerosCounts++; - } - } - - DEBUG_LOG(getName(), ", elementsCount = ", elementsCount, ", zerosCounts = ", - zerosCounts, ", nnzCount = ", elementsCount - zerosCounts); - - weiSparseRate = static_cast(zerosCounts) / static_cast(elementsCount); - - DEBUG_LOG(getName(), " | sparse rate = ", weiSparseRate * 100, "%, min sparse rate = ", - minSparseRate * 100, "%, use sparse weights = ", weiSparseRate >= minSparseRate); - - if (weiSparseRate < minSparseRate) { - return false; - } - - return true; + return getMaxPrecision(srcTypes); } void FullyConnected::fuseDecompressionMultiply(const MemoryCPtr& memory) { - fuseDecompressionConstant(memory, decompressionMultiplyPtr); + fuseDecompressionConstant(memory, attrs.decompressionMultiplyPtr); } void FullyConnected::fuseDecompressionSubtract(const MemoryCPtr& memory) { - fuseDecompressionConstant(memory, decompressionSubtractPtr); + fuseDecompressionConstant(memory, attrs.decompressionSubtractPtr); } void FullyConnected::fuseDecompressionConstant(const MemoryCPtr& memory, MemoryCPtr& decompressionValuesPtr) { @@ -1143,21 +309,6 @@ void FullyConnected::fuseDecompressionConstant(const MemoryCPtr& memory, MemoryC } } -DnnlMemoryDescPtr FullyConnected::makeTransposedWeightDescriptor(DnnlMemoryDescPtr desc) { - if (!getParentEdgeAt(1)->getParent()->isConstant()) - OPENVINO_THROW("Weight input is not const for node ", getName(), "."); - auto edgeMem = getParentEdgeAt(1)->getMemoryPtr(); - if (!edgeMem) - OPENVINO_THROW("Cannot get const weights edgeMem for node ", getName(), "."); - - auto constDnnlMemOutDesc = edgeMem->getDescWithType(); - auto weightSrcDesc = constDnnlMemOutDesc->getDnnlDesc(); - weightSrcDesc = {weightSrcDesc.get_dims(), weightSrcDesc.get_data_type(), memory::format_tag::ba}; - weightSrcDesc = weightSrcDesc.reshape(desc->getDnnlDesc().get_dims()); - - return DnnlExtensionUtils::makeDescriptor(weightSrcDesc); -} - -} // namespace node -} // namespace intel_cpu -} // namespace ov +} // namespace node +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/fullyconnected.h b/src/plugins/intel_cpu/src/nodes/fullyconnected.h index c1545ba3be240b..f0ee39ee183905 100644 --- a/src/plugins/intel_cpu/src/nodes/fullyconnected.h +++ b/src/plugins/intel_cpu/src/nodes/fullyconnected.h @@ -4,9 +4,18 @@ #pragma once -#include "common/dnnl_executor.h" -#include "node.h" -#include "oneapi/dnnl/dnnl.hpp" +#include + +#include +#include +#include +#include + +#include "cpu_memory.h" +#include "nodes/executors/executor_factory.hpp" +#include "nodes/executors/memory_arguments.hpp" +#include "nodes/executors/fullyconnected_config.hpp" +#include "post_ops.hpp" namespace ov { namespace intel_cpu { @@ -16,8 +25,7 @@ class FullyConnected : public Node { public: FullyConnected(const std::shared_ptr& op, const GraphContext::CPtr context); - std::vector getAvailableFormatsForDims(const Shape &dims) const override; - void getSupportedDescriptors() override; + void getSupportedDescriptors() override{}; void execute(dnnl::stream strm) override; bool created() const override; @@ -30,18 +38,13 @@ class FullyConnected : public Node { } const std::vector& getDefaultImplPriority() override; - void createDescriptor(const std::vector& inputDesc, - const std::vector& outputDesc) override; size_t descInputNumbers() override { return static_cast(getOriginalInputsNumber()); } void initSupportedPrimitiveDescriptors() override; - void initOptimalPrimitiveDescriptor() override; void createPrimitive() override; - std::shared_ptr getSrcMemDesc(const dnnl::primitive_desc &prim_desc, size_t idx) const override; - std::shared_ptr getDstMemDesc(const dnnl::primitive_desc &prim_desc, size_t idx) const override; ov::element::Type getRuntimePrecision() const override; @@ -53,75 +56,29 @@ class FullyConnected : public Node { void executeDynamicImpl(dnnl::stream strm) override; bool canBeExecutedInInt8() const override; void keepWeightsNonTransposed(bool weightsNonTransposed) { - this->weightsNonTransposed = weightsNonTransposed; + this->attrs.weightsNonTransposed = weightsNonTransposed; } void fuseDecompressionMultiply(const MemoryCPtr& memory); void fuseDecompressionSubtract(const MemoryCPtr& memory); private: - void createDescriptorInternal(const dnnl::memory::desc &inputDesc, - const dnnl::memory::desc &outputDesc); - - VectorDims makeDummyInputDims() const; - VectorDims makeDummyOutputDims(const VectorDims& inDims) const; - - VectorDims inDims; - VectorDims outDims; - - void setPostOps(dnnl::primitive_attr &attr, const VectorDims &dims); - - bool withBiases = false; - - std::string errorPrefix; static const size_t DATA_ID = 0; static const size_t WEIGHTS_ID = 1; static const size_t BIAS_ID = 2; - dnnl::memory::data_type outputDataType = dnnl::memory::data_type::undef; - - using executorPtr = std::shared_ptr; - executorPtr execPtr = nullptr; - bool useConv1x1 = false; - impl_desc_type implementationTypeIP = impl_desc_type::unknown; - MemoryDescPtr weightDescIP; - dnnl::primitive_attr attr; - - static dnnl::convolution_forward::primitive_desc - createDescriptorInternalForConv(DnnlMemoryDescCPtr inputDescPtr, - DnnlMemoryDescCPtr weightDescPtr, - DnnlMemoryDescCPtr biasDescPtr, - DnnlMemoryDescCPtr outputDescPtr, - const dnnl::primitive_attr& attr, - const dnnl::engine& engine); - - bool canBeExecutedInConv1x1() const; + + ExecutorPtr createExecutor(); void fuseDecompressionConstant(const MemoryCPtr& memory, MemoryCPtr& decompressionValuesPtr); - // sparse weights - bool useSparseWeights = false; - float minSparseRate = 1.f; - float weiSparseRate = 0.f; - bool useSparseWeightsDecompression(); - VectorDims expectedBiasDims {}; - bool useMlas = false; -#ifdef OV_CPU_WITH_MLAS - int64_t M, N, K; - MemoryPtr mlasPackedPtr = nullptr; - void executeMLAS(); - void prepackMLASWeight(); -#endif -#if defined(OV_CPU_WITH_ACL) - void prepareWeightsUsingDummyShape(); -#endif - bool useWeightsDecompressionImpl = false; - MemoryCPtr decompressionSubtractPtr = nullptr; - MemoryCPtr decompressionMultiplyPtr = nullptr; - - // FC with transposed weights - bool weightsNonTransposed = false; - DnnlMemoryDescPtr makeTransposedWeightDescriptor(DnnlMemoryDescPtr desc); + FCAttrs attrs; + PostOps postOps; + MemoryArgs memory; + MemoryPtr emptyMemory; + ExecutorFactoryPtr factory; + ExecutorPtr executor = nullptr; + std::string errorPrefix; }; -} // namespace node -} // namespace intel_cpu -} // namespace ov +} // namespace node +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/gather.cpp b/src/plugins/intel_cpu/src/nodes/gather.cpp index 102dbf509d00ea..a800dbafdcc694 100644 --- a/src/plugins/intel_cpu/src/nodes/gather.cpp +++ b/src/plugins/intel_cpu/src/nodes/gather.cpp @@ -2,17 +2,27 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "gather.h" + +#include +#include + #include #include #include "openvino/core/parallel.hpp" -#include "gather.h" -#include "openvino/opsets/opset1.hpp" +#include #include "common/cpu_memcpy.h" +#include "common/cpu_convert.h" #include "utils/general_utils.h" #include "kernels/x64/gather_uni_kernel.hpp" #include #include "shape_inference/custom/gather.hpp" +#include "utils/ngraph_utils.hpp" +#include "snippets/utils.hpp" +#include "memory_desc/dnnl_blocked_memory_desc.h" +#include "openvino/core/type/element_type.hpp" +#include "openvino/core/except.hpp" using namespace dnnl::impl::cpu; @@ -130,10 +140,19 @@ void Gather::initSupportedPrimitiveDescriptors() { // Implementation desc type will be redefined in the fn prepareParams if a kernel will be created. ov::element::Type dataPrecision = getOriginalInputPrecisionAtPort(GATHER_DATA); + + canOptimizeCompressedEmbedding = false; + if ((decompressionSubtractPtr != nullptr) && (decompressionMultiplyPtr != nullptr)) { + if (dataPrecision != ov::element::u8 || !isAxisInputConst || inputShapes[GATHER_DATA].getRank() != 2u) { + OPENVINO_THROW("Compression gather doesn't support demanded precisions, axis, data rank"); + } + canOptimizeCompressedEmbedding = true; + } + addSupportedPrimDesc({{LayoutType::ncsp, dataPrecision}, {LayoutType::ncsp, ov::element::i32}, {LayoutType::ncsp, ov::element::i32, isAxisInputConst}}, - {{LayoutType::ncsp, dataPrecision}}, + {{LayoutType::ncsp, canOptimizeCompressedEmbedding ? ov::element::f32 : dataPrecision}}, ref_any); // Let's check for the special inPlace memory use case @@ -254,20 +273,24 @@ bool Gather::needPrepareParams() const { } bool result = inputShapesModified(); if (!isAxisInputConst) - result = result || axis != (reinterpret_cast(getParentEdgeAt(GATHER_AXIS)->getMemoryPtr()->getData()))[0]; + result = result || axis != (getSrcDataAtPortAs(GATHER_AXIS))[0]; return result; } void Gather::prepareParams() { - auto dataMemPtr = getParentEdgeAt(GATHER_DATA)->getMemoryPtr(); + auto dataMemPtr = getSrcMemoryAtPort(GATHER_DATA); if (!dataMemPtr || !dataMemPtr->isAllocated()) THROW_ERROR(" has not allocated input data memory."); - auto idxMemPtr = getParentEdgeAt(GATHER_INDICES)->getMemoryPtr(); + auto idxMemPtr = getSrcMemoryAtPort(GATHER_INDICES); if (!idxMemPtr || !idxMemPtr->isAllocated()) THROW_ERROR(" has not allocated input indices memory."); if (getSelectedPrimitiveDescriptor() == nullptr) THROW_ERROR(" has unidentified preferable primitive descriptor."); + if (canOptimizeCompressedEmbedding) { + return; + } + // short 1D vector fast execution impl (typical in shape infer subgraph) canOptimize1DCase = false; if (dataSrcRank <= 1 && dataMemPtr->getDesc().getPrecision() == ov::element::i32) { @@ -281,7 +304,7 @@ void Gather::prepareParams() { } if (!isAxisInputConst) { - axis = (reinterpret_cast(getParentEdgeAt(GATHER_AXIS)->getMemoryPtr()->getData()))[0]; + axis = (getSrcDataAtPortAs(GATHER_AXIS))[0]; if (axis < 0) axis += dataSrcRank; if (axis < 0 || axis >= dataSrcRank || batchDims > axis) @@ -330,15 +353,21 @@ void Gather::execute(dnnl::stream strm) { return; } + if (canOptimizeCompressedEmbedding) { + execCompressedCase(); + return; + } + if (canOptimize1DCase) { exec1DCase(); return; } + #if defined(OPENVINO_ARCH_X86_64) if (jitKernel && jitKernel->isSupportedConfiguration(afterAxisSize)) { - const void* srcIndices = getParentEdgeAt(GATHER_INDICES)->getMemoryPtr()->getData(); - const void* srcData = getParentEdgeAt(GATHER_DATA)->getMemoryPtr()->getData(); - uint8_t* dstData = reinterpret_cast(getChildEdgeAt(0)->getMemoryPtr()->getData()); + const void* srcIndices = getSrcDataAtPort(GATHER_INDICES); + const void* srcData = getSrcDataAtPort(GATHER_DATA); + uint8_t* dstData = getDstDataAtPortAs(0); const uint64_t dataElPerVec = jitKernel->getDataElPerVec(); @@ -397,11 +426,15 @@ void Gather::executeDynamicImpl(dnnl::stream strm) { exec1DCase(); return; } + if (canOptimizeCompressedEmbedding) { + execCompressedCase(); + return; + } #if defined(OPENVINO_ARCH_X86_64) if (jitKernel && jitKernel->isSupportedConfiguration(afterAxisSize)) { - const void* srcIndices = getParentEdgeAt(GATHER_INDICES)->getMemoryPtr()->getData(); - const void* srcData = getParentEdgeAt(GATHER_DATA)->getMemoryPtr()->getData(); - uint8_t* dstData = reinterpret_cast(getChildEdgeAt(0)->getMemoryPtr()->getData()); + const void* srcIndices = getSrcDataAtPort(GATHER_INDICES); + const void* srcData = getSrcDataAtPort(GATHER_DATA); + uint8_t* dstData = getDstDataAtPortAs(0); const uint64_t dataElPerVec = jitKernel->getDataElPerVec(); @@ -526,9 +559,9 @@ void Gather::initShortParams(threadExecParams& p, const uint64_t start) { } void Gather::execReference() { - const int32_t* srcIndices = reinterpret_cast(getParentEdgeAt(GATHER_INDICES)->getMemoryPtr()->getData()); - const uint8_t* srcData = reinterpret_cast(getParentEdgeAt(GATHER_DATA)->getMemoryPtr()->getData()); - uint8_t* dstData = reinterpret_cast(getChildEdgeAt(0)->getMemoryPtr()->getData()); + const int32_t* srcIndices = getSrcDataAtPortAs(GATHER_INDICES); + const uint8_t* srcData = getSrcDataAtPortAs(GATHER_DATA); + uint8_t* dstData = getDstDataAtPortAs(0); const size_t dstAfterBatchSize = betweenBatchAndAxisSize * specIdxAndAfterAxSizeB; parallel_for2d(beforeBatchSize, specIndicesSize, [&](const size_t b, const size_t j) { @@ -580,6 +613,46 @@ void Gather::exec1DCase() { } } +void Gather::execCompressedCase() { + DEBUG_LOG(getName(), " execCompressedCase"); + auto srcMemPtr = getParentEdgeAt(GATHER_DATA)->getMemoryPtr(); + auto idxMemPtr = getParentEdgeAt(GATHER_INDICES)->getMemoryPtr(); + + const auto* psrc = srcMemPtr->getDataAs(); + const auto* pidx = idxMemPtr->getDataAs(); + + const auto* zp = decompressionSubtractPtr->getDataAs(); + const auto* scale = decompressionMultiplyPtr->getDataAs(); + + auto* pdst = getDstDataAtPortAs(0); + + const auto& idxDims = idxMemPtr->getStaticDims(); + const auto batch = idxDims[0]; + const auto seqLen = idxDims[1]; + + auto axisDim = srcMemPtr->getStaticDims()[0]; + auto feaDim = srcMemPtr->getStaticDims()[1]; + + parallel_for2d(batch, seqLen, [&](size_t b, size_t s) { + auto dstIdx = b * seqLen + s; + auto ii = pidx[dstIdx]; + if (ii < 0) { + if (reverseIndexing) + ii += axisDim; + else + ii = axisDim; + } + + auto* src = psrc + ii * feaDim; + auto* dst = pdst + dstIdx * feaDim; + auto& deq_zp = zp[ii]; + auto& deq_scale = scale[ii]; + for (size_t k = 0; k < feaDim; k++) { + dst[k] = (static_cast(src[k]) - deq_zp) * deq_scale; + } + }); +} + bool Gather::created() const { return getType() == Type::Gather; } @@ -606,7 +679,7 @@ void Gather::resolveInPlaceEdges(Edge::LOOK look) { "Gather node: ", getName(), " can not use inPlace memory with splitting on dynamic dimention"); - auto baseMemMngr = getParentEdgesAtPort(inplaceInpIndx).front()->getMemory().getMemoryMngr(); + auto baseMemMngr = getParentEdgeAt(inplaceInpIndx)->getMemory().getMemoryMngr(); const auto index = constIndices.front(); const ptrdiff_t offset = index < 0 ? baseDim + index : index; const auto& childEdges = getChildEdgesAtPort(outputPort); @@ -624,6 +697,30 @@ void Gather::resolveInPlaceEdges(Edge::LOOK look) { } } +void Gather::fuseDecompressionMultiply(const MemoryCPtr& memory) { + fuseDecompressionConstant(memory, decompressionMultiplyPtr); +} + +void Gather::fuseDecompressionSubtract(const MemoryCPtr& memory) { + fuseDecompressionConstant(memory, decompressionSubtractPtr); +} + +void Gather::fuseDecompressionConstant(const MemoryCPtr& memory, MemoryCPtr& decompressionValuesPtr) { + const auto decompression_prc = ov::element::f32; + if (memory->getDesc().getPrecision() == decompression_prc) { + decompressionValuesPtr = memory; + } else { + DnnlBlockedMemoryDesc memoryDesc(decompression_prc, memory->getShape()); + decompressionValuesPtr = std::make_shared(getEngine(), memoryDesc, nullptr, false); + const auto elementsCount = memory->getDescWithType()->getPaddedElementsCount(); + cpu_convert(memory->getData(), + decompressionValuesPtr->getData(), + DnnlExtensionUtils::DataTypeToElementType(memory->getDataType()), + ov::element::f32, + elementsCount); + } +} + } // namespace node } // namespace intel_cpu } // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/gather.h b/src/plugins/intel_cpu/src/nodes/gather.h index 87f4f3a09ce5be..5e6b6c999585ff 100644 --- a/src/plugins/intel_cpu/src/nodes/gather.h +++ b/src/plugins/intel_cpu/src/nodes/gather.h @@ -27,6 +27,9 @@ class Gather : public Node { bool isExecutable() const override; void resolveInPlaceEdges(Edge::LOOK look) override; + void fuseDecompressionMultiply(const MemoryCPtr& memory); + void fuseDecompressionSubtract(const MemoryCPtr& memory); + static bool isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept; struct threadExecParams { @@ -55,10 +58,14 @@ class Gather : public Node { private: void initShortParams(threadExecParams& p, uint64_t start); void execReference(); + void fuseDecompressionConstant(const MemoryCPtr& memory, MemoryCPtr& decompressionValuesPtr); bool canOptimize1DCase = false; void exec1DCase(); + bool canOptimizeCompressedEmbedding = false; + void execCompressedCase(); + bool isDataShapeStat = false; bool isIdxShapeStat = false; bool isAxisInputConst = false; @@ -91,6 +98,9 @@ class Gather : public Node { static constexpr size_t GATHER_AXIS = 2; std::shared_ptr jitKernel; + + MemoryCPtr decompressionSubtractPtr = nullptr; + MemoryCPtr decompressionMultiplyPtr = nullptr; }; } // namespace node diff --git a/src/plugins/intel_cpu/src/nodes/gather_elements.cpp b/src/plugins/intel_cpu/src/nodes/gather_elements.cpp index aaa3b14f90d01a..4fda1cc49c9b4a 100644 --- a/src/plugins/intel_cpu/src/nodes/gather_elements.cpp +++ b/src/plugins/intel_cpu/src/nodes/gather_elements.cpp @@ -8,7 +8,6 @@ #include "openvino/core/parallel.hpp" #include "gather_elements.h" #include "openvino/opsets/opset1.hpp" -#include #include "utils/general_utils.h" #include "common/cpu_memcpy.h" @@ -56,8 +55,8 @@ GatherElements::GatherElements(const std::shared_ptr& op, const GraphC } void GatherElements::prepareParams() { - const auto& dataDims = getParentEdgesAtPort(dataIndex_)[0]->getMemory().getStaticDims(); - const auto& dstDims = getChildEdgesAtPort(0)[0]->getMemory().getStaticDims(); + const auto& dataDims = getParentEdgeAt(dataIndex_)->getMemory().getStaticDims(); + const auto& dstDims = getChildEdgeAt(0)->getMemory().getStaticDims(); strideAxDst_ = 1; for (size_t i = dstDims.size() - 1; i > axis_; i--) strideAxDst_ *= dstDims[i]; @@ -101,11 +100,11 @@ void GatherElements::executeDynamicImpl(dnnl::stream strm) { template void GatherElements::directExecution() { - const auto *srcData = reinterpret_cast(getParentEdgeAt(dataIndex_)->getMemoryPtr()->getData()); - const auto *indices = reinterpret_cast(getParentEdgeAt(indicesIndex_)->getMemoryPtr()->getData()); - auto *dstData = reinterpret_cast(getChildEdgeAt(0)->getMemoryPtr()->getData()); + const auto *srcData = getSrcDataAtPortAs(dataIndex_); + const auto *indices = getSrcDataAtPortAs(indicesIndex_); + auto *dstData = getDstDataAtPortAs(0); - const int outSize = getChildEdgesAtPort(0)[0]->getMemory().getShape().getElementsCount(); + const int outSize = getChildEdgeAt(0)->getMemory().getShape().getElementsCount(); auto threadBody = [&](const int ithr, const int nthr) { int start(0lu), end(0lu); splitter(outSize, nthr, ithr, start, end); diff --git a/src/plugins/intel_cpu/src/nodes/gather_nd.cpp b/src/plugins/intel_cpu/src/nodes/gather_nd.cpp index b16d5bd5a65511..b6ed0e0e9bb5ed 100644 --- a/src/plugins/intel_cpu/src/nodes/gather_nd.cpp +++ b/src/plugins/intel_cpu/src/nodes/gather_nd.cpp @@ -9,7 +9,6 @@ #include "openvino/core/parallel.hpp" #include "gather_nd.h" #include -#include #include "utils/general_utils.h" #include "common/cpu_memcpy.h" @@ -82,9 +81,9 @@ void GatherND::initSupportedPrimitiveDescriptors() { } void GatherND::prepareParams() { - auto srcMemPtr = getParentEdgeAt(GATHERND_DATA)->getMemoryPtr(); - auto idxMemPtr = getParentEdgeAt(GATHERND_INDEXES)->getMemoryPtr(); - auto dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); + auto srcMemPtr = getSrcMemoryAtPort(GATHERND_DATA); + auto idxMemPtr = getSrcMemoryAtPort(GATHERND_INDEXES); + auto dstMemPtr = getDstMemoryAtPort(0); if (!srcMemPtr || !srcMemPtr->isAllocated()) THROW_ERROR(" has not allocated input memory of 'data'."); if (!idxMemPtr || !idxMemPtr->isAllocated()) @@ -129,9 +128,9 @@ void GatherND::execute(dnnl::stream strm) { if (!execPtr) THROW_ERROR("has not compiled executor."); - execPtr->exec(getParentEdgeAt(GATHERND_DATA)->getMemoryPtr(), - getParentEdgeAt(GATHERND_INDEXES)->getMemoryPtr(), - getChildEdgeAt(0)->getMemoryPtr()); + execPtr->exec(getSrcMemoryAtPort(GATHERND_DATA), + getSrcMemoryAtPort(GATHERND_INDEXES), + getDstMemoryAtPort(0)); } void GatherND::GatherNDExecutor::exec(const MemoryPtr& srcMemPtr, const MemoryPtr& idxMemPtr, const MemoryPtr& dstMemPtr) { @@ -148,9 +147,9 @@ void GatherND::GatherNDExecutor::exec(const MemoryPtr& srcMemPtr, const MemoryPt } void GatherND::GatherNDExecutor::gatherBlocks(const MemoryPtr& srcMemPtr, const MemoryPtr& idxMemPtr, const MemoryPtr& dstMemPtr) { - const uint8_t* srcData = reinterpret_cast(srcMemPtr->getData()); - const int32_t* indices = reinterpret_cast(idxMemPtr->getData()); - uint8_t* dstData = reinterpret_cast(dstMemPtr->getData()); + const uint8_t* srcData = srcMemPtr->getDataAs(); + const int32_t* indices = idxMemPtr->getDataAs(); + uint8_t* dstData = dstMemPtr->getDataAs(); parallel_nt(0, [&](const int ithr, const int nthr) { size_t start(0lu), end(0lu); @@ -185,9 +184,9 @@ void GatherND::GatherNDExecutor::gatherBlocks(const MemoryPtr& srcMemPtr, const template void GatherND::GatherNDExecutor::gatherElementwise(const MemoryPtr& srcMemPtr, const MemoryPtr& idxMemPtr, const MemoryPtr& dstMemPtr) { - const dataType* srcData = reinterpret_cast(srcMemPtr->getData()); - const int32_t* indices = reinterpret_cast(idxMemPtr->getData()); - dataType* dstData = reinterpret_cast(dstMemPtr->getData()); + const dataType* srcData = srcMemPtr->getDataAs(); + const int32_t* indices = idxMemPtr->getDataAs(); + dataType* dstData = dstMemPtr->getDataAs(); parallel_nt(0, [&](const int ithr, const int nthr) { size_t start(0lu), end(0lu); diff --git a/src/plugins/intel_cpu/src/nodes/gather_tree.cpp b/src/plugins/intel_cpu/src/nodes/gather_tree.cpp index 1f6f0fa7efd0e0..d5ae7f9f9ce1d4 100644 --- a/src/plugins/intel_cpu/src/nodes/gather_tree.cpp +++ b/src/plugins/intel_cpu/src/nodes/gather_tree.cpp @@ -79,24 +79,24 @@ void GatherTree::execute(dnnl::stream strm) { OPENVINO_THROW(errorPrefix, " has not compiled executor."); if (precision == ov::element::f32) - execPtr->exec(getParentEdgeAt(GATHER_TREE_STEP_IDX)->getMemoryPtr(), - getParentEdgeAt(GATHER_TREE_PARENT_IDX)->getMemoryPtr(), - getParentEdgeAt(GATHER_TREE_MAX_SEQ_LEN)->getMemoryPtr(), - getParentEdgeAt(GATHER_TREE_END_TOKEN)->getMemoryPtr(), - getChildEdgeAt(0)->getMemoryPtr()); + execPtr->exec(getSrcMemoryAtPort(GATHER_TREE_STEP_IDX), + getSrcMemoryAtPort(GATHER_TREE_PARENT_IDX), + getSrcMemoryAtPort(GATHER_TREE_MAX_SEQ_LEN), + getSrcMemoryAtPort(GATHER_TREE_END_TOKEN), + getDstMemoryAtPort(0)); else - execPtr->exec(getParentEdgeAt(GATHER_TREE_STEP_IDX)->getMemoryPtr(), - getParentEdgeAt(GATHER_TREE_PARENT_IDX)->getMemoryPtr(), - getParentEdgeAt(GATHER_TREE_MAX_SEQ_LEN)->getMemoryPtr(), - getParentEdgeAt(GATHER_TREE_END_TOKEN)->getMemoryPtr(), - getChildEdgeAt(0)->getMemoryPtr()); + execPtr->exec(getSrcMemoryAtPort(GATHER_TREE_STEP_IDX), + getSrcMemoryAtPort(GATHER_TREE_PARENT_IDX), + getSrcMemoryAtPort(GATHER_TREE_MAX_SEQ_LEN), + getSrcMemoryAtPort(GATHER_TREE_END_TOKEN), + getDstMemoryAtPort(0)); } void GatherTree::prepareParams() { - const auto& stepIdxMemPtr = getParentEdgeAt(GATHER_TREE_STEP_IDX)->getMemoryPtr(); - const auto& parentIdxMemPtr = getParentEdgeAt(GATHER_TREE_PARENT_IDX)->getMemoryPtr(); - const auto& maxSeqLenMemPtr = getParentEdgeAt(GATHER_TREE_MAX_SEQ_LEN)->getMemoryPtr(); - const auto& dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); + const auto& stepIdxMemPtr = getSrcMemoryAtPort(GATHER_TREE_STEP_IDX); + const auto& parentIdxMemPtr = getSrcMemoryAtPort(GATHER_TREE_PARENT_IDX); + const auto& maxSeqLenMemPtr = getSrcMemoryAtPort(GATHER_TREE_MAX_SEQ_LEN); + const auto& dstMemPtr = getDstMemoryAtPort(0); if (!stepIdxMemPtr || !stepIdxMemPtr->isAllocated()) OPENVINO_THROW(errorPrefix, " has not allocated input memory of 'step_ids'."); @@ -139,11 +139,11 @@ GatherTree::GatherTreeExecutor::GatherTreeExecutor(const VectorDims& stepIdxDims template void GatherTree::GatherTreeExecutor::exec(const MemoryPtr& stepIdxMemPtr, const MemoryPtr& parentIdxMemPtr, const MemoryPtr& maxSeqLenMemPtr, const MemoryPtr& endTokenMemPtr, const MemoryPtr& dstMemPtr) { - const auto *stepIdx = reinterpret_cast(stepIdxMemPtr->getData()); - const auto *parentIdx = reinterpret_cast(parentIdxMemPtr->getData()); - const auto *maxSeqLen = reinterpret_cast(maxSeqLenMemPtr->getData()); - const auto endToken = (reinterpret_cast(endTokenMemPtr->getData()))[0]; - auto *finalIdx = reinterpret_cast(dstMemPtr->getData()); + const auto *stepIdx = stepIdxMemPtr->getDataAs(); + const auto *parentIdx = parentIdxMemPtr->getDataAs(); + const auto *maxSeqLen = maxSeqLenMemPtr->getDataAs(); + const auto endToken = (endTokenMemPtr->getDataAs())[0]; + auto *finalIdx = dstMemPtr->getDataAs(); bool incorrectResult = false; parallel_for2d(batchSize, beamWidth, [&](size_t batch, size_t beam) { diff --git a/src/plugins/intel_cpu/src/nodes/generate_proposals.cpp b/src/plugins/intel_cpu/src/nodes/generate_proposals.cpp index 26608aac5227fe..7af995ab50580b 100644 --- a/src/plugins/intel_cpu/src/nodes/generate_proposals.cpp +++ b/src/plugins/intel_cpu/src/nodes/generate_proposals.cpp @@ -360,10 +360,10 @@ void GenerateProposals::execute(dnnl::stream strm) { } // Prepare memory - const float *p_deltas_item = reinterpret_cast(getParentEdgeAt(INPUT_DELTAS)->getMemoryPtr()->getData()); - const float *p_scores_item = reinterpret_cast(getParentEdgeAt(INPUT_SCORES)->getMemoryPtr()->getData()); - const float *p_anchors_item = reinterpret_cast(getParentEdgeAt(INPUT_ANCHORS)->getMemoryPtr()->getData()); - const float *p_img_info_cpu = reinterpret_cast(getParentEdgeAt(INPUT_IM_INFO)->getMemoryPtr()->getData()); + const float *p_deltas_item = getSrcDataAtPortAs(INPUT_DELTAS); + const float *p_scores_item = getSrcDataAtPortAs(INPUT_SCORES); + const float *p_anchors_item = getSrcDataAtPortAs(INPUT_ANCHORS); + const float *p_img_info_cpu = getSrcDataAtPortAs(INPUT_IM_INFO); const int anchors_num = scoreDims[1]; @@ -451,12 +451,12 @@ void GenerateProposals::execute(dnnl::stream strm) { } // copy to out memory redefineOutputMemory({VectorDims{total_num_rois, 4}, VectorDims{total_num_rois}, VectorDims{batch_size}}); - float *p_roi_item = reinterpret_cast(getChildEdgesAtPort(OUTPUT_ROIS)[0]->getMemoryPtr()->getData()); - float *p_roi_score_item = reinterpret_cast(getChildEdgesAtPort(OUTPUT_SCORES)[0]->getMemoryPtr()->getData()); - uint8_t* p_roi_num_item = reinterpret_cast(getChildEdgesAtPort(OUTPUT_ROI_NUM)[0]->getMemoryPtr()->getData()); + float *p_roi_item = getDstDataAtPortAs(OUTPUT_ROIS); + float *p_roi_score_item = getDstDataAtPortAs(OUTPUT_SCORES); + uint8_t* p_roi_num_item = getDstDataAtPortAs(OUTPUT_ROI_NUM); memcpy(p_roi_item, &roi_item[0], roi_item.size() * sizeof(float)); memcpy(p_roi_score_item, &score_item[0], score_item.size() * sizeof(float)); - memcpy(p_roi_num_item, &roi_num[0], getChildEdgesAtPort(OUTPUT_ROI_NUM)[0]->getMemoryPtr()->getSize()); + memcpy(p_roi_num_item, &roi_num[0], getDstMemoryAtPort(OUTPUT_ROI_NUM)->getSize()); } catch (const std::exception &e) { std::string errorMsg = e.what(); OPENVINO_THROW(errorMsg); diff --git a/src/plugins/intel_cpu/src/nodes/grid_sample.cpp b/src/plugins/intel_cpu/src/nodes/grid_sample.cpp index 842e7854604e68..912048b87b009e 100644 --- a/src/plugins/intel_cpu/src/nodes/grid_sample.cpp +++ b/src/plugins/intel_cpu/src/nodes/grid_sample.cpp @@ -181,13 +181,13 @@ void GridSample::createPrimitive() { } void GridSample::prepareParams() { - auto dataMemPtr = getParentEdgeAt(IN_DATA)->getMemoryPtr(); + auto dataMemPtr = getSrcMemoryAtPort(IN_DATA); if (!dataMemPtr || !dataMemPtr->isAllocated()) THROW_CPU_NODE_ERR("has not allocated input data memory."); - auto gridMemPtr = getParentEdgeAt(IN_GRID)->getMemoryPtr(); + auto gridMemPtr = getSrcMemoryAtPort(IN_GRID); if (!gridMemPtr || !gridMemPtr->isAllocated()) THROW_CPU_NODE_ERR("has not allocated input grid memory."); - auto dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); + auto dstMemPtr = getDstMemoryAtPort(0); if (!dstMemPtr || !dstMemPtr->isAllocated()) THROW_CPU_NODE_ERR("has not allocated output memory."); if (getSelectedPrimitiveDescriptor() == nullptr) @@ -264,9 +264,9 @@ void GridSample::prepareParams() { } void GridSample::execute(dnnl::stream strm) { - const void* srcData = getParentEdgeAt(IN_DATA)->getMemoryPtr()->getData(); - const uint8_t* gridData = reinterpret_cast(getParentEdgeAt(IN_GRID)->getMemoryPtr()->getData()); - uint8_t* dstData = reinterpret_cast(getChildEdgeAt(0)->getMemoryPtr()->getData()); + const void* srcData = getSrcDataAtPort(IN_DATA); + const uint8_t* gridData = getSrcDataAtPortAs(IN_GRID); + uint8_t* dstData = getDstDataAtPortAs(0); auto threadBody = [&](const int ithr, const int nthr) { const auto& p = execParamsPerThread[ithr]; diff --git a/src/plugins/intel_cpu/src/nodes/grn.cpp b/src/plugins/intel_cpu/src/nodes/grn.cpp index 8337a5249e7b18..1b7d2aeabd0965 100644 --- a/src/plugins/intel_cpu/src/nodes/grn.cpp +++ b/src/plugins/intel_cpu/src/nodes/grn.cpp @@ -58,8 +58,8 @@ void GRN::initSupportedPrimitiveDescriptors() { } void GRN::prepareParams() { - const auto& dataMemPtr = getParentEdgeAt(0)->getMemoryPtr(); - const auto& dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); + const auto& dataMemPtr = getSrcMemoryAtPort(0); + const auto& dstMemPtr = getDstMemoryAtPort(0); if (!dataMemPtr || !dataMemPtr->isAllocated()) OPENVINO_THROW(errorPrefix, " has not allocated input memory"); @@ -91,8 +91,8 @@ void GRN::executeDynamicImpl(dnnl::stream strm) { } void GRN::execute(dnnl::stream strm) { - const float* src_data = reinterpret_cast(getParentEdgeAt(0)->getMemoryPtr()->getData()); - float* dst_data = reinterpret_cast(getChildEdgesAtPort(0)[0]->getMemoryPtr()->getData()); + const float* src_data = getSrcDataAtPortAs(0); + float* dst_data = getDstDataAtPortAs(0); parallel_for3d(N, H, W, [&](int b, int h, int w) { double variance = 0; diff --git a/src/plugins/intel_cpu/src/nodes/if.cpp b/src/plugins/intel_cpu/src/nodes/if.cpp index 996ec577eed1c7..4053546391246a 100644 --- a/src/plugins/intel_cpu/src/nodes/if.cpp +++ b/src/plugins/intel_cpu/src/nodes/if.cpp @@ -3,9 +3,13 @@ // #include "if.h" + +#include "openvino/op/if.hpp" + #include "common/cpu_memcpy.h" #include "shape_inference/shape_inference_internal_dyn.hpp" #include "nodes/common/cpu_convert.h" +#include "transformations/utils/utils.hpp" #include #include @@ -113,7 +117,7 @@ void If::getSupportedDescriptors() { const std::string inputID = ov::op::util::get_ie_output_name(prev); auto outNode = outMapThen.find(inputID); if (outNode != outMapThen.end()) { - auto outMem = outNode->second->getParentEdgeAt(0)->getMemoryPtr(); + auto outMem = outNode->second->getSrcMemoryAtPort(0); outputMemThen.push_back(outMem); } else { OPENVINO_THROW("Then body of node If with name ", getName(), " does not have output with name: ", inputID); @@ -126,7 +130,7 @@ void If::getSupportedDescriptors() { const std::string inputID = ov::op::util::get_ie_output_name(prev); auto outNode = outMapElse.find(inputID); if (outNode != outMapElse.end()) { - auto outMem = outNode->second->getParentEdgeAt(0)->getMemoryPtr(); + auto outMem = outNode->second->getSrcMemoryAtPort(0); outputMemElse.push_back(outMem); } else { OPENVINO_THROW("Else body of node If with name ", getName(), " does not have output with name: ", inputID); @@ -199,7 +203,7 @@ void If::prepareBeforeMappers(const bool isThen, const dnnl::engine& eng) { auto &inputMems = isThen ? inputMemThen : inputMemElse; auto &beforeMappers = isThen ? beforeThenMappers : beforeElseMappers; for (auto& map_rule : inputPortMap) { - auto fromMem = getParentEdgesAtPort(map_rule.from)[0]->getMemoryPtr(); + auto fromMem = getSrcMemoryAtPort(map_rule.from); auto& toMems = inputMems[map_rule.to]; // Check precision between If node input/output and it's subgrapsh input/output. for (const auto& toMem : toMems) { @@ -244,7 +248,7 @@ std::deque If::getToMemories(const Node* node, const size_t port) con } void If::execute(dnnl::stream strm) { - const bool condition = static_cast((reinterpret_cast(getParentEdgeAt(0)->getMemoryPtr()->getData()))[0]); + const bool condition = static_cast((getSrcDataAtPortAs(0))[0]); auto& beforeMappers = condition ? beforeThenMappers : beforeElseMappers; auto& afterMappers = condition ? afterThenMappers : afterElseMappers; diff --git a/src/plugins/intel_cpu/src/nodes/input.cpp b/src/plugins/intel_cpu/src/nodes/input.cpp index 518350e3d47627..543278e8599d2e 100644 --- a/src/plugins/intel_cpu/src/nodes/input.cpp +++ b/src/plugins/intel_cpu/src/nodes/input.cpp @@ -267,7 +267,7 @@ void Input::cloneBlobIfRequired() { if (constOp->get_element_type() == element::string) { memory = std::make_shared(getEngine(), memDesc); auto src = constOp->get_data_ptr(); - auto dst = reinterpret_cast(memory->getData()); + auto dst = memory->getDataAs(); std::copy(src, src + size, dst); } else { memory = std::make_shared(getEngine(), memDesc); @@ -387,24 +387,51 @@ void Input::cloneBlobIfRequired() { } } +static std::vector createInputShapes(const Shape& shape, + const Type type) { + if (type == Type::Output) + return {shape}; + return {}; +} + +static std::vector createOutputShapes(const Shape& shape, + const Type type) { + if (type == Type::Input) + return {shape}; + return {}; +} + +static std::vector createInputPrecisions(const ov::element::Type& prc, + const Type type) { + if (type == Type::Output) + return {prc}; + return {}; +} + +static std::vector createOutputPrecisions(const ov::element::Type& prc, + const Type type) { + if (type == Type::Input) + return {prc}; + return {}; +} + Input::Input(const Shape& shape, const ov::element::Type& prc, const std::string& name, const std::string& type, const GraphContext::CPtr context) - : Node(type, name, context) { + : Node(type, + createInputShapes(shape, TypeFromName(type)), + createOutputShapes(shape, TypeFromName(type)), + createInputPrecisions(prc, TypeFromName(type)), + createOutputPrecisions(prc, TypeFromName(type)), + name, + context) { constant = ConstantType::NoConst; isDynamic = shape.isDynamic(); if (isDynamic) { shapeInference = PassThroughShapeInferFactory().makeShapeInfer(); } - if (getType() == Type::Input) { - outputShapes.emplace_back(shape); - addOriginalOutputPrecision(prc); - } else if (getType() == Type::Output) { - inputShapes.emplace_back(shape); - addOriginalInputPrecision(prc); - } } Input::Input(MemoryDescPtr memDesc, const std::string& name, const std::string& type, const GraphContext::CPtr context) @@ -443,13 +470,13 @@ void Input::initSupportedPrimitiveDescriptors() { void Input::createPrimitive() { for (size_t i = 0; i < getChildEdges().size(); i++) { - auto dstMemPtr = getChildEdgeAt(i)->getMemoryPtr(); + auto dstMemPtr = getDstMemoryAtPort(i); if (!dstMemPtr || !dstMemPtr->isAllocated()) THROW_CPU_NODE_ERR("has unallocated memory object at port ", i, " to node ", getChildEdgeAt(i)->getChild()->getName(), "."); } for (size_t i = 0; i < getParentEdges().size(); i++) { - auto srcMemPtr = getParentEdgeAt(i)->getMemoryPtr(); + auto srcMemPtr = getSrcMemoryAtPort(i); if (!srcMemPtr || !srcMemPtr->isAllocated()) THROW_CPU_NODE_ERR("has unallocated memory object at port ", i, " from node ", getParentEdgeAt(i)->getParent()->getName(), "."); diff --git a/src/plugins/intel_cpu/src/nodes/interaction.cpp b/src/plugins/intel_cpu/src/nodes/interaction.cpp index 25f2a6971e3d35..5e27dd13923b12 100644 --- a/src/plugins/intel_cpu/src/nodes/interaction.cpp +++ b/src/plugins/intel_cpu/src/nodes/interaction.cpp @@ -237,10 +237,10 @@ static inline void flat_triangle(const uint8_t* in, uint8_t* out, size_t size, s void Interaction::execRef(dnnl::stream strm) { using namespace dnnl; - uint8_t* outFeaturesPtr = reinterpret_cast(getChildEdgesAtPort(0)[0]->getMemoryPtr()->getData()); + uint8_t* outFeaturesPtr = getDstDataAtPortAs(0); std::vector inputPtrs(inputSizes); for (uint32_t n = 0; n < inputSizes; n++) { - auto inPtr = reinterpret_cast(getParentEdgeAt(n)->getMemoryPtr()->getData()); + auto inPtr = getSrcDataAtPortAs(n); inputPtrs[n] = inPtr; } std::unordered_map mem_ags{{DNNL_ARG_SRC, inputMemPtr->getPrimitive()}, @@ -248,10 +248,10 @@ void Interaction::execRef(dnnl::stream strm) { {DNNL_ARG_DST, outputMemPtr->getPrimitive()}}; float* scales = fqScales.empty() ? nullptr : fqScales.data(); for (int64_t start = 0; start < static_cast(batchSize); start++) { - cat(reinterpret_cast(inputMemPtr->getData()), inputPtrs, featureSizes, start, dataPrecision.size()); + cat(inputMemPtr->getDataAs(), inputPtrs, featureSizes, start, dataPrecision.size()); prim.execute(strm, mem_ags); - flat_triangle(reinterpret_cast(outputMemPtr->getData()), - reinterpret_cast(flatMemPtr->getData()), + flat_triangle(outputMemPtr->getDataAs(), + flatMemPtr->getDataAs(), inputSizes, dataPrecision.size()); // in1 dense feature diff --git a/src/plugins/intel_cpu/src/nodes/interpolate.cpp b/src/plugins/intel_cpu/src/nodes/interpolate.cpp index a10784492c28f9..0f373decbe5077 100644 --- a/src/plugins/intel_cpu/src/nodes/interpolate.cpp +++ b/src/plugins/intel_cpu/src/nodes/interpolate.cpp @@ -25,6 +25,7 @@ #include "shape_inference/static_shape.hpp" #include "utils/bfloat16.hpp" #include "utils/cpu_utils.hpp" +#include "utils/ngraph_utils.hpp" #include #include @@ -1656,14 +1657,14 @@ inline VectorDims to5Dim(VectorDims casesDim) { return dim5; } -using ngInterpMode = ov::opset4::Interpolate::InterpolateMode; -using ngInterpCoordTransf = ov::opset4::Interpolate::CoordinateTransformMode; -using ngInterpNearMode = ov::opset4::Interpolate::NearestMode; -using ngInterpShapeCalcMode = ov::opset4::Interpolate::ShapeCalcMode; +using ngInterpMode = ov::op::v4::Interpolate::InterpolateMode; +using ngInterpCoordTransf = ov::op::v4::Interpolate::CoordinateTransformMode; +using ngInterpNearMode = ov::op::v4::Interpolate::NearestMode; +using ngInterpShapeCalcMode = ov::op::v4::Interpolate::ShapeCalcMode; bool Interpolate::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - if (const auto interp = std::dynamic_pointer_cast(op)) { + if (const auto interp = std::dynamic_pointer_cast(op)) { const auto &interpAttr = interp->get_attrs(); const auto &interpMode = interpAttr.mode; if (!one_of(interpMode, ngInterpMode::NEAREST, ngInterpMode::LINEAR, ngInterpMode::LINEAR_ONNX, ngInterpMode::CUBIC)) { @@ -1705,17 +1706,17 @@ bool Interpolate::isSupportedOperation(const std::shared_ptr& op } if (!isDynamicNgraphNode(op) && interpShapeCalcMode == ngInterpShapeCalcMode::SCALES && - !ov::is_type(op->get_input_node_ptr(SCALES_ID))) { + !ov::is_type(op->get_input_node_ptr(SCALES_ID))) { errorMessage = "Only const 'scales' input is supported for static shapes in Interpolate-4"; return false; } if (interp->get_input_size() > 3 && - std::dynamic_pointer_cast(interp->get_input_node_shared_ptr(AXES_ID)) == nullptr) { + std::dynamic_pointer_cast(interp->get_input_node_shared_ptr(AXES_ID)) == nullptr) { errorMessage = "Only const 'axes' input is supported in Interpolate-4"; return false; } - } else if (const auto interp = std::dynamic_pointer_cast(op)) { + } else if (const auto interp = std::dynamic_pointer_cast(op)) { const auto &interpAttr = interp->get_attrs(); const auto &interpMode = interpAttr.mode; if (!one_of(interpMode, ngInterpMode::BILINEAR_PILLOW, ngInterpMode::BICUBIC_PILLOW)) { @@ -1734,12 +1735,12 @@ bool Interpolate::isSupportedOperation(const std::shared_ptr& op return false; } if (!isDynamicNgraphNode(op) && - !ov::is_type(op->get_input_node_ptr(SIZE_OR_SCALE_ID_V11))) { + !ov::is_type(op->get_input_node_ptr(SIZE_OR_SCALE_ID_V11))) { errorMessage = "Only const 'scales_or_sizes' input is supported for static shapes in Interpolate-11"; return false; } if (interp->get_input_size() > 2 && - std::dynamic_pointer_cast(interp->get_input_node_shared_ptr(AXES_ID_V11)) == nullptr) { + std::dynamic_pointer_cast(interp->get_input_node_shared_ptr(AXES_ID_V11)) == nullptr) { errorMessage = "Only const 'axes' input is supported in Interpolate-11"; return false; } @@ -1773,7 +1774,7 @@ class InterpolateShapeInferFactory : public ShapeInferFactory { } else { OPENVINO_ASSERT(false, "Unsupported interpolate shape calculation mode"); } - } else if (auto interp11 = ov::as_type_ptr(m_op)) { + } else if (auto interp11 = ov::as_type_ptr(m_op)) { port_mask = PortMask(Interpolate::SIZE_OR_SCALE_ID_V11, Interpolate::AXES_ID_V11); } else { OPENVINO_THROW("Shape infer factory cannot be created for ", @@ -1884,21 +1885,21 @@ Interpolate::Interpolate(const std::shared_ptr& op, const GraphContext interpAttrs.padEnd[i] = static_cast(interpAttr.pads_end[i]); } - const auto scalesNode = std::dynamic_pointer_cast(interp->get_input_node_shared_ptr(SCALES_ID)); + const auto scalesNode = std::dynamic_pointer_cast(interp->get_input_node_shared_ptr(SCALES_ID)); if (scalesNode) { scales = scalesNode->cast_vector(); isScaleConstant = true; } if (isAxesSpecified) { - axes = std::dynamic_pointer_cast(interp->get_input_node_shared_ptr(AXES_ID))->cast_vector(); + axes = std::dynamic_pointer_cast(interp->get_input_node_shared_ptr(AXES_ID))->cast_vector(); } else { axes.resize(dataRank); for (int i = 0; i < static_cast(dataRank); i++) { axes[i] = i; } } - } else if (const auto interp = std::dynamic_pointer_cast(op)) { + } else if (const auto interp = std::dynamic_pointer_cast(op)) { is_version11 = true; const auto numInputs = inputShapes.size(); if (numInputs != 2 && numInputs != 3) @@ -1925,7 +1926,7 @@ Interpolate::Interpolate(const std::shared_ptr& op, const GraphContext const auto &interpShapeCalcMode = interpAttr.shape_calculation_mode; if (interpShapeCalcMode == ngInterpShapeCalcMode::SCALES) { shapeCalcMode = InterpolateShapeCalcMode::scales; - const auto scalesNode = std::dynamic_pointer_cast(interp->get_input_node_shared_ptr(SIZE_OR_SCALE_ID_V11)); + const auto scalesNode = std::dynamic_pointer_cast(interp->get_input_node_shared_ptr(SIZE_OR_SCALE_ID_V11)); if (scalesNode) { scales = scalesNode->cast_vector(); isScaleConstant = true; @@ -1953,7 +1954,7 @@ Interpolate::Interpolate(const std::shared_ptr& op, const GraphContext } if (isAxesSpecified) { - axes = std::dynamic_pointer_cast(interp->get_input_node_shared_ptr(AXES_ID_V11))->cast_vector(); + axes = std::dynamic_pointer_cast(interp->get_input_node_shared_ptr(AXES_ID_V11))->cast_vector(); if (dataRank == 4 && axes.size() == 2 && axes[0] == 1 && axes[1] == 2 && mayiuse(cpu::x64::sse41)) { NCHWAsNHWC = true; axes[0] = 2; @@ -2189,7 +2190,7 @@ bool Interpolate::needShapeInfer() const { if (lastScales.empty()) { return true; } - const float *scales = reinterpret_cast(getParentEdgesAtPort(get_scale_id())[0]->getMemory().getData()); + const float *scales = getParentEdgeAt(get_scale_id())->getMemory().getDataAs(); for (size_t i = 0; i < lastScales.size(); i++) { if (lastScales[i] != scales[i]) { return true; @@ -2199,7 +2200,7 @@ bool Interpolate::needShapeInfer() const { if (lastSizes.empty()) { return true; } - const int32_t *sizes = reinterpret_cast(getParentEdgesAtPort(TARGET_SHAPE_ID)[0]->getMemory().getData()); + const int32_t *sizes = getParentEdgeAt(TARGET_SHAPE_ID)->getMemory().getDataAs(); for (size_t i = 0; i < lastSizes.size(); i++) { if (sizes[i] != lastSizes[i]) { return true; @@ -2213,18 +2214,18 @@ void Interpolate::executeDynamicImpl(dnnl::stream strm) { execute(strm); const size_t port = shapeCalcMode == InterpolateShapeCalcMode::sizes ? TARGET_SHAPE_ID : get_scale_id(); - const auto &memory = getParentEdgesAtPort(port)[0]->getMemory(); + const auto &memory = getParentEdgeAt(port)->getMemory(); if (shapeCalcMode == InterpolateShapeCalcMode::scales) { - const float *scales = reinterpret_cast(memory.getData()); + const float *scales = memory.getDataAs(); lastScales.assign(scales, scales + memory.getDesc().getShape().getElementsCount()); } else { - const int32_t *sizes = reinterpret_cast(memory.getData()); + const int32_t *sizes = memory.getDataAs(); lastSizes.assign(sizes, sizes + memory.getDesc().getShape().getElementsCount()); } } bool Interpolate::needPrepareParams() const { - return (inputShapesModified() || lastOutputDims != getChildEdgesAtPort(0)[0]->getMemory().getStaticDims()); + return (inputShapesModified() || lastOutputDims != getChildEdgeAt(0)->getMemory().getStaticDims()); } inline int Interpolate::get_scale_id() const { @@ -2247,26 +2248,26 @@ void Interpolate::prepareParams() { ", because input/output dims aren't defined"); } - auto dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); + auto dstMemPtr = getDstMemoryAtPort(0); if (!dstMemPtr || !dstMemPtr->isAllocated()) OPENVINO_THROW(errorPrefix, " did not allocate destination memory"); - auto srcMemPtr = getParentEdgeAt(DATA_ID)->getMemoryPtr(); + auto srcMemPtr = getSrcMemoryAtPort(DATA_ID); if (!srcMemPtr || !srcMemPtr->isAllocated()) OPENVINO_THROW(errorPrefix, " did not allocate input memory"); if (shapeCalcMode == InterpolateShapeCalcMode::sizes) { - auto tsMemPtr = getParentEdgeAt(TARGET_SHAPE_ID)->getMemoryPtr(); + auto tsMemPtr = getSrcMemoryAtPort(TARGET_SHAPE_ID); if (!tsMemPtr || !tsMemPtr->isAllocated()) OPENVINO_THROW(errorPrefix, " did not allocate target shape memory"); } else { - auto scaleMemPtr = getParentEdgeAt(get_scale_id())->getMemoryPtr(); + auto scaleMemPtr = getSrcMemoryAtPort(get_scale_id()); if (!scaleMemPtr || !scaleMemPtr->isAllocated()) OPENVINO_THROW(errorPrefix, " did not allocate scales memory"); } if (isAxesSpecified) { - auto axesMemPtr = getParentEdgeAt(get_axis_id())->getMemoryPtr(); + auto axesMemPtr = getSrcMemoryAtPort(get_axis_id()); if (!axesMemPtr || !axesMemPtr->isAllocated()) OPENVINO_THROW(errorPrefix, " did not allocate axes memory"); } @@ -2296,8 +2297,8 @@ void Interpolate::prepareParams() { if (shapeCalcMode == InterpolateShapeCalcMode::scales) { if (!isScaleConstant) { - const auto& scalesMem = getParentEdgesAtPort(get_scale_id())[0]->getMemory(); - const float* scalesData = reinterpret_cast(scalesMem.getData()); + const auto& scalesMem = getParentEdgeAt(get_scale_id())->getMemory(); + const float* scalesData = scalesMem.getDataAs(); scales.assign(scalesData, scalesData + scalesMem.getStaticDims()[0]); } } @@ -2312,10 +2313,10 @@ void Interpolate::prepareParams() { std::vector srcMemoryDescs; for (size_t i = 0; i < getParentEdges().size(); i++) { - srcMemoryDescs.push_back(getParentEdgeAt(i)->getMemoryPtr()->getDescPtr()); + srcMemoryDescs.push_back(getSrcMemoryAtPort(i)->getDescPtr()); } std::vector dstMemoryDescs; - dstMemoryDescs.push_back(getChildEdgeAt(0)->getMemoryPtr()->getDescPtr()); + dstMemoryDescs.push_back(getDstMemoryAtPort(0)->getDescPtr()); auto selectedPD = getSelectedPrimitiveDescriptor(); aclExecPtr = selectedPD->getExecutorFactoryAs()->makeExecutor(interpAttrs, srcMemoryDescs, dstMemoryDescs, {}); @@ -2362,8 +2363,8 @@ void Interpolate::prepareParams() { } void Interpolate::createPrimitive() { - auto srcMemPtr = getParentEdgeAt(DATA_ID)->getMemoryPtr(); - auto dstMemPtr = getChildEdgesAtPort(0)[0]->getMemoryPtr(); + auto srcMemPtr = getSrcMemoryAtPort(DATA_ID); + auto dstMemPtr = getDstMemoryAtPort(0); if (!srcMemPtr || !srcMemPtr->isAllocated()) OPENVINO_THROW(errorPrefix, " did not allocate input memory"); if (!dstMemPtr || !dstMemPtr->isAllocated()) @@ -2455,12 +2456,12 @@ std::vector Interpolate::getScales(const VectorDims &srcDimPad, const Vec } void Interpolate::execute(dnnl::stream strm) { - auto dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); - auto srcMemPtr = getParentEdgeAt(DATA_ID)->getMemoryPtr(); + auto dstMemPtr = getDstMemoryAtPort(0); + auto srcMemPtr = getSrcMemoryAtPort(DATA_ID); if (execPtr) { - uint8_t *dst_data = reinterpret_cast(dstMemPtr->getData()); - const uint8_t *src_data_origin = reinterpret_cast(srcMemPtr->getData()); + uint8_t *dst_data = dstMemPtr->getDataAs(); + const uint8_t *src_data_origin = srcMemPtr->getDataAs(); const uint8_t *src_data = nullptr; std::vector srcPadded; if (hasPad) { diff --git a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/common.hpp b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/common.hpp index 6ed0e2d50d65f5..e624382fd2eb0f 100644 --- a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/common.hpp +++ b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/common.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "openvino/core/type/bfloat16.hpp" #include "openvino/core/type/float16.hpp" @@ -24,14 +25,31 @@ static constexpr size_t vec_len_f32_avx512 = vec_len_avx512 / sizeof(float); static constexpr size_t vec_len_f32_avx2 = vec_len_avx2 / sizeof(float); #ifdef HAVE_AVX512F - inline __m512 mm512_uni_loadu_ps(ov::bfloat16* a) { - auto vec_bf16 = _mm256_loadu_si256(reinterpret_cast<__m256i*>(a)); - __m512i y = _mm512_cvtepu16_epi32(vec_bf16); + inline __m512 cvt_bf16_to_fp32(const __m256i src) { + __m512i y = _mm512_cvtepu16_epi32(src); return _mm512_castsi512_ps(_mm512_slli_epi32(y, 16)); } - inline __m512 mm512_uni_loadu_ps(float* a) { + + inline __m512 mm512_uni_loadu_ps(const ov::bfloat16* a) { + auto vec_bf16 = _mm256_loadu_si256(reinterpret_cast(a)); + return cvt_bf16_to_fp32(vec_bf16); + } + + inline __m512 mm512_uni_loadu_ps(const float* a) { return _mm512_loadu_ps(a); } + + inline __m512 mm512_uni_loadu_tail_ps(const float* a, size_t count) { + __mmask16 mask = (1 << count) - 1; + return _mm512_maskz_loadu_ps(mask, a); + } + + inline __m512 mm512_uni_loadu_tail_ps(const ov::bfloat16* a, size_t count) { + auto mask = (1 << count) - 1; + auto bf16_vec = _mm256_maskz_loadu_epi16(mask, a); + return cvt_bf16_to_fp32(bf16_vec); + } + inline void mm512_uni_storeu_ps(float* a, __m512 v) { _mm512_storeu_ps(a, v); } @@ -61,7 +79,7 @@ static constexpr size_t vec_len_f32_avx2 = vec_len_avx2 / sizeof(float); } inline __m512 mm512_uni_loadu_ps(ov::float16* a) { - auto vec_f16 = _mm256_loadu_si256(reinterpret_cast<__m256i*>(a)); + auto vec_f16 = _mm256_loadu_si256(reinterpret_cast(a)); return _mm512_cvtph_ps(vec_f16); } inline void mm512_uni_storeu_ps(ov::float16* addr, __m512 v) { @@ -71,19 +89,45 @@ static constexpr size_t vec_len_f32_avx2 = vec_len_avx2 / sizeof(float); #endif #ifdef HAVE_AVX2 - inline __m256 mm256_uni_loadu_ps(float* a) { + inline __m256i get_mask(int N7) { + static __m256i mask[] = { + _mm256_set_epi32(0, 0, 0, 0, 0, 0, 0, 0), + _mm256_set_epi32(0, 0, 0, 0, 0, 0, 0, -1), + _mm256_set_epi32(0, 0, 0, 0, 0, 0, -1, -1), + _mm256_set_epi32(0, 0, 0, 0, 0, -1, -1, -1), + _mm256_set_epi32(0, 0, 0, 0, -1, -1, -1, -1), + _mm256_set_epi32(0, 0, 0, -1, -1, -1, -1, -1), + _mm256_set_epi32(0, 0, -1, -1, -1, -1, -1, -1), + _mm256_set_epi32(0, -1, -1, -1, -1, -1, -1, -1), + _mm256_set_epi32(-1, -1, -1, -1, -1, -1, -1, -1), + }; + return _mm256_loadu_si256(&mask[N7]); + } + inline __m256 mm256_uni_loadu_ps(const float* a) { return _mm256_loadu_ps(a); } inline void mm256_uni_storeu_ps(float* a, __m256 v) { _mm256_storeu_ps(a, v); } - inline __m256 mm256_uni_loadu_ps(ov::bfloat16* a) { - auto vec_bf16 = _mm_loadu_si128(reinterpret_cast<__m128i*>(a)); + inline __m256 mm256_uni_loadu_ps(const ov::bfloat16* a) { + auto vec_bf16 = _mm_loadu_si128(reinterpret_cast(a)); auto o = _mm256_castsi256_ps(_mm256_slli_epi32(_mm256_cvtepu16_epi32(vec_bf16), 16)); return o; } + inline __m256 mm256_uni_loadu_tail_ps(const float* a, const size_t count) { + auto mask = get_mask(count); + return _mm256_maskload_ps(a, mask); + } + + inline __m256 mm256_uni_loadu_tail_ps(const ov::bfloat16* a, const size_t count) { + assert("AVX2 version of bfloat16 tail load is just for compilation pass"); + ov::bfloat16 tmp_values[8] = {0}; + std::memcpy(tmp_values, a, count * sizeof(ov::bfloat16)); + return mm256_uni_loadu_ps(tmp_values); + } + inline void mm256_uni_storeu_ps(ov::bfloat16 *addr, __m256 xps) { __m256i xpi32 = _mm256_castps_si256(xps); __m256i nan = _mm256_set1_epi32(0xffff); diff --git a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/mha_single_token.cpp b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/mha_single_token.cpp index 45a0bd4b95b662..393d58fcfde958 100644 --- a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/mha_single_token.cpp +++ b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/mha_single_token.cpp @@ -175,7 +175,9 @@ void mha_single_token_kernel(const ov::intel_cpu::PlainTensor& query, // apply attention mask & sofmax auto ncausal = auto_causal ? (kv_len - q_len + pq + 1) : kv_len; float* alibi_ptr = alibi_mask ? &alibi_mask.at({b, h, pq, 0}, true) : nullptr; - float* attn_mask_ptr = attention_mask ? &attention_mask.at({b, h, pq, 0}, true) : nullptr; + uint8_t* attn_mask_ptr = nullptr; + auto attn_mask_prec = attention_mask.get_precision(); + attn_mask_ptr = reinterpret_cast(&attention_mask.at({b, h, 0, 0}, true)); uint8_t* cmask_ptr = causal_mask ? &causal_mask.at({b, h, pq, 0}, true) : nullptr; attn_softmax_kernel(&buf_attn_w.at({b, h, pq, 0}), &buf_attn_w.at({b, h, pq, 0}), @@ -186,6 +188,7 @@ void mha_single_token_kernel(const ov::intel_cpu::PlainTensor& query, select_nfltmax_at_0, ncausal, kv_len, + attn_mask_prec, ov::element::f32); }); diff --git a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/softmax.cpp b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/softmax.cpp index f196add14b9ba1..92d96858c8cbb0 100644 --- a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/softmax.cpp +++ b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/softmax.cpp @@ -27,13 +27,14 @@ void attn_softmax(float* a, void* a_dst, float scale, float* alibi, - float* attn_mask, + void* attn_mask, uint8_t* causal_mask, bool select_nfltmax_at_0, size_t len, size_t total_size, + ov::element::Type attn_mask_prec, ov::element::Type dst_precision) { - attn_softmax_kernel(a, a_dst, scale, alibi, attn_mask, causal_mask, select_nfltmax_at_0, len, total_size, dst_precision); + attn_softmax_kernel(a, a_dst, scale, alibi, attn_mask, causal_mask, select_nfltmax_at_0, len, total_size, attn_mask_prec, dst_precision); } } // namespace XARCH diff --git a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/softmax.hpp b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/softmax.hpp index 9efd4ab1d663ed..e439399d237f18 100644 --- a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/softmax.hpp +++ b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/softmax.hpp @@ -18,11 +18,12 @@ void attn_softmax(float* a, void* a_dst, float scale, float* alibi, - float* attn_mask, + void* attn_mask, uint8_t* causal_mask, bool select_nfltmax_at_0, size_t len, size_t total_size, + ov::element::Type attn_mask_prec, ov::element::Type dst_precision); } // namespace XARCH } // namespace Cpu diff --git a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/softmax_kernel.hpp b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/softmax_kernel.hpp index 85900cb1929d15..4d85af64d137aa 100644 --- a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/softmax_kernel.hpp +++ b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/softmax_kernel.hpp @@ -17,21 +17,6 @@ namespace Cpu { namespace XARCH { #if defined(HAVE_AVX2) -inline __m256i get_mask(int N7) { - static __m256i mask[] = { - _mm256_set_epi32(0, 0, 0, 0, 0, 0, 0, 0), - _mm256_set_epi32(0, 0, 0, 0, 0, 0, 0, -1), - _mm256_set_epi32(0, 0, 0, 0, 0, 0, -1, -1), - _mm256_set_epi32(0, 0, 0, 0, 0, -1, -1, -1), - _mm256_set_epi32(0, 0, 0, 0, -1, -1, -1, -1), - _mm256_set_epi32(0, 0, 0, -1, -1, -1, -1, -1), - _mm256_set_epi32(0, 0, -1, -1, -1, -1, -1, -1), - _mm256_set_epi32(0, -1, -1, -1, -1, -1, -1, -1), - _mm256_set_epi32(-1, -1, -1, -1, -1, -1, -1, -1), - }; - return _mm256_loadu_si256(&mask[N7]); -} - inline void hmax(__m256& x) { __m256 y; // x: 0 1 2 3 4 5 6 7 y = _mm256_permute_ps(x, 0x39); // y: 1 2 3 0 5 6 7 4 @@ -175,11 +160,12 @@ inline void scale_add_reduce_max(float* a, const float scale, const float* b, co } #endif } -template + +template inline void scale_add2_reduce_max(float* a, float scale, const float* alibi, - const float* attn_mask, + const T* attn_mask, const uint8_t* causal_mask, bool select_nfltmax_at_0, // true: 0 in mask set -FLT_MAX size_t size, @@ -203,7 +189,7 @@ inline void scale_add2_reduce_max(float* a, } if (has_attn_mask) { - auto v_mask = _mm512_loadu_ps(attn_mask + i); + auto v_mask = mm512_uni_loadu_ps(attn_mask + i); v_a = _mm512_add_ps(v_a, v_mask); } @@ -231,7 +217,7 @@ inline void scale_add2_reduce_max(float* a, } if (has_attn_mask) { - auto v_mask = _mm512_maskz_loadu_ps(mask, attn_mask + i); + auto v_mask = mm512_uni_loadu_tail_ps(attn_mask + i, size - i); v_a = _mm512_add_ps(v_a, v_mask); } @@ -266,7 +252,7 @@ inline void scale_add2_reduce_max(float* a, } if (has_attn_mask) { - auto v_mask = _mm256_loadu_ps(attn_mask + i); + auto v_mask = mm256_uni_loadu_ps(attn_mask + i); v_a = _mm256_add_ps(v_a, v_mask); } @@ -295,7 +281,7 @@ inline void scale_add2_reduce_max(float* a, } if (has_attn_mask) { - auto v_mask = _mm256_maskload_ps(attn_mask + i, mask); + auto v_mask = mm256_uni_loadu_tail_ps(attn_mask + i, size - i); v_a = _mm256_add_ps(v_a, v_mask); } @@ -531,14 +517,26 @@ inline void attn_softmax_kernel(float* a, void* a_dst, float scale, float* alibi, - float* attn_mask, + void* attn_mask, uint8_t* causal_mask, bool select_nfltmax_at_0, size_t len, size_t total_size, + ov::element::Type attn_mask_prec, ov::element::Type dst_precision) { - using func_type = void (*)(float*, float, const float*, const float*, const uint8_t*, bool, size_t, float&); - static func_type funcs[] = { + using func_fp32_type = void (*)(float*, float, const float*, const float*, const uint8_t*, bool, size_t, float&); + using func_bf16_type = void (*)(float*, float, const float*, const ov::bfloat16*, const uint8_t*, bool, size_t, float&); + static func_fp32_type funcs_fp32[] = { + scale_add2_reduce_max, + scale_add2_reduce_max, + scale_add2_reduce_max, + scale_add2_reduce_max, + scale_add2_reduce_max, + scale_add2_reduce_max, + scale_add2_reduce_max, + scale_add2_reduce_max + }; + static func_bf16_type funcs_bf16[] = { scale_add2_reduce_max, scale_add2_reduce_max, scale_add2_reduce_max, @@ -550,7 +548,11 @@ inline void attn_softmax_kernel(float* a, }; int dispatch = (alibi ? 0b100 : 0) | (attn_mask ? 0b010 : 0) | (causal_mask ? 0b001 : 0); float max = std::numeric_limits::lowest(); - funcs[dispatch](a, scale, alibi, attn_mask, causal_mask, select_nfltmax_at_0, len, max); + if (attn_mask_prec == ov::element::f32) { + funcs_fp32[dispatch](a, scale, alibi, static_cast(attn_mask), causal_mask, select_nfltmax_at_0, len, max); + } else { + funcs_bf16[dispatch](a, scale, alibi, static_cast(attn_mask), causal_mask, select_nfltmax_at_0, len, max); + } float sum = 0.0f; // exp sum diff --git a/src/plugins/intel_cpu/src/nodes/kernels/x64/brgemm_kernel.cpp b/src/plugins/intel_cpu/src/nodes/kernels/x64/brgemm_kernel.cpp new file mode 100644 index 00000000000000..eda7a3ae3192a7 --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/kernels/x64/brgemm_kernel.cpp @@ -0,0 +1,367 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "brgemm_kernel.hpp" + +#include "dnnl_extension_utils.h" +#include "utils/cpu_utils.hpp" +#include +#include + +using namespace dnnl::impl::cpu::x64; +using namespace dnnl::impl; +using namespace dnnl::impl::cpu::x64::matmul; + +#define THROW_ERROR(...) OPENVINO_THROW("brgemm executor Init Failure '", __VA_ARGS__) +namespace ov { +namespace intel_cpu { + +BrgemmKernel::BrgemmKernel(size_t M, size_t N, size_t K, size_t lda, size_t ldb, size_t ldc, bool b_transposed) + : M(M), + K(K), + N(N), + lda(lda), + ldb(ldb), + ldc(ldc), + b_transposed(b_transposed), + inType(ov::element::bf16) { + // blocking M + M_blk = matmulOptimalM; + M_tail = M % M_blk; + brgVnniFactor = 4 / inType.size(); + if (!mayiuse(avx512_core_bf16)) + THROW_ERROR("brgemm bf16bf16f32 kernel could only be used above avx512_bf16"); + bool isAMXSupported = mayiuse(avx512_core_amx); + // blocing N + N_tail = N % N_blk; + + // blocing K + K_blk = isAMXSupported ? 32 : K; + K_tail = K % K_blk; + if (isAMXSupported && K_tail) { + K_tail = rnd_up(K_tail, 2); + } + size_t vlen = cpu_isa_traits::vlen; + // copied K must be round up by vlen / inType.size(), otherwise copy B kernel may access wrong memory + packedBSize = rnd_up(K, vlen / inType.size()) * rnd_up(N, N_blk) * inType.size(); + size_t brg0BaseIdx = std::numeric_limits::max(); + for (size_t m = 0; m < 2; m++) { + for (size_t k = 0; k < 2; k++) { + for (size_t n = 0; n < 2; n++) { + auto& brgemmCtx = brgCtxs[getBrgIdx(m, k, n)]; + + auto M_ = m ? M_tail : M < M_blk ? 0 : M_blk; + auto N_ = n ? N_tail : N - N_tail; + auto K_ = k ? K_tail : K - K % K_blk; + auto beta = k && brgCtxs[getBrgIdx(m, 0, n)].K != 0 ? 1.0f : 0.0f; + + brgemmCtx.M = M_; + brgemmCtx.N = N_; + brgemmCtx.K = K_; + brgemmCtx.LDA = k ? K_blk : lda; + brgemmCtx.LDB = rnd_up(N, N_blk); // B is copied with bf16 + brgemmCtx.LDC = ldc; + brgemmCtx.dt_in0 = static_cast(DnnlExtensionUtils::ElementTypeToDataType(inType)); + brgemmCtx.dt_in1 = static_cast(DnnlExtensionUtils::ElementTypeToDataType(inType)); + brgemmCtx.beta = beta; + + // don't create brgemm kernels for empty tiles + if (M_ != 0 && K_ != 0 && N_ != 0) { + if (brg0BaseIdx == std::numeric_limits::max()) + brg0BaseIdx = getBrgIdx(m, k, n); + init_brgemm(brgemmCtx, brgKernels[getBrgIdx(m, k, n)], isAMXSupported); + } + } + } + } + + auto& brgemmCtx0 = brgCtxs[brg0BaseIdx]; + + if (brgemmCtx0.is_with_amx && K_tail) { + init_brgemm_copy_a(brgCopyAKernel, K, K_blk, K_tail, K_blk, brgemmCtx0.dt_in0, false, lda * inType.size()); + packedASize = M_blk * rnd_up(K, K_blk) * inType.size(); + } + + if (brgemmCtx0.is_with_amx || inType == ov::element::bf16) { + size_t b_stride = 0; + // must set actual stride when stride is not K/N + if (b_transposed) { + b_stride = ldb == K ? 0 : ldb * inType.size(); + } else { + b_stride = ldb == N ? 0 : ldb * inType.size(); + } + // K should use the original K + init_brgemm_copy_b(brgCopyBKernel, + N, + N_blk, + N_tail, + brgemmCtx0.LDB, + K, + brgemmCtx0.is_with_amx, + brgemmCtx0.dt_in0, + brgemmCtx0.dt_in1, + b_transposed, + b_stride); + } +} + +const size_t BrgemmKernel::get_scratch_a_size() const { + return packedASize; +} + +const size_t BrgemmKernel::get_scratch_b_size() const { + return packedBSize; +} + +void BrgemmKernel::init_brgemm(brgemmCtx& ctx, + std::unique_ptr& brgKernel, + bool use_amx) { + brgemm_t brgDesc; + + const bool is_int8 = + one_of(ctx.dt_in0, data_type::u8, data_type::s8) && one_of(ctx.dt_in1, data_type::u8, data_type::s8); + auto isa = use_amx ? isa_undef + : ctx.dt_in0 == dnnl_data_type_t::dnnl_bf16 ? avx512_core_bf16 + : (is_int8 ? avx512_core_vnni : avx512_core); + auto status = brgemm_desc_init(&brgDesc, + isa, + brgemm_addr, + ctx.dt_in0, + ctx.dt_in1, + ctx.transpose_a, + ctx.transpose_b, + brgemm_row_major, + 1.f, + ctx.beta, + ctx.LDA, + ctx.LDB, + ctx.LDC, + ctx.M, + ctx.N, + ctx.K, + nullptr); + if (status != dnnl_success) { + THROW_ERROR("cannot be executed due to invalid brgconv params"); + } + + ctx.is_with_amx = use_amx; + status = brgemm_init_tiles(brgDesc, ctx.palette); + if (use_amx) { + amx_tile_configure(ctx.palette); + } + + ctx.is_with_comp = ctx.dt_in0 == dnnl_data_type_t::dnnl_s8 && !ctx.is_with_amx; + + brgemm_kernel_t* brgKernel_ = nullptr; + status = brgemm_kernel_create(&brgKernel_, brgDesc); + if (status != dnnl_success) { + THROW_ERROR("cannot be executed due to invalid brgconv params"); + } + brgKernel.reset(brgKernel_); +} +void BrgemmKernel::init_brgemm_copy_a( + std::unique_ptr& brgCopyKernel, + size_t K, + size_t K_blk, + size_t K_tail, + size_t LDA, + dnnl_data_type_t dt_in0, + bool transpose, + size_t copy_A_src_stride) { + brgemm_matmul_conf_t brgCopyKernelConf; + brgCopyKernelConf.src_tag = dnnl_abcd; + brgCopyKernelConf.K = K; + brgCopyKernelConf.K_tail = K_tail; + brgCopyKernelConf.K_blk = K_blk; + brgCopyKernelConf.use_buffer_a_tail_only = false; + //padding K tail to K_blk, LDA is the stride for target tensor + brgCopyKernelConf.LDA = LDA; + brgCopyKernelConf.has_zero_point_b = false; + brgCopyKernelConf.s8s8_compensation_required = false; + brgCopyKernelConf.wei_zp_type = dnnl::impl::cpu::x64::none; + brgCopyKernelConf.src_zp_type = dnnl::impl::cpu::x64::none; + brgCopyKernelConf.src_dt = dt_in0; + brgCopyKernelConf.copy_A_src_stride = copy_A_src_stride; + brgCopyKernelConf.a_dt_sz = DnnlExtensionUtils::sizeOfDataType(static_cast(dt_in0)); + // copied A has the same precision of original + brgCopyKernelConf.tr_a_dt_sz = DnnlExtensionUtils::sizeOfDataType(static_cast(dt_in0)); + brgCopyKernelConf.transposed_A = transpose; + brgCopyKernelConf.isa = avx512_core_amx; + + create_brgemm_matmul_copy_a(brgCopyKernel, &brgCopyKernelConf); +} + +void BrgemmKernel::init_brgemm_copy_b( + std::unique_ptr& brgCopyKernel, + size_t N, + size_t N_blk, + size_t N_tail, + size_t LDB, + size_t K, + bool is_with_amx, + dnnl_data_type_t dt_in0, + dnnl_data_type_t dt_in1, + bool transpose, + size_t copy_B_wei_stride) { + brgemm_matmul_conf_t brgCopyKernelConf; + brgCopyKernelConf.src_dt = dt_in0; + brgCopyKernelConf.wei_dt = dt_in1; + brgCopyKernelConf.wei_n_blk = N_blk; + // B could come from strided tensor, must use copy_B_wei_stride if set. + brgCopyKernelConf.wei_tag = copy_B_wei_stride != 0 ? transpose ? dnnl_adbc : dnnl_acbd : transpose ? dnnl_ba : dnnl_ab; + brgCopyKernelConf.copy_B_wei_stride = copy_B_wei_stride; + // LDB here is for the target tensor, not source tensor + brgCopyKernelConf.LDB = LDB; + brgCopyKernelConf.N = N; + brgCopyKernelConf.N_tail = N_tail; + brgCopyKernelConf.N_blk = N_blk; + brgCopyKernelConf.K = K; + brgCopyKernelConf.K_blk = K; + brgCopyKernelConf.K_tail = 0; + brgCopyKernelConf.N_chunk_elems = brgCopyKernelConf.N_blk; + brgCopyKernelConf.b_dt_sz = + DnnlExtensionUtils::sizeOfDataType(static_cast(brgCopyKernelConf.src_dt)); + brgCopyKernelConf.tr_b_dt_sz = + DnnlExtensionUtils::sizeOfDataType(static_cast(brgCopyKernelConf.src_dt)); + brgCopyKernelConf.req_wei_vnni_downconvert = false; + + if (is_with_amx) { + brgCopyKernelConf.isa = avx512_core_amx; + brgCopyKernelConf.s8s8_compensation_required = false; + } else { + brgCopyKernelConf.isa = dt_in0 == dnnl_data_type_t::dnnl_bf16 ? avx512_core_bf16 : avx512_core_vnni; + } + + brgCopyKernelConf.has_zero_point_a = false; + brgCopyKernelConf.has_zero_point_b = false; + brgCopyKernelConf.src_zp_type = dnnl::impl::cpu::x64::none; + + auto ret = create_brgemm_matmul_copy_b(brgCopyKernel, &brgCopyKernelConf); + if (ret != dnnl::impl::status_t::dnnl_success) + THROW_ERROR("cannot create_brgemm_matmul_copy_b kernel"); +} + +void BrgemmKernel::copy_buffer_b(void* b, void* scratch_b) { + auto ptr_b = reinterpret_cast(b); + auto ptr_scartch_b = reinterpret_cast(scratch_b); + if (brgCopyBKernel) { + for (size_t nb = 0; nb < div_up(N, N_blk); nb++) { + auto N_stride = b_transposed ? ldb : 1; + auto pCopyKernel0In = ptr_b + nb * N_blk * inType.size() * N_stride; + auto pCopyKernel0Out = ptr_scartch_b + nb * N_blk * brgVnniFactor * inType.size(); + + auto ctx = jit_brgemm_matmul_copy_b_t::ctx_t(); + + const bool is_N_tail = (N - nb * N_blk < N_blk); + ctx.current_N_blk = is_N_tail ? N_tail : N_blk; + ctx.src = pCopyKernel0In; + ctx.tr_src = pCopyKernel0Out; + ctx.compensation_ptr = nullptr; + ctx.zp_a_compensation_ptr = nullptr; + ctx.zp_a_neg_value_ptr = nullptr; + ctx.current_K_start = 0; + ctx.current_K_iters = K; + (*brgCopyBKernel)(&ctx); + } + } +} + +void BrgemmKernel::executeGemmPackedB(bool is_M_tail, void* a, void* repacked_b, void* c, void* wsp, void* scratch_a) { + auto ptr_A = reinterpret_cast(a); + auto ptr_C = reinterpret_cast(c); + auto ptr_scartch_a = reinterpret_cast(scratch_a); + auto ptr_scartch_b = reinterpret_cast(repacked_b); + uint8_t* ptr_a_tail = nullptr; + + size_t brgIdx0 = getBrgIdx(0, 0, 0); + // The step for matrix A over main K dimension + size_t K0_step0 = brgCtxs[brgIdx0].K; + auto cur_M_blk = is_M_tail ? M_tail : M_blk; + if (brgCopyAKernel) { + // only copy tailed data; + size_t K_offset = K < K_blk ? 0 : K0_step0 * inType.size(); + auto pCopyKernelIn = ptr_A + K_offset; + auto pCopyKernelOut = ptr_scartch_a; + + auto ctx = jit_brgemm_matmul_copy_a_t::ctx_t(); + + ctx.current_M_blk = cur_M_blk; + ctx.zp_b_compensation_buffer_ptr = nullptr; + ctx.zp_a_compensation_result_ptr = nullptr; + ctx.zp_b_neg_value_ptr = nullptr; + ctx.zp_ab_comp_ptr = nullptr; + ctx.src = pCopyKernelIn; + ctx.tr_src = pCopyKernelOut; + ctx.current_K_start = 0; + ctx.current_K_blk = K % K_blk; + + (*brgCopyAKernel)(&ctx); + + ptr_a_tail = pCopyKernelOut; + } + size_t count_N = 0; + for (size_t n = 0; n < 2; n++) { + size_t count_K = 0; + for (size_t k = 0; k < 2; k++) { + size_t mIdx = is_M_tail ? 1 : 0; + auto& brgemmCtx = brgCtxs[getBrgIdx(mIdx, k, n)]; + if (brgemmCtx.K != 0 && brgemmCtx.N != 0) { + auto local_a_ptr = k > 0 ? ptr_a_tail : ptr_A; + auto B_stride = (k * count_K + n * count_N * brgVnniFactor) * inType.size(); + auto weight_ptr = ptr_scartch_b + B_stride; + auto C_stride = n * count_N * ov::element::f32.size(); + auto out_ptr = ptr_C + C_stride; + callBrgemm(brgemmCtx, + brgKernels[getBrgIdx(mIdx, k, n)], + local_a_ptr, + weight_ptr, + out_ptr, + wsp); + // stride K, N if body kernel is executed. + if (k == 0) { + count_K = brgemmCtx.K * brgemmCtx.LDB; + } + if (n == 0) { + count_N = brgemmCtx.N; + } + } + } + } +} + +void BrgemmKernel::executeGemm(void* a, void* b, void* c, void* wsp, void* scratch_a, void* scratch_b) { + auto ptr_A = reinterpret_cast(a); + auto ptr_B = reinterpret_cast(b); + auto ptr_C = reinterpret_cast(c); + + copy_buffer_b(ptr_B, scratch_b); + + for (size_t mb = 0; mb < div_up(M, M_blk); mb++) { + const bool is_M_tail = (M - mb * M_blk < M_blk); + auto ptr_a = ptr_A + (mb * M_blk * lda) * inType.size(); + auto ptr_c = ptr_C + (mb * M_blk * ldc) * inType.size(); + executeGemmPackedB(is_M_tail, ptr_a, scratch_b, wsp, ptr_c, scratch_a); + } +} +void BrgemmKernel::callBrgemm(brgemmCtx& ctx, + std::unique_ptr& brgKernel, + const void* pin0, + const void* pin1, + void* pout, + void* wsp) { + if (ctx.is_with_amx) + amx_tile_configure(ctx.palette); + if (ctx.is_with_comp) { + brgemm_post_ops_data_t post_ops_data; + brgemm_kernel_execute_postops(brgKernel.get(), 1, pin0, pin1, nullptr, pout, pout, post_ops_data, wsp); + } else { + brgemm_batch_element_t addr_batch; + addr_batch.ptr.A = pin0; + addr_batch.ptr.B = pin1; + brgemm_kernel_execute(brgKernel.get(), 1, &addr_batch, pout, wsp, nullptr); + } +} + +} // namespace intel_cpu +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/src/nodes/kernels/x64/brgemm_kernel.hpp b/src/plugins/intel_cpu/src/nodes/kernels/x64/brgemm_kernel.hpp new file mode 100644 index 00000000000000..a0877a41019fba --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/kernels/x64/brgemm_kernel.hpp @@ -0,0 +1,106 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace ov { +namespace intel_cpu { + +class BrgemmKernel { +public: + // Construct brgemm kernel for matmul (M, K) * (K, N)/(N, K)^T + // BF16 * BF16 -> FP32 + // lda is the leading dimension for A matrix + // ldb is the leading dimension for B matrix + // ldc is the leading dimension for C matrix + // b_transpose indicates wheter B matrix is transposed. + BrgemmKernel(size_t M, size_t N, size_t K, size_t lda, size_t ldb, size_t ldc, bool b_transposed = false); + // execute all M + void executeGemm(void* a, void* b, void* c, void* wsp, void* scratch_a, void* scratch_b); + // execute m_blk + void executeGemmPackedB(bool is_M_tail, void* a, void* repacked_b, void* c, void* wsp, void* scratch_a); + + void copy_buffer_b(void* b, void* scratch_b); + // bytes needed to place scratch buffer a + const size_t get_scratch_a_size() const; + // bytes needed to place scratch buffer b + const size_t get_scratch_b_size() const; + const size_t get_mblk_size() const { + return matmulOptimalM; + } + const size_t get_k_blk() const { + return K_blk; + } + const size_t get_wsp_size() const { + return 4 * 1024; + } + +private: + size_t M = 0, M_blk = 0, M_tail = 0; + size_t K = 0, K_blk = 0, K_tail = 0, N = 0, N_tail = 0; + size_t lda = 0, ldb = 0, ldc = 0; + bool b_transposed = false; + size_t brgVnniFactor = 0; + size_t packedBSize = 0; + size_t packedASize = 0; + ov::element::Type inType; + static constexpr size_t N_blk = 32; + static constexpr size_t MHA_BRGEMM_KERNELS_NUM = 8; + static constexpr size_t matmulOptimalM = 32; + struct brgemmCtx { + size_t M = 0, N = 0, K = 0, LDA = 0, LDB = 0, LDC = 0; + dnnl_data_type_t dt_in0 = dnnl_data_type_undef; + dnnl_data_type_t dt_in1 = dnnl_data_type_undef; + char palette[64]; + bool is_with_amx = false; + bool is_with_comp = false; + bool transpose_a = false; + bool transpose_b = false; + float beta = 0.0f; + }; + brgemmCtx brgCtxs[MHA_BRGEMM_KERNELS_NUM]; + std::unique_ptr brgKernels[MHA_BRGEMM_KERNELS_NUM]; + std::unique_ptr brgCopyAKernel; + std::unique_ptr brgCopyBKernel; + size_t getBrgIdx(size_t mIdx, size_t kIdx, size_t nIdx) { + return mIdx * 4 + kIdx * 2 + nIdx; + } + void init_brgemm(brgemmCtx& ctx, std::unique_ptr& brgKernel, bool use_amx); + // LDA, LDB is used for stride of target memory + void init_brgemm_copy_a(std::unique_ptr& brgCopyKernel, + size_t K, + size_t K_blk, + size_t K_tail, + size_t LDA, + dnnl_data_type_t dt_in0, + bool transpose = false, + size_t copy_A_src_stride = 0); + + void init_brgemm_copy_b(std::unique_ptr& brgCopyKernel, + size_t N, + size_t N_blk, + size_t N_tail, + size_t LDB, + size_t K, + bool is_with_amx, + dnnl_data_type_t dt_in0, + dnnl_data_type_t dt_in1, + bool transpose = false, + size_t copy_B_wei_stride = 0); + + void callBrgemm(brgemmCtx& ctx, + std::unique_ptr& brgKernel, + const void* pin0, + const void* pin1, + void* pout, + void* wsp); +}; +} // namespace intel_cpu +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/src/nodes/log_softmax.cpp b/src/plugins/intel_cpu/src/nodes/log_softmax.cpp index c8f2af91020d23..5dd7653d060c07 100644 --- a/src/plugins/intel_cpu/src/nodes/log_softmax.cpp +++ b/src/plugins/intel_cpu/src/nodes/log_softmax.cpp @@ -63,7 +63,7 @@ void LogSoftmax::initSupportedPrimitiveDescriptors() { } void LogSoftmax::prepareParams() { - const auto &dims = getParentEdgesAtPort(0)[0]->getMemory().getStaticDims(); + const auto &dims = getParentEdgeAt(0)->getMemory().getStaticDims(); reducedAxisStride = 1; axisStep = 1; isLastDim = false; @@ -86,8 +86,8 @@ void LogSoftmax::executeDynamicImpl(dnnl::stream strm) { } void LogSoftmax::execute(dnnl::stream strm) { - const float *srcData = reinterpret_cast(getParentEdgeAt(0)->getMemoryPtr()->getData()); - float* dstData = reinterpret_cast(getChildEdgesAtPort(0)[0]->getMemoryPtr()->getData()); + const float *srcData = getSrcDataAtPortAs(0); + float* dstData = getDstDataAtPortAs(0); if (isLastDim) { parallel_for(axisStep, [&](size_t i) { diff --git a/src/plugins/intel_cpu/src/nodes/lrn.cpp b/src/plugins/intel_cpu/src/nodes/lrn.cpp index bf0732fc04aa4c..f0efb8ba5ed0e6 100644 --- a/src/plugins/intel_cpu/src/nodes/lrn.cpp +++ b/src/plugins/intel_cpu/src/nodes/lrn.cpp @@ -161,8 +161,8 @@ std::shared_ptr Lrn::getSrcMemDesc(const dnnl::primitive_desc &prim_ } void Lrn::prepareParams() { - auto srcMemPtr = getParentEdgeAt(0)->getMemoryPtr(); - auto dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); + auto srcMemPtr = getSrcMemoryAtPort(0); + auto dstMemPtr = getDstMemoryAtPort(0); if (!srcMemPtr || !srcMemPtr->isAllocated()) OPENVINO_THROW(errorPrefix, " input memory did not allocate"); if (!dstMemPtr || !dstMemPtr->isAllocated()) diff --git a/src/plugins/intel_cpu/src/nodes/mathematics.cpp b/src/plugins/intel_cpu/src/nodes/mathematics.cpp index d22ed520ca78b9..e248c88e24165e 100644 --- a/src/plugins/intel_cpu/src/nodes/mathematics.cpp +++ b/src/plugins/intel_cpu/src/nodes/mathematics.cpp @@ -7,8 +7,8 @@ #include #include "openvino/core/parallel.hpp" +#include "openvino/opsets/opset1.hpp" #include "mathematics.h" -#include "utils/general_utils.h" #include namespace ov { @@ -68,9 +68,9 @@ void Math::executeDynamicImpl(dnnl::stream strm) { } void Math::execute(dnnl::stream strm) { - size_t dataSize = getChildEdgesAtPort(0)[0]->getMemory().getShape().getElementsCount(); - const float *src_data = reinterpret_cast(getParentEdgeAt(0)->getMemoryPtr()->getData()); - float* dst_data = reinterpret_cast(getChildEdgeAt(0)->getMemoryPtr()->getData()); + size_t dataSize = getChildEdgeAt(0)->getMemory().getShape().getElementsCount(); + const float *src_data = getSrcDataAtPortAs(0); + float* dst_data = getDstDataAtPortAs(0); switch (getAlgorithm()) { case Algorithm::MathAbs: diff --git a/src/plugins/intel_cpu/src/nodes/matmul.cpp b/src/plugins/intel_cpu/src/nodes/matmul.cpp index 9de62ae2ada01c..91886211416593 100644 --- a/src/plugins/intel_cpu/src/nodes/matmul.cpp +++ b/src/plugins/intel_cpu/src/nodes/matmul.cpp @@ -170,7 +170,7 @@ void MatMul::setPostOps(dnnl::primitive_attr& attr, const VectorDims& dims, bool bool isINT8 = canBeExecutedInInt8(); - DnnlPostOpsComposer dnnlpoc(getEngine(), attr, ops, postOpsArgs, dims, dims.size() - 1, isINT8, 1 << (dims.size() - 1), getDQScales(), withBiases); + DnnlPostOpsComposerLegacy dnnlpoc(getEngine(), attr, ops, postOpsArgs, dims, dims.size() - 1, isINT8, 1 << (dims.size() - 1), getDQScales(), withBiases); for (size_t i = 0; i < fusedWith.size(); ++i) { auto& node = fusedWith[i]; @@ -524,9 +524,9 @@ ov::element::Type MatMul::getRuntimePrecision() const { } void MatMul::prepareParams() { - auto dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); - auto src0MemPtr = getParentEdgeAt(0)->getMemoryPtr(); - auto src1MemPtr = getParentEdgeAt(1)->getMemoryPtr(); + auto dstMemPtr = getDstMemoryAtPort(0); + auto src0MemPtr = getSrcMemoryAtPort(0); + auto src1MemPtr = getSrcMemoryAtPort(1); if (!dstMemPtr || !dstMemPtr->isAllocated()) OPENVINO_THROW(errorPrefix, " did not allocate destination memory"); if (!src0MemPtr || !src0MemPtr->isAllocated() || !src1MemPtr || !src1MemPtr->isAllocated()) @@ -564,7 +564,7 @@ void MatMul::prepareParams() { DnnlMemoryDescPtr dnnlBiasMemDesc = nullptr; if (withBiases) { - auto biasMemory = getParentEdgeAt(2)->getMemoryPtr(); + auto biasMemory = getSrcMemoryAtPort(2); if (!biasMemory || !biasMemory->isAllocated()) OPENVINO_THROW(errorPrefix, " did not allocate bias memory"); dnnlBiasMemDesc = biasMemory->getDescWithType(); @@ -623,7 +623,7 @@ void MatMul::prepareParams() { primArgs[DNNL_ARG_WEIGHTS_0] = src1MemPtr->getPrimitive(); primArgs[DNNL_ARG_DST] = dstMemPtr->getPrimitive(); if (withBiases) - primArgs[DNNL_ARG_BIAS] = getParentEdgeAt(2)->getMemoryPtr()->getPrimitive(); + primArgs[DNNL_ARG_BIAS] = getSrcMemoryAtPort(2)->getPrimitive(); appendPostOpArgs(*attr, primArgs, postOpsArgs); #ifdef CPU_DEBUG_CAPS diff --git a/src/plugins/intel_cpu/src/nodes/matrix_nms.cpp b/src/plugins/intel_cpu/src/nodes/matrix_nms.cpp index 8bc913311ecd03..e8e31a2b805832 100644 --- a/src/plugins/intel_cpu/src/nodes/matrix_nms.cpp +++ b/src/plugins/intel_cpu/src/nodes/matrix_nms.cpp @@ -300,8 +300,8 @@ void MatrixNms::executeDynamicImpl(dnnl::stream strm) { } void MatrixNms::execute(dnnl::stream strm) { - const float* boxes = reinterpret_cast(getParentEdgeAt(NMS_BOXES)->getMemoryPtr()->getData()); - const float* scores = reinterpret_cast(getParentEdgeAt(NMS_SCORES)->getMemoryPtr()->getData()); + const float* boxes = getSrcDataAtPortAs(NMS_BOXES); + const float* scores = getSrcDataAtPortAs(NMS_SCORES); ov::parallel_for2d(m_numBatches, m_numClasses, [&](size_t batchIdx, size_t classIdx) { if (classIdx == static_cast(m_backgroundClass)) { @@ -368,9 +368,9 @@ void MatrixNms::execute(dnnl::stream strm) { } } - auto selectedOutputsMemPtr = getChildEdgesAtPort(NMS_SELECTED_OUTPUTS)[0]->getMemoryPtr(); - auto selectedIndicesMemPtr = getChildEdgesAtPort(NMS_SELECTED_INDICES)[0]->getMemoryPtr(); - auto validOutputsMemPtr = getChildEdgesAtPort(NMS_VALID_OUTPUTS)[0]->getMemoryPtr(); + auto selectedOutputsMemPtr = getDstMemoryAtPort(NMS_SELECTED_OUTPUTS); + auto selectedIndicesMemPtr = getDstMemoryAtPort(NMS_SELECTED_INDICES); + auto validOutputsMemPtr = getDstMemoryAtPort(NMS_VALID_OUTPUTS); // NMS-alike nodes are always transformed to NMSIEInternal node in case of legacy api, for compatibility. // And on the other hand in case of api 2.0, keep them internal dynamic for better performance and functionality. @@ -378,9 +378,9 @@ void MatrixNms::execute(dnnl::stream strm) { size_t totalBox = std::accumulate(m_numPerBatch.begin(), m_numPerBatch.end(), size_t(0)); redefineOutputMemory({{totalBox, 6}, {totalBox, 1}, {m_numBatches}}); } - float* selectedOutputs = reinterpret_cast(selectedOutputsMemPtr->getData()); - int* selectedIndices = reinterpret_cast(selectedIndicesMemPtr->getData()); - int* validOutputs = reinterpret_cast(validOutputsMemPtr->getData()); + float* selectedOutputs = selectedOutputsMemPtr->getDataAs(); + int* selectedIndices = selectedIndicesMemPtr->getDataAs(); + int* validOutputs = validOutputsMemPtr->getDataAs(); for (size_t i = 0; i < m_numPerBatch.size(); i++) validOutputs[i] = static_cast(m_numPerBatch[i]); diff --git a/src/plugins/intel_cpu/src/nodes/memory.cpp b/src/plugins/intel_cpu/src/nodes/memory.cpp index c2e7978da0679e..532be191fa2526 100644 --- a/src/plugins/intel_cpu/src/nodes/memory.cpp +++ b/src/plugins/intel_cpu/src/nodes/memory.cpp @@ -123,13 +123,11 @@ MemoryOutputBase::MemoryOutputBase(const std::string id, const Shape& input_shape, const ov::element::Type& input_prc, const GraphContext::CPtr context) : - Node(type, name, context), MemoryNode(id) { + Node(type, {input_shape}, {}, {input_prc}, {}, name, context), MemoryNode(id) { isDynamic = input_shape.isDynamic(); if (isDynamic) { shapeInference = PassThroughShapeInferFactory().makeShapeInfer(); } - inputShapes.emplace_back(input_shape); - addOriginalInputPrecision(input_prc); } MemoryOutputBase::~MemoryOutputBase() { @@ -256,7 +254,7 @@ void MemoryOutput::assignExtMemory(const MemoryPtr& mem, const MemoryDescPtr& me } void MemoryOutput::execute(dnnl::stream strm) { - auto inputMem = getParentEdgeAt(0)->getMemoryPtr(); + auto inputMem = getSrcMemoryAtPort(0); OPENVINO_ASSERT(assignedMem, "MemoryOutput ", getName(), @@ -269,7 +267,7 @@ void MemoryOutput::execute(dnnl::stream strm) { void MemoryOutput::executeDynamicImpl(dnnl::stream strm) { //first we have to resize the output memory - auto inputMem = getParentEdgeAt(0)->getMemoryPtr(); + auto inputMem = getSrcMemoryAtPort(0); const auto& newDims = inputMem->getStaticDims(); OPENVINO_ASSERT(extMemDesc, "MemoryOutput ", @@ -543,7 +541,7 @@ void MemoryInput::execute(dnnl::stream strm) { if (!isExecutableFlag) return; auto&& src = getParentEdgeAt(0)->getMemory(); - auto&& dst = getChildEdgesAtPort(0).front()->getMemoryPtr(); + auto&& dst = getDstMemoryAtPort(0); dst->load(src); } diff --git a/src/plugins/intel_cpu/src/nodes/mha.cpp b/src/plugins/intel_cpu/src/nodes/mha.cpp index 5a4f4e5dcf3776..e46bcb09b700e3 100644 --- a/src/plugins/intel_cpu/src/nodes/mha.cpp +++ b/src/plugins/intel_cpu/src/nodes/mha.cpp @@ -14,6 +14,7 @@ #include "transformations/cpu_opset/x64/op/mha.hpp" #include "utils/bfloat16.hpp" #include "utils/general_utils.h" +#include "utils/ngraph_utils.hpp" #include #include @@ -900,11 +901,11 @@ void MHA::prepareParams() { return new_vec; }; - const auto memDescTranspose0In0 = getParentEdgeAt(0)->getMemoryPtr()->getDescWithType(); - const auto memDescTranspose1In0 = getParentEdgeAt(1)->getMemoryPtr()->getDescWithType(); - const auto memDescAddIn1 = getParentEdgeAt(2)->getMemoryPtr()->getDescWithType(); - const auto memDescTranspose2In0 = getParentEdgeAt(3)->getMemoryPtr()->getDescWithType(); - const auto memDescOut = getChildEdgeAt(0)->getMemoryPtr()->getDescWithType(); + const auto memDescTranspose0In0 = getSrcMemoryAtPort(0)->getDescWithType(); + const auto memDescTranspose1In0 = getSrcMemoryAtPort(1)->getDescWithType(); + const auto memDescAddIn1 = getSrcMemoryAtPort(2)->getDescWithType(); + const auto memDescTranspose2In0 = getSrcMemoryAtPort(3)->getDescWithType(); + const auto memDescOut = getDstMemoryAtPort(0)->getDescWithType(); dimsTranspose0In0 = memDescTranspose0In0->getBlockDims(); dimsTranspose1In0 = memDescTranspose1In0->getBlockDims(); @@ -1213,11 +1214,11 @@ void MHA::callBrgemm(brgemmCtx& ctx, std::unique_ptr& brgKernel template void MHA::mhaImpl() { - const uint8_t* pTranspose0In0 = reinterpret_cast(getParentEdgeAt(0)->getMemoryPtr()->getData()); - const uint8_t* pTranspose1In0 = reinterpret_cast(getParentEdgeAt(1)->getMemoryPtr()->getData()); - const float* pAddIn1 = reinterpret_cast(getParentEdgeAt(2)->getMemoryPtr()->getData()); - const uint8_t* pTranspose2In0 = reinterpret_cast(getParentEdgeAt(3)->getMemoryPtr()->getData()); - uint8_t* pout = reinterpret_cast(getChildEdgeAt(0)->getMemoryPtr()->getData()); + const uint8_t* pTranspose0In0 = getSrcDataAtPortAs(0); + const uint8_t* pTranspose1In0 = getSrcDataAtPortAs(1); + const float* pAddIn1 = getSrcDataAtPortAs(2); + const uint8_t* pTranspose2In0 = getSrcDataAtPortAs(3); + uint8_t* pout = getDstDataAtPortAs(0); auto outPrcSize = outputPrecision.size(); diff --git a/src/plugins/intel_cpu/src/nodes/multiclass_nms.cpp b/src/plugins/intel_cpu/src/nodes/multiclass_nms.cpp index 362179870b545e..13268bb4e76cff 100644 --- a/src/plugins/intel_cpu/src/nodes/multiclass_nms.cpp +++ b/src/plugins/intel_cpu/src/nodes/multiclass_nms.cpp @@ -224,8 +224,8 @@ void MultiClassNms::executeDynamicImpl(dnnl::stream strm) { } void MultiClassNms::execute(dnnl::stream strm) { - const float* boxes = reinterpret_cast(getParentEdgeAt(NMS_BOXES)->getMemoryPtr()->getData()); - const float* scores = reinterpret_cast(getParentEdgeAt(NMS_SCORES)->getMemoryPtr()->getData()); + const float* boxes = getSrcDataAtPortAs(NMS_BOXES); + const float* scores = getSrcDataAtPortAs(NMS_SCORES); auto dims_boxes = getParentEdgeAt(NMS_BOXES)->getMemory().getStaticDims(); auto dims_scores = getParentEdgeAt(NMS_SCORES)->getMemory().getStaticDims(); @@ -236,9 +236,9 @@ void MultiClassNms::execute(dnnl::stream strm) { const bool has_roinum = getOriginalInputsNumber() == 3; const auto shared = dims_scores.size() == 3; // bboxes shared among classes - auto selectedOutputsMemPtr = getChildEdgesAtPort(NMS_SELECTEDOUTPUTS)[0]->getMemoryPtr(); - auto selectedIndicesMemPtr = getChildEdgesAtPort(NMS_SELECTEDINDICES)[0]->getMemoryPtr(); - auto validOutputsMemPtr = getChildEdgesAtPort(NMS_SELECTEDNUM)[0]->getMemoryPtr(); + auto selectedOutputsMemPtr = getDstMemoryAtPort(NMS_SELECTEDOUTPUTS); + auto selectedIndicesMemPtr = getDstMemoryAtPort(NMS_SELECTEDINDICES); + auto validOutputsMemPtr = getDstMemoryAtPort(NMS_SELECTEDNUM); auto boxesStrides = getParentEdgeAt(NMS_BOXES)->getMemory().getDescWithType()->getStrides(); auto scoresStrides = getParentEdgeAt(NMS_SCORES)->getMemory().getDescWithType()->getStrides(); @@ -246,7 +246,7 @@ void MultiClassNms::execute(dnnl::stream strm) { int* roisnum = nullptr; VectorDims roisnumStrides; if (has_roinum) { - roisnum = reinterpret_cast(getParentEdgeAt(NMS_ROISNUM)->getMemoryPtr()->getData()); + roisnum = getSrcDataAtPortAs(NMS_ROISNUM); roisnumStrides = getParentEdgeAt(NMS_ROISNUM)->getMemory().getDescWithType()->getStrides(); } @@ -349,9 +349,9 @@ void MultiClassNms::execute(dnnl::stream strm) { size_t totalBox = std::accumulate(m_selected_num.begin(), m_selected_num.end(), size_t(0)); redefineOutputMemory({{totalBox, 6}, {totalBox, 1}, {m_numBatches}}); } - int* selected_indices = reinterpret_cast(selectedIndicesMemPtr->getData()); - float* selected_outputs = reinterpret_cast(selectedOutputsMemPtr->getData()); - int* selected_num = reinterpret_cast(validOutputsMemPtr->getData()); + int* selected_indices = selectedIndicesMemPtr->getDataAs(); + float* selected_outputs = selectedOutputsMemPtr->getDataAs(); + int* selected_num = validOutputsMemPtr->getDataAs(); auto _flattened_index = [](int batch_idx, int box_idx, int num_box) { return batch_idx * num_box + box_idx; diff --git a/src/plugins/intel_cpu/src/nodes/multinomial.cpp b/src/plugins/intel_cpu/src/nodes/multinomial.cpp index dba1ad7df0da9c..cefea23a8f4cd7 100644 --- a/src/plugins/intel_cpu/src/nodes/multinomial.cpp +++ b/src/plugins/intel_cpu/src/nodes/multinomial.cpp @@ -5,6 +5,8 @@ #include "multinomial.hpp" #include "openvino/op/multinomial.hpp" +#include +#include #include "utils/bfloat16.hpp" namespace ov { @@ -93,10 +95,10 @@ void Multinomial::prepareParams() { if (m_num_samples_precision == ov::element::i32) { m_samples_count = - reinterpret_cast(getParentEdgeAt(NUM_SAMPLES_PORT)->getMemoryPtr()->getData())[0]; + getSrcDataAtPortAs(NUM_SAMPLES_PORT)[0]; } else { m_samples_count = - reinterpret_cast(getParentEdgeAt(NUM_SAMPLES_PORT)->getMemoryPtr()->getData())[0]; + getSrcDataAtPortAs(NUM_SAMPLES_PORT)[0]; } m_batches_count = probs_shape[0]; @@ -144,8 +146,8 @@ void Multinomial::execute_probs_type() { template void Multinomial::execute_convert_type() { - const auto* probs = reinterpret_cast(getParentEdgeAt(PROBS_PORT)->getMemoryPtr()->getData()); - auto* output = reinterpret_cast(getChildEdgeAt(OUTPUT_PORT)->getMemoryPtr()->getData()); + const auto* probs = getSrcDataAtPortAs(PROBS_PORT); + auto* output = getDstDataAtPortAs(OUTPUT_PORT); std::vector

m_cdf(m_input_elements_count); std::vector

m_max_per_batch(m_batches_count); diff --git a/src/plugins/intel_cpu/src/nodes/mvn.cpp b/src/plugins/intel_cpu/src/nodes/mvn.cpp index 6c0e34963618fc..d251200d7b4d0c 100644 --- a/src/plugins/intel_cpu/src/nodes/mvn.cpp +++ b/src/plugins/intel_cpu/src/nodes/mvn.cpp @@ -2015,8 +2015,8 @@ void MVN::MVNRefExecutor::exec(const uint8_t *src_data, uint8_t *dst_data, const } void MVN::prepareParams() { - auto dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); - auto srcMemPtr = getParentEdgeAt(0)->getMemoryPtr(); + auto dstMemPtr = getDstMemoryAtPort(0); + auto srcMemPtr = getSrcMemoryAtPort(0); if (!dstMemPtr || !dstMemPtr->isAllocated()) OPENVINO_THROW("Destination memory didn't allocate."); if (!srcMemPtr || !srcMemPtr->isAllocated()) @@ -2052,10 +2052,10 @@ void MVN::prepareParams() { if (canUseAclExecutor) { std::vector srcMemoryDescs; for (size_t i = 0; i < getParentEdges().size(); i++) { - srcMemoryDescs.push_back(getParentEdgeAt(i)->getMemoryPtr()->getDescPtr()); + srcMemoryDescs.push_back(getSrcMemoryAtPort(i)->getDescPtr()); } std::vector dstMemoryDescs; - dstMemoryDescs.push_back(getChildEdgeAt(0)->getMemoryPtr()->getDescPtr()); + dstMemoryDescs.push_back(getDstMemoryAtPort(0)->getDescPtr()); auto selectedPD = getSelectedPrimitiveDescriptor(); aclExecPtr = selectedPD->getExecutorFactoryAs()->makeExecutor(mvnAttrs, srcMemoryDescs, dstMemoryDescs, {}); @@ -2146,12 +2146,12 @@ void MVN::executeDynamicImpl(dnnl::stream strm) { } void MVN::execute(dnnl::stream strm) { - auto dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); - auto srcMemPtr = getParentEdgeAt(0)->getMemoryPtr(); + auto dstMemPtr = getDstMemoryAtPort(0); + auto srcMemPtr = getSrcMemoryAtPort(0); if (execPtr) { - uint8_t *dst_data = reinterpret_cast(dstMemPtr->getData()); - uint8_t *src_data = reinterpret_cast(srcMemPtr->getData()); + uint8_t *dst_data = dstMemPtr->getDataAs(); + uint8_t *src_data = srcMemPtr->getDataAs(); execPtr->exec(src_data, dst_data, postOpsDataPtrs.data(), shape5D); } else if (aclExecPtr) { aclExecPtr->exec({srcMemPtr}, {dstMemPtr}, postOpsDataPtrs.data()); @@ -2769,4 +2769,4 @@ bool MVN::created() const { } // namespace node } // namespace intel_cpu -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/ngram.cpp b/src/plugins/intel_cpu/src/nodes/ngram.cpp index 15c44718acad3e..573a9d6480fea4 100644 --- a/src/plugins/intel_cpu/src/nodes/ngram.cpp +++ b/src/plugins/intel_cpu/src/nodes/ngram.cpp @@ -66,13 +66,13 @@ void Ngram::initSupportedPrimitiveDescriptors() { } void Ngram::prepareParams() { - const auto& srcDataDims = getParentEdgeAt(0)->getMemoryPtr()->getStaticDims(); - const auto& srcIndicesDims = getParentEdgeAt(1)->getMemoryPtr()->getStaticDims(); - const auto& outDims = getChildEdgeAt(0)->getMemoryPtr()->getStaticDims();; + const auto& srcDataDims = getSrcMemoryAtPort(0)->getStaticDims(); + const auto& srcIndicesDims = getSrcMemoryAtPort(1)->getStaticDims(); + const auto& outDims = getDstMemoryAtPort(0)->getStaticDims();; idcesShapeSize = std::accumulate(srcIndicesDims.begin(), srcIndicesDims.end(), 1, std::multiplies()); numOutElems = std::accumulate(outDims.begin(), outDims.end(), 1, std::multiplies()); - idcesStride = getParentEdgeAt(1)->getMemoryPtr()->getDescWithType()->getStrides()[0]; + idcesStride = getSrcMemoryAtPort(1)->getDescWithType()->getStrides()[0]; numIdces = srcIndicesDims[0]; windowStride = srcDataDims[1]; @@ -83,7 +83,7 @@ void Ngram::prepareParams() { template std::vector Ngram::computeBatchLenghts() { - auto* srcIndices = reinterpret_cast(getParentEdgeAt(1)->getMemoryPtr()->getData()); + auto* srcIndices = getSrcDataAtPortAs(1); std::vector batchLenghts{0}; batchLenghts.reserve(numIdces + 1); @@ -98,8 +98,8 @@ std::vector Ngram::computeBatchLenghts() { } void Ngram::execute(dnnl::stream strm) { - auto* srcData = reinterpret_cast(getParentEdgeAt(0)->getMemoryPtr()->getData()); - auto* dstData = reinterpret_cast(getChildEdgeAt(0)->getMemoryPtr()->getData()); + auto* srcData = getSrcDataAtPortAs(0); + auto* dstData = getDstDataAtPortAs(0); std::vector batchLenghts; if (idcesPrecision == ov::element::i32) { diff --git a/src/plugins/intel_cpu/src/nodes/non_max_suppression.cpp b/src/plugins/intel_cpu/src/nodes/non_max_suppression.cpp index 3574e0bfe3cb69..38f0ec16c4adfa 100644 --- a/src/plugins/intel_cpu/src/nodes/non_max_suppression.cpp +++ b/src/plugins/intel_cpu/src/nodes/non_max_suppression.cpp @@ -168,9 +168,9 @@ void NonMaxSuppression::initSupportedPrimitiveDescriptors() { } void NonMaxSuppression::prepareParams() { - const auto& boxesDims = isDynamicNode() ? getParentEdgesAtPort(NMS_BOXES)[0]->getMemory().getStaticDims() : + const auto& boxesDims = isDynamicNode() ? getParentEdgeAt(NMS_BOXES)->getMemory().getStaticDims() : getInputShapeAtPort(NMS_BOXES).getStaticDims(); - const auto& scoresDims = isDynamicNode() ? getParentEdgesAtPort(NMS_SCORES)[0]->getMemory().getStaticDims() : + const auto& scoresDims = isDynamicNode() ? getParentEdgeAt(NMS_SCORES)->getMemory().getStaticDims() : getInputShapeAtPort(NMS_SCORES).getStaticDims(); m_batches_num = boxesDims[0]; @@ -207,9 +207,9 @@ void NonMaxSuppression::createJitKernel() { void NonMaxSuppression::executeDynamicImpl(dnnl::stream strm) { if (hasEmptyInputTensors() || (inputShapes.size() > NMS_MAX_OUTPUT_BOXES_PER_CLASS && - reinterpret_cast(getParentEdgeAt(NMS_MAX_OUTPUT_BOXES_PER_CLASS)->getMemoryPtr()->getData())[0] == 0)) { + getSrcDataAtPortAs(NMS_MAX_OUTPUT_BOXES_PER_CLASS)[0] == 0)) { redefineOutputMemory({{0, 3}, {0, 3}, {1}}); - *reinterpret_cast(getChildEdgesAtPort(NMS_VALID_OUTPUTS)[0]->getMemoryPtr()->getData()) = 0; + *getDstDataAtPortAs(NMS_VALID_OUTPUTS) = 0; return; } execute(strm); @@ -220,7 +220,7 @@ void NonMaxSuppression::execute(dnnl::stream strm) { size_t max_number_of_boxes = m_output_boxes_per_class * m_batches_num * m_classes_num; if (inputs_num > NMS_MAX_OUTPUT_BOXES_PER_CLASS) { - auto val = reinterpret_cast(getParentEdgeAt(NMS_MAX_OUTPUT_BOXES_PER_CLASS)->getMemoryPtr()->getData())[0]; + auto val = getSrcDataAtPortAs(NMS_MAX_OUTPUT_BOXES_PER_CLASS)[0]; m_max_output_boxes_per_class = val <= 0l ? 0lu : static_cast(val); m_output_boxes_per_class = std::min(m_max_output_boxes_per_class, m_boxes_num); max_number_of_boxes = m_output_boxes_per_class * m_batches_num * m_classes_num; @@ -231,21 +231,21 @@ void NonMaxSuppression::execute(dnnl::stream strm) { } if (inputs_num > NMS_IOU_THRESHOLD) { - m_iou_threshold = reinterpret_cast(getParentEdgeAt(NMS_IOU_THRESHOLD)->getMemoryPtr()->getData())[0]; + m_iou_threshold = getSrcDataAtPortAs(NMS_IOU_THRESHOLD)[0]; } if (inputs_num > NMS_SCORE_THRESHOLD) { - m_score_threshold = reinterpret_cast(getParentEdgeAt(NMS_SCORE_THRESHOLD)->getMemoryPtr()->getData())[0]; + m_score_threshold = getSrcDataAtPortAs(NMS_SCORE_THRESHOLD)[0]; } if (inputs_num > NMS_SOFT_NMS_SIGMA) { - m_soft_nms_sigma = reinterpret_cast(getParentEdgeAt(NMS_SOFT_NMS_SIGMA)->getMemoryPtr()->getData())[0]; + m_soft_nms_sigma = getSrcDataAtPortAs(NMS_SOFT_NMS_SIGMA)[0]; m_scale = (m_soft_nms_sigma > 0.f) ? (-0.5f / m_soft_nms_sigma) : 0.f; } - auto boxes_memory = getParentEdgeAt(NMS_BOXES)->getMemoryPtr(); - auto scores_memory = getParentEdgeAt(NMS_SCORES)->getMemoryPtr(); + auto boxes_memory = getSrcMemoryAtPort(NMS_BOXES); + auto scores_memory = getSrcMemoryAtPort(NMS_SCORES); - auto boxes = reinterpret_cast(boxes_memory->getData()); - auto scores = reinterpret_cast(scores_memory->getData()); + auto boxes = boxes_memory->getDataAs(); + auto scores = scores_memory->getDataAs(); const auto& boxes_strides = boxes_memory->getDescWithType()->getStrides(); const auto& scores_strides = scores_memory->getDescWithType()->getStrides(); @@ -292,7 +292,7 @@ void NonMaxSuppression::execute(dnnl::stream strm) { } if (m_defined_outputs[NMS_SELECTED_INDICES]) { - auto out_ptr = reinterpret_cast(getChildEdgesAtPort(NMS_SELECTED_INDICES)[0]->getMemoryPtr()->getData()); + auto out_ptr = getDstDataAtPortAs(NMS_SELECTED_INDICES); int32_t* boxes_ptr = &(m_filtered_boxes[0].batch_index); size_t idx = 0lu; @@ -308,7 +308,7 @@ void NonMaxSuppression::execute(dnnl::stream strm) { } if (m_defined_outputs[NMS_SELECTED_SCORES]) { - auto out_ptr = reinterpret_cast(getChildEdgesAtPort(NMS_SELECTED_SCORES)[0]->getMemoryPtr()->getData()); + auto out_ptr = getDstDataAtPortAs(NMS_SELECTED_SCORES); size_t idx = 0lu; for (; idx < valid_outputs; idx++) { @@ -324,7 +324,7 @@ void NonMaxSuppression::execute(dnnl::stream strm) { } if (m_defined_outputs[NMS_VALID_OUTPUTS]) { - auto out_ptr = reinterpret_cast(getChildEdgesAtPort(NMS_VALID_OUTPUTS)[0]->getMemoryPtr()->getData()); + auto out_ptr = getDstDataAtPortAs(NMS_VALID_OUTPUTS); *out_ptr = static_cast(valid_outputs); } } diff --git a/src/plugins/intel_cpu/src/nodes/non_zero.cpp b/src/plugins/intel_cpu/src/nodes/non_zero.cpp index 345a93ce655445..e7d867b8bca6db 100644 --- a/src/plugins/intel_cpu/src/nodes/non_zero.cpp +++ b/src/plugins/intel_cpu/src/nodes/non_zero.cpp @@ -119,7 +119,7 @@ void NonZero::executeDynamicImpl(dnnl::stream strm) { } void NonZero::execute(dnnl::stream strm) { - auto inputPrec = getParentEdgesAtPort(0)[0]->getMemory().getDesc().getPrecision(); + auto inputPrec = getParentEdgeAt(0)->getMemory().getDesc().getPrecision(); NonZeroContext ctx = {*this }; OV_SWITCH(intel_cpu, NonZeroExecute, ctx, inputPrec, OV_CASE(ov::element::f32, float), @@ -133,8 +133,8 @@ void NonZero::execute(dnnl::stream strm) { template void NonZero::executeSpecified() { const T zero = 0; - const T *src = reinterpret_cast(getParentEdgeAt(0)->getMemoryPtr()->getData()); - auto dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); + const T *src = getSrcDataAtPortAs(0); + auto dstMemPtr = getDstMemoryAtPort(0); Shape inShape = getParentEdgeAt(0)->getMemory().getShape(); size_t inRank = inShape.getRank(); std::vector nonZeroCounts = getNonZeroElementsCount(src, inShape); @@ -150,7 +150,7 @@ void NonZero::executeSpecified() { VectorDims newDims{inRank, totalNonZeroCount}; redefineOutputMemory({newDims}); } - int* dst = reinterpret_cast(dstMemPtr->getData()); + int* dst = dstMemPtr->getDataAs(); if (totalNonZeroCount == 0) return; diff --git a/src/plugins/intel_cpu/src/nodes/normalize.cpp b/src/plugins/intel_cpu/src/nodes/normalize.cpp index 6e6005084adde9..8b8b7b10bbc8b0 100644 --- a/src/plugins/intel_cpu/src/nodes/normalize.cpp +++ b/src/plugins/intel_cpu/src/nodes/normalize.cpp @@ -882,8 +882,8 @@ void NormalizeL2::setPostOps(dnnl::primitive_attr& kernel_attrs, const VectorDim } void NormalizeL2::createPrimitive() { - auto dstMemPtr = getChildEdgeAt(DATA)->getMemoryPtr(); - auto srcMemPtr = getParentEdgeAt(DATA)->getMemoryPtr(); + auto dstMemPtr = getDstMemoryAtPort(DATA); + auto srcMemPtr = getSrcMemoryAtPort(DATA); if (!dstMemPtr || !dstMemPtr->isAllocated()) THROW_ERROR("can't get destination memory"); if (!srcMemPtr || !srcMemPtr->isAllocated()) @@ -917,7 +917,7 @@ bool NormalizeL2::isExecutable() const { } void NormalizeL2::prepareParams() { - const auto& dims = getParentEdgeAt(DATA)->getMemoryPtr()->getStaticDims(); + const auto& dims = getSrcMemoryAtPort(DATA)->getStaticDims(); setPostOps(kernel_attrs, dims, true); @@ -945,8 +945,8 @@ void NormalizeL2::execute(dnnl::stream strm) { if (!execPtr) THROW_ERROR("doesn't have a compiled executor."); - const uint8_t *src_ptr = reinterpret_cast(getParentEdgeAt(DATA)->getMemoryPtr()->getData()); - uint8_t *dst_ptr = reinterpret_cast(getChildEdgeAt(DATA)->getMemoryPtr()->getData()); + const uint8_t *src_ptr = getSrcDataAtPortAs(DATA); + uint8_t *dst_ptr = getDstDataAtPortAs(DATA); execPtr->exec(src_ptr, dst_ptr, postOpsDataPtrs.data()); } diff --git a/src/plugins/intel_cpu/src/nodes/one_hot.cpp b/src/plugins/intel_cpu/src/nodes/one_hot.cpp index 65cc2d27130355..ba3637069a8dbc 100644 --- a/src/plugins/intel_cpu/src/nodes/one_hot.cpp +++ b/src/plugins/intel_cpu/src/nodes/one_hot.cpp @@ -78,7 +78,7 @@ OneHot::OneHot(const std::shared_ptr& op, const GraphContext::CPtr con } bool OneHot::needShapeInfer() const { - const auto depthNodePtr = reinterpret_cast(getParentEdgesAtPort(1)[0]->getMemoryPtr()->getData()); + const auto depthNodePtr = getSrcDataAtPortAs(1); if (depth != static_cast(depthNodePtr[0])) { depth = depthNodePtr[0]; return true; @@ -108,11 +108,11 @@ void OneHot::initSupportedPrimitiveDescriptors() { template void OneHot::one_hot(size_t prefix_size, size_t suffix_size) { - const auto *src_data = reinterpret_cast(getParentEdgeAt(0)->getMemoryPtr()->getData()); - auto *dst_data = reinterpret_cast(getChildEdgeAt(0)->getMemoryPtr()->getData()); + const auto *src_data = getSrcDataAtPortAs(0); + auto *dst_data = getDstDataAtPortAs(0); - const out_type on_value = reinterpret_cast(getParentEdgeAt(2)->getMemoryPtr()->getData())[0]; - const out_type off_value = reinterpret_cast(getParentEdgeAt(3)->getMemoryPtr()->getData())[0]; + const out_type on_value = getSrcDataAtPortAs(2)[0]; + const out_type off_value = getSrcDataAtPortAs(3)[0]; // fill the output with off_value std::size_t dst_size = prefix_size * depth * suffix_size; diff --git a/src/plugins/intel_cpu/src/nodes/pad.cpp b/src/plugins/intel_cpu/src/nodes/pad.cpp index 02a208fbf71839..edfae076befa0f 100644 --- a/src/plugins/intel_cpu/src/nodes/pad.cpp +++ b/src/plugins/intel_cpu/src/nodes/pad.cpp @@ -176,11 +176,11 @@ bool Pad::needPrepareParams() const { void Pad::createPrimitive() { if (srcMemory.empty()) { for (size_t i = 0; i < getOriginalInputsNumber(); i++) { - srcMemory.push_back(getParentEdgeAt(i)->getMemoryPtr()); + srcMemory.push_back(getSrcMemoryAtPort(i)); } } if (dstMemory.empty()) { - dstMemory.push_back(getChildEdgeAt(0)->getMemoryPtr()); + dstMemory.push_back(getDstMemoryAtPort(0)); } if (inputShapesDefined() && isExecutable() && !shapeHasDataDependency) { prepareParams(); @@ -233,7 +233,7 @@ void Pad::PadExecutor::paramsInitialization(const PadAttrs& attrs, auto fillingInParameters = [&](VectorIdxs& parameter, const size_t type, const size_t size, const int value) { - const int* ptr = reinterpret_cast(srcMemory[type]->getData()); + const int* ptr = srcMemory[type]->getDataAs(); parameter.resize(size); for (size_t i = 0; i < size; i++) { parameter[i] = static_cast(ptr[i]); @@ -245,7 +245,7 @@ void Pad::PadExecutor::paramsInitialization(const PadAttrs& attrs, if (params.attrs.padsEnd.empty()) fillingInParameters(params.attrs.padsEnd, PADS_END_ID, srcDims.size(), 0); if (!params.attrs.constPadValue) - params.attrs.padValue = reinterpret_cast(srcMemory[PAD_VALUE_ID]->getData())[0]; + params.attrs.padValue = srcMemory[PAD_VALUE_ID]->getDataAs()[0]; // pads are constant, so we can calculate new collapsing pads for first target dimensions and use it for the next // dimensions to avoid permanent identical pad calculations const size_t blockSize = srcMemPtr->getDesc().hasLayoutType(LayoutType::nCsp16c) @@ -388,7 +388,7 @@ void Pad::execute(dnnl::stream strm) { if (!execPtr) OPENVINO_THROW(errorPrefix, "has not compiled executor."); - execPtr->exec(getParentEdgeAt(0)->getMemoryPtr(), getChildEdgeAt(0)->getMemoryPtr()); + execPtr->exec(getSrcMemoryAtPort(0), getDstMemoryAtPort(0)); } void Pad::executeDynamicImpl(dnnl::stream strm) { @@ -434,7 +434,7 @@ void Pad::PadExecutor::padConstant(const MemoryPtr& srcMemPtr, const MemoryPtr& template void Pad::PadExecutor::padConstantCommon(const MemoryPtr& srcMemPtr, const MemoryPtr& dstMemPtr) { - T* dstData = reinterpret_cast(dstMemPtr->getData()); + T* dstData = dstMemPtr->getDataAs(); const T value = static_cast(params.attrs.padValue); if (zeroInputDimsCase) { const auto workAmount = dstMemPtr->getDescWithType()->getPaddedElementsCount(); @@ -445,7 +445,7 @@ void Pad::PadExecutor::padConstantCommon(const MemoryPtr& srcMemPtr, const Memor return; } - const T* srcData = reinterpret_cast(srcMemPtr->getData()); + const T* srcData = srcMemPtr->getDataAs(); parallel_nt(params.nThreads, [&](const int ithr, const int nthr) { size_t start = 0, end = 0; @@ -483,8 +483,8 @@ void Pad::PadExecutor::padConstantCommon(const MemoryPtr& srcMemPtr, const Memor } void Pad::PadExecutor::padConstantZero(const MemoryPtr& srcMemPtr, const MemoryPtr& dstMemPtr) { - const uint8_t* srcData = reinterpret_cast(srcMemPtr->getData()); - uint8_t* dstData = reinterpret_cast(dstMemPtr->getData()); + const uint8_t* srcData = srcMemPtr->getDataAs(); + uint8_t* dstData = dstMemPtr->getDataAs(); parallel_nt(params.nThreads, [&](const int ithr, const int nthr) { size_t start = 0, end = 0; @@ -524,8 +524,8 @@ void Pad::PadExecutor::padConstantZero(const MemoryPtr& srcMemPtr, const MemoryP } void Pad::PadExecutor::padEdge(const MemoryPtr& srcMemPtr, const MemoryPtr& dstMemPtr) { - const uint8_t* srcData = reinterpret_cast(srcMemPtr->getData()); - uint8_t* dstData = reinterpret_cast(dstMemPtr->getData()); + const uint8_t* srcData = srcMemPtr->getDataAs(); + uint8_t* dstData = dstMemPtr->getDataAs(); parallel_nt(params.nThreads, [&](const int ithr, const int nthr) { size_t start = 0, end = 0; @@ -565,8 +565,8 @@ void Pad::PadExecutor::padEdge(const MemoryPtr& srcMemPtr, const MemoryPtr& dstM } void Pad::PadExecutor::padReflectOrSymmetric(const MemoryPtr& srcMemPtr, const MemoryPtr& dstMemPtr, const bool isSymmetric) { - const uint8_t* srcData = reinterpret_cast(srcMemPtr->getData()); - uint8_t* dstData = reinterpret_cast(dstMemPtr->getData()); + const uint8_t* srcData = srcMemPtr->getDataAs(); + uint8_t* dstData = dstMemPtr->getDataAs(); const size_t shift = isSymmetric ? 1 : 0; const size_t endSrcShift = (params.srcDimsForReflectOrSymmetric[params.nDimsForWork] - params.srcODims[params.nDimsForWork]) * params.shift; diff --git a/src/plugins/intel_cpu/src/nodes/pooling.cpp b/src/plugins/intel_cpu/src/nodes/pooling.cpp index da3b66921dc9bf..144d0678784265 100644 --- a/src/plugins/intel_cpu/src/nodes/pooling.cpp +++ b/src/plugins/intel_cpu/src/nodes/pooling.cpp @@ -4,9 +4,9 @@ #include "pooling.h" +#include "openvino/op/avg_pool.hpp" +#include "openvino/op/max_pool.hpp" #include "fake_quantize.h" -#include "conv.h" -#include "concat.h" #include #include #include @@ -400,8 +400,8 @@ void Pooling::prepareParams() { } } if (useACL) { - auto dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); - auto srcMemPtr = getParentEdgeAt(0)->getMemoryPtr(); + auto dstMemPtr = getDstMemoryAtPort(0); + auto srcMemPtr = getSrcMemoryAtPort(0); if (!dstMemPtr || !dstMemPtr->isAllocated()) OPENVINO_THROW("Destination memory didn't allocate."); if (!srcMemPtr || !srcMemPtr->isAllocated()) @@ -409,11 +409,11 @@ void Pooling::prepareParams() { std::vector srcMemoryDescs; for (size_t i = 0; i < getOriginalInputsNumber(); i++) { - srcMemoryDescs.push_back(getParentEdgeAt(i)->getMemoryPtr()->getDescPtr()); + srcMemoryDescs.push_back(getSrcMemoryAtPort(i)->getDescPtr()); } std::vector dstMemoryDescs; for (size_t i = 0; i < getOriginalOutputsNumber(); i++) { - dstMemoryDescs.push_back(getChildEdgeAt(i)->getMemoryPtr()->getDescPtr()); + dstMemoryDescs.push_back(getDstMemoryAtPort(i)->getDescPtr()); } execPtr = selected_pd->getExecutorFactoryAs()->makeExecutor(poolingAttrs, @@ -422,8 +422,8 @@ void Pooling::prepareParams() { *attr); selected_pd->setImplementationType(execPtr->getImplType()); } else { - auto inDesc = getParentEdgesAtPort(0)[0]->getMemory().getDescWithType(); - auto outDesc = getChildEdgesAtPort(0)[0]->getMemory().getDescWithType(); + auto inDesc = getParentEdgeAt(0)->getMemory().getDescWithType(); + auto outDesc = getChildEdgeAt(0)->getMemory().getDescWithType(); if (isDynamicNode()) { initEffectiveAttributes(inDesc->getShape(), outDesc->getShape()); @@ -477,8 +477,8 @@ void Pooling::prepareParams() { auto scratchpadMem = getScratchPadMem(dnnlExecPtr->getScratchPadDesc()); primArgs[DNNL_ARG_SCRATCHPAD] = scratchpadMem->getPrimitive(); - primArgs[DNNL_ARG_SRC] = getParentEdgesAtPort(0)[0]->getMemoryPtr()->getPrimitive(); - primArgs[DNNL_ARG_DST] = getChildEdgesAtPort(0)[0]->getMemoryPtr()->getPrimitive(); + primArgs[DNNL_ARG_SRC] = getSrcMemoryAtPort(0)->getPrimitive(); + primArgs[DNNL_ARG_DST] = getDstMemoryAtPort(0)->getPrimitive(); Node::appendPostOpArgs(*attr, primArgs, postOpsArgs); @@ -497,11 +497,11 @@ void Pooling::execute(dnnl::stream strm) { } else if (execPtr) { std::vector srcMemory; for (size_t i = 0; i < getOriginalInputsNumber(); i++) { - srcMemory.push_back(getParentEdgeAt(i)->getMemoryPtr()); + srcMemory.push_back(getSrcMemoryAtPort(i)); } std::vector dstMemory; for (size_t i = 0; i < getOriginalOutputsNumber(); i++) { - dstMemory.push_back(getChildEdgeAt(i)->getMemoryPtr()); + dstMemory.push_back(getDstMemoryAtPort(i)); } execPtr->exec(srcMemory, dstMemory, postOpsArgs); diff --git a/src/plugins/intel_cpu/src/nodes/priorbox.cpp b/src/plugins/intel_cpu/src/nodes/priorbox.cpp index fea1c739f634d7..6eb269a6e9dac7 100644 --- a/src/plugins/intel_cpu/src/nodes/priorbox.cpp +++ b/src/plugins/intel_cpu/src/nodes/priorbox.cpp @@ -107,13 +107,13 @@ PriorBox::PriorBox(const std::shared_ptr& op, const GraphContext::CPtr } bool PriorBox::needShapeInfer() const { - auto memory = getChildEdgeAt(0)->getMemoryPtr(); + auto memory = getDstMemoryAtPort(0); if (memory->getShape().isDynamic()) { return true; } const auto& outputShape = memory->getShape().getStaticDims(); - const int* in_data = reinterpret_cast(memory->getData()); + const int* in_data = memory->getDataAs(); const int h = in_data[0]; const int w = in_data[1]; const auto output = static_cast(4 * h * w * number_of_priors); @@ -144,18 +144,18 @@ void PriorBox::createPrimitive() { } void PriorBox::execute(dnnl::stream strm) { - const int* in_data = reinterpret_cast(getParentEdgeAt(0)->getMemoryPtr()->getData()); + const int* in_data = getSrcDataAtPortAs(0); const int H = in_data[0]; const int W = in_data[1]; - const int* in_image = reinterpret_cast(getParentEdgeAt(1)->getMemoryPtr()->getData()); + const int* in_image = getSrcDataAtPortAs(1); const int IH = in_image[0]; const int IW = in_image[1]; const int OH = 4 * H * W * number_of_priors; const int OW = 1; - float* dst_data = reinterpret_cast(getChildEdgeAt(0)->getMemoryPtr()->getData()); + float* dst_data = getDstDataAtPortAs(0); float step_ = step; auto min_size_ = min_size; diff --git a/src/plugins/intel_cpu/src/nodes/priorbox_clustered.cpp b/src/plugins/intel_cpu/src/nodes/priorbox_clustered.cpp index fd78240844439e..857a2ed9e37441 100644 --- a/src/plugins/intel_cpu/src/nodes/priorbox_clustered.cpp +++ b/src/plugins/intel_cpu/src/nodes/priorbox_clustered.cpp @@ -57,13 +57,13 @@ PriorBoxClustered::PriorBoxClustered(const std::shared_ptr& op, const } bool PriorBoxClustered::needShapeInfer() const { - auto memory = getChildEdgeAt(0)->getMemoryPtr(); + auto memory = getDstMemoryAtPort(0); if (memory->getShape().isDynamic()) { return true; } const auto& outputShape = memory->getShape().getStaticDims(); - const int* in_data = reinterpret_cast(memory->getData()); + const int* in_data = memory->getDataAs(); const int h = in_data[0]; const int w = in_data[1]; const auto output = static_cast(4 * h * w * number_of_priors); @@ -94,11 +94,11 @@ void PriorBoxClustered::createPrimitive() { } void PriorBoxClustered::execute(dnnl::stream strm) { - const int* in_data = reinterpret_cast(getParentEdgeAt(0)->getMemoryPtr()->getData()); + const int* in_data = getSrcDataAtPortAs(0); const int layer_height = in_data[0]; const int layer_width = in_data[1]; - const int* in_image = reinterpret_cast(getParentEdgeAt(1)->getMemoryPtr()->getData()); + const int* in_image = getSrcDataAtPortAs(1); int img_height = in_image[0]; int img_width = in_image[1]; @@ -109,7 +109,7 @@ void PriorBoxClustered::execute(dnnl::stream strm) { step_h = static_cast(img_height) / layer_height; } - float* dst_data = reinterpret_cast(getChildEdgeAt(0)->getMemoryPtr()->getData()); + float* dst_data = getDstDataAtPortAs(0); const auto& out_shape = getChildEdgeAt(0)->getMemory().getShape().getStaticDims(); size_t var_size = variances.size(); diff --git a/src/plugins/intel_cpu/src/nodes/proposal.cpp b/src/plugins/intel_cpu/src/nodes/proposal.cpp index 6bc79580bc27fb..68c0b9f9009034 100644 --- a/src/plugins/intel_cpu/src/nodes/proposal.cpp +++ b/src/plugins/intel_cpu/src/nodes/proposal.cpp @@ -162,13 +162,13 @@ void Proposal::executeDynamicImpl(dnnl::stream strm) { void Proposal::execute(dnnl::stream strm) { try { - const float* probabilitiesData = reinterpret_cast(getParentEdgeAt(PROBABILITIES_IN_IDX)->getMemoryPtr()->getData()); - const float* anchorsData = reinterpret_cast(getParentEdgeAt(ANCHORS_IN_IDX)->getMemoryPtr()->getData()); - const float* imgInfoData = reinterpret_cast(getParentEdgeAt(IMG_INFO_IN_IDX)->getMemoryPtr()->getData()); - float* outRoiData = reinterpret_cast (getChildEdgesAtPort(ROI_OUT_IDX)[0]->getMemoryPtr()->getData()); + const float* probabilitiesData = getSrcDataAtPortAs(PROBABILITIES_IN_IDX); + const float* anchorsData = getSrcDataAtPortAs(ANCHORS_IN_IDX); + const float* imgInfoData = getSrcDataAtPortAs(IMG_INFO_IN_IDX); + float* outRoiData = reinterpret_cast (getDstDataAtPort(ROI_OUT_IDX)); float* outProbData = nullptr; if (store_prob) - outProbData = reinterpret_cast (getChildEdgesAtPort(PROBABILITIES_OUT_IDX)[0]->getMemoryPtr()->getData()); + outProbData = reinterpret_cast (getDstDataAtPort(PROBABILITIES_OUT_IDX)); auto inProbDims = getParentEdgeAt(0)->getMemory().getStaticDims(); const size_t imgInfoSize = getParentEdgeAt(2)->getMemory().getStaticDims()[0]; diff --git a/src/plugins/intel_cpu/src/nodes/psroi_pooling.cpp b/src/plugins/intel_cpu/src/nodes/psroi_pooling.cpp index d00c4afb911a86..b4511cc84f8396 100644 --- a/src/plugins/intel_cpu/src/nodes/psroi_pooling.cpp +++ b/src/plugins/intel_cpu/src/nodes/psroi_pooling.cpp @@ -13,6 +13,7 @@ #include "psroi_pooling.h" #include "cpu/x64/jit_generator.hpp" #include "nodes/common/blocked_desc_creator.h" +#include "utils/ngraph_utils.hpp" using namespace dnnl; using namespace dnnl::impl; @@ -492,9 +493,9 @@ void PSROIPooling::executeBilinearDeformable(const inputType *srcData, outputTyp template void PSROIPooling::executeSpecified() { - const auto *srcData = reinterpret_cast(getParentEdgeAt(0)->getMemoryPtr()->getData()); - const auto *bottomRoisBeginning = reinterpret_cast(getParentEdgeAt(1)->getMemoryPtr()->getData()); - auto *dstData = reinterpret_cast(getChildEdgeAt(0)->getMemoryPtr()->getData()); + const auto *srcData = getSrcDataAtPortAs(0); + const auto *bottomRoisBeginning = getSrcDataAtPortAs(1); + auto *dstData = getDstDataAtPortAs(0); auto srcDesc = getParentEdgeAt(0)->getMemory().getDescWithType(); auto dstDesc = getChildEdgeAt(0)->getMemory().getDescWithType(); @@ -512,8 +513,8 @@ void PSROIPooling::executeSpecified() { int numClasses = 1; int channelsEachClass = outputDim; if (!noTrans) { - const auto mem = getParentEdgeAt(2)->getMemoryPtr(); - bottomTrans = reinterpret_cast(mem->getData()); + const auto mem = getSrcMemoryAtPort(2); + bottomTrans = mem->getDataAs(); numClasses = static_cast(mem->getStaticDims()[1]) / 2; channelsEachClass /= numClasses; } @@ -551,8 +552,8 @@ struct PSROIPooling::PSROIPoolingExecute { }; void PSROIPooling::execute(dnnl::stream strm) { - auto inputPrec = getParentEdgesAtPort(0)[0]->getMemory().getDesc().getPrecision(); - auto outputPrec = getChildEdgesAtPort(0)[0]->getMemory().getDesc().getPrecision(); + auto inputPrec = getParentEdgeAt(0)->getMemory().getDesc().getPrecision(); + auto outputPrec = getChildEdgeAt(0)->getMemory().getDesc().getPrecision(); if (!((inputPrec == ov::element::bf16 && outputPrec == ov::element::bf16) || (inputPrec == ov::element::f32 && outputPrec == ov::element::f32))) { diff --git a/src/plugins/intel_cpu/src/nodes/random_uniform.cpp b/src/plugins/intel_cpu/src/nodes/random_uniform.cpp index 90564904e1466f..bcc018b7e8c01b 100644 --- a/src/plugins/intel_cpu/src/nodes/random_uniform.cpp +++ b/src/plugins/intel_cpu/src/nodes/random_uniform.cpp @@ -88,10 +88,10 @@ void RandomUniform::initSupportedPrimitiveDescriptors() { void RandomUniform::createPrimitive() { if (m_const_inputs[MIN_VAL]) { - initEdgeValues(m_min_val, getParentEdgeAt(MIN_VAL)->getMemoryPtr()->getData(), m_output_prc); + initEdgeValues(m_min_val, getSrcDataAtPort(MIN_VAL), m_output_prc); } if (m_const_inputs[MAX_VAL]) { - initEdgeValues(m_max_val, getParentEdgeAt(MAX_VAL)->getMemoryPtr()->getData(), m_output_prc); + initEdgeValues(m_max_val, getSrcDataAtPort(MAX_VAL), m_output_prc); evalRange(); } @@ -124,14 +124,14 @@ void RandomUniform::createPrimitive() { } bool RandomUniform::needPrepareParams() const { - if (m_out_shape != getChildEdgeAt(0)->getMemoryPtr()->getShape().getStaticDims()) { + if (m_out_shape != getDstMemoryAtPort(0)->getShape().getStaticDims()) { return true; } return false; } void RandomUniform::prepareParams() { - m_out_shape = getChildEdgeAt(0)->getMemoryPtr()->getShape().getStaticDims(); + m_out_shape = getDstMemoryAtPort(0)->getShape().getStaticDims(); m_out_el_num = std::accumulate(m_out_shape.begin(), m_out_shape.end(), 1lu, std::multiplies()); if (m_algo == PHILOX) { @@ -182,17 +182,17 @@ void RandomUniform::prepareParams() { void RandomUniform::execute(dnnl::stream strm) { if (!m_const_inputs[MIN_VAL]) { - initEdgeValues(m_min_val, getParentEdgeAt(MIN_VAL)->getMemoryPtr()->getData(), m_output_prc); + initEdgeValues(m_min_val, getSrcDataAtPort(MIN_VAL), m_output_prc); if (m_const_inputs[MAX_VAL]) { evalRange(); } } if (!m_const_inputs[MAX_VAL]) { - initEdgeValues(m_max_val, getParentEdgeAt(MAX_VAL)->getMemoryPtr()->getData(), m_output_prc); + initEdgeValues(m_max_val, getSrcDataAtPort(MAX_VAL), m_output_prc); evalRange(); } - auto data = getChildEdgeAt(0)->getMemoryPtr()->getData(); + auto data = getDstDataAtPort(0); if (m_algo == PHILOX) { m_state = computePhilox(data, m_out_el_num, m_state); diff --git a/src/plugins/intel_cpu/src/nodes/range.cpp b/src/plugins/intel_cpu/src/nodes/range.cpp index b1562499679814..5cb23e754f49e8 100644 --- a/src/plugins/intel_cpu/src/nodes/range.cpp +++ b/src/plugins/intel_cpu/src/nodes/range.cpp @@ -116,9 +116,9 @@ size_t Range::getWorkAmount(data_t *startPtr, data_t *stopPtr, data_t *stepPtr) stopPtr = &limit; if (stepPtr == nullptr) stepPtr = δ - *startPtr = reinterpret_cast(getParentEdgeAt(RANGE_START)->getMemoryPtr()->getData())[0]; - *stopPtr = reinterpret_cast(getParentEdgeAt(RANGE_LIMIT)->getMemoryPtr()->getData())[0]; - *stepPtr = reinterpret_cast(getParentEdgeAt(RANGE_DELTA)->getMemoryPtr()->getData())[0]; + *startPtr = getSrcDataAtPortAs(RANGE_START)[0]; + *stopPtr = getSrcDataAtPortAs(RANGE_LIMIT)[0]; + *stepPtr = getSrcDataAtPortAs(RANGE_DELTA)[0]; const data_t span = *stopPtr - *startPtr; const data_t step = *stepPtr; if (std::is_same::value) { @@ -138,7 +138,7 @@ Range::StatusCode Range::rangeKernel() { VectorDims newOutputShape {work_amount_dst}; redefineOutputMemory({newOutputShape}); } - data_t* dst_data = reinterpret_cast(getChildEdgesAtPort(0)[0]->getMemoryPtr()->getData()); + data_t* dst_data = getDstDataAtPortAs(0); parallel_nt(0, [&](const int ithr, const int nthr) { size_t iwork = 0, end = 0; splitter(work_amount_dst, nthr, ithr, iwork, end); diff --git a/src/plugins/intel_cpu/src/nodes/rdft.cpp b/src/plugins/intel_cpu/src/nodes/rdft.cpp index 3f895bd42a5ae2..c7752a3d29b3f6 100644 --- a/src/plugins/intel_cpu/src/nodes/rdft.cpp +++ b/src/plugins/intel_cpu/src/nodes/rdft.cpp @@ -155,8 +155,8 @@ void RDFT::execute(dnnl::stream strm) { const auto& inputShape = inputMem.getStaticDims(); const auto& outputShape = outputMem.getStaticDims(); - auto inputPtr = reinterpret_cast(inputMem.getData()); - auto outputPtr = reinterpret_cast(outputMem.getData()); + auto inputPtr = inputMem.getDataAs(); + auto outputPtr = outputMem.getDataAs(); auto rank = inputShape.size() - inverse; @@ -180,12 +180,12 @@ bool RDFT::created() const { void RDFT::prepareParams() { if (axesChanged()) { - const auto& axesMem = getParentEdgeAt(AXES_INDEX)->getMemoryPtr(); + const auto& axesMem = getSrcMemoryAtPort(AXES_INDEX); auto newAxesSize = axesMem->getStaticDims()[0]; if (axes.size() != newAxesSize) { axes.resize(newAxesSize); } - auto axesPtr = reinterpret_cast(axesMem->getData()); + auto axesPtr = axesMem->getDataAs(); auto inputRank = inputShapes[DATA_INDEX].getRank() - inverse; for (size_t i = 0; i < axes.size(); i++) { axes[i] = axesPtr[i] < 0 ? axesPtr[i] + inputRank : axesPtr[i]; @@ -206,12 +206,12 @@ void RDFT::prepareParams() { signalSizes.back() = inputShape[axes.back()]; } } else { - const auto& signalSizesMem = getParentEdgeAt(SIGNAL_SIZE_INDEX)->getMemoryPtr(); + const auto& signalSizesMem = getSrcMemoryAtPort(SIGNAL_SIZE_INDEX); auto newSize = signalSizesMem->getStaticDims()[0]; if (signalSizes.size() != newSize) { signalSizes.resize(newSize); } - const auto& signalSizesPtr = reinterpret_cast(signalSizesMem->getData()); + const auto& signalSizesPtr = signalSizesMem->getDataAs(); for (size_t i = 0; i < newSize; i++) { signalSizes[i] = signalSizesPtr[i]; } @@ -226,11 +226,11 @@ bool RDFT::axesChanged() const { if (isAxesConstant) { return false; } - const auto& axesMem = getParentEdgeAt(AXES_INDEX)->getMemoryPtr(); + const auto& axesMem = getSrcMemoryAtPort(AXES_INDEX); if (axes.size() != axesMem->getStaticDims()[0]) { return true; } - auto axesPtr = reinterpret_cast(axesMem->getData()); + auto axesPtr = axesMem->getDataAs(); auto inputRank = inputShapes[DATA_INDEX].getRank() - inverse; for (size_t i = 0; i < axes.size(); i++) { auto newAxis = axesPtr[i] < 0 ? axesPtr[i] + inputRank : axesPtr[i]; @@ -260,12 +260,12 @@ bool RDFT::signalSizesChanged() const { return inverse ? static_cast(signalSizes.back()) != 2 * (inputShape[axes.back()] - 1) : static_cast(signalSizes.back()) != inputShape[axes.back()]; } else { - const auto& signalSizesMem = getParentEdgeAt(SIGNAL_SIZE_INDEX)->getMemoryPtr(); + const auto& signalSizesMem = getSrcMemoryAtPort(SIGNAL_SIZE_INDEX); auto newSize = signalSizesMem->getStaticDims()[0]; if (signalSizes.size() != newSize || signalSizes.size() != axes.size()) { return true; } - const auto& signalSizesPtr = reinterpret_cast(signalSizesMem->getData()); + const auto& signalSizesPtr = signalSizesMem->getDataAs(); for (size_t i = 0; i < newSize; i++) { if (signalSizesPtr[i] != signalSizes[i]) { return true; diff --git a/src/plugins/intel_cpu/src/nodes/reduce.cpp b/src/plugins/intel_cpu/src/nodes/reduce.cpp index 8770a8190782d7..e8e7a5ead0c0e0 100644 --- a/src/plugins/intel_cpu/src/nodes/reduce.cpp +++ b/src/plugins/intel_cpu/src/nodes/reduce.cpp @@ -2033,10 +2033,10 @@ void Reduce::prepareParams() { if (canUseAclExecutor) { std::vector srcMemoryDescs; for (size_t i = 0; i < getParentEdges().size(); i++) { - srcMemoryDescs.push_back(getParentEdgeAt(i)->getMemoryPtr()->getDescPtr()); + srcMemoryDescs.push_back(getSrcMemoryAtPort(i)->getDescPtr()); } std::vector dstMemoryDescs; - dstMemoryDescs.push_back(getChildEdgeAt(0)->getMemoryPtr()->getDescPtr()); + dstMemoryDescs.push_back(getDstMemoryAtPort(0)->getDescPtr()); auto selectedPD = getSelectedPrimitiveDescriptor(); aclExecPtr = selectedPD->getExecutorFactoryAs()->makeExecutor(reduceAttrs, srcMemoryDescs, dstMemoryDescs, {}); @@ -2045,7 +2045,7 @@ void Reduce::prepareParams() { return; } - src_dims = getParentEdgesAtPort(REDUCE_DATA)[0]->getMemory().getDesc().getShape().getDims(); + src_dims = getParentEdgeAt(REDUCE_DATA)->getMemory().getDesc().getShape().getDims(); std::vector reduce_axes; if (jit_mode && jit_beyond_5D) { reduce_axes = update_src_dims(); @@ -2053,7 +2053,7 @@ void Reduce::prepareParams() { reduce_axes = raw_axes; } - auto dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); + auto dstMemPtr = getDstMemoryAtPort(0); const VectorDims &dst_dims = dstMemPtr->getDesc().getShape().getDims(); dst_size = dstMemPtr->getSize(); calc_process_dst_dims(reduce_axes, dst_dims); @@ -2104,8 +2104,8 @@ void Reduce::createPrimitive() { if (!isExecutable()) { return; } - auto dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); - auto srcMemPtr = getParentEdgeAt(REDUCE_DATA)->getMemoryPtr(); + auto dstMemPtr = getDstMemoryAtPort(0); + auto srcMemPtr = getSrcMemoryAtPort(REDUCE_DATA); if (!dstMemPtr || !dstMemPtr->isAllocated()) OPENVINO_THROW(errorPrefix, " has not allocated destination memory."); if (!srcMemPtr || !srcMemPtr->isAllocated()) @@ -2201,11 +2201,11 @@ void Reduce::executeDynamicImpl(dnnl::stream strm) { } void Reduce::execute(dnnl::stream strm) { - auto dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); - auto srcMemPtr = getParentEdgeAt(REDUCE_DATA)->getMemoryPtr(); + auto dstMemPtr = getDstMemoryAtPort(0); + auto srcMemPtr = getSrcMemoryAtPort(REDUCE_DATA); - const uint8_t *src_data = reinterpret_cast(srcMemPtr->getData()); - uint8_t *dst_data = reinterpret_cast(dstMemPtr->getData()); + const uint8_t *src_data = srcMemPtr->getDataAs(); + uint8_t *dst_data = dstMemPtr->getDataAs(); if (jit_mode) { if (is_hybrid_layout) { @@ -2215,10 +2215,10 @@ void Reduce::execute(dnnl::stream strm) { } else if (aclExecPtr) { std::vector srcMemory; for (size_t i = 0; i < getParentEdges().size(); i++) { - srcMemory.push_back(getParentEdgeAt(i)->getMemoryPtr()); + srcMemory.push_back(getSrcMemoryAtPort(i)); } std::vector dstMemory; - dstMemory.push_back(getChildEdgeAt(0)->getMemoryPtr()); + dstMemory.push_back(getDstMemoryAtPort(0)); aclExecPtr->exec(srcMemory, dstMemory, postOpsDataPtrs.data()); } else { @@ -2247,8 +2247,8 @@ void Reduce::reduce_type(const uint8_t *in_ptr, uint8_t *out_ptr) { if (is_hybrid_layout) { uint8_t *proc_ptr = out_ptr; - auto dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); - out_ptr = reinterpret_cast(dstMemPtr->getData()); + auto dstMemPtr = getDstMemoryAtPort(0); + out_ptr = dstMemPtr->getDataAs(); if (layout == ReduceLayoutType::reduce_nspc) { nspc2ncsp(proc_ptr, out_ptr); } else { diff --git a/src/plugins/intel_cpu/src/nodes/reference.cpp b/src/plugins/intel_cpu/src/nodes/reference.cpp index 327c54f9d55558..947568fa3666b1 100644 --- a/src/plugins/intel_cpu/src/nodes/reference.cpp +++ b/src/plugins/intel_cpu/src/nodes/reference.cpp @@ -83,14 +83,14 @@ void Reference::executeDynamicImpl(dnnl::stream strm) { } Node::redefineOutputMemory(newOutputDims); for (size_t i = 0; i < outputShapes.size(); ++i) { - auto memory = getChildEdgesAtPort(i)[0]->getMemoryPtr(); + auto memory = getDstMemoryAtPort(i); auto& tensor = outputs[i]; if (memory->getSize() != tensor.get_byte_size()) { THROW_CPU_NODE_ERR("output tensor data size mismatch occurred during the inference on output port number ", i); } if (tensor.get_element_type() == element::string) { auto srcPtr = tensor.data(); - auto dstPtr = reinterpret_cast(memory->getData()); + auto dstPtr = memory->getDataAs(); std::copy(srcPtr, srcPtr + tensor.get_size(), dstPtr); } else { cpu_memcpy(memory->getData(), tensor.data(), tensor.get_byte_size()); @@ -110,9 +110,9 @@ bool Reference::needShapeInfer() const { ov::TensorVector Reference::prepareInputs() const { ov::TensorVector inputs; for (size_t i = 0lu; i < inputShapes.size(); i++) { - void *srcDataPtr = getParentEdgesAtPort(i)[0]->getMemory().getData(); + void *srcDataPtr = getParentEdgeAt(i)->getMemory().getData(); ov::Shape shape = ovCoreNode->get_input_partial_shape(i).rank().get_length() == 0 ? - ov::Shape{} : getParentEdgesAtPort(i)[0]->getMemory().getStaticDims(); + ov::Shape{} : getParentEdgeAt(i)->getMemory().getStaticDims(); if (std::any_of(shape.begin(), shape.end(), [](const size_t dim) { return dim == 0lu; } )) { inputs.push_back(ov::Tensor(ovCoreNode->get_input_element_type(i), shape)); @@ -127,9 +127,9 @@ ov::TensorVector Reference::prepareInputs() const { ov::TensorVector Reference::prepareOutputs() const { ov::TensorVector outputs; for (size_t i = 0lu; i < outputShapes.size(); i++) { - void *dstDataPtr = getChildEdgesAtPort(i)[0]->getMemory().getData(); + void *dstDataPtr = getChildEdgeAt(i)->getMemory().getData(); ov::Shape shape = ovCoreNode->get_output_partial_shape(i).rank().get_length() == 0 ? - ov::Shape{} : getChildEdgesAtPort(i)[0]->getMemory().getStaticDims(); + ov::Shape{} : getChildEdgeAt(i)->getMemory().getStaticDims(); if (std::any_of(shape.begin(), shape.end(), [](const size_t dim) { return dim == 0lu; } )) { outputs.push_back(ov::Tensor(ovCoreNode->get_output_element_type(i), shape)); @@ -143,4 +143,4 @@ ov::TensorVector Reference::prepareOutputs() const { } // namespace node } // namespace intel_cpu -} // namespace ov +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/src/nodes/region_yolo.cpp b/src/plugins/intel_cpu/src/nodes/region_yolo.cpp index f8b919d7240052..4ff8ba57e0260b 100644 --- a/src/plugins/intel_cpu/src/nodes/region_yolo.cpp +++ b/src/plugins/intel_cpu/src/nodes/region_yolo.cpp @@ -402,17 +402,17 @@ void RegionYolo::execute(dnnl::stream strm) { output_size = B * IH * IW * mask_size * (classes + coords + 1); } - if (output_size != getChildEdgeAt(0)->getMemoryPtr()->getShape().getElementsCount()) + if (output_size != getDstMemoryAtPort(0)->getShape().getElementsCount()) OPENVINO_THROW("Incorrect layer configuration or output dimensions. ", output_size, " != ", - getChildEdgeAt(0)->getMemoryPtr()->getShape().getElementsCount()); + getDstMemoryAtPort(0)->getShape().getElementsCount()); size_t inputs_size = IH * IW * num_ * (classes + coords + 1); size_t total_size = 2 * IH * IW; - const auto *src_data = reinterpret_cast(getParentEdgeAt(0)->getMemoryPtr()->getData()); - auto *dst_data = reinterpret_cast(getChildEdgeAt(0)->getMemoryPtr()->getData()); + const auto *src_data = getSrcDataAtPortAs(0); + auto *dst_data = getDstDataAtPortAs(0); cpu_convert(src_data, dst_data, getParentEdgeAt(0)->getMemory().getDesc().getPrecision(), getChildEdgeAt(0)->getMemory().getDesc().getPrecision(), output_size); diff --git a/src/plugins/intel_cpu/src/nodes/reorder.cpp b/src/plugins/intel_cpu/src/nodes/reorder.cpp index 17b88b6f93ac26..d3008b70770179 100644 --- a/src/plugins/intel_cpu/src/nodes/reorder.cpp +++ b/src/plugins/intel_cpu/src/nodes/reorder.cpp @@ -3,6 +3,19 @@ // #include "reorder.h" +#include +#include +#include +#include +#include "openvino/core/parallel.hpp" +#include "utils/general_utils.h" +#include +#include "nodes/common/cpu_memcpy.h" +#include "nodes/common/cpu_convert.h" +#include "nodes/common/reorder_prim.h" +#include "convert.h" +#include +#include #include "convert.h" #include "cpu/x64/cpu_isa_traits.hpp" @@ -30,8 +43,11 @@ Reorder::Reorder(const std::shared_ptr& op, const GraphContext::CPtr c THROW_CPU_NODE_ERR("could not create CPU node from Core node."); } -Reorder::Reorder(const std::string& name, const GraphContext::CPtr context) : - Node("Reorder", name, context) {} +Reorder::Reorder(const MemoryDesc& input, const MemoryDesc& output, const std::string& name, const GraphContext::CPtr context) : + Node("Reorder", {input.getShape()}, {output.getShape()}, {input.getPrecision()}, {output.getPrecision()}, name, context) { + this->input = input.clone(); + this->output = output.clone(); +} void Reorder::getSupportedDescriptors() { if (getParentEdges().size() != 1) @@ -161,7 +177,7 @@ void Reorder::prepareReorderAsTranspose(MemoryDescPtr parentDesc, MemoryDescPtr {parentDesc}, {transposedDesc}, attr); - getSelectedPrimitiveDescriptor()->setImplementationType(transposeExecutor->getImplType()); + getSelectedPrimitiveDescriptor()->setImplementationType(transposeExecutor->implType()); return; } #endif // OV_CPU_ARM_ENABLE_FP16 @@ -170,8 +186,8 @@ void Reorder::prepareParams() { if (isOptimized) return; - auto srcMemPtr = getParentEdgeAt(0)->getMemoryPtr(); - auto dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); + auto srcMemPtr = getSrcMemoryAtPort(0); + auto dstMemPtr = getDstMemoryAtPort(0); if (!dstMemPtr || !dstMemPtr->isAllocated()) THROW_CPU_NODE_ERR("has unallocated destination memory object."); if (!srcMemPtr || !srcMemPtr->isAllocated()) @@ -294,6 +310,7 @@ void Reorder::createReorderPrimitive(const dnnl::memory::desc& srcDesc, auto result = getReorderPrim(context->getParamsCache(), getEngine(), src_desc, dst_desc); if (!result) { + DEBUG_LOG("src desc: ", src_desc, " dst_desc: ", dst_desc); THROW_CPU_NODE_ERR("could not create reorder primitive: unsupported reorder case."); } prim = result; @@ -301,8 +318,8 @@ void Reorder::createReorderPrimitive(const dnnl::memory::desc& srcDesc, selectedPD->setImplementationType( parse_impl_name(DnnlExtensionUtils::query_impl_info_str(prim.get_primitive_desc()))); - auto src = getParentEdgesAtPort(0)[0]->getMemoryPtr()->getPrimitive(); - auto dst = getChildEdgesAtPort(0)[0]->getMemoryPtr()->getPrimitive(); + auto src = getSrcMemoryAtPort(0)->getPrimitive(); + auto dst = getDstMemoryAtPort(0)->getPrimitive(); primArgs = {{DNNL_ARG_SRC, src}, {DNNL_ARG_DST, dst}}; #ifdef CPU_DEBUG_CAPS @@ -336,8 +353,8 @@ void Reorder::optimizedNcsp2Nspc() { const size_t DIM3 = inDims[ndims - 2]; const size_t DIM4 = inDims[ndims - 1]; - auto src_data = reinterpret_cast(parentEdge->getMemoryPtr()->getData()); - auto dst_data = reinterpret_cast(childEdge->getMemoryPtr()->getData()); + auto src_data = parentEdge->getMemoryPtr()->getDataAs(); + auto dst_data = childEdge->getMemoryPtr()->getDataAs(); const size_t src_batch_stride = DIM1 * DIM2 * DIM3 * DIM4; const size_t dst_batch_stride = dstStrides[0]; @@ -369,8 +386,8 @@ void Reorder::optimizedNspc2Ncsp() { const size_t DIM3 = inDims[ndims - 2]; const size_t DIM4 = inDims[ndims - 1]; - auto src_data = reinterpret_cast(parentEdge->getMemoryPtr()->getData()); - auto dst_data = reinterpret_cast(childEdge->getMemoryPtr()->getData()); + auto src_data = parentEdge->getMemoryPtr()->getDataAs(); + auto dst_data = childEdge->getMemoryPtr()->getDataAs(); const auto dstStrides = childEdge->getMemoryPtr()->getDescWithType()->getStrides(); const size_t block_size = DIM2 * DIM3 * DIM4; @@ -390,10 +407,9 @@ void Reorder::optimizedNspc2Ncsp() { void Reorder::execute(dnnl::stream strm) { #if defined(OV_CPU_ARM_ENABLE_FP16) if (transposeExecutor) { - auto dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); - auto srcMemPtr = getParentEdgeAt(0)->getMemoryPtr(); - int MB = srcMemPtr->getStaticDims()[0]; - return transposeExecutor->exec({srcMemPtr}, {dstMemPtr}, MB); + auto dstMemPtr = getDstMemoryAtPort(0); + auto srcMemPtr = getSrcMemoryAtPort(0); + return transposeExecutor->exec({srcMemPtr}, {dstMemPtr}); } #endif @@ -442,8 +458,8 @@ void Reorder::reorderData(const IMemory &input, const IMemory &output, MultiCach if (input.getDesc().isCompatible(output.getDesc())) { if (input.getDesc().getPrecision() == element::string) { - auto srcPtr = reinterpret_cast(input.getData()); - auto dstPtr = reinterpret_cast(output.getData()); + auto srcPtr = input.getDataAs(); + auto dstPtr = output.getDataAs(); std::copy(srcPtr, srcPtr + output.getShape().getElementsCount(), dstPtr); } else { auto srcPtr = static_cast(input.getData()); diff --git a/src/plugins/intel_cpu/src/nodes/reorder.h b/src/plugins/intel_cpu/src/nodes/reorder.h index ffe43f0b56c0ef..baf73b52342c68 100644 --- a/src/plugins/intel_cpu/src/nodes/reorder.h +++ b/src/plugins/intel_cpu/src/nodes/reorder.h @@ -17,7 +17,7 @@ namespace node { class Reorder : public Node { public: Reorder(const std::shared_ptr& op, const GraphContext::CPtr context); - Reorder(const std::string& name, const GraphContext::CPtr context); + Reorder(const MemoryDesc& input, const MemoryDesc& output, const std::string& name, const GraphContext::CPtr context); void getSupportedDescriptors() override; void initSupportedPrimitiveDescriptors() override; @@ -33,16 +33,6 @@ class Reorder : public Node { void executeDynamicImpl(dnnl::stream strm) override; - void setDescs(const MemoryDesc& input, const MemoryDesc& output) { - this->input = input.clone(); - inputShapes.clear(); - inputShapes.push_back(this->input->getShape()); - - this->output = output.clone(); - outputShapes.clear(); - outputShapes.push_back(this->output->getShape()); - } - void setSrcPermutation(const std::vector & src_perm) { this->src_permutation = src_perm; } diff --git a/src/plugins/intel_cpu/src/nodes/reorg_yolo.cpp b/src/plugins/intel_cpu/src/nodes/reorg_yolo.cpp index 9bc109c34b9492..8833034e5adf4b 100644 --- a/src/plugins/intel_cpu/src/nodes/reorg_yolo.cpp +++ b/src/plugins/intel_cpu/src/nodes/reorg_yolo.cpp @@ -57,8 +57,8 @@ void ReorgYolo::executeDynamicImpl(dnnl::stream strm) { } void ReorgYolo::execute(dnnl::stream strm) { - const auto *src_data = reinterpret_cast(getParentEdgeAt(0)->getMemoryPtr()->getData()); - auto *dst_data = reinterpret_cast(getChildEdgesAtPort(0)[0]->getMemoryPtr()->getData()); + const auto *src_data = getSrcDataAtPortAs(0); + auto *dst_data = getDstDataAtPortAs(0); const auto &inDims = getParentEdgeAt(0)->getMemory().getStaticDims(); int IW = (inDims.size() > 3) ? inDims[3] : 1; diff --git a/src/plugins/intel_cpu/src/nodes/reshape.cpp b/src/plugins/intel_cpu/src/nodes/reshape.cpp index 06a45e2fff479f..ac96aabebe72aa 100644 --- a/src/plugins/intel_cpu/src/nodes/reshape.cpp +++ b/src/plugins/intel_cpu/src/nodes/reshape.cpp @@ -62,11 +62,11 @@ Reshape::Reshape(const std::shared_ptr& op, const GraphContext::CPtr c } bool Reshape::needShapeInfer() const { - const auto& mem = getParentEdgesAtPort(1)[0]->getMemory(); + const auto& mem = getParentEdgeAt(1)->getMemory(); if (lastSecondInputValues.empty()) { lastSecondInputValues.resize(mem.getStaticDims()[0], 0); } - const int32_t *sndInput = reinterpret_cast(mem.getData()); + const int32_t *sndInput = mem.getDataAs(); for (size_t i = 0; i < lastSecondInputValues.size(); i++) { if (lastSecondInputValues[i] != sndInput[i]) { for (size_t i = 0; i < lastSecondInputValues.size(); i++) { @@ -127,8 +127,8 @@ void Reshape::executeDynamicImpl(dnnl::stream strm) { } void Reshape::execute(dnnl::stream strm) { - auto srcMemPtr = getParentEdgeAt(0)->getMemoryPtr(); - auto dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); + auto srcMemPtr = getSrcMemoryAtPort(0); + auto dstMemPtr = getDstMemoryAtPort(0); auto srcPtr = static_cast(srcMemPtr->getData()); auto dstPtr = static_cast(dstMemPtr->getData()); diff --git a/src/plugins/intel_cpu/src/nodes/reverse_sequence.cpp b/src/plugins/intel_cpu/src/nodes/reverse_sequence.cpp index f08df2342b2a85..d0b52d906d6223 100644 --- a/src/plugins/intel_cpu/src/nodes/reverse_sequence.cpp +++ b/src/plugins/intel_cpu/src/nodes/reverse_sequence.cpp @@ -80,9 +80,9 @@ void ReverseSequence::initSupportedPrimitiveDescriptors() { } void ReverseSequence::prepareParams() { - const auto& dataMemPtr = getParentEdgeAt(REVERSESEQUENCE_DATA)->getMemoryPtr(); - const auto& seqLengthsMemPtr = getParentEdgeAt(REVERSESEQUENCE_LENGTHS)->getMemoryPtr(); - const auto& dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); + const auto& dataMemPtr = getSrcMemoryAtPort(REVERSESEQUENCE_DATA); + const auto& seqLengthsMemPtr = getSrcMemoryAtPort(REVERSESEQUENCE_LENGTHS); + const auto& dstMemPtr = getDstMemoryAtPort(0); if (!dataMemPtr || !dataMemPtr->isAllocated()) OPENVINO_THROW(errorPrefix, " has not allocated input memory of 'data'"); @@ -128,9 +128,9 @@ ReverseSequence::ReverseSequenceExecutor::ReverseSequenceExecutor(const VectorDi template void ReverseSequence::ReverseSequenceExecutor::exec(const MemoryPtr& dataMemPtr, const MemoryPtr& seqLengthsMemPtr, const MemoryPtr& dstMemPtr) { const VectorDims& srcDims = dataMemPtr->getStaticDims(); - const auto *srcData = reinterpret_cast(dataMemPtr->getData()); - auto *dstData = reinterpret_cast(dstMemPtr->getData()); - auto *seqLengthsData = reinterpret_cast(seqLengthsMemPtr->getData()); + const auto *srcData = dataMemPtr->getDataAs(); + auto *dstData = dstMemPtr->getDataAs(); + auto *seqLengthsData = seqLengthsMemPtr->getDataAs(); for (size_t i = 0; i < srcDims[batchAxis]; ++i) { if (static_cast(seqLengthsData[i]) > static_cast(srcDims[seqAxis])) { @@ -174,13 +174,13 @@ void ReverseSequence::execute(dnnl::stream strm) { OPENVINO_THROW("ReverseSequence layer does not support ", precision , " precision"); if (precision == ov::element::f32) - execPtr->exec(getParentEdgeAt(REVERSESEQUENCE_DATA)->getMemoryPtr(), - getParentEdgeAt(REVERSESEQUENCE_LENGTHS)->getMemoryPtr(), - getChildEdgeAt(0)->getMemoryPtr()); + execPtr->exec(getSrcMemoryAtPort(REVERSESEQUENCE_DATA), + getSrcMemoryAtPort(REVERSESEQUENCE_LENGTHS), + getDstMemoryAtPort(0)); else - execPtr->exec(getParentEdgeAt(REVERSESEQUENCE_DATA)->getMemoryPtr(), - getParentEdgeAt(REVERSESEQUENCE_LENGTHS)->getMemoryPtr(), - getChildEdgeAt(0)->getMemoryPtr()); + execPtr->exec(getSrcMemoryAtPort(REVERSESEQUENCE_DATA), + getSrcMemoryAtPort(REVERSESEQUENCE_LENGTHS), + getDstMemoryAtPort(0)); } bool ReverseSequence::created() const { diff --git a/src/plugins/intel_cpu/src/nodes/rnn.cpp b/src/plugins/intel_cpu/src/nodes/rnn.cpp index 596c21526717e0..d1bcbdcf9a9591 100644 --- a/src/plugins/intel_cpu/src/nodes/rnn.cpp +++ b/src/plugins/intel_cpu/src/nodes/rnn.cpp @@ -776,10 +776,10 @@ void RNN::fillWeights(const int *gate_map, const size_t wIdx, const size_t rIdx) const size_t ie_w_vec_size = getInputShapeAtPort(wIdx).getElementsCount(); const size_t ie_r_vec_size = getInputShapeAtPort(rIdx).getElementsCount(); - auto *wInputNode = dynamic_cast(getParentEdgesAtPort(wIdx)[0]->getParent().get()); + auto *wInputNode = dynamic_cast(getParentEdgeAt(wIdx)->getParent().get()); auto wConstBlob = wInputNode->getMemoryPtr(); - auto *rInputNode = dynamic_cast(getParentEdgesAtPort(rIdx)[0]->getParent().get()); + auto *rInputNode = dynamic_cast(getParentEdgeAt(rIdx)->getParent().get()); auto rConstBlob = rInputNode->getMemoryPtr(); std::vector ie_w_vec(ie_w_vec_size), ie_r_vec(ie_r_vec_size); @@ -830,7 +830,7 @@ void RNN::fillBiases(const int *gate_map) { if (b_ptr == nullptr) OPENVINO_THROW("NotAllocated: Internal blob was not allocated for node ", getName(), "."); - auto *constInputNode = dynamic_cast(getParentEdgesAtPort(bIdx)[0]->getParent().get()); + auto *constInputNode = dynamic_cast(getParentEdgeAt(bIdx)->getParent().get()); auto constBlob = constInputNode->getMemoryPtr(); auto const elementsCount = constBlob->getSize() / constBlob->getDesc().getPrecision().size(); @@ -1099,15 +1099,15 @@ Node::AttrPtr RNN::initPrimitiveAttr() { void RNN::prepareParams() { for (size_t i = 0; i < wIdx; i++) { - auto memPtr = getParentEdgesAtPort(i).front()->getMemoryPtr(); + auto memPtr = getSrcMemoryAtPort(i); if (!memPtr || !memPtr->isAllocated()) THROW_ERROR("has uninitialized memory at port ", i); } - if ((is_cell && DC != getParentEdgesAtPort(0)[0]->getMemory().getDesc().getShape().getStaticDims()[1]) || - (!is_cell && DC != getParentEdgesAtPort(0)[0]->getMemory().getDesc().getShape().getStaticDims()[2])) + if ((is_cell && DC != getParentEdgeAt(0)->getMemory().getDesc().getShape().getStaticDims()[1]) || + (!is_cell && DC != getParentEdgeAt(0)->getMemory().getDesc().getShape().getStaticDims()[2])) THROW_ERROR("has incorrect input size value in the first input."); - auto dataMemPtr = getParentEdgesAtPort(0).front()->getMemoryPtr(); + auto dataMemPtr = getSrcMemoryAtPort(0); const size_t B = dataMemPtr->getShape().getStaticDims()[0]; const size_t SL = is_cell ? 1lu : dataMemPtr->getShape().getStaticDims()[1]; const Shape shapeS_4D{L, D, B, SC}; @@ -1187,8 +1187,8 @@ void RNN::execute(dnnl::stream strm) { if (!execPtr) THROW_ERROR("does not have initialized primitive to execute."); - const auto src_data_mem = getParentEdgeAt(0)->getMemoryPtr(); - const auto dst_data_mem = getChildEdgeAt(0)->getMemoryPtr(); + const auto src_data_mem = getSrcMemoryAtPort(0); + const auto dst_data_mem = getDstMemoryAtPort(0); auto args = primArgs; @@ -1198,22 +1198,22 @@ void RNN::execute(dnnl::stream strm) { int state_i_tags[] {DNNL_ARG_SRC_ITER, DNNL_ARG_SRC_ITER_C}; int state_o_tags[] {DNNL_ARG_DST_ITER, DNNL_ARG_DST_ITER_C}; for (size_t s = 0; s < S; s++) { - args[state_i_tags[s]] = getParentEdgeAt(s+1)->getMemoryPtr()->getPrimitive(); + args[state_i_tags[s]] = getSrcMemoryAtPort(s+1)->getPrimitive(); } if (is_augru) { const auto atten_port = is_cell ? 5 : 6; - args[DNNL_ARG_AUGRU_ATTENTION] = getParentEdgeAt(atten_port)->getMemoryPtr()->getPrimitive(); + args[DNNL_ARG_AUGRU_ATTENTION] = getSrcMemoryAtPort(atten_port)->getPrimitive(); } if (is_cell) { for (size_t s = 0; s < S; s++) { - args[state_o_tags[s]] = getChildEdgesAtPort(s)[0]->getMemoryPtr()->getPrimitive(); + args[state_o_tags[s]] = getDstMemoryAtPort(s)->getPrimitive(); } } else { size_t n_ports_with_init_states = outputShapes.size() - 1; // first is a sequence data for (size_t s = 0; s < std::min(S, n_ports_with_init_states); s++) { if (s < outputShapes.size()) { - args[state_o_tags[s]] = getChildEdgesAtPort(s+1)[0]->getMemoryPtr()->getPrimitive(); + args[state_o_tags[s]] = getDstMemoryAtPort(s+1)->getPrimitive(); } } } diff --git a/src/plugins/intel_cpu/src/nodes/roi_align.cpp b/src/plugins/intel_cpu/src/nodes/roi_align.cpp index a5d2a7834aaade..5822abb4e07092 100644 --- a/src/plugins/intel_cpu/src/nodes/roi_align.cpp +++ b/src/plugins/intel_cpu/src/nodes/roi_align.cpp @@ -814,8 +814,8 @@ void ROIAlign::initSupportedPrimitiveDescriptors() { } void ROIAlign::createPrimitive() { - auto srcMemPtr = getParentEdgeAt(0)->getMemoryPtr(); - auto dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); + auto srcMemPtr = getSrcMemoryAtPort(0); + auto dstMemPtr = getDstMemoryAtPort(0); if (!srcMemPtr || !srcMemPtr->isAllocated()) OPENVINO_THROW(errorPrefix, " did not allocate input memory"); if (!dstMemPtr || !dstMemPtr->isAllocated()) @@ -876,10 +876,10 @@ void ROIAlign::executeSpecified() { auto isPlainFmt = srcBlockDesc->hasLayoutType(LayoutType::ncsp); - const auto *srcData = reinterpret_cast(getParentEdgeAt(0)->getMemoryPtr()->getData()); - const auto *srcRoi = reinterpret_cast(getParentEdgeAt(1)->getMemoryPtr()->getData()); - const auto *srcRoiIdx = reinterpret_cast(getParentEdgeAt(2)->getMemoryPtr()->getData()); - auto *dst = reinterpret_cast(getChildEdgeAt(0)->getMemoryPtr()->getData()); + const auto *srcData = getSrcDataAtPortAs(0); + const auto *srcRoi = getSrcDataAtPortAs(1); + const auto *srcRoiIdx = getSrcDataAtPortAs(2); + auto *dst = getDstDataAtPortAs(0); auto nominalRoiCount = static_cast(srcMemory1.getStaticDims()[0]); int realRois = 0; diff --git a/src/plugins/intel_cpu/src/nodes/roi_pooling.cpp b/src/plugins/intel_cpu/src/nodes/roi_pooling.cpp index a3c8362ae7ddfe..ae398dd9166cfc 100644 --- a/src/plugins/intel_cpu/src/nodes/roi_pooling.cpp +++ b/src/plugins/intel_cpu/src/nodes/roi_pooling.cpp @@ -498,9 +498,9 @@ void ROIPooling::executeDynamicImpl(dnnl::stream strm) { } void ROIPooling::prepareParams() { - const auto& srcMemPtr0 = getParentEdgeAt(0)->getMemoryPtr(); - const auto& srcMemPtr1 = getParentEdgeAt(0)->getMemoryPtr(); - const auto& dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); + const auto& srcMemPtr0 = getSrcMemoryAtPort(0); + const auto& srcMemPtr1 = getSrcMemoryAtPort(0); + const auto& dstMemPtr = getDstMemoryAtPort(0); if (!srcMemPtr0 || !srcMemPtr0->isAllocated()) OPENVINO_THROW("Input memory has not been allocated."); if (!srcMemPtr1 || !srcMemPtr1->isAllocated()) @@ -511,7 +511,7 @@ void ROIPooling::prepareParams() { OPENVINO_THROW("Preferable primitive descriptor is not set."); const auto& inDims = getParentEdgeAt(0)->getMemory().getStaticDims(); - const auto& outDims = getChildEdgesAtPort(0)[0]->getMemory().getStaticDims(); + const auto& outDims = getChildEdgeAt(0)->getMemory().getStaticDims(); refParams.mb = outDims[0]; refParams.c = rnd_up(inDims[1], refParams.c_block); @@ -560,9 +560,9 @@ class ROIPooling::ROIPoolingJitExecutor : public ROIPooling::ROIPoolingExecutor auto src_strides = srcData.getDescWithType()->getStrides(); auto src_roi_step = srcRoi.getDescWithType()->getStrides()[0]; auto dst_strides = dst.getDescWithType()->getStrides(); - const auto* src_ptr = reinterpret_cast(srcData.getData()); - const auto* roi_ptr = reinterpret_cast(srcRoi.getData()); - auto* dst_ptr = reinterpret_cast(dst.getData()); + const auto* src_ptr = srcData.getDataAs(); + const auto* roi_ptr = srcRoi.getDataAs(); + auto* dst_ptr = dst.getDataAs(); executeOptimizedGeneric(src_ptr, roi_ptr, dst_ptr, src_strides, dst_strides, src_roi_step); } @@ -680,9 +680,9 @@ class ROIPooling::ROIPoolingRefExecutor : public ROIPooling::ROIPoolingExecutor auto src_strides = srcData.getDescWithType()->getStrides(); auto src_roi_step = srcRoi.getDescWithType()->getStrides()[0]; auto dst_strides = dst.getDescWithType()->getStrides(); - const auto* src_ptr = reinterpret_cast(srcData.getData()); - const auto* roi_ptr = reinterpret_cast(srcRoi.getData()); - auto* dst_ptr = reinterpret_cast(dst.getData()); + const auto* src_ptr = srcData.getDataAs(); + const auto* roi_ptr = srcRoi.getDataAs(); + auto* dst_ptr = dst.getDataAs(); executeReference(src_ptr, roi_ptr, dst_ptr, src_strides, dst_strides, src_roi_step); } diff --git a/src/plugins/intel_cpu/src/nodes/roll.cpp b/src/plugins/intel_cpu/src/nodes/roll.cpp index babce67a6811fe..072d128d10e734 100644 --- a/src/plugins/intel_cpu/src/nodes/roll.cpp +++ b/src/plugins/intel_cpu/src/nodes/roll.cpp @@ -97,10 +97,10 @@ void Roll::initSupportedPrimitiveDescriptors() { } void Roll::prepareParams() { - const auto& dataMemPtr = getParentEdgeAt(DATA_INDEX)->getMemoryPtr(); - const auto& shiftMemPtr = getParentEdgeAt(SHIFT_INDEX)->getMemoryPtr(); - const auto& axesMemPtr = getParentEdgeAt(AXES_INDEX)->getMemoryPtr(); - const auto& dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); + const auto& dataMemPtr = getSrcMemoryAtPort(DATA_INDEX); + const auto& shiftMemPtr = getSrcMemoryAtPort(SHIFT_INDEX); + const auto& axesMemPtr = getSrcMemoryAtPort(AXES_INDEX); + const auto& dstMemPtr = getDstMemoryAtPort(0); if (!dataMemPtr || !dataMemPtr->isAllocated()) OPENVINO_THROW(layerErrorPrefix, " has not allocated input memory of 'data'"); @@ -133,24 +133,24 @@ void Roll::execute(dnnl::stream strm) { const auto& dataTypeSize = dataPrecision.size(); switch (dataTypeSize) { case sizeof(element_type_traits::value_type): { - execPtr->exec::value_type>(getParentEdgeAt(DATA_INDEX)->getMemoryPtr(), - getParentEdgeAt(SHIFT_INDEX)->getMemoryPtr(), - getParentEdgeAt(AXES_INDEX)->getMemoryPtr(), - getChildEdgeAt(0)->getMemoryPtr()); + execPtr->exec::value_type>(getSrcMemoryAtPort(DATA_INDEX), + getSrcMemoryAtPort(SHIFT_INDEX), + getSrcMemoryAtPort(AXES_INDEX), + getDstMemoryAtPort(0)); break; } case sizeof(element_type_traits::value_type): { - execPtr->exec::value_type>(getParentEdgeAt(DATA_INDEX)->getMemoryPtr(), - getParentEdgeAt(SHIFT_INDEX)->getMemoryPtr(), - getParentEdgeAt(AXES_INDEX)->getMemoryPtr(), - getChildEdgeAt(0)->getMemoryPtr()); + execPtr->exec::value_type>(getSrcMemoryAtPort(DATA_INDEX), + getSrcMemoryAtPort(SHIFT_INDEX), + getSrcMemoryAtPort(AXES_INDEX), + getDstMemoryAtPort(0)); break; } case sizeof(element_type_traits::value_type): { - execPtr->exec::value_type>(getParentEdgeAt(DATA_INDEX)->getMemoryPtr(), - getParentEdgeAt(SHIFT_INDEX)->getMemoryPtr(), - getParentEdgeAt(AXES_INDEX)->getMemoryPtr(), - getChildEdgeAt(0)->getMemoryPtr()); + execPtr->exec::value_type>(getSrcMemoryAtPort(DATA_INDEX), + getSrcMemoryAtPort(SHIFT_INDEX), + getSrcMemoryAtPort(AXES_INDEX), + getDstMemoryAtPort(0)); break; } default: @@ -176,10 +176,10 @@ Roll::RollExecutor::RollExecutor(const VectorDims& dataDims, const VectorDims& s template void Roll::RollExecutor::exec(const MemoryPtr& dataMemPtr, const MemoryPtr& shiftMemPtr, const MemoryPtr& axesMemPtr, const MemoryPtr& dstMemPtr) { - const auto *data = reinterpret_cast(dataMemPtr->getData()); - const auto *shift = reinterpret_cast(shiftMemPtr->getData()); - const auto *axes = reinterpret_cast(axesMemPtr->getData()); - auto *dst = reinterpret_cast(dstMemPtr->getData()); + const auto *data = dataMemPtr->getDataAs(); + const auto *shift = shiftMemPtr->getDataAs(); + const auto *axes = axesMemPtr->getDataAs(); + auto *dst = dstMemPtr->getDataAs(); std::vector shiftsVector(numOfDims, 0ul); const VectorDims& dataDims = dataMemPtr->getStaticDims(); diff --git a/src/plugins/intel_cpu/src/nodes/rope.cpp b/src/plugins/intel_cpu/src/nodes/rope.cpp index 9bee380d4ee276..970279c41c0e3d 100644 --- a/src/plugins/intel_cpu/src/nodes/rope.cpp +++ b/src/plugins/intel_cpu/src/nodes/rope.cpp @@ -279,10 +279,10 @@ void RoPE::initSupportedPrimitiveDescriptors() { void RoPE::execute(dnnl::stream strm) { std::vector inputs(getParentEdges().size()), outputs(getChildEdges().size()); for (size_t i = 0; i < inputs.size(); i++) { - inputs[i] = getParentEdgeAt(i)->getMemoryPtr(); + inputs[i] = getSrcMemoryAtPort(i); } for (size_t i = 0; i < outputs.size(); i++) { - outputs[i] = getChildEdgeAt(i)->getMemoryPtr(); + outputs[i] = getDstMemoryAtPort(i); } m_executor->execute(strm, m_config, inputs, outputs); } diff --git a/src/plugins/intel_cpu/src/nodes/scaled_attn.cpp b/src/plugins/intel_cpu/src/nodes/scaled_attn.cpp index aa659a636238ac..594306b4b2d169 100644 --- a/src/plugins/intel_cpu/src/nodes/scaled_attn.cpp +++ b/src/plugins/intel_cpu/src/nodes/scaled_attn.cpp @@ -27,6 +27,8 @@ #include "kernels/scaled_attn/softmax.hpp" #include "kernels/scaled_attn/mha_single_token.hpp" #include "kernels/scaled_attn/attn_memcpy.hpp" +#include "kernels/x64/brgemm_kernel.hpp" +#include "nodes/common/cpu_convert.h" #include #include @@ -63,7 +65,9 @@ bool ScaledDotProductAttentionKey::operator==(const ScaledDotProductAttentionKey // default implementation: reference template struct MHAKernel { - MHAKernel() = default; + const GraphContext::CPtr context; + MHAKernel() = delete; + explicit MHAKernel(GraphContext::CPtr ctx) : context(ctx) {} template float dot_product(const D* a, const D* b, int len, int stride_b = 1) { @@ -193,6 +197,7 @@ struct MHAKernel { // q: [B, H, q_len, S] // k: [B, H, kv_len, S] // v: [B, H, kv_len, S] + const GraphContext::CPtr context; dnnl::memory::desc q_md; dnnl::memory::desc k_md; dnnl::memory::desc weight_md; @@ -200,10 +205,136 @@ struct MHAKernel { dnnl::memory::desc out_md; dnnl::memory attn_score; dnnl::memory attn_weight; + PlainTensor fp32_out; + PlainTensor qk_scratch_a; + PlainTensor qk_scratch_b; + PlainTensor wv_scratch_a; + PlainTensor wv_scratch_b; + std::vector wsp; + size_t wsp_size_per_thread = 0; dnnl::matmul qk_prim; dnnl::matmul wv_prim; using tag = dnnl::memory::format_tag; using dt = dnnl::memory::data_type; + struct brgemmKey { + size_t M; + size_t N; + size_t K; + size_t lda; + size_t ldb; + size_t ldc; + bool b_transposed; + size_t hash() const { + using namespace dnnl::impl; + using namespace dnnl::impl::primitive_hashing; + size_t seed = 0; + seed = hash_combine(seed, M); + seed = hash_combine(seed, N); + seed = hash_combine(seed, K); + seed = hash_combine(seed, lda); + seed = hash_combine(seed, ldb); + seed = hash_combine(seed, ldc); + seed = hash_combine(seed, b_transposed); + return seed; + } + bool operator==(const brgemmKey& rhs) const { + return (rhs.M == M) && (rhs.N == N) && (rhs.K == K) && (rhs.lda == lda) && (rhs.ldb == ldb) && + (rhs.ldc == ldc) && (rhs.b_transposed == b_transposed); + } + }; + + std::shared_ptr qk_gemm_ptr = nullptr; + std::shared_ptr wv_gemm_ptr = nullptr; + + MHAKernel() = delete; + explicit MHAKernel(GraphContext::CPtr ctx) + : context(ctx), + fp32_out(true), + qk_scratch_a(true), + qk_scratch_b(true), + wv_scratch_a(true), + wv_scratch_b(true) {} + + dnnl::memory::dims make_dnnl_dims(const std::vector& dims) { + dnnl::memory::dims dnnl_dims(dims.size()); + for (size_t i = 0; i < dims.size(); i++) + dnnl_dims[i] = static_cast(dims[i]); + return dnnl_dims; + } + + void prepare_multiquery_prim(dnnl::stream strm, + PlainTensor& query, + PlainTensor& present_key, + bool has_out_transpose) { + auto qkv_dt = precision_of::value == ov::element::f32 ? dt::f32 : dt::bf16; + if (qkv_dt != dt::bf16) + OPENVINO_THROW("Brgemm multi-query kernel only supports BF16"); + auto B = query.size(0); + auto H = query.size(1); + auto q_len = query.size(2); + auto head_size = query.size(3); + auto kv_len = present_key.size(2); + auto Hk = present_key.size(1); + brgemmKey qk_key = {q_len, kv_len, head_size, query.stride(2), present_key.stride(2), kv_len, true}; + + auto builder = [](const brgemmKey& key) -> std::shared_ptr { + return std::make_shared(key.M, key.N, key.K, key.lda, key.ldb, key.ldc, key.b_transposed); + }; + + auto cache = this->context->getParamsCache(); + auto qk_result = cache->getOrCreate(qk_key, builder); + if (!qk_result.first) { + OPENVINO_THROW("ScaledDotProductAttention 1st token qk gemm creation fails"); + } + + qk_gemm_ptr = qk_result.first; + dnnl::memory::desc attn_md(make_dnnl_dims({B, H, q_len, kv_len}), dt::f32, tag::abcd); + weight_md = dnnl::memory::desc(make_dnnl_dims({B, H, q_len, kv_len}), qkv_dt, tag::abcd); + out_md = dnnl::memory::desc(make_dnnl_dims({B, H, q_len, head_size}), qkv_dt, tag::abcd); + + size_t ldc_index = 2; + if (has_out_transpose) { + ldc_index = 1; + } + brgemmKey wv_key = {q_len, + head_size, + kv_len, + kv_len, + present_key.stride(2), + static_cast(out_md.get_strides()[ldc_index]), + false}; + + auto wv_result = cache->getOrCreate(wv_key, builder); + if (!wv_result.first) { + OPENVINO_THROW("ScaledDotProductAttention 1st token wv gemm creation fails"); + } + + wv_gemm_ptr = wv_result.first; + + size_t nthr = static_cast(parallel_get_max_threads()); + + // wsp is used to compute beta when K is blocked + wsp_size_per_thread = wv_gemm_ptr->get_wsp_size(); + wsp.resize(nthr * wsp_size_per_thread); + + // allocate scratch a/b, notice get_scratch_a_size/get_scratch_b_size returns in bytes + size_t data_size = sizeof(T); + qk_scratch_a.resize({nthr, qk_gemm_ptr->get_scratch_a_size() / data_size}); + wv_scratch_a.resize({nthr, wv_gemm_ptr->get_scratch_a_size() / data_size}); + + qk_scratch_b.resize({B, Hk, qk_gemm_ptr->get_scratch_b_size() / data_size}); + wv_scratch_b.resize({B, Hk, wv_gemm_ptr->get_scratch_b_size() / data_size}); + if (!attn_score || attn_md.get_size() > attn_score.get_desc().get_size()) { + attn_score = dnnl::memory(attn_md, strm.get_engine()); + attn_weight = dnnl::memory(weight_md, strm.get_engine()); + } + if (has_out_transpose) { + fp32_out.resize({B, q_len, H, head_size}); + } else { + fp32_out.resize({B, H, q_len, head_size}); + } + return; + } void prepare_prim(dnnl::stream strm, PlainTensor& query, @@ -216,12 +347,6 @@ struct MHAKernel { size_t kv_len, size_t S, bool has_out_transpose) { - auto make_dnnl_dims = [](const std::vector& dims) { - dnnl::memory::dims dnnl_dims(dims.size()); - for (size_t i = 0; i < dims.size(); i++) - dnnl_dims[i] = static_cast(dims[i]); - return dnnl_dims; - }; auto qkv_dt = precision_of::value == ov::element::f32 ? dt::f32 : dt::bf16; dnnl::memory::desc cur_q_md(make_dnnl_dims({B, H, q_len, S}), qkv_dt, query.get_strides()); dnnl::memory::desc cur_k_md(make_dnnl_dims({B, Hk, kv_len, S}), qkv_dt, present_key.get_strides()); @@ -249,6 +374,103 @@ struct MHAKernel { } } + void exec_multiquery(PlainTensor& query, + PlainTensor& present_key, + PlainTensor& present_value, + const PlainTensor& alibi_mask, + const PlainTensor& attention_mask, + PlainTensor& output_emb, + bool has_out_transpose, + bool auto_causal, + float d_scale = 0.0f) { + const auto B = query.size(0); + const auto H = query.size(1); + const auto q_len = query.size(2); + const auto head_size = query.size(3); + const auto Hk = present_key.size(1); + const auto kv_len = present_key.size(2); + size_t h_each_group_len = H / Hk; + PlainTensor score, weight; + score.resize({B, H, q_len, kv_len}, static_cast(attn_score.get_data_handle())); + weight.resize({B, H, q_len, kv_len}, static_cast(attn_weight.get_data_handle())); + const size_t m_block_size = qk_gemm_ptr->get_mblk_size(); + auto m_blocks = (q_len + m_block_size - 1) / m_block_size; + // packed k, v + parallel_for2d(B, Hk, [&](size_t b, size_t h) { + bfloat16* k_ptr = &present_key.at({b, h, 0, 0}); + bfloat16* v_ptr = &present_value.at({b, h, 0, 0}); + qk_gemm_ptr->copy_buffer_b(k_ptr, &qk_scratch_b.at({b, h, 0})); + wv_gemm_ptr->copy_buffer_b(v_ptr, &wv_scratch_b.at({b, h, 0})); + }); + + // attention + parallel_for3d(B, H, m_blocks, [&](size_t b, size_t h, size_t m_blk) { + auto m_start = m_blk * m_block_size; + auto m_end = std::min(m_start + m_block_size, q_len); + auto m_cnt = m_end - m_start; + size_t tid = parallel_get_thread_num(); + bfloat16* q_ptr = &query.at({b, h, m_start, 0}); + float* c_ptr = &score.at({b, h, m_start, 0}); + qk_gemm_ptr->executeGemmPackedB(m_cnt < m_block_size, + q_ptr, + &qk_scratch_b.at({b, h / h_each_group_len, 0}), + c_ptr, + wsp.data() + tid * wsp_size_per_thread, + qk_scratch_a ? &qk_scratch_a.at({tid, 0}) : nullptr); + float* alibi_ptr = nullptr; + auto alibi_stride = 0; + if (alibi_mask) { + alibi_ptr = &alibi_mask.at({b, h, 0, 0}, true); + if (alibi_mask.size(2) > 1) + alibi_stride = alibi_mask.stride(2); + } + + uint8_t* attn_mask_ptr = nullptr; + auto attn_mask_stride = 0; + if (attention_mask) { + attn_mask_ptr = reinterpret_cast(&attention_mask.at({b, h, 0, 0}, true)); + if (attention_mask.size(2) > 1) + attn_mask_stride = attention_mask.stride(2) * sizeof(T); + } + uint8_t* cmask_ptr = nullptr; + auto cmask_stride = 0; + if (causal_mask) { + cmask_ptr = &causal_mask.at({b, h, 0, 0}, true); + if (causal_mask.size(2) > 1) + cmask_stride = causal_mask.stride(2); + } + for (size_t m = m_start; m < m_end; m++) { + // apply attention mask & sofmax + auto ncausal = auto_causal ? (kv_len - q_len + m + 1) : kv_len; + attn_softmax(&score.at({b, h, m, 0}), + &weight.at({b, h, m, 0}), + d_scale, + alibi_ptr + m * alibi_stride, + attn_mask_ptr + m * attn_mask_stride, + cmask_ptr + m * cmask_stride, + select_nfltmax_at_0, + ncausal, + kv_len, + precision_of::value, + precision_of::value); + } + bfloat16* w_ptr = &weight.at({b, h, m_start, 0}); + float* fp32_out_ptr = + has_out_transpose ? &fp32_out.at({b, m_start, h, 0}) : &fp32_out.at({b, h, m_start, 0}); + wv_gemm_ptr->executeGemmPackedB(m_cnt < m_block_size, + w_ptr, + &wv_scratch_b.at({b, h / h_each_group_len, 0}), + fp32_out_ptr, + wsp.data() + tid * wsp_size_per_thread, + wv_scratch_a ? &wv_scratch_a.at({tid, 0}) : nullptr); + }); + cpu_convert(&fp32_out.at({0, 0, 0, 0}), + &output_emb.at({0, 0, 0, 0}), + ov::element::f32, + ov::element::bf16, + B * H * q_len * head_size); + } + void exec_qk(dnnl::stream strm, PlainTensor& query, PlainTensor& present_key) { dnnl::memory q(q_md, strm.get_engine(), query.data()); dnnl::memory k(k_md, strm.get_engine(), present_key.data()); @@ -293,10 +515,23 @@ struct MHAKernel { auto head_size = query.size(3); auto Hk = present_key.size(1); auto kv_len = present_key.size(2); - + bool is_multi_query = H != Hk; if (d_scale == 0.0f) d_scale = 1.0f / sqrt(head_size); + if (is_multi_query) { + prepare_multiquery_prim(strm, query, present_key, has_out_transpose); + exec_multiquery(query, + present_key, + present_value, + alibi_mask, + attention_mask, + output_emb, + has_out_transpose, + auto_causal, + d_scale); + return; + } prepare_prim(strm, query, present_key, present_value, B, H, Hk, q_len, kv_len, head_size, has_out_transpose); exec_qk(strm, query, present_key); @@ -308,17 +543,26 @@ struct MHAKernel { parallel_for3d(B, H, q_len, [&](size_t b, size_t h, size_t m) { // apply attention mask & sofmax auto ncausal = auto_causal ? (kv_len - q_len + m + 1) : kv_len; + uint8_t* attn_mask_ptr = nullptr; + auto attn_mask_stride = 0; + if (attention_mask) { + attn_mask_ptr = reinterpret_cast(&attention_mask.at({b, h, 0, 0}, true)); + if (attention_mask.size(2) > 1) + attn_mask_stride = attention_mask.stride(2) * sizeof(T); + } attn_softmax(&score.at({b, h, m, 0}), &weight.at({b, h, m, 0}), d_scale, alibi_mask ? &alibi_mask.at({b, h, m, 0}, true) : nullptr, - attention_mask ? &attention_mask.at({b, h, m, 0}, true) : nullptr, + attn_mask_ptr + m * attn_mask_stride, causal_mask ? &causal_mask.at({b, h, m, 0}, true) : nullptr, select_nfltmax_at_0, ncausal, kv_len, + precision_of::value, precision_of::value); }); + exec_kv(strm, present_value, output_emb); } }; @@ -326,11 +570,13 @@ struct MHAKernel { #ifdef OV_CPU_WITH_MLAS template <> struct MHAKernel { + const GraphContext::CPtr context; size_t m_block_size; // buffer to hold qk temp std::vector qk_buffers; - MHAKernel() { + MHAKernel() = delete; + explicit MHAKernel(GraphContext::CPtr ctx): context(ctx) { m_block_size = 4; select_nfltmax_at_0 = false; qk_buffers.resize(parallel_get_max_threads(), PlainTensor(true)); @@ -397,12 +643,12 @@ struct MHAKernel { if (alibi_mask.size(2) > 1) alibi_stride = alibi_mask.stride(2); } - float* attn_mask_ptr = nullptr; + uint8_t* attn_mask_ptr = nullptr; auto attn_mask_stride = 0; if (attention_mask) { - attn_mask_ptr = &attention_mask.at({b, h, 0, 0}, true); + attn_mask_ptr = reinterpret_cast(&attention_mask.at({b, h, 0, 0}, true)); if (attention_mask.size(2) > 1) - attn_mask_stride = attention_mask.stride(2); + attn_mask_stride = attention_mask.stride(2) * sizeof(float); } uint8_t* cmask_ptr = nullptr; auto cmask_stride = 0; @@ -458,6 +704,7 @@ struct MHAKernel { select_nfltmax_at_0, ncausal, kv_len, + ov::element::f32, ov::element::f32); } mlas_sgemm("N", @@ -510,16 +757,17 @@ struct MHASingleToken { template struct ScaledDotProductAttention::AttentionExecutor : public ScaledDotProductAttention::Executor { + GraphContext::CPtr context; PlainTensor attn_buf; // f32[[B|1],[H|1], L1|1, L0+L1] MHAKernel kernel; MHASingleToken kernel_single_token; - AttentionExecutor() : attn_buf(true) {} + AttentionExecutor(GraphContext::CPtr ctx) : context(ctx), attn_buf(true), kernel(context) {} void prepare_attn_mask(MemoryPtr attn_input) { attn_buf.resize(attn_input->getStaticDims()); - auto p = reinterpret_cast(attn_input->getData()); + auto p = attn_input->getDataAs(); for (size_t i = 0; i < attn_input->getSize(); i++) attn_buf.data()[i] = p[i] ? 0.0f : -FLT_MAX; } @@ -558,7 +806,7 @@ struct ScaledDotProductAttention::AttentionExecutor : public ScaledDotProductAtt } // if has scale, attn_mask must be present if (input_num > 4) { - scale_input = *reinterpret_cast(inputs[4]->getData()); + scale_input = *inputs[4]->getDataAs(); } } @@ -678,7 +926,7 @@ void ScaledDotProductAttention::initSupportedPrimitiveDescriptors() { ov::element::u8, getInputShapeAtPort(nextPortIdx))); } else { config.inConfs[nextPortIdx].setMemDesc(creatorsMap.at(LayoutType::ncsp)->createSharedDesc( - ov::element::f32, getInputShapeAtPort(nextPortIdx))); + rtPrecision, getInputShapeAtPort(nextPortIdx))); } nextPortIdx++; } @@ -734,34 +982,39 @@ void ScaledDotProductAttention::createPrimitive() { auto builder = [&](const ScaledDotProductAttentionKey& key) -> std::shared_ptr { std::shared_ptr executor; if (rtPrecision == ov::element::bf16) { - executor = std::make_shared>(); +#ifdef OPENVINO_ARCH_X86_64 + executor = std::make_shared>(context); +#endif } else { - #ifdef OV_CPU_WITH_MLAS - executor = std::make_shared>(); - #else - executor = std::make_shared>(); - #endif +#ifdef OV_CPU_WITH_MLAS + executor = std::make_shared>(context); +#else + executor = std::make_shared>(context); +#endif } return executor; }; auto cache = context->getParamsCache(); auto result = cache->getOrCreate(key, builder); + if (!result.first) { + OPENVINO_THROW("ScaleDotAttention AttentionExecutor creation fails with precision " + rtPrecision.to_string()); + } m_executor = result.first; } void ScaledDotProductAttention::execute(dnnl::stream strm) { auto orginSDPInputNumber = getOriginalInputsNumber() - (m_config.config.fuse_concat ? 3 : 0); std::vector inputs(orginSDPInputNumber); - auto output = getChildEdgeAt(0)->getMemoryPtr(); + auto output = getDstMemoryAtPort(0); MemoryPtr presentk_input, presentv_input, beam_input; for (size_t i = 0; i < orginSDPInputNumber; i++) { - inputs[i] = getParentEdgeAt(i)->getMemoryPtr(); + inputs[i] = getSrcMemoryAtPort(i); } if (m_config.config.fuse_concat) { // initialization will be also completed in this func - gatherConcatPastkv(inputs[1], inputs[2], getParentEdgeAt(orginSDPInputNumber)->getMemoryPtr()); + gatherConcatPastkv(inputs[1], inputs[2], getSrcMemoryAtPort(orginSDPInputNumber)); presentk_input = m_k_state->internal_state_mem(); presentv_input = m_v_state->internal_state_mem(); @@ -1172,8 +1425,8 @@ void ScaledDotProductAttention::updatePastkv(const MemoryPtr& mem_cur_k, const M } if (L0 > 0 && is_reset) { auto inputNumber = getOriginalInputsNumber(); - auto k_mem = getParentEdgeAt(inputNumber - 2)->getMemoryPtr(); - auto v_mem = getParentEdgeAt(inputNumber - 1)->getMemoryPtr(); + auto k_mem = getSrcMemoryAtPort(inputNumber - 2); + auto v_mem = getSrcMemoryAtPort(inputNumber - 1); auto&& k_shape = k_mem->getShape(); auto&& v_shape = v_mem->getShape(); if (!k_shape.hasZeroDims() && !v_shape.hasZeroDims()) { @@ -1200,21 +1453,12 @@ ov::element::Type ScaledDotProductAttention::getKVCachePrecision() { ov::element::Type ScaledDotProductAttention::getRuntimePrecision() const { auto rtPrecision = getOriginalInputPrecisionAtPort(0); - // only support bf16 and f32 - if (rtPrecision != ov::element::bf16 && rtPrecision != ov::element::f32) - rtPrecision = ov::element::f32; - - size_t H_idx = 1; - if (!m_config.config.permute_axes.empty()) { - H_idx = m_config.config.permute_axes[1]; - } - const auto& qDims = getInputShapeAtPort(0).getDims(); - const auto& kDims = getInputShapeAtPort(1).getDims(); - // if multi-query, enforce fp32 TODO: support BF16 - if (qDims[H_idx] != kDims[H_idx]) { + // bf16 should be enabled only when platform supports + if (rtPrecision == ov::element::bf16 && ov::with_cpu_x86_bfloat16()) { + rtPrecision = ov::element::bf16; + } else { rtPrecision = ov::element::f32; } - return rtPrecision; } diff --git a/src/plugins/intel_cpu/src/nodes/scatter_update.cpp b/src/plugins/intel_cpu/src/nodes/scatter_update.cpp index cd3e3c41aeb503..c4406b364f2880 100644 --- a/src/plugins/intel_cpu/src/nodes/scatter_update.cpp +++ b/src/plugins/intel_cpu/src/nodes/scatter_update.cpp @@ -264,15 +264,15 @@ static std::vector getBlockND(const VectorDims& shape) { } void ScatterUpdate::execute(dnnl::stream strm) { - auto srcMemPtr = getParentEdgeAt(DATA_ID)->getMemoryPtr(); - auto dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); - auto indicesMemPtr = getParentEdgeAt(INDICES_ID)->getMemoryPtr(); - auto updateMemPtr = getParentEdgeAt(UPDATE_ID)->getMemoryPtr(); + auto srcMemPtr = getSrcMemoryAtPort(DATA_ID); + auto dstMemPtr = getDstMemoryAtPort(0); + auto indicesMemPtr = getSrcMemoryAtPort(INDICES_ID); + auto updateMemPtr = getSrcMemoryAtPort(UPDATE_ID); - uint8_t *dstPtr = reinterpret_cast(dstMemPtr->getData()); - uint8_t *srcPtr = reinterpret_cast(srcMemPtr->getData()); - uint8_t *indicesPtr = reinterpret_cast(indicesMemPtr->getData()); - uint8_t *updatePtr = reinterpret_cast(updateMemPtr->getData()); + uint8_t *dstPtr = dstMemPtr->getDataAs(); + uint8_t *srcPtr = srcMemPtr->getDataAs(); + uint8_t *indicesPtr = indicesMemPtr->getDataAs(); + uint8_t *updatePtr = updateMemPtr->getDataAs(); const auto& srcDataDim = getParentEdgeAt(DATA_ID)->getMemory().getStaticDims(); const auto& indicesDim = getParentEdgeAt(INDICES_ID)->getMemory().getStaticDims(); @@ -302,8 +302,8 @@ void ScatterUpdate::execute(dnnl::stream strm) { int axis = 0; if (axisRelaxed) { - auto axisMemPtr = getParentEdgeAt(AXIS_ID)->getMemoryPtr(); - uint8_t *axisPtr = reinterpret_cast(axisMemPtr->getData()); + auto axisMemPtr = getSrcMemoryAtPort(AXIS_ID); + uint8_t *axisPtr = axisMemPtr->getDataAs(); if (axisSize == 4) { auto *axisPtr32 = reinterpret_cast(axisPtr); axis = *axisPtr32; diff --git a/src/plugins/intel_cpu/src/nodes/shapeof.cpp b/src/plugins/intel_cpu/src/nodes/shapeof.cpp index 0a15713e4d2cf8..e4596a7f9dec02 100644 --- a/src/plugins/intel_cpu/src/nodes/shapeof.cpp +++ b/src/plugins/intel_cpu/src/nodes/shapeof.cpp @@ -84,14 +84,14 @@ bool ShapeOf::isExecutable() const { } void ShapeOf::execute(dnnl::stream strm) { - auto inPtr = getParentEdgeAt(0)->getMemoryPtr(); - auto outPtr = getChildEdgeAt(0)->getMemoryPtr(); + auto inPtr = getSrcMemoryAtPort(0); + auto outPtr = getDstMemoryAtPort(0); auto&& inDims = inPtr->getStaticDims(); size_t dimsCount = inDims.size(); if (outPtr->getStaticDims().size() != 1 || dimsCount != outPtr->getStaticDims()[0]) OPENVINO_THROW(errorPrefix, "has inconsistent input shape and output size"); - auto* dst = reinterpret_cast(outPtr->getData()); + auto* dst = outPtr->getDataAs(); for (size_t i = 0; i < dimsCount; i++) { dst[i] = inDims[i]; diff --git a/src/plugins/intel_cpu/src/nodes/shuffle_channels.cpp b/src/plugins/intel_cpu/src/nodes/shuffle_channels.cpp index 06b3ddbd4820a1..02adcc9f6358fe 100644 --- a/src/plugins/intel_cpu/src/nodes/shuffle_channels.cpp +++ b/src/plugins/intel_cpu/src/nodes/shuffle_channels.cpp @@ -4,12 +4,13 @@ #include "shuffle_channels.h" +#include + #include "openvino/core/parallel.hpp" #include "dnnl_extension_utils.h" #include "cpu/x64/jit_generator.hpp" #include "common/blocked_desc_creator.h" -#include "common/cpu_memcpy.h" #include "utils/general_utils.h" #include @@ -125,8 +126,8 @@ void ShuffleChannels::initSupportedPrimitiveDescriptors() { } void ShuffleChannels::createPrimitive() { - auto dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); - auto srcMemPtr = getParentEdgeAt(0)->getMemoryPtr(); + auto dstMemPtr = getDstMemoryAtPort(0); + auto srcMemPtr = getSrcMemoryAtPort(0); if (!dstMemPtr || !dstMemPtr->isAllocated()) THROW_SHCH_ERROR("has not allocated destination memory"); if (!srcMemPtr || !srcMemPtr->isAllocated()) @@ -149,7 +150,7 @@ void ShuffleChannels::createPrimitive() { } void ShuffleChannels::prepareParams() { - auto srcMemPtr = getParentEdgeAt(0)->getMemoryPtr(); + auto srcMemPtr = getSrcMemoryAtPort(0); auto builder = [](const ShuffleChannelsAttributes& key) -> std::shared_ptr { return std::make_shared(key); }; @@ -292,10 +293,10 @@ void ShuffleChannels::execute(dnnl::stream strm) { if (!execPtr) THROW_SHCH_ERROR("doesn't have a compiled executor."); - int MB = (attrs.axis != 0) ? getParentEdgeAt(0)->getMemoryPtr()->getStaticDims()[0] : -1; + int MB = (attrs.axis != 0) ? getSrcMemoryAtPort(0)->getStaticDims()[0] : -1; - const uint8_t* srcData = reinterpret_cast(getParentEdgeAt(0)->getMemoryPtr()->getData()); - uint8_t* dstData = reinterpret_cast(getChildEdgeAt(0)->getMemoryPtr()->getData()); + const uint8_t* srcData = getSrcDataAtPortAs(0); + uint8_t* dstData = getDstDataAtPortAs(0); execPtr->exec(srcData, dstData, MB); } diff --git a/src/plugins/intel_cpu/src/nodes/softmax.cpp b/src/plugins/intel_cpu/src/nodes/softmax.cpp index 315d3e17f58369..a49140770c3293 100644 --- a/src/plugins/intel_cpu/src/nodes/softmax.cpp +++ b/src/plugins/intel_cpu/src/nodes/softmax.cpp @@ -217,8 +217,8 @@ void SoftMax::prepareParams() { auto scratchpadMem = getScratchPadMem(execPtr->getScratchPadDesc()); primArgs[DNNL_ARG_SCRATCHPAD] = scratchpadMem->getPrimitive(); - primArgs[DNNL_ARG_SRC] = getParentEdgesAtPort(0)[0]->getMemoryPtr()->getPrimitive(); - primArgs[DNNL_ARG_DST] = getChildEdgesAtPort(0)[0]->getMemoryPtr()->getPrimitive(); + primArgs[DNNL_ARG_SRC] = getSrcMemoryAtPort(0)->getPrimitive(); + primArgs[DNNL_ARG_DST] = getDstMemoryAtPort(0)->getPrimitive(); #ifdef CPU_DEBUG_CAPS if (result.second == CacheEntryBase::LookUpStatus::Miss) { auto pd = execPtr->getPrimitiveDesc(); diff --git a/src/plugins/intel_cpu/src/nodes/space_to_batch.cpp b/src/plugins/intel_cpu/src/nodes/space_to_batch.cpp index 17e9505b8a617f..cbfa4b40a14b18 100644 --- a/src/plugins/intel_cpu/src/nodes/space_to_batch.cpp +++ b/src/plugins/intel_cpu/src/nodes/space_to_batch.cpp @@ -96,24 +96,24 @@ static std::vector getShape5D(const VectorDims &shape) { template void SpaceToBatch::SpaceToBatchKernel() { - const auto& srcMem = getParentEdgesAtPort(0)[0]->getMemoryPtr(); - const auto& dstMem = getChildEdgesAtPort(0)[0]->getMemoryPtr(); + const auto& srcMem = getSrcMemoryAtPort(0); + const auto& dstMem = getDstMemoryAtPort(0); - const auto *blockShapesPtr = reinterpret_cast(getParentEdgeAt(1)->getMemoryPtr()->getData()); + const auto *blockShapesPtr = getSrcDataAtPortAs(1); size_t dataRank = srcMem->getShape().getRank(); blockShapeIn.clear(); for (size_t i = 0; i < dataRank; i++) { blockShapeIn.push_back(*(blockShapesPtr + i)); } - const auto *padsBeginPtr = reinterpret_cast(getParentEdgeAt(2)->getMemoryPtr()->getData()); + const auto *padsBeginPtr = getSrcDataAtPortAs(2); padsBeginIn.clear(); for (size_t i = 0; i < dataRank; i++) { padsBeginIn.push_back(*(padsBeginPtr + i)); } - const auto *srcData = reinterpret_cast(srcMem->getData()); - auto *dstData = reinterpret_cast(dstMem->getData()); + const auto *srcData = srcMem->getDataAs(); + auto *dstData = dstMem->getDataAs(); const int64_t srcLen = srcMem->getSize() / sizeof(T); const int64_t dstLen = dstMem->getSize() / sizeof(T); diff --git a/src/plugins/intel_cpu/src/nodes/space_to_depth.cpp b/src/plugins/intel_cpu/src/nodes/space_to_depth.cpp index f36aec86dd6aa1..747b9a6aa1022a 100644 --- a/src/plugins/intel_cpu/src/nodes/space_to_depth.cpp +++ b/src/plugins/intel_cpu/src/nodes/space_to_depth.cpp @@ -163,8 +163,8 @@ void SpaceToDepth::initSupportedPrimitiveDescriptors() { } void SpaceToDepth::createPrimitive() { - auto dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); - auto srcMemPtr = getParentEdgeAt(0)->getMemoryPtr(); + auto dstMemPtr = getDstMemoryAtPort(0); + auto srcMemPtr = getSrcMemoryAtPort(0); if (!dstMemPtr || !dstMemPtr->isAllocated()) THROW_ERROR("has not allocated destination memory"); if (!srcMemPtr || !srcMemPtr->isAllocated()) @@ -189,9 +189,9 @@ void SpaceToDepth::createPrimitive() { void SpaceToDepth::prepareParams() { attrs.srcBlockedDims = - getParentEdgeAt(0)->getMemoryPtr()->getDescWithType()->getBlockDims(); + getSrcMemoryAtPort(0)->getDescWithType()->getBlockDims(); attrs.destBlockedDims = - getChildEdgeAt(0)->getMemoryPtr()->getDescWithType()->getBlockDims(); + getDstMemoryAtPort(0)->getDescWithType()->getBlockDims(); auto builder = [](const SpaceToDepthAttrs& key) -> std::shared_ptr { return std::make_shared(key); }; @@ -312,9 +312,9 @@ void SpaceToDepth::execute(dnnl::stream strm) { if (!execPtr) { THROW_ERROR("doesn't have a compiled executor."); } - const uint8_t* srcData = reinterpret_cast(getParentEdgeAt(0)->getMemoryPtr()->getData()); - uint8_t* dstData = reinterpret_cast(getChildEdgeAt(0)->getMemoryPtr()->getData()); - const int MB = getParentEdgeAt(0)->getMemoryPtr()->getStaticDims()[0]; + const uint8_t* srcData = getSrcDataAtPortAs(0); + uint8_t* dstData = getDstDataAtPortAs(0); + const int MB = getSrcMemoryAtPort(0)->getStaticDims()[0]; execPtr->exec(srcData, dstData, MB); } diff --git a/src/plugins/intel_cpu/src/nodes/split.cpp b/src/plugins/intel_cpu/src/nodes/split.cpp index e6bb1fcde13861..b353431c40e0bf 100644 --- a/src/plugins/intel_cpu/src/nodes/split.cpp +++ b/src/plugins/intel_cpu/src/nodes/split.cpp @@ -207,12 +207,12 @@ bool Split::needShapeInfer() const { if (Node::needShapeInfer()) { return true; } else if (!constSplitLengths) { - const auto& lengthsMemPtr = getParentEdgeAt(2)->getMemoryPtr(); + const auto& lengthsMemPtr = getSrcMemoryAtPort(2); const auto curLengthsSize = lengthsMemPtr->getStaticDims()[0]; if (curLengthsSize != splitLengths.size()) { return true; } - const int* curLengthsValues = reinterpret_cast(lengthsMemPtr->getData()); + const int* curLengthsValues = lengthsMemPtr->getDataAs(); for (size_t i = 0; i < curLengthsSize; ++i) { if (curLengthsValues[i] != splitLengths[i]) { return true; @@ -230,14 +230,14 @@ bool Split::needPrepareParams() const { } void Split::prepareParams() { - const auto &srcMemPtr = getParentEdgesAtPort(0)[0]->getMemoryPtr(); + const auto &srcMemPtr = getSrcMemoryAtPort(0); if (!srcMemPtr || !srcMemPtr->isAllocated()) { THROW_ERROR("has not allocated input memory"); } if (!constSplitLengths) { - const auto& splitLengthsPtr = getParentEdgeAt(2)->getMemoryPtr(); - const int* curSplitLengths = reinterpret_cast(splitLengthsPtr->getData()); + const auto& splitLengthsPtr = getSrcMemoryAtPort(2); + const int* curSplitLengths = splitLengthsPtr->getDataAs(); const auto curLengthsSize = splitLengthsPtr->getStaticDims()[0]; splitLengths.assign(curSplitLengths, curSplitLengths + curLengthsSize); } @@ -245,7 +245,7 @@ void Split::prepareParams() { dstMemPtrs.clear(); std::vector outDescs; for (size_t port = 0; port < outputShapes.size(); ++port) { - const auto &outMemPtr = this->getChildEdgesAtPort(port)[0]->getMemoryPtr(); + const auto &outMemPtr = this->getDstMemoryAtPort(port); if (!outMemPtr || !outMemPtr->isAllocated()) { THROW_ERROR("has not allocated destination memory"); } @@ -279,14 +279,14 @@ void Split::execute(dnnl::stream strm) { if (dstMemPtrs.empty()) THROW_ERROR("Output data pointers have not been initialized."); - const auto &srcMem = getParentEdgesAtPort(0)[0]->getMemory(); + const auto &srcMem = getParentEdgeAt(0)->getMemory(); if (canUseOptimizedNspc2Ncsp) { optimizedNspc2Ncsp(srcMem.getStaticDims()[0]); return; } - uint8_t* srcData = reinterpret_cast(srcMem.getData()); + uint8_t* srcData = srcMem.getDataAs(); OPENVINO_ASSERT(execPtr != nullptr); execPtr->exec(srcData, getRawDstMemPtrs()); } @@ -420,7 +420,7 @@ void Split::optimizedNspc2Ncsp(size_t MB) { const size_t W = parentDims[rank - 1]; auto& srcMem = parentEdge->getMemory(); - auto srcData = reinterpret_cast(srcMem.getData()); + auto srcData = srcMem.getDataAs(); const auto dataSize = srcMem.getDesc().getPrecision().size(); const size_t DHW = D*H*W; @@ -429,10 +429,10 @@ void Split::optimizedNspc2Ncsp(size_t MB) { const size_t strideOC = DHW * dataSize; for (size_t i = 0, sIdx = 0; i < dstMemPtrs.size(); i++) { - auto dstData = reinterpret_cast(dstMemPtrs[i].second->getData()); + auto dstData = dstMemPtrs[i].second->getDataAs(); size_t innerSize = 1; - auto dims = getChildEdgesAtPort(dstMemPtrs[i].first)[0]->getMemory().getStaticDims(); + auto dims = getChildEdgeAt(dstMemPtrs[i].first)->getMemory().getStaticDims(); for (size_t j = axis; j < dims.size(); j++) { innerSize *= dims[j]; @@ -459,7 +459,7 @@ void Split::optimizedNspc2Ncsp(size_t MB) { std::vector Split::getRawDstMemPtrs() const { std::vector result(dstMemPtrs.size()); for (size_t i = 0; i < dstMemPtrs.size(); ++i) { - result[i] = reinterpret_cast(dstMemPtrs[i].second->getData()); + result[i] = dstMemPtrs[i].second->getDataAs(); if (!result[i]) { THROW_ERROR("can't get child edge indx ", dstMemPtrs[i].first, " data."); } @@ -538,7 +538,7 @@ void Split::resolveInPlaceEdges(Edge::LOOK look) { " Split node: ", getName(), " can not use inPlace memory with splitting on dynamic dimension"); - auto baseMemMngr = getParentEdgesAtPort(inplaceInpIndx).front()->getMemory().getMemoryMngr(); + auto baseMemMngr = getParentEdgeAt(inplaceInpIndx)->getMemory().getMemoryMngr(); ptrdiff_t offset = 0; for (size_t i = 0; i < numberOfOutputs; ++i) { auto partDim = outputShapes[i].getDims()[axis]; diff --git a/src/plugins/intel_cpu/src/nodes/strided_slice.cpp b/src/plugins/intel_cpu/src/nodes/strided_slice.cpp index d5d2fc2e3620c3..a59eea3f0f45d3 100644 --- a/src/plugins/intel_cpu/src/nodes/strided_slice.cpp +++ b/src/plugins/intel_cpu/src/nodes/strided_slice.cpp @@ -288,12 +288,12 @@ void StridedSlice::prepareParams() { if (srcMemory.empty()) { for (size_t i = 0; i < getOriginalInputsNumber(); i++) { - srcMemory.push_back(getParentEdgeAt(i)->getMemoryPtr()); + srcMemory.push_back(getSrcMemoryAtPort(i)); } } if (dstMemory.empty()) { for (size_t i = 0; i < getOriginalOutputsNumber(); i++) { - dstMemory.push_back(getChildEdgeAt(i)->getMemoryPtr()); + dstMemory.push_back(getDstMemoryAtPort(i)); } } execPtr = std::make_shared(attrs, srcMemory, dstMemory, errorPrefix); @@ -390,7 +390,7 @@ void StridedSlice::StridedSliceCommonExecutor::paramsInitialization(const Stride const size_t nDims = std::max(inputRank, outputRank); auto fillingInParameters = [&](std::vector ¶meter, const size_t type, const size_t size, const int value) { - const int *ptr = reinterpret_cast(srcMemory[type]->getData()); + const int *ptr = srcMemory[type]->getDataAs(); parameter.assign(ptr, ptr + size); if (type != AXES_ID && params.attrs.ellipsisMaskCounter == 0 && size < nDims) { @@ -725,8 +725,8 @@ void StridedSlice::StridedSliceCommonExecutor::indicesCalculationForOptimized() } void StridedSlice::StridedSliceCommonExecutor::exec(const std::vector& srcMemory, const std::vector& dstMemory) { - const uint8_t* srcData = reinterpret_cast(srcMemory[0]->getData()); - uint8_t* dstData = reinterpret_cast(dstMemory[0]->getData()); + const uint8_t* srcData = srcMemory[0]->getDataAs(); + uint8_t* dstData = dstMemory[0]->getDataAs(); const uint8_t* srcShiftedData = srcData + srcShift; parallel_nt(nThreads, [&](const int ithr, const int nthr) { size_t start = 0, end = 0; diff --git a/src/plugins/intel_cpu/src/nodes/subgraph.cpp b/src/plugins/intel_cpu/src/nodes/subgraph.cpp index b63def7f19d641..0b174a89b0afd8 100644 --- a/src/plugins/intel_cpu/src/nodes/subgraph.cpp +++ b/src/plugins/intel_cpu/src/nodes/subgraph.cpp @@ -31,6 +31,7 @@ #include "transformations/snippets/x64/pass/enforce_precision.hpp" #include "transformations/snippets/x64/shape_inference.hpp" #include "utils/cpu_utils.hpp" +#include "utils/ngraph_utils.hpp" #include #include @@ -393,9 +394,9 @@ ov::element::Type Snippet::getRuntimePrecision() const { void Snippet::prepareParams() { for (size_t i = 0; i < inputNum; i++) - snippetAttrs.inMemBlockedDims[i] = getParentEdgesAtPort(i)[0]->getMemory().getDescWithType()->getBlockDims(); + snippetAttrs.inMemBlockedDims[i] = getParentEdgeAt(i)->getMemory().getDescWithType()->getBlockDims(); for (size_t i = 0; i < outputNum; i++) - snippetAttrs.outMemBlockedDims[i] = getChildEdgesAtPort(i)[0]->getMemory().getDescWithType()->getBlockDims(); + snippetAttrs.outMemBlockedDims[i] = getChildEdgeAt(i)->getMemory().getDescWithType()->getBlockDims(); SnippetKey key = {snippetAttrs}; @@ -433,7 +434,7 @@ bool Snippet::needPrepareParams() const { } bool Snippet::canBeInPlace() const { - if (isDynamic || getParentEdgesAtPort(0)[0]->getParent()->getType() == Type::Input) { + if (isDynamic || getParentEdgeAt(0)->getParent()->getType() == Type::Input) { return false; } if (getChildEdges().size() != 1) { @@ -466,9 +467,9 @@ void Snippet::execute(dnnl::stream strm) { OPENVINO_THROW("Can't execute Subgraph node. Primitive didn't created"); } for (size_t i = 0; i < inputNum; i++) - srcMemPtrs[i] = getParentEdgeAt(i)->getMemoryPtr(); + srcMemPtrs[i] = getSrcMemoryAtPort(i); for (size_t i = 0; i < outputNum; i++) - dstMemPtrs[i] = getChildEdgeAt(i)->getMemoryPtr(); + dstMemPtrs[i] = getDstMemoryAtPort(i); execPtr->exec(srcMemPtrs, dstMemPtrs); } @@ -505,10 +506,10 @@ void Snippet::SnippetJitExecutor::exec(const std::vector& inMemPtrs, void Snippet::SnippetJitExecutor::update_ptrs(jit_snippets_call_args& call_args, const std::vector& inMemPtrs, const std::vector& outMemPtrs) { for (size_t i = 0; i < inMemPtrs.size(); i++) - call_args.src_ptrs[i] = reinterpret_cast(inMemPtrs[i]->getData()) + start_offset_in[i]; + call_args.src_ptrs[i] = inMemPtrs[i]->getDataAs() + start_offset_in[i]; for (size_t i = 0; i < outMemPtrs.size(); i++) - call_args.dst_ptrs[i] = reinterpret_cast(outMemPtrs[i]->getData()) + start_offset_out[i]; + call_args.dst_ptrs[i] = outMemPtrs[i]->getDataAs() + start_offset_out[i]; if (buffer_scratchpad_size > 0) { call_args.buffer_scratchpad_ptr = diff --git a/src/plugins/intel_cpu/src/nodes/tensoriterator.cpp b/src/plugins/intel_cpu/src/nodes/tensoriterator.cpp index 6d7ab4d1623c3b..9ce943b3ae259e 100644 --- a/src/plugins/intel_cpu/src/nodes/tensoriterator.cpp +++ b/src/plugins/intel_cpu/src/nodes/tensoriterator.cpp @@ -10,6 +10,7 @@ #include "shape_inference/shape_inference_internal_dyn.hpp" #include "transformations/utils/utils.hpp" #include "utils/general_utils.h" +#include "utils/debug_capabilities.h" #include #include @@ -143,7 +144,7 @@ class PortIteratorHelper : public PortMapHelper { class BackEdgePortHelper : public PortMapHelper { public: - BackEdgePortHelper(MultiCachePtr cache, const MemoryPtr &from, const MemoryPtr &to, const dnnl::engine& eng) { + BackEdgePortHelper(MultiCachePtr cache, const MemoryPtr &from, const MemoryPtr &to) { mem_holder_src = from->getPrimitive(); mem_holder_dst = to->getPrimitive(); reorder = getReorderPrim(cache, mem_holder_dst.get_engine(), mem_holder_src.get_desc(), mem_holder_dst.get_desc()); @@ -310,8 +311,8 @@ void DynamicBuffer::move_buffer(const MemoryPtr& new_buffer) { const auto src_offset_in_byte = stride > 0 ? 0 : (src_stride - valid_size); chunk_offset_in_byte = stride > 0 ? 0 : (dst_stride - valid_size); // reset chunk_offset_in_byte - copy(reinterpret_cast(mem_holder_buffer->getData()) + src_offset_in_byte, - reinterpret_cast(new_buffer->getData()) + chunk_offset_in_byte, + copy(mem_holder_buffer->getDataAs() + src_offset_in_byte, + new_buffer->getDataAs() + chunk_offset_in_byte, src_stride, dst_stride, count, valid_size); // assign mem_holder_buffer @@ -330,7 +331,7 @@ void DynamicBuffer::move_data() { const auto src_stride = abs(map_rule.stride) * len; const auto dst_stride = chunk_stride_in_byte; - copy(reinterpret_cast(from->getData()), reinterpret_cast(mem_holder_buffer->getData()) + chunk_offset_in_byte, + copy(from->getDataAs(), mem_holder_buffer->getDataAs() + chunk_offset_in_byte, src_stride, dst_stride, count, chunk_unit_in_byte); // adjust for next execution @@ -361,8 +362,10 @@ void DynamicBuffer::transfer(const Node* node) { const auto dst_stride = to.front()->getStaticDims()[axis] * len; const auto valid_size = chunk_unit_in_byte * num_execs; const auto src_offset_in_byte = stride > 0 ? 0 : (src_stride - valid_size); - copy(reinterpret_cast(mem_holder_buffer->getData()) + src_offset_in_byte, reinterpret_cast(to.front()->getData()), - src_stride, dst_stride, count, dst_stride); + + copy(mem_holder_buffer->getDataAs() + src_offset_in_byte, + to.front()->getDataAs(), + src_stride, dst_stride, count, dst_stride); } else { VectorDims newDims = to.front()->getShape().getDims(); nullifyUndefinedDims(newDims); @@ -422,7 +425,7 @@ void TensorIterator::getSupportedDescriptors() { const auto inputID = ov::op::util::create_ie_output_name(prev); auto outNode = outMap.find(inputID); if (outNode != outMap.end()) { - auto outMem = outNode->second->getParentEdgeAt(0)->getMemoryPtr(); + auto outMem = outNode->second->getSrcMemoryAtPort(0); output_mem.push_back(outMem); } } @@ -519,8 +522,8 @@ void TensorIterator::createPrimitive() { bool TensorIterator::needPrepareParams() const { if (getAlgorithm() == Algorithm::TensorIteratorLoop) { - const auto tripCountPtr = reinterpret_cast(getParentEdgesAtPort(loopTripCountIdx).front()->getMemoryPtr()->getData()); - const auto condPtr = reinterpret_cast(getParentEdgesAtPort(loopExecutionConditionIdx).front()->getMemoryPtr()->getData()); + const auto tripCountPtr = getSrcDataAtPortAs(loopTripCountIdx); + const auto condPtr = getSrcDataAtPortAs(loopExecutionConditionIdx); if (tripCountPtr[0] != static_cast(lastUsedTripCount) || static_cast(condPtr[0]) != lastUsedCond) return true; } @@ -568,6 +571,7 @@ void TensorIterator::prepareParams() { void TensorIterator::execute(dnnl::stream strm) { //Special case, the subgraph is dynamic while the node has all static shapes if (runAsDynamic()) { + restoreSubgraphInputByBackEdges(); executeDynamicImpl(strm); return; } @@ -578,7 +582,7 @@ void TensorIterator::execute(dnnl::stream strm) { int max_num_iter = trip_count_check->getStatus(); for (auto &mapper : first_mappers) - mapper->execute(strm); + mapper.second->execute(strm); // use "i != max_num_iter" only to allow "-1" works like infinite loop for (int i = 0; i != max_num_iter && continue_cond; i++) { @@ -608,7 +612,7 @@ void TensorIterator::executeDynamicImpl(dnnl::stream strm) { int max_num_iter = trip_count_check->getStatus(); for (auto &mapper : first_mappers) - mapper->execute(strm); + mapper.second->execute(strm); // use "i != max_num_iter" only to allow "-1" works like infinite loop for (int i = 0; i != max_num_iter && continue_cond; i++) { @@ -638,11 +642,12 @@ void TensorIterator::executeDynamicImpl(dnnl::stream strm) { void TensorIterator::prepareInputPorts() { const auto &eng = getEngine(); for (auto map_rule : inputPortMap) { - auto from_mem = getParentEdgesAtPort(map_rule.from)[0]->getMemoryPtr(); + auto from_mem = getSrcMemoryAtPort(map_rule.from); auto &to_mem = input_mems[map_rule.to].front(); // first memory is enough to access the shared underlying physical memory if (map_rule.axis == -1) - first_mappers.emplace_back(std::make_shared(context->getParamsCache(), from_mem, to_mem, eng)); + first_mappers.emplace(std::make_pair(map_rule.from, map_rule.to), + std::make_shared(context->getParamsCache(), from_mem, to_mem)); else before_mappers.emplace_back( std::make_shared(context->getParamsCache(), from_mem, to_mem, true, map_rule, eng)); @@ -652,28 +657,26 @@ void TensorIterator::prepareInputPorts() { void TensorIterator::prepareOutputPorts() { const auto &eng = getEngine(); for (auto map_rule : outputPortMap) { - auto to_mem = getChildEdgesAtPort(map_rule.from)[0]->getMemoryPtr(); + auto to_mem = getDstMemoryAtPort(map_rule.from); auto &from_mem = output_mem[map_rule.to]; if (map_rule.axis == -1) - last_mappers.emplace_back(std::make_shared(context->getParamsCache(), from_mem, to_mem, eng)); + last_mappers.emplace_back(std::make_shared(context->getParamsCache(), from_mem, to_mem)); else after_mappers.emplace_back(std::make_shared(context->getParamsCache(), from_mem, to_mem, false, map_rule, eng)); } } void TensorIterator::prepareBackEdges() { - const auto &eng = getEngine(); for (auto map_rule : backEdges) { auto from_mem = output_mem[map_rule.from]; auto to_mem = input_mems[map_rule.to].front(); - before_mappers.emplace_back(std::make_shared(context->getParamsCache(), from_mem, to_mem, eng)); + before_mappers.emplace_back(std::make_shared(context->getParamsCache(), from_mem, to_mem)); } } void TensorIterator::prepareDynamicBackEdges() { - const auto &eng = getEngine(); back_mappers.clear(); for (auto map_rule : backEdges) { auto from_mem = output_mem[map_rule.from]; @@ -682,7 +685,7 @@ void TensorIterator::prepareDynamicBackEdges() { redefineToMemories(to_mems, from_mem->getDescPtr()); // first memory is enough to get common memory ptr - back_mappers.emplace_back(std::make_shared(context->getParamsCache(), from_mem, to_mems.front(), eng)); + back_mappers.emplace_back(std::make_shared(context->getParamsCache(), from_mem, to_mems.front())); } } @@ -713,7 +716,7 @@ void TensorIterator::prepareContinueCond() { void TensorIterator::prepareInitialCond() { if (loopExecutionConditionIdx != -1 || !initial_cond_check) { - auto mem = getParentEdgesAtPort(loopExecutionConditionIdx)[0]->getMemoryPtr(); + auto mem = getSrcMemoryAtPort(loopExecutionConditionIdx); initial_cond_check.reset(new asBoolCheck(mem)); lastUsedCond = initial_cond_check->getStatus(); } @@ -723,7 +726,7 @@ void TensorIterator::prepareTripCount() { if (loopTripCountIdx == -1) { trip_count_check.reset(new staticValueCheck(getNumIteration(inputPortMap, outputPortMap))); } else { - auto mem = getParentEdgesAtPort(loopTripCountIdx)[0]->getMemoryPtr(); + auto mem = getSrcMemoryAtPort(loopTripCountIdx); trip_count_check.reset(new asIntCheck(mem)); } lastUsedTripCount = trip_count_check->getStatus(); @@ -740,7 +743,7 @@ inline VectorDims sliced_input_dims(const MemoryPtr& mem, const int axis, const void TensorIterator::reshapeSubgraphInput() { for (auto map_rule : inputPortMap) { - auto new_dims = sliced_input_dims(getParentEdgesAtPort(map_rule.from)[0]->getMemoryPtr(), map_rule.axis, map_rule.stride); + auto new_dims = sliced_input_dims(getSrcMemoryAtPort(map_rule.from), map_rule.axis, map_rule.stride); auto &to_mems = input_mems[map_rule.to]; const auto& body_inshape = to_mems.front()->getShape(); if (body_inshape.isDynamic() || body_inshape.getDims() != new_dims) { @@ -751,7 +754,6 @@ void TensorIterator::reshapeSubgraphInput() { } void TensorIterator::reshapeAndFillOutput(dnnl::stream strm) { - auto eng = strm.get_engine(); for (auto map_rule : outputPortMap) { if (map_rule.axis == -1) { auto to_mems = getToMemories(this, map_rule.from); @@ -767,7 +769,7 @@ void TensorIterator::reshapeAndFillOutput(dnnl::stream strm) { redefineToMemories(to_mems, desc); if (!newShape.isDynamic()) { - BackEdgePortHelper mapper(context->getParamsCache(), from_mem, to_mems.front(), eng); + BackEdgePortHelper mapper(context->getParamsCache(), from_mem, to_mems.front()); mapper.execute(strm); } } @@ -780,7 +782,7 @@ void TensorIterator::reshapeAndFillOutput(dnnl::stream strm) { bool TensorIterator::checkForInputAndBodyShapesInequality() const { for (auto map_rule : inputPortMap) { - auto original_dims = sliced_input_dims(getParentEdgesAtPort(map_rule.from)[0]->getMemoryPtr(), map_rule.axis, map_rule.stride); + auto original_dims = sliced_input_dims(getSrcMemoryAtPort(map_rule.from), map_rule.axis, map_rule.stride); auto &to_mems = input_mems[map_rule.to]; const auto& body_inshape = to_mems.front()->getShape(); if (body_inshape.isDynamic() || body_inshape.getDims() != original_dims) { @@ -791,6 +793,27 @@ bool TensorIterator::checkForInputAndBodyShapesInequality() const { return false; } +// redefine memory for input nodes of subgraph and reset first_mappers as the primitives are invalid, +// when the node is static while runs a dynamic subgraph. +void TensorIterator::restoreSubgraphInputByBackEdges() { + for (auto& input_map : first_mappers) { + const auto extern_input_index = std::get<0>(input_map.first); + const auto body_input_index = std::get<1>(input_map.first); + auto from_mem = getParentEdgeAt(extern_input_index)->getMemoryPtr(); + auto &to_mems = input_mems[body_input_index]; + auto &to_mem = to_mems.front(); + const auto& input_dims = from_mem->getStaticDims(); + const auto& body_dims = to_mem->getStaticDims(); + if (body_dims != input_dims) { + const auto desc = std::make_shared(to_mem->getDesc().getPrecision(), Shape(input_dims)); + redefineToMemories(to_mems, desc); + + // update first_mappers to replace its legacy input memory addr. + input_map.second.reset(new BackEdgePortHelper(context->getParamsCache(), from_mem, to_mem)); + } + } +} + int TensorIterator::getNumIteration(const std::vector& inputPortMap, const std::vector& outputPortMap) const { const auto isIterable = [](const PortMap& rule) { return rule.axis != -1; @@ -843,7 +866,7 @@ int TensorIterator::getNumIteration(const std::vector& inputPortMap, co int numIterations = 1; bool isDefault = true; for (const auto& rule : inputPortMap) { - const auto& dims = getParentEdgesAtPort(rule.from)[0]->getMemoryPtr()->getStaticDims(); + const auto& dims = getSrcMemoryAtPort(rule.from)->getStaticDims(); if (!isIterable(rule)) { continue; } diff --git a/src/plugins/intel_cpu/src/nodes/tensoriterator.h b/src/plugins/intel_cpu/src/nodes/tensoriterator.h index 07a1c0106b799b..e2968d274e2bf3 100644 --- a/src/plugins/intel_cpu/src/nodes/tensoriterator.h +++ b/src/plugins/intel_cpu/src/nodes/tensoriterator.h @@ -138,14 +138,26 @@ class TensorIterator : public Node { void reshapeAndFillOutput(dnnl::stream strm); bool checkForInputAndBodyShapesInequality() const; int getNumIteration(const std::vector& inputPortMap, const std::vector& outputPortMap) const; + + /* run dynamic subgraph inside a static node */ bool runAsDynamic() const; + void restoreSubgraphInputByBackEdges(); Graph sub_graph; std::vector> input_mems; std::vector output_mem; + struct PortMapHasher { + std::size_t operator()(const std::pair& p) const { + std::size_t seed = 0; + dnnl::impl::hash_combine(seed, p.first); + dnnl::impl::hash_combine(seed, p.second); + return seed; + } + }; + std::unordered_map, std::shared_ptr, PortMapHasher> first_mappers; /// < Applied once before loop + std::vector> - first_mappers, /// < Applied once before loop last_mappers, /// < Applied once after loop before_mappers, /// < Applied before each iteration after_mappers, /// < Applied after each iteration diff --git a/src/plugins/intel_cpu/src/nodes/tile.cpp b/src/plugins/intel_cpu/src/nodes/tile.cpp index 79f1c36bcc26f0..3272d8a2b0ee42 100644 --- a/src/plugins/intel_cpu/src/nodes/tile.cpp +++ b/src/plugins/intel_cpu/src/nodes/tile.cpp @@ -3,7 +3,12 @@ // #include "tile.h" + +#include "openvino/op/tile.hpp" +#include "openvino/op/constant.hpp" + #include "common/cpu_memcpy.h" +#include "utils/ngraph_utils.hpp" namespace ov { namespace intel_cpu { @@ -114,9 +119,9 @@ bool Tile::needPrepareParams() const { void Tile::prepareParams() { if (!constMap[TILE_REPEATS]) { - const auto& repeatsMem = getParentEdgesAtPort(TILE_REPEATS)[0]->getMemory(); + const auto& repeatsMem = getParentEdgeAt(TILE_REPEATS)->getMemory(); - const int32_t* repeatsData = reinterpret_cast(repeatsMem.getData()); + const int32_t* repeatsData = repeatsMem.getDataAs(); originRepeats.assign(repeatsData, repeatsData + repeatsMem.getStaticDims()[0]); repeats.assign(std::max(originRepeats.size(), getInputShapeAtPort(TILE_INPUT).getRank()), 1lu); @@ -140,7 +145,7 @@ bool Tile::needShapeInfer() const { if (!constMap[TILE_REPEATS]) { if (originRepeats.empty()) return true; - const int32_t* repeatsData = reinterpret_cast(getParentEdgesAtPort(TILE_REPEATS)[0]->getMemory().getData()); + const int32_t* repeatsData = getParentEdgeAt(TILE_REPEATS)->getMemory().getDataAs(); for (size_t i = 0lu; i < originRepeats.size(); i++) { if (originRepeats[i] != static_cast(repeatsData[i])) return true; @@ -156,7 +161,7 @@ void Tile::executeDynamicImpl(dnnl::stream strm) { void Tile::execute(dnnl::stream strm) { if (optimizedCase) { - optimizedExecute(getParentEdgeAt(TILE_INPUT)->getMemoryPtr(), getChildEdgeAt(0)->getMemoryPtr()); + optimizedExecute(getSrcMemoryAtPort(TILE_INPUT), getDstMemoryAtPort(0)); } else { plainExecute(strm); } @@ -169,8 +174,8 @@ void Tile::plainExecute(dnnl::stream strm) { auto& srcMemory = getParentEdgeAt(TILE_INPUT)->getMemory(); - const uint8_t* src_ptr = reinterpret_cast(srcMemory.getData()); - uint8_t* dst_ptr = reinterpret_cast(getChildEdgeAt(0)->getMemory().getData()); + const uint8_t* src_ptr = srcMemory.getDataAs(); + uint8_t* dst_ptr = getChildEdgeAt(0)->getMemory().getDataAs(); int m_inner_dim = 1; int m_outer_dim = 1; diff --git a/src/plugins/intel_cpu/src/nodes/topk.cpp b/src/plugins/intel_cpu/src/nodes/topk.cpp index 10f51fdde8934a..2e8c029a03ac21 100644 --- a/src/plugins/intel_cpu/src/nodes/topk.cpp +++ b/src/plugins/intel_cpu/src/nodes/topk.cpp @@ -12,7 +12,7 @@ #include "onednn/dnnl.h" #include "openvino/core/parallel.hpp" #include "openvino/op/topk.hpp" -#include "openvino/opsets/opset1.hpp" +#include "utils/ngraph_utils.hpp" #include #include @@ -1941,12 +1941,12 @@ void TopK::initSupportedPrimitiveDescriptors() { } bool TopK::needShapeInfer() const { - const int src_k = reinterpret_cast(getParentEdgeAt(TOPK_K)->getMemoryPtr()->getData())[0]; + const int src_k = getSrcDataAtPortAs(TOPK_K)[0]; return inputShapesModified() || src_k != top_k; } bool TopK::needPrepareParams() const { - const int src_k = reinterpret_cast(getParentEdgeAt(TOPK_K)->getMemoryPtr()->getData())[0]; + const int src_k = getSrcDataAtPortAs(TOPK_K)[0]; return inputShapesModified() || top_k != src_k; } @@ -1978,8 +1978,8 @@ void TopK::preset_params() { } void TopK::prepareParams() { - auto dstMemPtr = getChildEdgeAt(TOPK_DATA)->getMemoryPtr(); - auto srcMemPtr = getParentEdgeAt(TOPK_DATA)->getMemoryPtr(); + auto dstMemPtr = getDstMemoryAtPort(TOPK_DATA); + auto srcMemPtr = getSrcMemoryAtPort(TOPK_DATA); if (!dstMemPtr || !dstMemPtr->isAllocated()) OPENVINO_THROW(errorPrefix, " has not allocated destination memory."); if (!srcMemPtr || !srcMemPtr->isAllocated()) @@ -1991,14 +1991,14 @@ void TopK::prepareParams() { dst_dims = dstMemPtr->getDesc().getShape().getDims(); if (isDynamicNode()) { - const int src_k = reinterpret_cast(getParentEdgeAt(TOPK_K)->getMemoryPtr()->getData())[0]; + const int src_k = getSrcDataAtPortAs(TOPK_K)[0]; if (static_cast(src_k) > src_dims[axis]) OPENVINO_THROW(errorPrefix, " gets top_k out of range!"); if (top_k != src_k) { top_k = src_k; } } else { - top_k = reinterpret_cast(getParentEdgeAt(TOPK_K)->getMemoryPtr()->getData())[0]; + top_k = getSrcDataAtPortAs(TOPK_K)[0]; } if (jit_mode) { @@ -2061,7 +2061,7 @@ void TopK::prepareParams() { } void TopK::createPrimitive() { - auto srcMemPtr = getParentEdgeAt(TOPK_DATA)->getMemoryPtr(); + auto srcMemPtr = getSrcMemoryAtPort(TOPK_DATA); if (srcMemPtr->getDesc().hasLayoutType(LayoutType::ncsp)) { layout = TopKLayoutType::topk_ncsp; } else if (srcMemPtr->getDesc().hasLayoutType(LayoutType::nspc)) { @@ -2134,13 +2134,13 @@ void TopK::executeDynamicImpl(dnnl::stream strm) { } void TopK::execute(dnnl::stream strm) { - auto srcMemPtr = getParentEdgeAt(TOPK_DATA)->getMemoryPtr(); - auto dstMemPtr = getChildEdgeAt(TOPK_DATA)->getMemoryPtr(); - auto dstIndexesMemPtr = getChildEdgeAt(TOPK_INDEX)->getMemoryPtr(); + auto srcMemPtr = getSrcMemoryAtPort(TOPK_DATA); + auto dstMemPtr = getDstMemoryAtPort(TOPK_DATA); + auto dstIndexesMemPtr = getDstMemoryAtPort(TOPK_INDEX); - const uint8_t *src_data = reinterpret_cast(srcMemPtr->getData()); - uint8_t *dst_data = reinterpret_cast(dstMemPtr->getData()); - uint8_t *dst_idx = reinterpret_cast(dstIndexesMemPtr->getData()); + const uint8_t *src_data = srcMemPtr->getDataAs(); + uint8_t *dst_data = dstMemPtr->getDataAs(); + uint8_t *dst_idx = dstIndexesMemPtr->getDataAs(); if (jit_mode) { topk_process(src_data, dst_data, dst_idx); diff --git a/src/plugins/intel_cpu/src/nodes/transpose.cpp b/src/plugins/intel_cpu/src/nodes/transpose.cpp index 6ba77faa8d2e09..9baa63be581c47 100644 --- a/src/plugins/intel_cpu/src/nodes/transpose.cpp +++ b/src/plugins/intel_cpu/src/nodes/transpose.cpp @@ -3,10 +3,12 @@ // #include "transpose.h" -#include "openvino/core/parallel.hpp" + +#include "openvino/op/transpose.hpp" +#include "openvino/op/constant.hpp" + #include "nodes/common/reorder_prim.h" -#include #include #include "dnnl_extension_utils.h" #include "common/primitive_hashing_utils.hpp" @@ -137,8 +139,8 @@ void Transpose::prepareParams() { if (performAsReorder) { // Transpose(order={0,3,1,2}) can be performed as Reorder(acdb=>abcd) - auto srcMemPtr = getParentEdgeAt(INPUT_DATA_IDX)->getMemoryPtr(); - auto dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); + auto srcMemPtr = getSrcMemoryAtPort(INPUT_DATA_IDX); + auto dstMemPtr = getDstMemoryAtPort(0); auto dstDesc = dstMemPtr->getDescWithType()->getDnnlDesc(); auto srcDesc = dnnl::memory::desc(dstDesc.get_dims(), dstDesc.get_data_type(), memory::format_tag::acdb); auto result = getReorderPrim(context->getParamsCache(), getEngine(), srcDesc, dstDesc); @@ -166,8 +168,8 @@ void Transpose::prepareParams() { transposeParams.permuteParams.dst_block_dims = dstDesc->getBlockDims(); if (!isInputOrderConst) { - auto orderPtr = reinterpret_cast(getParentEdgeAt(0)->getMemoryPtr()->getData()); - auto orderLen = getParentEdgeAt(0)->getMemoryPtr()->getSize(); + auto orderPtr = getSrcDataAtPortAs(0); + auto orderLen = getSrcMemoryAtPort(0)->getSize(); transposeParams.permuteParams.order.assign(orderPtr, orderPtr + orderLen); } @@ -196,8 +198,8 @@ void Transpose::createPrimitive() { if (isOptimized) return; - auto dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); - auto srcMemPtr = getParentEdgeAt(INPUT_DATA_IDX)->getMemoryPtr(); + auto dstMemPtr = getDstMemoryAtPort(0); + auto srcMemPtr = getSrcMemoryAtPort(INPUT_DATA_IDX); if (!dstMemPtr || !dstMemPtr->isAllocated()) OPENVINO_THROW("Destination memory was not allocated."); if (!srcMemPtr || !srcMemPtr->isAllocated()) @@ -241,12 +243,10 @@ void Transpose::execute(dnnl::stream strm) { if (prim) { prim.execute(strm, primArgs); } else if (execPtr) { - auto dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); - auto srcMemPtr = getParentEdgeAt(INPUT_DATA_IDX)->getMemoryPtr(); - - int MB = srcMemPtr->getStaticDims()[0]; + auto dstMemPtr = getDstMemoryAtPort(0); + auto srcMemPtr = getSrcMemoryAtPort(INPUT_DATA_IDX); - execPtr->exec({srcMemPtr}, {dstMemPtr}, MB); + execPtr->exec({srcMemPtr}, {dstMemPtr}); } else { OPENVINO_THROW("Could not execute Transpose node. Primitive was not created."); } diff --git a/src/plugins/intel_cpu/src/nodes/unique.cpp b/src/plugins/intel_cpu/src/nodes/unique.cpp index dc2196102682cf..153da710de2f08 100644 --- a/src/plugins/intel_cpu/src/nodes/unique.cpp +++ b/src/plugins/intel_cpu/src/nodes/unique.cpp @@ -4,8 +4,10 @@ #include "unique.hpp" -#include "openvino/core/parallel.hpp" #include +#include + +#include "openvino/core/parallel.hpp" #include "common/cpu_memcpy.h" #include "shape_inference/shape_inference_internal_dyn.hpp" @@ -88,13 +90,13 @@ void Unique::createPrimitive() { } void Unique::prepareParams() { - auto dataMemPtr = getParentEdgeAt(IN_DATA)->getMemoryPtr(); + auto dataMemPtr = getSrcMemoryAtPort(IN_DATA); if (!dataMemPtr || !dataMemPtr->isAllocated()) { THROW_ERROR(" has not allocated input data memory."); } for (int i = 0; i < 4; i++) { if (definedOutputs[i]) { - auto dstMemPtr = getChildEdgeAt(i)->getMemoryPtr(); + auto dstMemPtr = getDstMemoryAtPort(i); if (!dstMemPtr || !dstMemPtr->isAllocated()) { THROW_ERROR(" has not allocated output memory at port ", i); } @@ -106,9 +108,9 @@ void Unique::prepareParams() { size_t srcLen = 1; if (flattened) { - srcLen = getParentEdgeAt(IN_DATA)->getMemoryPtr()->getSize() / dataTypeSize; + srcLen = getSrcMemoryAtPort(IN_DATA)->getSize() / dataTypeSize; } else { - auto dstDataShape = getParentEdgeAt(IN_DATA)->getMemoryPtr()->getStaticDims(); + auto dstDataShape = getSrcMemoryAtPort(IN_DATA)->getStaticDims(); srcLen = dstDataShape[axis]; } firstUniTmp.resize(srcLen, 0); @@ -147,7 +149,7 @@ void Unique::execute(dnnl::stream strm) { } void Unique::executeDynamicImpl(dnnl::stream strm) { - const auto& srcDataDims = getParentEdgeAt(IN_DATA)->getMemoryPtr()->getStaticDims(); + const auto& srcDataDims = getSrcMemoryAtPort(IN_DATA)->getStaticDims(); VectorDims dstDataDims; Dim uniqLen = 1; if (flattened) { @@ -164,8 +166,8 @@ void Unique::executeDynamicImpl(dnnl::stream strm) { template void Unique::flattenTensorExec() { - const T* srcDataPtr = reinterpret_cast(getParentEdgeAt(IN_DATA)->getMemoryPtr()->getData()); - const size_t inputLen = getParentEdgeAt(IN_DATA)->getMemoryPtr()->getSize() / sizeof(T); + const T* srcDataPtr = getSrcDataAtPortAs(IN_DATA); + const size_t inputLen = getSrcMemoryAtPort(IN_DATA)->getSize() / sizeof(T); std::vector uniDataTmp(inputLen); auto uniDataTmpPtr = uniDataTmp.data(); int *firstTmpPtr = nullptr, *inToOutTmpPtr = nullptr, *occurTmpPtr = nullptr; @@ -263,26 +265,26 @@ void Unique::flattenTensorExec() { redefineOutputMemory({ {uniqueLen}, {uniqueLen}, {inputLen}, {uniqueLen}}); - T* uniDataPtr = reinterpret_cast(getChildEdgesAtPort(UNIQUE_DATA)[0]->getMemoryPtr()->getData()); + T* uniDataPtr = getDstDataAtPortAs(UNIQUE_DATA); cpu_parallel_memcpy(uniDataPtr, uniDataTmpPtr, uniqueLen * sizeof(T)); if (definedOutputs[FIRST_UNIQUE_IDX]) { - int *firstPtr = reinterpret_cast(getChildEdgesAtPort(FIRST_UNIQUE_IDX)[0]->getMemoryPtr()->getData()); + int *firstPtr = getDstDataAtPortAs(FIRST_UNIQUE_IDX); cpu_parallel_memcpy(firstPtr, firstUniTmp.data(), uniqueLen * sizeof(int)); } if (definedOutputs[INPUT_TO_UNIQ_IDX]) { - auto inToOutPtr = reinterpret_cast(getChildEdgesAtPort(INPUT_TO_UNIQ_IDX)[0]->getMemoryPtr()->getData()); + auto inToOutPtr = getDstDataAtPortAs(INPUT_TO_UNIQ_IDX); cpu_parallel_memcpy(inToOutPtr, inToOutTmp.data(), inputLen * sizeof(int)); } if (definedOutputs[OCCURRENCES_NUM]) { - auto occurPtr = reinterpret_cast(getChildEdgesAtPort(OCCURRENCES_NUM)[0]->getMemoryPtr()->getData()); + auto occurPtr = getDstDataAtPortAs(OCCURRENCES_NUM); cpu_parallel_memcpy(occurPtr, occurTmp.data(), uniqueLen * sizeof(int)); } } template void Unique::slicedTensorExec() { - auto inDataMemPtr = getParentEdgeAt(IN_DATA)->getMemoryPtr(); - auto srcDataPtr = reinterpret_cast(inDataMemPtr->getData()); + auto inDataMemPtr = getSrcMemoryAtPort(IN_DATA); + auto srcDataPtr = inDataMemPtr->getDataAs(); int *firstTmpPtr = nullptr, *inToOutTmpPtr = nullptr, *occurTmpPtr = nullptr; if (definedOutputs[FIRST_UNIQUE_IDX]) { firstTmpPtr = firstUniTmp.data(); @@ -367,16 +369,16 @@ void Unique::slicedTensorExec() { int *firstPtr = nullptr, *inToOutPtr = nullptr, *occurNPtr = nullptr; if (definedOutputs[FIRST_UNIQUE_IDX]) { - firstPtr = reinterpret_cast(getChildEdgesAtPort(FIRST_UNIQUE_IDX)[0]->getMemoryPtr()->getData()); + firstPtr = getDstDataAtPortAs(FIRST_UNIQUE_IDX); } if (definedOutputs[INPUT_TO_UNIQ_IDX]) { - inToOutPtr = reinterpret_cast(getChildEdgesAtPort(INPUT_TO_UNIQ_IDX)[0]->getMemoryPtr()->getData()); + inToOutPtr = getDstDataAtPortAs(INPUT_TO_UNIQ_IDX); } if (definedOutputs[OCCURRENCES_NUM]) { - occurNPtr = reinterpret_cast(getChildEdgesAtPort(OCCURRENCES_NUM)[0]->getMemoryPtr()->getData()); + occurNPtr = getDstDataAtPortAs(OCCURRENCES_NUM); } - T* dstDataPtr = reinterpret_cast(getChildEdgesAtPort(UNIQUE_DATA)[0]->getMemoryPtr()->getData()); + T* dstDataPtr = getDstDataAtPortAs(UNIQUE_DATA); const auto dstOuterStep = innerLen * uniqueLen; // Filling of the first output if needed. if (sorted || definedOutputs[UNIQUE_DATA]) { diff --git a/src/plugins/intel_cpu/src/onednn/iml_type_mapper.cpp b/src/plugins/intel_cpu/src/onednn/iml_type_mapper.cpp index fa247408b32e06..85d5f7cc88e9dd 100644 --- a/src/plugins/intel_cpu/src/onednn/iml_type_mapper.cpp +++ b/src/plugins/intel_cpu/src/onednn/iml_type_mapper.cpp @@ -4,6 +4,8 @@ #include "iml_type_mapper.h" #include +#include +#include namespace ov { namespace intel_cpu { @@ -129,5 +131,5 @@ bool contains(const std::vector& priorities, const impl_desc_typ return std::find(priorities.begin(), priorities.end(), impl_type_str) != priorities.end(); } -} // namespace intel_cpu +} // namespace intel_cpu } // namespace ov diff --git a/src/plugins/intel_cpu/src/onednn/iml_type_mapper.h b/src/plugins/intel_cpu/src/onednn/iml_type_mapper.h index e30511de60cea7..a2c66f145f7d62 100644 --- a/src/plugins/intel_cpu/src/onednn/iml_type_mapper.h +++ b/src/plugins/intel_cpu/src/onednn/iml_type_mapper.h @@ -103,6 +103,7 @@ enum impl_desc_type { gemm_mlas = gemm | mlas }; +std::vector extractTypeAndImplName(const std::string& priority); const char * impl_type_to_string(impl_desc_type type); impl_desc_type parse_impl_name(std::string impl_desc_name); bool contains(const std::vector& priorities, const impl_desc_type impl_type_str); diff --git a/src/plugins/intel_cpu/src/plugin.cpp b/src/plugins/intel_cpu/src/plugin.cpp index a899f277e73d72..4b18b1b391ae13 100644 --- a/src/plugins/intel_cpu/src/plugin.cpp +++ b/src/plugins/intel_cpu/src/plugin.cpp @@ -8,7 +8,6 @@ #include "itt.h" #include "openvino/runtime/intel_cpu/properties.hpp" #include "openvino/runtime/internal_properties.hpp" -#include "openvino/runtime/performance_heuristics.hpp" #include "openvino/runtime/properties.hpp" #include "openvino/runtime/threading/cpu_streams_info.hpp" #include "openvino/runtime/threading/executor_manager.hpp" @@ -185,272 +184,49 @@ static bool streamsSet(const ov::AnyMap& config) { return config.count(ov::num_streams.name()); } -void Engine::apply_performance_hints(ov::AnyMap& config, const std::shared_ptr& model) const { - auto getNumStreamsThroughput = [&]() { - const auto isa = dnnl::get_effective_cpu_isa(); - float isaSpecificThreshold = 1.0f; - switch (isa) { - case dnnl::cpu_isa::sse41: - isaSpecificThreshold = 0.5f; - break; - case dnnl::cpu_isa::avx2: - case dnnl::cpu_isa::avx512_core: - isaSpecificThreshold = 1.0f; - break; - case dnnl::cpu_isa::avx512_core_vnni: - case dnnl::cpu_isa::avx2_vnni: - isaSpecificThreshold = 2.0f; - break; - case dnnl::cpu_isa::avx512_core_amx: - isaSpecificThreshold = 4.0f; - break; - default: - isaSpecificThreshold = 1.0f; - } - // the more "capable" the CPU in general, the more streams we may want to keep to keep it utilized - const float memThresholdAssumeLimitedForISA = ov::MemBandwidthPressure::LIMITED / isaSpecificThreshold; - const float L2_cache_size = dnnl::utils::get_cache_size(2 /*level*/, true /*per core */); - ov::MemBandwidthPressure networkToleranceForLowCache = - ov::mem_bandwidth_pressure_tolerance(model, L2_cache_size, memThresholdAssumeLimitedForISA); - const auto default_streams = get_streams_num(engConfig.streamExecutorConfig._threadBindingType, - ov::threading::IStreamsExecutor::Config::StreamMode::DEFAULT, - engConfig.streamExecutorConfig._enable_hyper_thread); - auto streams_info = default_streams; - if (networkToleranceForLowCache.max_mem_tolerance == ov::MemBandwidthPressure::UNKNOWN) { - if ((networkToleranceForLowCache.ratio_compute_convs == ov::MemBandwidthPressure::ALL) || - (networkToleranceForLowCache.ratio_compute_deconvs == ov::MemBandwidthPressure::ALL)) { - // all relevant layers (convs, etc) are compute-limited, the most aggressive val for #streams - streams_info = get_streams_num(engConfig.streamExecutorConfig._threadBindingType, - ov::threading::IStreamsExecutor::Config::StreamMode::AGGRESSIVE, - engConfig.streamExecutorConfig._enable_hyper_thread); - } // otherwise (no recognized layers) falling back to the default value - } else if (networkToleranceForLowCache.max_mem_tolerance > memThresholdAssumeLimitedForISA) { - // network is below the ISA-specific threshold - streams_info = get_streams_num(engConfig.streamExecutorConfig._threadBindingType, - ov::threading::IStreamsExecutor::Config::StreamMode::AGGRESSIVE, - engConfig.streamExecutorConfig._enable_hyper_thread); - } else if (networkToleranceForLowCache.max_mem_tolerance > ov::MemBandwidthPressure::LIMITED) { - // network is below general threshold - streams_info = get_streams_num(engConfig.streamExecutorConfig._threadBindingType, - ov::threading::IStreamsExecutor::Config::StreamMode::LESSAGGRESSIVE, - engConfig.streamExecutorConfig._enable_hyper_thread); - streams_info.num_streams = std::max(default_streams.num_streams, streams_info.num_streams); - } - - auto num_requests = config.find(ov::hint::num_requests.name()); - if (num_requests != config.end()) { // arrived with config to the LoadNetwork (and thus higher pri) - int val = -1; - try { - ov::Any value = num_requests->second.as(); - val = value.as(); - if (val < 0) - OPENVINO_THROW("invalid value!"); - } catch (const ov::Exception&) { - OPENVINO_THROW("Wrong value of ", - num_requests->second.as(), - " for property key ", - ov::hint::num_requests.name(), - ". Expected only positive integer numbers"); - } - if (val > 0) - streams_info.num_streams = std::min(streams_info.num_streams, val); - } else if (engConfig.hintNumRequests > 0) { // set thru SetConfig to the plugin, 2nd priority - streams_info.num_streams = std::min(streams_info.num_streams, static_cast(engConfig.hintNumRequests)); - } - return std::pair(std::to_string(streams_info.num_streams), streams_info); - }; - - auto getPerfHintName = [&]() { - const bool streamsExplicitlySetForModel = streamsSet(config); - // checking streams (to avoid overriding what user might explicitly set in the incoming config or previously via - // SetConfig) - if (streamsExplicitlySetForModel || streamsExplicitlySetForEngine) - return std::string(); - - const auto& perf_hint = config.find(ov::hint::performance_mode.name()); - /* performance hints set for network has higher pririty than engine ones. - * This applies for all the configuration parameters */ - const auto& perf_hint_name = (perf_hint != config.end()) ? perf_hint->second.as() - : ov::util::to_string(engConfig.hintPerfMode); - return perf_hint_name; - }; - - // We compute both hints values because the optimal number of streams are computed based on ov::Model - // while we export model in cpu internal opset so we need to save precomputed optimal # streams for both hint modes - const auto latency_hints = ov::util::to_string(ov::streams::NUMA); - const auto tput_hints = getNumStreamsThroughput(); - - // save hints parameters to model rt_info - ov::AnyMap hints_props; - const auto latency_name = - ov::util::to_string(ov::hint::PerformanceMode::LATENCY) + "_" + std::string(ov::num_streams.name()); - const auto tput_name = - ov::util::to_string(ov::hint::PerformanceMode::THROUGHPUT) + "_" + std::string(ov::num_streams.name()); - hints_props.insert({latency_name, latency_hints}); - hints_props.insert({tput_name, std::to_string(tput_hints.second.num_streams)}); - model->set_rt_info(hints_props, "intel_cpu_hints_config"); - - const auto perf_hint_name = getPerfHintName(); - if (perf_hint_name == ov::util::to_string(ov::hint::PerformanceMode::LATENCY)) { - config[ov::num_streams.name()] = latency_hints; - } else if (perf_hint_name == ov::util::to_string(ov::hint::PerformanceMode::THROUGHPUT)) { - config[ov::num_streams.name()] = tput_hints.first; - config[ov::threading::big_core_streams.name()] = std::to_string(tput_hints.second.big_core_streams); - config[ov::threading::small_core_streams.name()] = std::to_string(tput_hints.second.small_core_streams); - config[ov::threading::threads_per_stream_big.name()] = std::to_string(tput_hints.second.threads_per_stream_big); - config[ov::threading::threads_per_stream_small.name()] = - std::to_string(tput_hints.second.threads_per_stream_small); - config[ov::threading::small_core_offset.name()] = std::to_string(tput_hints.second.small_core_offset); - } -} - void Engine::get_performance_streams(Config& config, const std::shared_ptr& model) const{ const int latency_streams = get_default_latency_streams(config.latencyThreadingMode); + int streams_set = config.streams; int streams; - if (config.streamExecutorConfig._streams_changed) { - streams = config.streamExecutorConfig._streams; + if (config.streamsChanged) { + streams = streams_set; } else if (config.hintPerfMode == ov::hint::PerformanceMode::LATENCY) { streams = latency_streams; } else if (config.hintPerfMode == ov::hint::PerformanceMode::THROUGHPUT) { streams = 0; } else { - streams = config.streamExecutorConfig._streams == 1 ? 0 : config.streamExecutorConfig._streams; + streams = streams_set == 1 ? 0 : streams_set; } - if (!((0 == config.streamExecutorConfig._streams) && config.streamExecutorConfig._streams_changed)) { + if (!((0 == streams_set) && config.streamsChanged)) { get_num_streams(streams, model, config); - } else { - config.streamExecutorConfig.set_config_zero_stream(); } } void Engine::calculate_streams(Config& conf, const std::shared_ptr& model, bool imported) const { - // import config props from caching model - if (imported && !is_cpu_map_available()) { - if (model->has_rt_info("intel_cpu_hints_config")) { - const auto perf_mode = conf.hintPerfMode; - if (perf_mode == ov::hint::PerformanceMode::LATENCY || perf_mode == ov::hint::PerformanceMode::THROUGHPUT) { - const auto& hints_config = model->get_rt_info("intel_cpu_hints_config"); - const auto hints_param_name = - ov::util::to_string(perf_mode) + "_" + std::string(ov::num_streams.name()); - const auto it = hints_config.find(hints_param_name); - if (it != hints_config.end()) { - conf.readProperties({{std::string(ov::num_streams.name()), it->second.as()}}); - } else { - OPENVINO_THROW("Cache file doesn't contain precalculated number of streams for mode ", - ov::util::to_string(perf_mode)); - } + const auto model_prefer_name = std::string("MODEL_PREFER_THREADS"); + if (imported && model->has_rt_info("intel_cpu_hints_config")) { + // load model_prefer_threads from cache + int cache_model_prefer; + const auto& hints_config = model->get_rt_info("intel_cpu_hints_config"); + const auto it_model_prefer = hints_config.find(model_prefer_name); + if (it_model_prefer != hints_config.end()) { + try { + cache_model_prefer = it_model_prefer->second.as(); + } catch (const ov::Exception&) { + OPENVINO_THROW("Cache file doesn't have valid value for " + model_prefer_name); } - } - } - if (is_cpu_map_available()) { - const auto model_prefer_name = std::string("MODEL_PREFER_THREADS"); - if (imported && model->has_rt_info("intel_cpu_hints_config")) { - // load model_prefer_threads from cache - int cache_model_prefer; - const auto& hints_config = model->get_rt_info("intel_cpu_hints_config"); - const auto it_model_prefer = hints_config.find(model_prefer_name); - if (it_model_prefer != hints_config.end()) { - try { - cache_model_prefer = it_model_prefer->second.as(); - } catch (const ov::Exception&) { - OPENVINO_THROW("Cache file doesn't have valid value for " + model_prefer_name); - } - - conf.modelPreferThreads = cache_model_prefer; - } - } - get_performance_streams(conf, model); - // save model_prefer_threads to model rt_info when loading network - if (!imported) { - ov::AnyMap hints_props; - hints_props.insert({model_prefer_name, std::to_string(conf.modelPreferThreads)}); - model->set_rt_info(hints_props, "intel_cpu_hints_config"); + conf.modelPreferThreads = cache_model_prefer; } } -} - -StreamCfg Engine::get_streams_num(ov::threading::IStreamsExecutor::ThreadBindingType thread_binding_type, - int stream_mode, - const bool enable_hyper_thread) const { - const int sockets = static_cast(get_available_numa_nodes().size()); - const int num_cores = - thread_binding_type == IStreamsExecutor::ThreadBindingType::HYBRID_AWARE - ? parallel_get_max_threads() - : (sockets == 1 ? (enable_hyper_thread ? parallel_get_max_threads() : get_number_of_cpu_cores()) - : get_number_of_cpu_cores()); - const int num_cores_phy = get_number_of_cpu_cores(); - const int num_big_cores_phy = get_number_of_cpu_cores(true); - const int num_small_cores = num_cores_phy - num_big_cores_phy; - const int num_big_cores = num_cores > num_cores_phy ? num_big_cores_phy * 2 : num_big_cores_phy; - StreamCfg stream_cfg = {0}; - - if (stream_mode == IStreamsExecutor::Config::StreamMode::DEFAULT) { - // bare minimum of streams (that evenly divides available number of core) - if (thread_binding_type == IStreamsExecutor::ThreadBindingType::HYBRID_AWARE) { - if (0 == num_big_cores_phy % 4) { - stream_cfg.threads_per_stream_big = 4; - } else if (0 == num_big_cores_phy % 5) { - stream_cfg.threads_per_stream_big = 5; - } else if (0 == num_big_cores_phy % 3) { - stream_cfg.threads_per_stream_big = 3; - } else { // if user disables some cores say in BIOS, so we got weird #cores which is not easy to divide - stream_cfg.threads_per_stream_big = num_big_cores_phy; - } - - stream_cfg.big_core_streams = num_big_cores / stream_cfg.threads_per_stream_big; - stream_cfg.threads_per_stream_small = stream_cfg.threads_per_stream_big; - if (num_small_cores == 0) { - stream_cfg.threads_per_stream_small = 0; - } else if (num_small_cores < stream_cfg.threads_per_stream_small) { - stream_cfg.small_core_streams = 1; - stream_cfg.threads_per_stream_small = num_small_cores; - stream_cfg.threads_per_stream_big = stream_cfg.threads_per_stream_small; - // Balance the computation of physical core and logical core, the number of threads on the physical core - // and logical core should be equal - stream_cfg.big_core_streams = num_big_cores_phy / stream_cfg.threads_per_stream_big * 2; - } else { - stream_cfg.small_core_streams = num_small_cores / stream_cfg.threads_per_stream_small; - } - } else { - if (0 == num_cores % 4) - stream_cfg.num_streams = std::max(4, num_cores / 4); - else if (0 == num_cores % 5) - stream_cfg.num_streams = std::max(5, num_cores / 5); - else if (0 == num_cores % 3) - stream_cfg.num_streams = std::max(3, num_cores / 3); - else // if user disables some cores say in BIOS, so we got weird #cores which is not easy to divide - stream_cfg.num_streams = 1; - } - } else if (stream_mode == IStreamsExecutor::Config::StreamMode::AGGRESSIVE) { - if (thread_binding_type == IStreamsExecutor::ThreadBindingType::HYBRID_AWARE) { - stream_cfg.big_core_streams = num_big_cores; - stream_cfg.small_core_streams = num_small_cores; - stream_cfg.threads_per_stream_big = num_big_cores / stream_cfg.big_core_streams; - stream_cfg.threads_per_stream_small = - num_small_cores == 0 ? 0 : num_small_cores / stream_cfg.small_core_streams; - } else { - stream_cfg.num_streams = num_cores_phy; - } - } else if (stream_mode == IStreamsExecutor::Config::StreamMode::LESSAGGRESSIVE) { - if (thread_binding_type == IStreamsExecutor::ThreadBindingType::HYBRID_AWARE) { - stream_cfg.big_core_streams = num_big_cores / 2; - stream_cfg.small_core_streams = num_small_cores / 2; - stream_cfg.threads_per_stream_big = num_big_cores / stream_cfg.big_core_streams; - stream_cfg.threads_per_stream_small = - num_small_cores == 0 ? 0 : num_small_cores / stream_cfg.small_core_streams; - } else { - stream_cfg.num_streams = num_cores_phy / 2; - } - } else { - OPENVINO_THROW("Wrong stream mode to get num of streams: ", stream_mode); + get_performance_streams(conf, model); + // save model_prefer_threads to model rt_info when loading network + if (!imported) { + ov::AnyMap hints_props; + hints_props.insert({model_prefer_name, std::to_string(conf.modelPreferThreads)}); + model->set_rt_info(hints_props, "intel_cpu_hints_config"); } - stream_cfg.num_streams = stream_cfg.num_streams > 0 - ? stream_cfg.num_streams - : stream_cfg.big_core_streams + stream_cfg.small_core_streams; - stream_cfg.small_core_offset = num_small_cores == 0 ? 0 : num_big_cores; - return stream_cfg; } static bool shouldEnableLPT(const ov::AnyMap& modelConfig, const Config& engineConfig) { @@ -543,10 +319,6 @@ Engine::compile_model(const std::shared_ptr& model, const ov::A transformations.UpToLpt(); - if (!is_cpu_map_available()) { - apply_performance_hints(config, cloned_model); - } - conf.readProperties(config, modelType); calculate_streams(conf, cloned_model); @@ -612,16 +384,16 @@ bool Engine::is_legacy_api() const { ov::Any Engine::get_property(const std::string& name, const ov::AnyMap& options) const { if (name == ov::optimal_number_of_infer_requests) { - const auto streams = engConfig.streamExecutorConfig._streams; + const auto streams = engConfig.streamExecutorConfig.get_streams(); return decltype(ov::optimal_number_of_infer_requests)::value_type( streams); // ov::optimal_number_of_infer_requests has no negative values } else if (name == ov::num_streams) { - const auto streams = engConfig.streamExecutorConfig._streams; + const auto streams = engConfig.streamExecutorConfig.get_streams(); return decltype(ov::num_streams)::value_type( streams); // ov::num_streams has special negative values (AUTO = -1, NUMA = -2) OPENVINO_SUPPRESS_DEPRECATED_START } else if (name == ov::affinity) { - const auto affinity = engConfig.streamExecutorConfig._threadBindingType; + const auto affinity = engConfig.threadBindingType; switch (affinity) { case IStreamsExecutor::ThreadBindingType::NONE: return ov::Affinity::NONE; @@ -637,8 +409,8 @@ ov::Any Engine::get_property(const std::string& name, const ov::AnyMap& options) } else if (name == ov::device::id.name()) { return decltype(ov::device::id)::value_type{engConfig.device_id}; } else if (name == ov::inference_num_threads) { - const auto num_threads = engConfig.streamExecutorConfig._threads; - return decltype(ov::inference_num_threads)::value_type(num_threads); + const auto threads = engConfig.streamExecutorConfig.get_threads(); + return decltype(ov::inference_num_threads)::value_type(threads); } else if (name == ov::enable_profiling.name()) { const bool perfCount = engConfig.collectPerfCounters; return decltype(ov::enable_profiling)::value_type(perfCount); @@ -707,7 +479,6 @@ ov::Any Engine::get_ro_property(const std::string& name, const ov::AnyMap& optio RO_property(ov::device::architecture.name()), }; // the whole config is RW before model is loaded. - OPENVINO_SUPPRESS_DEPRECATED_START std::vector rwProperties {RW_property(ov::num_streams.name()), RW_property(ov::affinity.name()), RW_property(ov::inference_num_threads.name()), @@ -724,7 +495,6 @@ ov::Any Engine::get_ro_property(const std::string& name, const ov::AnyMap& optio RW_property(ov::log::level.name()), RW_property(ov::intel_cpu::sparse_weights_decompression_rate.name()), }; - OPENVINO_SUPPRESS_DEPRECATED_END std::vector supportedProperties; supportedProperties.reserve(roProperties.size() + rwProperties.size()); diff --git a/src/plugins/intel_cpu/src/plugin.h b/src/plugins/intel_cpu/src/plugin.h index 53f52706f3c0fd..5f33c05a9ba8f9 100644 --- a/src/plugins/intel_cpu/src/plugin.h +++ b/src/plugins/intel_cpu/src/plugin.h @@ -48,11 +48,7 @@ class Engine : public ov::IPlugin { ov::Any get_ro_property(const std::string& name, const ov::AnyMap& options) const; - void apply_performance_hints(ov::AnyMap &config, const std::shared_ptr& model) const; - void get_performance_streams(Config &config, const std::shared_ptr& model) const; - StreamCfg get_streams_num(ov::threading::IStreamsExecutor::ThreadBindingType thread_binding_type, - int stream_mode, - const bool enable_hyper_thread = true) const; + void get_performance_streams(Config& config, const std::shared_ptr& model) const; void calculate_streams(Config& conf, const std::shared_ptr& model, bool imported = false) const; Config engConfig; diff --git a/src/plugins/intel_cpu/src/post_ops.cpp b/src/plugins/intel_cpu/src/post_ops.cpp new file mode 100644 index 00000000000000..73d8e6334cc48c --- /dev/null +++ b/src/plugins/intel_cpu/src/post_ops.cpp @@ -0,0 +1,197 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "post_ops.hpp" +#include "node.h" +#include "nodes/eltwise.h" +#include "nodes/fake_quantize.h" + +namespace ov { +namespace intel_cpu { + +EltwiseKind getEltwiseKind(const Algorithm alg) { + switch (alg) { + case Algorithm::EltwiseSqrt: + case Algorithm::EltwiseRelu: + case Algorithm::EltwiseTanh: + case Algorithm::EltwiseElu: + case Algorithm::EltwiseAbs: + case Algorithm::EltwiseSoftRelu: + case Algorithm::EltwiseSigmoid: + case Algorithm::EltwiseExp: + case Algorithm::EltwiseGeluErf: + case Algorithm::EltwiseGeluTanh: + case Algorithm::EltwiseClamp: + case Algorithm::EltwiseSwish: + case Algorithm::EltwiseHswish: + case Algorithm::EltwiseMish: + case Algorithm::EltwiseHsigmoid: + case Algorithm::EltwiseRoundHalfToEven: + case Algorithm::EltwiseRoundHalfAwayFromZero: + return EltwiseKind::Activation; + case Algorithm::EltwiseAdd: + case Algorithm::EltwiseSubtract: + case Algorithm::EltwiseDivide: + case Algorithm::EltwiseMultiply: + case Algorithm::EltwiseMulAdd: + case Algorithm::EltwisePowerStatic: + case Algorithm::EltwisePrelu: + return EltwiseKind::ScaleShift; + default: + OPENVINO_THROW("Unexpected eltwise algorithm: ", algToString(alg)); + } +} + +ScaleShiftPostOp::Type convertToScaleShiftOpt(const Algorithm alg) { + switch (alg) { + case Algorithm::EltwiseAdd: + return ScaleShiftPostOp::add; + case Algorithm::EltwiseSubtract: + return ScaleShiftPostOp::subtract; + case Algorithm::EltwiseDivide: + return ScaleShiftPostOp::divide; + case Algorithm::EltwiseMultiply: + return ScaleShiftPostOp::multiply; + case Algorithm::EltwiseMulAdd: + return ScaleShiftPostOp::muladd; + case Algorithm::EltwisePowerStatic: + return ScaleShiftPostOp::powerstatic; + case Algorithm::EltwisePrelu: + return ScaleShiftPostOp::prelu; + default: + OPENVINO_THROW("Unexpected eltwise algorithm: ", algToString(alg)); + } +} + +ActivationPostOp::Type convertToActivationPostOpt(const Algorithm alg) { + switch (alg) { + case Algorithm::EltwiseSqrt: + return ActivationPostOp::Type::sqrt; + case Algorithm::EltwiseRelu: + return ActivationPostOp::Type::relu; + case Algorithm::EltwiseTanh: + return ActivationPostOp::Type::tanh; + case Algorithm::EltwiseElu: + return ActivationPostOp::Type::elu; + case Algorithm::EltwiseAbs: + return ActivationPostOp::Type::abs; + case Algorithm::EltwiseSoftRelu: + return ActivationPostOp::Type::soft_relu; + case Algorithm::EltwiseSigmoid: + return ActivationPostOp::Type::logistic; + case Algorithm::EltwiseExp: + return ActivationPostOp::Type::exp; + case Algorithm::EltwiseGeluErf: + return ActivationPostOp::Type::gelu_erf; + case Algorithm::EltwiseGeluTanh: + return ActivationPostOp::Type::gelu_tanh; + case Algorithm::EltwiseClamp: + return ActivationPostOp::Type::clip; + case Algorithm::EltwiseSwish: + return ActivationPostOp::Type::swish; + case Algorithm::EltwiseHswish: + return ActivationPostOp::Type::hardswish; + case Algorithm::EltwiseMish: + return ActivationPostOp::Type::mish; + case Algorithm::EltwiseHsigmoid: + return ActivationPostOp::Type::hsigmoid; + case Algorithm::EltwiseRoundHalfToEven: + return ActivationPostOp::Type::round_half_to_even; + case Algorithm::EltwiseRoundHalfAwayFromZero: + return ActivationPostOp::Type::round_half_away_from_zero; + default: + OPENVINO_THROW("Unexpected eltwise algorithm: ", algToString(alg)); + } +} + +Algorithm convertToEltwiseAlgorithm(const ActivationPostOp::Type type) { + switch (type) { + case ActivationPostOp::Type::sqrt: + return Algorithm::EltwiseSqrt; + case ActivationPostOp::Type::relu: + return Algorithm::EltwiseRelu; + case ActivationPostOp::Type::tanh: + return Algorithm::EltwiseTanh; + case ActivationPostOp::Type::elu: + return Algorithm::EltwiseElu; + case ActivationPostOp::Type::abs: + return Algorithm::EltwiseAbs; + case ActivationPostOp::Type::soft_relu: + return Algorithm::EltwiseSoftRelu; + case ActivationPostOp::Type::logistic: + return Algorithm::EltwiseSigmoid; + case ActivationPostOp::Type::exp: + return Algorithm::EltwiseExp; + case ActivationPostOp::Type::gelu_erf: + return Algorithm::EltwiseGeluErf; + case ActivationPostOp::Type::gelu_tanh: + return Algorithm::EltwiseGeluTanh; + case ActivationPostOp::Type::clip: + return Algorithm::EltwiseClamp; + case ActivationPostOp::Type::swish: + return Algorithm::EltwiseSwish; + case ActivationPostOp::Type::hardswish: + return Algorithm::EltwiseHswish; + case ActivationPostOp::Type::mish: + return Algorithm::EltwiseMish; + case ActivationPostOp::Type::hsigmoid: + return Algorithm::EltwiseHsigmoid; + case ActivationPostOp::Type::round_half_to_even: + return Algorithm::EltwiseRoundHalfToEven; + case ActivationPostOp::Type::round_half_away_from_zero: + return Algorithm::EltwiseRoundHalfAwayFromZero; + case ActivationPostOp::Type::square: + OPENVINO_THROW("square is not supported"); + case ActivationPostOp::Type::linear: + OPENVINO_THROW("linear is not supported"); + } + + OPENVINO_THROW("Unsupported algorithm"); +} + +PostOps getPostOps(std::vector fused) { + PostOps ops; + + auto makeActivationPostOp = [](const std::shared_ptr eltwise) { + return std::make_shared(convertToActivationPostOpt(eltwise->getAlgorithm()), + eltwise->getAlpha(), + eltwise->getBeta(), + eltwise->getGamma()); + }; + + auto makeScaleShiftPostOp = [](const std::shared_ptr eltwise) { + return std::make_shared(convertToScaleShiftOpt(eltwise->getAlgorithm()), + eltwise->getScales(), + eltwise->getShifts()); + }; + + for (const auto& node : fused) { + if (const auto eltwise = std::dynamic_pointer_cast(node)) { + const auto eltwiseKind = getEltwiseKind(eltwise->getAlgorithm()); + switch (eltwiseKind) { + case EltwiseKind::Activation: + ops.push_back(makeActivationPostOp(eltwise)); + break; + case EltwiseKind::ScaleShift: + ops.push_back(makeScaleShiftPostOp(eltwise)); + break; + } + } + + if (const auto fq = std::dynamic_pointer_cast(node)) { + ops.push_back(std::make_shared(fq->getCropLow(), + fq->getCropHigh(), + fq->getInputScale(), + fq->getInputShift(), + fq->getOutputScale(), + fq->getOutputShift(), + fq->getLevels())); + } + } + + return ops; +} + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/post_ops.hpp b/src/plugins/intel_cpu/src/post_ops.hpp new file mode 100644 index 00000000000000..8ad8b26d92ba12 --- /dev/null +++ b/src/plugins/intel_cpu/src/post_ops.hpp @@ -0,0 +1,197 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include + +#include "cpu_types.h" +#include "nodes/executors/executor.hpp" +#include "node.h" + +namespace ov { +namespace intel_cpu { + +struct PostOp; +using PostOps = std::vector>; + +struct PostOp { + virtual ~PostOp() = default; +}; + +struct ActivationPostOp; +using eltwiseExecutorCreatingStrategy = std::function, + std::vector, + const PostOps&)>; + +struct ActivationPostOp : PostOp { + enum class Type : size_t { + relu, + tanh, + elu, + square, + abs, + sqrt, + soft_relu, + logistic, + exp, + gelu_erf, + gelu_tanh, + clip, + swish, + hardswish, + mish, + hsigmoid, + round_half_to_even, + round_half_away_from_zero, + linear, + }; + + ActivationPostOp(const Type type, + const float alpha, + const float beta, + const float gamma, + eltwiseExecutorCreatingStrategy strategy = nullptr) + : m_type(type), + m_alpha(alpha), + m_beta(beta), + m_gamma(gamma) + {} + + float alpha() const { + return m_alpha; + } + + float beta() const { + return m_beta; + } + + float gamma() const { + return m_gamma; + } + + Type type() const { + return m_type; + } + +private: + const Type m_type; + const float m_alpha; + const float m_beta; + const float m_gamma; +}; + +struct ScaleShiftPostOp : PostOp { + enum Type { + add, + subtract, + divide, + multiply, + muladd, + powerstatic, + prelu, + }; + + ScaleShiftPostOp(const Type m_type, + std::vector _scales, + std::vector _shifts) + : m_type(m_type), + m_scales(std::move(_scales)), + m_shifts(std::move(_shifts)) {} + + const std::vector& scales() const { + return m_scales; + } + + const std::vector& shifts() const { + return m_shifts; + } + + Type type() const { + return m_type; + } + +private: + const Type m_type; + const std::vector m_scales; + const std::vector m_shifts; +}; + +struct FakeQuantizePostOp : PostOp { + FakeQuantizePostOp(std::vector cropLow, + std::vector cropHigh, + std::vector inputScale, + std::vector inputShift, + std::vector outputScale, + std::vector outputShift, + const size_t levels) : + m_cropLow(std::move(cropLow)), + m_cropHigh(std::move(cropHigh)), + m_inputScale(std::move(inputScale)), + m_inputShift(std::move(inputShift)), + m_outputScale(std::move(outputScale)), + m_outputShift(std::move(outputShift)), + m_levels(levels) {} + + const std::vector& cropLow() const { + return m_cropLow; + } + + const std::vector& cropHigh() const { + return m_cropHigh; + } + + const std::vector& inputScale() const { + return m_inputScale; + } + + const std::vector& inputShift() const { + return m_inputShift; + } + + const std::vector& outputScale() const { + return m_outputScale; + } + + const std::vector& outputShift() const { + return m_outputShift; + } + + size_t levels() const { + return m_levels; + } + +private: + const std::vector m_cropLow; + const std::vector m_cropHigh; + const std::vector m_inputScale; + const std::vector m_inputShift; + const std::vector m_outputScale; + const std::vector m_outputShift; + const size_t m_levels; +}; + +enum class EltwiseKind { + Activation, + ScaleShift, + // @todo Binary? +}; + +using PostOps = std::vector>; + +EltwiseKind getEltwiseKind(const Algorithm alg); + +ScaleShiftPostOp::Type convertToScaleShiftOpt(const Algorithm alg); + +ActivationPostOp::Type convertToActivationPostOpt(const Algorithm alg); + +Algorithm convertToEltwiseAlgorithm(const ActivationPostOp::Type m_type); + +PostOps getPostOps(std::vector fused); +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/serialize.cpp b/src/plugins/intel_cpu/src/serialize.cpp index 0b91061684e741..4453854fb0754b 100644 --- a/src/plugins/intel_cpu/src/serialize.cpp +++ b/src/plugins/intel_cpu/src/serialize.cpp @@ -55,9 +55,24 @@ void ModelDeserializer::operator>>(std::shared_ptr& model) { std::string xmlString; ov::Tensor dataBlob; + // get file size before seek content + // blob from cache may have other header, skip it + const size_t _pos = _istream.tellg(); + _istream.seekg(0, _istream.end); + const size_t file_size = _istream.tellg(); + _istream.seekg(_pos, _istream.beg); + StreamSerialize::DataHeader hdr = {}; _istream.read(reinterpret_cast(&hdr), sizeof hdr); + // check if model header contains valid data + bool isValidModel = (hdr.custom_data_offset == sizeof(hdr) + _pos) && + (hdr.custom_data_size == hdr.consts_offset - hdr.custom_data_offset) && + (hdr.consts_size == hdr.model_offset - hdr.consts_offset) && + (hdr.model_size = file_size - hdr.model_offset); + if (!isValidModel) { + OPENVINO_THROW("Failed to read CPU device xml header"); + } // read model input/output precisions _istream.seekg(hdr.custom_data_offset); diff --git a/src/plugins/intel_cpu/src/shape_inference/custom/adaptive_pooling.cpp b/src/plugins/intel_cpu/src/shape_inference/custom/adaptive_pooling.cpp index 5517aeffd074c0..f7b734e115909e 100644 --- a/src/plugins/intel_cpu/src/shape_inference/custom/adaptive_pooling.cpp +++ b/src/plugins/intel_cpu/src/shape_inference/custom/adaptive_pooling.cpp @@ -26,7 +26,7 @@ Result AdaptivePoolingShapeInfer::infer( VectorDims outputDims(inputRank); outputDims[0] = inputDims[0]; outputDims[1] = inputDims[1]; - auto newSpatialDimsPtr = reinterpret_cast(data_dependency.at(1)->getData()); + auto newSpatialDimsPtr = data_dependency.at(1)->getDataAs(); for (size_t i = 0; i < spatialDimsSize; i++) { outputDims[i + 2] = newSpatialDimsPtr[i]; } diff --git a/src/plugins/intel_cpu/src/shape_inference/custom/gather.cpp b/src/plugins/intel_cpu/src/shape_inference/custom/gather.cpp index 81e25801d5d5b8..17eefd339aa9c7 100644 --- a/src/plugins/intel_cpu/src/shape_inference/custom/gather.cpp +++ b/src/plugins/intel_cpu/src/shape_inference/custom/gather.cpp @@ -22,7 +22,7 @@ Result GatherShapeInfer::infer(const std::vectorgetDesc().getPrecision(), " for axis tensor."); } - m_axis = reinterpret_cast(data_dependency.at(GATHER_AXIS)->getData())[0]; + m_axis = data_dependency.at(GATHER_AXIS)->getDataAs()[0]; } if (m_axis < 0) { m_axis += input_shape.size(); diff --git a/src/plugins/intel_cpu/src/shape_inference/custom/one_hot.cpp b/src/plugins/intel_cpu/src/shape_inference/custom/one_hot.cpp index c8f5609b7c91bf..fdcc8ede041499 100644 --- a/src/plugins/intel_cpu/src/shape_inference/custom/one_hot.cpp +++ b/src/plugins/intel_cpu/src/shape_inference/custom/one_hot.cpp @@ -18,7 +18,7 @@ namespace node { Result OneHotShapeInfer::infer( const std::vector>& input_shapes, const std::unordered_map& data_dependency) { - auto depth = reinterpret_cast(data_dependency.at(1)->getData())[0]; + auto depth = data_dependency.at(1)->getDataAs()[0]; if (depth < 0) { OPENVINO_THROW("OneHot depth value can't be negative."); } diff --git a/src/plugins/intel_cpu/src/shape_inference/custom/priorbox.cpp b/src/plugins/intel_cpu/src/shape_inference/custom/priorbox.cpp index 0504fbf7b82038..e422802b1bccbc 100644 --- a/src/plugins/intel_cpu/src/shape_inference/custom/priorbox.cpp +++ b/src/plugins/intel_cpu/src/shape_inference/custom/priorbox.cpp @@ -18,7 +18,7 @@ namespace node { Result PriorBoxShapeInfer::infer( const std::vector>& input_shapes, const std::unordered_map& data_dependency) { - const int* in_data = reinterpret_cast(data_dependency.at(0)->getData()); + const int* in_data = data_dependency.at(0)->getDataAs(); const int H = in_data[0]; const int W = in_data[1]; const auto output = static_cast(4 * H * W * m_number_of_priors); diff --git a/src/plugins/intel_cpu/src/shape_inference/custom/priorbox_clustered.cpp b/src/plugins/intel_cpu/src/shape_inference/custom/priorbox_clustered.cpp index 809e205f396aec..bf6ff05d5fe9e8 100644 --- a/src/plugins/intel_cpu/src/shape_inference/custom/priorbox_clustered.cpp +++ b/src/plugins/intel_cpu/src/shape_inference/custom/priorbox_clustered.cpp @@ -19,7 +19,7 @@ namespace node { Result PriorBoxClusteredShapeInfer::infer( const std::vector>& input_shapes, const std::unordered_map& data_dependency) { - const int* in_data = reinterpret_cast(data_dependency.at(0)->getData()); + const int* in_data = data_dependency.at(0)->getDataAs(); const int H = in_data[0]; const int W = in_data[1]; const auto output = static_cast(4 * H * W * m_number_of_priors); diff --git a/src/plugins/intel_cpu/src/shape_inference/custom/strided_slice.cpp b/src/plugins/intel_cpu/src/shape_inference/custom/strided_slice.cpp index 07f054a3a3a0a7..f233d45dcf933d 100644 --- a/src/plugins/intel_cpu/src/shape_inference/custom/strided_slice.cpp +++ b/src/plugins/intel_cpu/src/shape_inference/custom/strided_slice.cpp @@ -34,9 +34,9 @@ Result StridedSliceShapeInfer::infer( data_dependency.at(STRIDE_ID)->getDesc().getPrecision() != ov::element::i32) { OPENVINO_THROW("The data type of begin/end/stride is NOT I32, which is unexpected!"); } - auto beginPtr = reinterpret_cast(data_dependency.at(BEGIN_ID)->getData()); - auto endPtr = reinterpret_cast(data_dependency.at(END_ID)->getData()); - auto stridePtr = reinterpret_cast(data_dependency.at(STRIDE_ID)->getData()); + auto beginPtr = data_dependency.at(BEGIN_ID)->getDataAs(); + auto endPtr = data_dependency.at(END_ID)->getDataAs(); + auto stridePtr = data_dependency.at(STRIDE_ID)->getDataAs(); for (size_t i = 0, new_idx = 0; i < shapeIn.size(); ++i) { if (m_new_axis_mask_set.count(i)) { diff --git a/src/plugins/intel_cpu/src/shape_inference/shape_inference_cpu.hpp b/src/plugins/intel_cpu/src/shape_inference/shape_inference_cpu.hpp index 2f6286864e9d85..8ac3eff1d79dbd 100644 --- a/src/plugins/intel_cpu/src/shape_inference/shape_inference_cpu.hpp +++ b/src/plugins/intel_cpu/src/shape_inference/shape_inference_cpu.hpp @@ -5,7 +5,8 @@ #pragma once #include -#include +#include +#include #include "openvino/core/coordinate_diff.hpp" #include "openvino/core/node.hpp" diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_matmul_to_fc.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_matmul_to_fc.cpp index f979d79a827452..7b1623d9bc8d62 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_matmul_to_fc.cpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_matmul_to_fc.cpp @@ -174,6 +174,9 @@ ov::intel_cpu::ConvertMatMulToFC::ConvertMatMulToFC() { auto fc = std::make_shared(fc_input_a, fc_input_b, output_rank, matmul->get_output_element_type(0)); fc->set_friendly_name(matmul->get_friendly_name()); + ///todo: CVS-130863 Remove after fp16_compression is copyable + if (ov::fp16_compression_is_disabled(matmul)) + disable_fp16_compression(fc); new_ops.push_back(fc); ov::copy_runtime_info(matmul, new_ops); ov::replace_node(matmul, fc); diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/rope_fusion.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/rope_fusion.cpp index 8552013de64294..274320e202cbf7 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/rope_fusion.cpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/rope_fusion.cpp @@ -88,6 +88,13 @@ ov::intel_cpu::RoPEFusionGPTNEOX::RoPEFusionGPTNEOX() { auto old_node = root; auto new_node = std::make_shared(new_args, config); new_node->set_friendly_name(old_node->get_friendly_name()); + ov::copy_runtime_info({pattern_map.at(x2neg).get_node_shared_ptr(), + pattern_map.at(x_rotate_half).get_node_shared_ptr(), + pattern_map.at(mul_cos).get_node_shared_ptr(), + pattern_map.at(mul_sin).get_node_shared_ptr(), + pattern_map.at(result).get_node_shared_ptr()}, + new_node); + ov::replace_node(old_node, new_node); // this new node may match following additional matchers @@ -225,6 +232,9 @@ ov::intel_cpu::RoPEFusionIOSlicing::RoPEFusionIOSlicing() { // remove slice & concat rope_node->set_argument(0, pattern_map.at(data)); rope_node->set_friendly_name(root->get_friendly_name()); + ov::copy_runtime_info({rope_node, + pattern_map.at(result).get_node_shared_ptr()}, + rope_node); ov::replace_node(root, rope_node); rope_node->validate_and_infer_types(); @@ -449,6 +459,22 @@ ov::intel_cpu::RoPEFusionGPTJ::RoPEFusionGPTJ() { auto new_node = std::make_shared(new_args, config); new_node->set_friendly_name(old_node->get_friendly_name()); + ov::copy_runtime_info({pattern_map.at(varsplit).get_node_shared_ptr(), + pattern_map.at(unsqueeze_sin).get_node_shared_ptr(), + pattern_map.at(unsqueeze_cos).get_node_shared_ptr(), + pattern_map.at(repeat_interleave_sin).get_node_shared_ptr(), + pattern_map.at(repeat_interleave_cos).get_node_shared_ptr(), + pattern_map.at(neg_Multiply_1177).get_node_shared_ptr(), + pattern_map.at(Unsqueeze_65524).get_node_shared_ptr(), + pattern_map.at(Unsqueeze_65525).get_node_shared_ptr(), + pattern_map.at(stack_1182).get_node_shared_ptr(), + pattern_map.at(flatten_Concat_1197).get_node_shared_ptr(), + pattern_map.at(mul_cos).get_node_shared_ptr(), + pattern_map.at(mul_sin).get_node_shared_ptr(), + pattern_map.at(rotary_emb).get_node_shared_ptr(), + pattern_map.at(cat_Concat_1211).get_node_shared_ptr(), + pattern_map.at(permute_Transpose_1213).get_node_shared_ptr()}, + new_node); ov::replace_node(old_node, new_node); return true; }; @@ -574,6 +600,10 @@ ov::intel_cpu::RoPEFusionChatGLM::RoPEFusionChatGLM(int split_output_id) { auto new_node = std::make_shared(new_args, config); new_node->set_friendly_name(old_node->get_friendly_name()); + ov::copy_runtime_info({pattern_map.at(flatten_Reshape_501).get_node_shared_ptr(), + pattern_map.at(slice_Slice_443).get_node_shared_ptr(), + pattern_map.at(cat_Concat_505).get_node_shared_ptr()}, + new_node); ov::replace_node(old_node, new_node); return true; }; @@ -680,7 +710,6 @@ ov::intel_cpu::RoPEFusionQwen::RoPEFusionQwen(int split_output_id) { {{"auto_broadcast", "numpy"}}); // tensor_array auto result = add_Add_597; - matcher_pass_callback callback = [=](ov::pass::pattern::Matcher& m) { const auto& pattern_map = m.get_pattern_value_map(); auto root = m.get_match_root(); @@ -713,6 +742,14 @@ ov::intel_cpu::RoPEFusionQwen::RoPEFusionQwen(int split_output_id) { auto old_node = root; auto new_node = std::make_shared(new_args, config); new_node->set_friendly_name(old_node->get_friendly_name()); + ov::copy_runtime_info({pattern_map.at(Multiply_567527).get_node_shared_ptr(), + pattern_map.at(ListUnpack_586_Squeeze_0).get_node_shared_ptr(), + pattern_map.at(ListUnpack_586_Squeeze).get_node_shared_ptr(), + pattern_map.at(cat_Concat_593).get_node_shared_ptr(), + pattern_map.at(slice_Slice_470).get_node_shared_ptr(), + pattern_map.at(mul_Multiply_594).get_node_shared_ptr(), + pattern_map.at(add_Add_597).get_node_shared_ptr()}, + new_node); ov::replace_node(old_node, new_node); return true; }; diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/stateful_sdpa_fusion.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/stateful_sdpa_fusion.cpp index 9de3f49d26aeac..6489a2947afa82 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/stateful_sdpa_fusion.cpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/stateful_sdpa_fusion.cpp @@ -55,14 +55,21 @@ StatefulSDPAFusion::StatefulSDPAFusion() { auto multi_query_bcst = [](std::shared_ptr kv) { auto reshape_kv = wrap_type({kv, any_input()}); - auto unsqueeze_kv = makePattern({kv, -2}); - auto constant_bcst = makeConst(ov::element::f32, ov::PartialShape("[...]"), [](ov::op::v0::Constant& node) { - const auto& bcst_arg = node.cast_vector(); + auto unsqueeze_kv = makePattern({kv, any_input()}); + + auto check_one = [] (Output output) -> bool { + auto node = std::dynamic_pointer_cast(output.get_node_shared_ptr()); + const auto& bcst_arg = node->cast_vector(); return std::all_of(bcst_arg.begin(), bcst_arg.end(), [](float i) { - return i == 1.0; + return i == 1.0f; }); - }); - auto multiply_kv = wrap_type({reshape_kv | unsqueeze_kv, constant_bcst}); + }; + auto constant_bcst = wrap_type(check_one); + + auto computed_bcst = makePattern({wrap_type(check_one), + any_input(), any_input()}, {{"mode", "numpy"}}); + + auto multiply_kv = wrap_type({reshape_kv | unsqueeze_kv, constant_bcst | computed_bcst}); return wrap_type({multiply_kv, any_input()}); }; @@ -94,7 +101,6 @@ StatefulSDPAFusion::StatefulSDPAFusion() { ov::matcher_pass_callback callback = [=](Matcher& m) { const auto& pattern_map = m.get_pattern_value_map(); auto root = m.get_match_root(); - PatternValidator validator(m); if (!validator) { return false; @@ -102,7 +108,7 @@ StatefulSDPAFusion::StatefulSDPAFusion() { auto find_assign = [&](const ov::Output& out, opset6::Assign*& assign, opset1::Convert*& cvt) { auto present_to = out.get_target_inputs(); - if (present_to.size() != 2) + if (present_to.size() < 2) return false; for (auto& to : present_to) { auto to_node = to.get_node(); @@ -192,9 +198,10 @@ StatefulSDPAFusion::StatefulSDPAFusion() { } } - auto old_node = sdp_node; + auto& old_node = sdp_node; auto new_node = std::make_shared(args, config); new_node->set_friendly_name(old_node->get_friendly_name()); + copy_runtime_info(old_node, new_node); ov::replace_node(old_node, {new_node->output(0)}); if (assign_cvt_k_node) assign_cvt_k_node->set_arguments({new_node->output(1)}); diff --git a/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/snippets_mark_skipped.cpp b/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/snippets_mark_skipped.cpp index b427ce5f84dafe..7f12b67d54aae4 100644 --- a/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/snippets_mark_skipped.cpp +++ b/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/snippets_mark_skipped.cpp @@ -10,6 +10,7 @@ #include #include "utils/general_utils.h" #include +#include "transformations/utils.hpp" #include "itt.hpp" @@ -401,6 +402,9 @@ bool isSuitableMatMulWithConstantPath(const std::shared_ptr& node) { !ov::is_type(node->get_input_node_shared_ptr(1)) && ov::op::util::is_on_constant_path(node->input_value(1)); } +bool isSuitableGatherWithConstantPath(const std::shared_ptr& node) { + return is_gather_with_compressed_weights(node); +} // Continue fusing chain of the passed type if the node has one child // Otherwise mark node as FusedTerminator (Fused, but fusing chain is interrupted) void PropagateIfHasOnlyChild(const std::shared_ptr &node, NodeFusingType nodeType) { @@ -477,7 +481,14 @@ bool SnippetsMarkSkipped::run_on_model(const std::shared_ptr &m) { }; std::unordered_set visited; ov::op::util::visit_constant_path(node->get_input_node_ptr(1), visited, markup_func); + } else if (isSuitableGatherWithConstantPath(node)) { + auto markup_func = [](Node* node) { + SetSnippetsNodeType(node->shared_from_this(), snippets::pass::SnippetsNodeType::SkippedByPlugin); + }; + std::unordered_set visited; + ov::op::util::visit_constant_path(node->get_input_node_ptr(0), visited, markup_func); } + if (isSuitableConvolutionParent(node)) { // Initiate fusing chain SetNodeFusingType(node, NodeFusingType::FusedWithConvolution); diff --git a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp index b98d7a8979701d..17c2574affb081 100644 --- a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp +++ b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp @@ -85,6 +85,7 @@ #include "transformations/init_node_info.hpp" #include "utils/ngraph_transformation.hpp" #include "utils/print_model.hpp" +#include "transformations/utils.hpp" // LPT transformations #include "low_precision/add.hpp" @@ -160,13 +161,46 @@ bool Transformations::is_decompression_multiply(const_node_ptr& node) const { } if (consumer != nullptr && ov::is_type(consumer)) { consumer = get_single_consumer(consumer); - if (consumer != nullptr && ov::is_type(consumer)) { - return true; + if (consumer != nullptr) { + if (ov::is_type(consumer)) { + return true; + } + if (is_gather_with_compressed_weights(consumer)) { + return true; + } } } return false; } +bool Transformations::fuse_type_to_fq(const std::shared_ptr& node, const precisions_map& precisions) { + auto fq = ov::as_type_ptr(node); + if (!fq) + return false; + const auto& from = node->get_output_element_type(0); + auto it = precisions.find(from); + if (it == precisions.end()) + return false; + const auto& to = it->second; + + for (size_t i = 0; i < node->get_input_size(); ++i) { + auto convert_before = std::make_shared(node->input_value(i), from); + node->input(i).replace_source_output(convert_before); + } + + auto consumers = node->output(0).get_target_inputs(); + for (auto& input : consumers) { + const auto consumer = input.get_node(); + if (ov::is_type(consumer) || ov::is_type(consumer)) { + continue; + } + auto convert_after = std::make_shared(node, to); + input.replace_source_output(convert_after); + } + + return true; +} + bool Transformations::fuse_type_to_convert(const std::shared_ptr& node, const precisions_map& precisions) { auto convert = ov::as_type_ptr(node); if (!convert) @@ -210,28 +244,24 @@ bool Transformations::fuse_type_to_convert(const std::shared_ptr& node } void Transformations::UpToLpt() { + using namespace ov::pass::low_precision; + static const std::set& supported_fq_levels = { + levels::int4, + levels::int4_narrow_range, + levels::int8, + levels::int8_narrow_range + }; + const bool useLpt = enableLpt && - ov::pass::low_precision::LowPrecision::isFunctionQuantized(model) && + LowPrecision::isFunctionQuantized(model, supported_fq_levels) && CPU_DEBUG_CAP_IS_TRANSFORMATION_ENABLED(config.debugCaps, Lpt); - auto defaultPrecisions = useLpt ? ov::pass::low_precision::precision_set::get_int8_support() : std::vector{}; - bool hasINT16orINT32Levels = false; - - if (useLpt) { - CPU_LPT_SCOPE(LowPrecisionTransformations_Part1); - hasINT16orINT32Levels = ov::pass::low_precision::LowPrecision::isFQLevelsPresent( - model, - {ov::pass::low_precision::levels::int16, ov::pass::low_precision::levels::int16_narrow_range, - ov::pass::low_precision::levels::int32, ov::pass::low_precision::levels::int32_narrow_range}); - if (hasINT16orINT32Levels) { - defaultPrecisions = ov::pass::low_precision::precision_set::get_int8_int16_int32_support(); - } - } + const auto defaultPrecisions = useLpt ? precision_set::get_int8_support() : std::vector{}; PreLpt(defaultPrecisions, isLegacyApi); if (useLpt) - Lpt(hasINT16orINT32Levels, defaultPrecisions); + Lpt(defaultPrecisions); } void Transformations::CpuSpecificOpSet(void) { @@ -301,12 +331,12 @@ void Transformations::PreLpt(const std::vector& defaultPrecis const auto precisions = get_convert_precisions(); if (inferencePrecision == ov::element::f16) { precisions_map fp_convert_precision_map = {{ov::element::f32, ov::element::f16}}; - type_to_fuse_map empty_fuse_map = {}; + type_to_fuse_map f16_fuse_map = {{ov::opset1::FakeQuantize::get_type_info_static(), fuse_type_to_fq}}; const bool keep_precision_sensitive_in_fp32 = true; CPU_REGISTER_PASS_COMMON(manager, ov::pass::ConvertPrecision, fp_convert_precision_map, - empty_fuse_map, + f16_fuse_map, keep_precision_sensitive_in_fp32, false); } @@ -512,7 +542,7 @@ void Transformations::PreLpt(const std::vector& defaultPrecis manager.run_passes(model); } -void Transformations::Lpt(const bool hasINT16orINT32Levels, const std::vector& defaultPrecisions) { +void Transformations::Lpt(const std::vector& defaultPrecisions) { CPU_DEBUG_CAP_TRANSFORMATION_SCOPE(this, Lpt); using namespace ov::pass::low_precision; @@ -571,18 +601,11 @@ void Transformations::Lpt(const bool hasINT16orINT32Levels, const std::vector({0}) }); - // for GNA networks reference execution - bool updatePrecision = true; - if (hasINT16orINT32Levels) { - updatePrecision = false; - supportedPrecisions = std::vector({}); - } - ov::pass::Manager lptManager; CPU_REGISTER_PASS_COMMON(lptManager, LowPrecision, supportedPrecisions, quantizationRestrictions, - LayerTransformation::Params(updatePrecision, ov::element::f32, defaultPrecisions)); + LayerTransformation::Params(true, ov::element::f32, defaultPrecisions)); CPU_SET_CALLBACK_COMMON(lptManager, [](const_node_ptr& node) -> bool { return ov::is_type(node) && @@ -677,7 +700,7 @@ void Transformations::MainSnippets(void) { // To avoid sitations when Transpose is not alone node between MatMul and Result, // Plugin disables Transpose tokenization on output tokenization_config.mha_token_enable_transpose_on_output = (inferencePrecision == ov::element::f32); - tokenization_config.concurrency = config.streamExecutorConfig._threadsPerStream; + tokenization_config.concurrency = config.threadsPerStream; if (tokenization_config.concurrency == 0) tokenization_config.concurrency = parallel_get_max_threads(); // The optimization "SplitDimensionM" depends on target machine (thread count). diff --git a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.h b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.h index b3a9bb078f8c2d..e79dadf44da680 100644 --- a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.h +++ b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.h @@ -50,7 +50,7 @@ class Transformations { void PreLpt(const std::vector& defaultPrecisions, const bool isLegacyApi); - void Lpt(const bool hasINT16orINT32Levels, const std::vector& defaultPrecisions); + void Lpt(const std::vector& defaultPrecisions); void MainSnippets(void); @@ -59,6 +59,7 @@ class Transformations { bool is_decompression_multiply(const std::shared_ptr& node) const; static bool fuse_type_to_convert(const std::shared_ptr& node, const precisions_map& precisions); + static bool fuse_type_to_fq(const std::shared_ptr& node, const precisions_map& precisions); }; } // namespace intel_cpu diff --git a/src/plugins/intel_cpu/src/transformations/utils.cpp b/src/plugins/intel_cpu/src/transformations/utils.cpp index f1943027917e8c..cd9da617108644 100644 --- a/src/plugins/intel_cpu/src/transformations/utils.cpp +++ b/src/plugins/intel_cpu/src/transformations/utils.cpp @@ -40,5 +40,89 @@ bool has_matmul_with_compressed_weights(const std::shared_ptr& return false; } +// Check specific pattern: +// Constant +// | +// Convert Constant +// \ / +// Subtract Constant +// \ / +// Multiply +// | +// Convert input Constant +// \ / / +// \ / / +// Gather +bool is_gather_with_compressed_weights(const std::shared_ptr& node) { + if (!ov::is_type(node)) { + return false; + } + if (node->get_input_size() != 3) { + return false; + } + + auto is_constant_with_2d = [](const ov::Node* node) { + const ov::Node* const_node = ov::is_type(node) ? node->get_input_node_ptr(0) : node; + + if (ov::is_type(const_node) && const_node->get_input_size() == 0) { + auto cur_shape = const_node->get_output_shape(0); + if (cur_shape.size() == 2 && cur_shape[1] == 1u) { + return true; + } + } + return false; + }; + + // Check axis + auto axis = node->get_input_node_ptr(2); + auto axisPtr = ov::as_type(axis); + if (!axisPtr) { + return false; + } + int32_t axis_const = axisPtr->cast_vector()[0]; + if (axis_const != 0) { + return false; + } + + // Check weights + ov::Node* multiply = nullptr; + auto multiply_convert = node->get_input_node_ptr(0); + if (ov::is_type(multiply_convert)) { + multiply = multiply_convert->get_input_node_ptr(0); + } else { + multiply = node->get_input_node_ptr(0); + } + if (!ov::is_type(multiply)) { + return false; + } + if (!is_constant_with_2d(multiply->get_input_node_ptr(1))) { + return false; + } + + auto subtract = multiply->get_input_node_ptr(0); + if (!ov::is_type(subtract)) { + return false; + } + if (!is_constant_with_2d(subtract->get_input_node_ptr(1))) { + return false; + } + + auto weights_convert = subtract->get_input_node_ptr(0); + if (!ov::is_type(weights_convert)) { + return false; + } + + auto weights = weights_convert->get_input_node_ptr(0); + auto weights_ptr = ov::as_type(weights); + if (!weights_ptr) { + return false; + } + auto weights_shape = weights_ptr->get_output_shape(0); + if (weights_shape.size() != 2u) { + return false; + } + return true; +} + } // namespace intel_cpu } // namespace ov diff --git a/src/plugins/intel_cpu/src/transformations/utils.hpp b/src/plugins/intel_cpu/src/transformations/utils.hpp index 64ebca6dfa5ed9..fabc95abf1525c 100644 --- a/src/plugins/intel_cpu/src/transformations/utils.hpp +++ b/src/plugins/intel_cpu/src/transformations/utils.hpp @@ -11,5 +11,7 @@ namespace intel_cpu { bool has_matmul_with_compressed_weights(const std::shared_ptr& model); +bool is_gather_with_compressed_weights(const std::shared_ptr& node); + } // namespace intel_cpu } // namespace ov diff --git a/src/plugins/intel_cpu/src/utils/blob_dump.cpp b/src/plugins/intel_cpu/src/utils/blob_dump.cpp index 8eef1639f45fb3..26626404aeea98 100644 --- a/src/plugins/intel_cpu/src/utils/blob_dump.cpp +++ b/src/plugins/intel_cpu/src/utils/blob_dump.cpp @@ -92,7 +92,7 @@ void BlobDumper::prepare_plain_data(const MemoryPtr &memory, std::vector(memory->getData()), size); + cpu_memcpy(data.data(), memory->getDataAs(), size); return; } @@ -166,7 +166,7 @@ void BlobDumper::dumpAsTxt(std::ostream &stream) const { << "shape: "; for (size_t d : dims) stream << d << " "; stream << "(" << data_size << ")" << - " by address 0x" << std::hex << reinterpret_cast(memory->getData()) << std::dec <getDataAs() << std::dec <getData(); diff --git a/src/plugins/intel_cpu/src/utils/cpp/maybe_unused.hpp b/src/plugins/intel_cpu/src/utils/cpp/maybe_unused.hpp new file mode 100644 index 00000000000000..1bbe4ad8da0d8a --- /dev/null +++ b/src/plugins/intel_cpu/src/utils/cpp/maybe_unused.hpp @@ -0,0 +1,22 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once +// Define a macro to silence "unused variable" warnings +#if defined(__GNUC__) || defined(__clang__) +# define OV_CPU_MAYBE_UNUSED(x) ((void)(x)) +#elif defined(_MSC_VER) +# define OV_CPU_MAYBE_UNUSED(x) __pragma(warning(suppress : 4100)) x +#else +# define OV_CPU_MAYBE_UNUSED(x) ((void)(x)) +#endif + +// Define a macro to silence "unused function" warnings +#if defined(__GNUC__) || defined(__clang__) +# define OV_CPU_MAYBE_UNUSED_FUNCTION __attribute__((unused)) +#elif defined(_MSC_VER) +# define OV_CPU_MAYBE_UNUSED_FUNCTION __pragma(warning(suppress : 4505)) +#else +# define OV_CPU_MAYBE_UNUSED_FUNCTION +#endif diff --git a/src/plugins/intel_cpu/src/utils/debug_capabilities.cpp b/src/plugins/intel_cpu/src/utils/debug_capabilities.cpp index 8c1b6c194aa653..4968528677cbdb 100644 --- a/src/plugins/intel_cpu/src/utils/debug_capabilities.cpp +++ b/src/plugins/intel_cpu/src/utils/debug_capabilities.cpp @@ -2,12 +2,6 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // -#include "common/primitive_desc_iface.hpp" -#include "memory_desc/blocked_memory_desc.h" -#include "oneapi/dnnl/dnnl.hpp" -#include "onednn/iml_type_mapper.h" - -#include #ifdef CPU_DEBUG_CAPS #include "cpu_memory.h" @@ -17,7 +11,14 @@ #include #include "nodes/input.h" #include "nodes/eltwise.h" -#include "snippets/op/subgraph.hpp" + +#include "openvino/op/util/multi_subgraph_base.hpp" +#include "common/primitive_desc_iface.hpp" +#include "memory_desc/cpu_memory_desc.h" +#include "oneapi/dnnl/dnnl.hpp" +#include "onednn/iml_type_mapper.h" +#include "transformations/rt_info/disable_fp16_compression.hpp" +#include namespace dnnl { namespace impl { @@ -124,28 +125,28 @@ std::ostream & operator<<(std::ostream & os, const dnnl::algorithm& alg) { return dnnl::impl::operator<<(os, convert_to_c(alg)); } +std::ostream & operator<<(std::ostream & os, const PortConfig& config) { + const char* sep = ","; + os << sep << *config.getMemDesc(); + os << " inPlace:" << config.inPlace(); + config.constant() ? os << " constant" : os << " non-constant"; + return os; +} + +std::ostream & operator<<(std::ostream & os, const NodeConfig& config) { + os << "("; + for (auto & conf : config.inConfs) + os << conf; + os << ") -> ("; + for (auto & conf : config.outConfs) + os << conf; + os << ")" << '\n'; + return os; +} + std::ostream & operator<<(std::ostream & os, const NodeDesc& desc) { - std::stringstream ss; - ss << " " << impl_type_to_string(desc.getImplementationType()) << "("; - const char * sep = ""; - for (auto & conf : desc.getConfig().inConfs) { - ss << sep << *conf.getMemDesc(); - if (conf.inPlace() >= 0) ss << " inPlace:" << conf.inPlace(); - if (conf.constant()) ss << " constant"; - sep = ","; - } - ss << ") -> ("; - sep = ""; - for (auto & conf : desc.getConfig().outConfs) { - ss << sep << *conf.getMemDesc(); - if (conf.inPlace() >= 0) ss << " inPlace:" << conf.inPlace(); - if (conf.constant()) ss << " constant"; - sep = ","; - } - ss << ")" << std::endl; - auto str = ss.str(); - replace_all(str, "0 - ?", "?"); - os << str; + os << " " << impl_type_to_string(desc.getImplementationType()); + os << desc.getConfig(); return os; } @@ -161,7 +162,7 @@ std::ostream & operator<<(std::ostream & os, const Node &c_node) { const char * comma = ""; auto node_id = [](Node & node) { auto id = node.getName(); - if (id.size() > 20) + if (id.size() > 50) return node.getTypeStr() + "_" + std::to_string(node.getExecIndex()); return id; }; @@ -380,6 +381,10 @@ std::ostream & operator<<(std::ostream & os, const Node &c_node) { return os; } +std::ostream & operator<<(std::ostream & os, const Shape& shape) { + os << shape.toString(); + return os; +} class OstreamAttributeVisitor : public ov::AttributeVisitor { std::ostream & os; @@ -533,7 +538,11 @@ std::ostream & operator<<(std::ostream & os, const PrintableModel& model) { } } os << prefix << "}\n"; - + os << prefix << "fp16_compress disabled Ngraph nodes:\n"; + for (const auto& op : f.get_ordered_ops()) { + if (ov::fp16_compression_is_disabled(op) && !std::dynamic_pointer_cast(op)) + os << "\t" << tag << op->get_friendly_name() << "\n"; + } return os; } @@ -590,6 +599,7 @@ std::ostream & operator<<(std::ostream & os, const dnnl::memory::desc& desc) { } os << " " << dnnl_dt2str(desc.get()->data_type); + os << " " << dnnl_fmt_kind2str(desc.get()->format_kind); return os; } @@ -645,6 +655,17 @@ std::ostream& operator<<(std::ostream& os, const IMemory& mem) { } return os; } +// @todo remove +void print_dnnl_memory(const dnnl::memory& memory, const size_t size, const int id, const char* message) { + const size_t s = memory.get_desc().get_size() / sizeof(float); + std::cout << message << " " << id << " size: " << s << ", values: "; + auto m = reinterpret_cast(memory.get_data_handle()); + for (size_t i = 0; i < std::min(s, size); i++) { + std::cout << *m << " "; + m++; + } + std::cout << "\n"; +} } // namespace intel_cpu } // namespace ov diff --git a/src/plugins/intel_cpu/src/utils/debug_capabilities.h b/src/plugins/intel_cpu/src/utils/debug_capabilities.h index f593bfa36dc3d7..01c78c043b4122 100644 --- a/src/plugins/intel_cpu/src/utils/debug_capabilities.h +++ b/src/plugins/intel_cpu/src/utils/debug_capabilities.h @@ -2,14 +2,17 @@ // SPDX-License-Identifier: Apache-2.0 // #pragma once + #ifdef CPU_DEBUG_CAPS #include #include #include #include +#include #include "onednn/dnnl.h" +#include "nodes/node_config.h" #include #include "onednn/iml_type_mapper.h" #include "openvino/core/model.hpp" @@ -89,8 +92,11 @@ class PrintableTimer { } }; +std::ostream & operator<<(std::ostream & os, const PortConfig& desc); +std::ostream & operator<<(std::ostream & os, const NodeConfig& desc); std::ostream & operator<<(std::ostream & os, const NodeDesc& desc); std::ostream & operator<<(std::ostream & os, const Node& node); +std::ostream & operator<<(std::ostream & os, const Shape& shape); std::ostream & operator<<(std::ostream & os, const MemoryDesc& desc); std::ostream & operator<<(std::ostream & os, const IMemory& mem); std::ostream & operator<<(std::ostream & os, const Edge& edge); @@ -106,6 +112,8 @@ std::ostream & operator<<(std::ostream & os, const dnnl::memory::format_tag dtyp std::ostream & operator<<(std::ostream & os, const dnnl::primitive_attr& attr); std::ostream & operator<<(std::ostream & os, const dnnl::algorithm& alg); +void print_dnnl_memory(const dnnl::memory& memory, const size_t size, const int id, const char* message = ""); + template std::ostream & operator<<(std::ostream & os, const PrintableVector& vec) { std::stringstream ss; @@ -160,10 +168,11 @@ static inline std::ostream& _write_all_to_stream(std::ostream& os, const T& arg, /* * important debugging tools for accuracy issues - * OV_CPU_INFER_PRC_TYPES : comma separated list of node types for which infer-precision is enforced + * OV_CPU_INFER_PRC_POS_PATTERN : positive regex pattern to filter node type & orgname. + * OV_CPU_INFER_PRC_NEG_PATTERN : negative regex pattern to filter after pos-pattern was matched. * OV_CPU_INFER_PRC_CNT : number of nodes totally allowed to enforced * adjust these two settings until accuracy issue happens/disappears - * from the log we can spot the first node having issue when enabled f16 + * from the log we can spot the node having issue when enabled bf16/f16 */ struct EnforceInferPrcDebug { std::string safe_getenv(const char* name, const char* default_value = "") { @@ -174,25 +183,80 @@ struct EnforceInferPrcDebug { return value; } - std::string nodeTypes = safe_getenv("OV_CPU_INFER_PRC_TYPES", ""); + bool pattern_verbose; + const char* str_pos_pattern; + const char* str_neg_pattern; + std::regex pos_pattern; + std::regex neg_pattern; + std::map> all_enabled_nodes; int count_limit = atoi(safe_getenv("OV_CPU_INFER_PRC_CNT", "9999999").c_str()); int count = 0; - bool enabled(std::string type, std::string name) { - if (nodeTypes.size() == 0) - return true; - auto idx = nodeTypes.find(type + ","); - if (idx != std::string::npos) { - // negative pattern - if (idx > 0 && nodeTypes[idx-1] == '-') - return false; - if (count < count_limit) { - std::cout << " infer precision enforced: [" << count << "/" << count_limit << "] : " << type << " " << name << std::endl; - count++; - return true; + EnforceInferPrcDebug() { + str_pos_pattern = std::getenv("OV_CPU_INFER_PRC_POS_PATTERN"); + str_neg_pattern = std::getenv("OV_CPU_INFER_PRC_NEG_PATTERN"); + if (str_pos_pattern || str_neg_pattern) { + pattern_verbose = true; + } else { + pattern_verbose = false; + } + if (str_pos_pattern) + pos_pattern = std::regex(str_pos_pattern); + if (str_neg_pattern) + neg_pattern = std::regex(str_neg_pattern); + } + + ~EnforceInferPrcDebug() { + if (pattern_verbose) { + if (str_pos_pattern) + std::cout << "OV_CPU_INFER_PRC_POS_PATTERN=\"" << str_pos_pattern << "\"" << std::endl; + if (str_neg_pattern) + std::cout << "OV_CPU_INFER_PRC_NEG_PATTERN=\"" << str_neg_pattern << "\"" << std::endl; + std::cout << "infer precision enforced Types: "; + size_t total_cnt = 0; + for (auto& ent : all_enabled_nodes) { + std::cout << ent.first << ","; + total_cnt += ent.second.size(); + } + std::cout << " total number of nodes: " << total_cnt << std::endl; + for (auto& ent : all_enabled_nodes) { + std::cout << ent.first << " : " << std::endl; + for (auto& name : ent.second) { + std::cout << "\t" << name << std::endl; + } + } + std::cout << std::endl; + } + } + + bool enabled(std::string type, std::string name, std::string org_names) { + std::string tag = type + "@" + org_names; + std::smatch match; + bool matched = true; + // filter using pos pattern + if (str_pos_pattern) { + matched = std::regex_search(tag, match, pos_pattern); + } + // filter using neg pattern + if (matched && str_neg_pattern) { + matched = !std::regex_search(tag, match, neg_pattern); + } + + // limit by CNT + if (matched && count > count_limit) { + matched = false; + } + + if (matched) { + auto it = all_enabled_nodes.find(type); + if (it == all_enabled_nodes.end()) { + all_enabled_nodes.insert({type, {tag}}); + } else { + it->second.push_back(tag); } + count++; } - return false; + return matched; } }; diff --git a/src/plugins/intel_cpu/src/utils/debug_caps_config.cpp b/src/plugins/intel_cpu/src/utils/debug_caps_config.cpp index 9064fb1a10cc71..2653eada1550d7 100644 --- a/src/plugins/intel_cpu/src/utils/debug_caps_config.cpp +++ b/src/plugins/intel_cpu/src/utils/debug_caps_config.cpp @@ -43,16 +43,16 @@ void DebugCapsConfig::readProperties() { blobDumpFormat = parseDumpFormat(envVarValue); if ((envVarValue = readEnv("OV_CPU_BLOB_DUMP_NODE_EXEC_ID"))) - blobDumpFilters[BY_EXEC_ID] = envVarValue; + blobDumpFilters[FILTER::BY_EXEC_ID] = envVarValue; if ((envVarValue = readEnv("OV_CPU_BLOB_DUMP_NODE_PORTS"))) - blobDumpFilters[BY_PORTS] = envVarValue; + blobDumpFilters[FILTER::BY_PORTS] = envVarValue; if ((envVarValue = readEnv("OV_CPU_BLOB_DUMP_NODE_TYPE"))) - blobDumpFilters[BY_TYPE] = envVarValue; + blobDumpFilters[FILTER::BY_TYPE] = envVarValue; if ((envVarValue = readEnv("OV_CPU_BLOB_DUMP_NODE_NAME"))) - blobDumpFilters[BY_NAME] = envVarValue; + blobDumpFilters[FILTER::BY_NAME] = envVarValue; if ((envVarValue = readEnv("OV_CPU_SUMMARY_PERF"))) { summaryPerf = envVarValue; diff --git a/src/plugins/intel_cpu/src/utils/debug_caps_config.h b/src/plugins/intel_cpu/src/utils/debug_caps_config.h index bc52c94ac123d5..7a04b9e4baf55b 100644 --- a/src/plugins/intel_cpu/src/utils/debug_caps_config.h +++ b/src/plugins/intel_cpu/src/utils/debug_caps_config.h @@ -2,10 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 // #pragma once + #ifdef CPU_DEBUG_CAPS #include "openvino/core/except.hpp" #include "openvino/util/common_util.hpp" +#include "utils/enum_class_hash.hpp" #include #include @@ -25,7 +27,7 @@ class DebugCapsConfig { readProperties(); } - enum FILTER { + enum class FILTER { BY_PORTS, BY_EXEC_ID, BY_TYPE, @@ -41,8 +43,7 @@ class DebugCapsConfig { std::string verbose; std::string blobDumpDir = "cpu_dump"; FORMAT blobDumpFormat = FORMAT::TEXT; - // std::hash is necessary for Ubuntu-16.04 (gcc-5.4 and defect in C++11 standart) - std::unordered_map> blobDumpFilters; + std::unordered_map blobDumpFilters; std::string summaryPerf = ""; struct TransformationFilter { diff --git a/src/plugins/intel_cpu/src/utils/enum_class_hash.hpp b/src/plugins/intel_cpu/src/utils/enum_class_hash.hpp new file mode 100644 index 00000000000000..7e17af42d05a97 --- /dev/null +++ b/src/plugins/intel_cpu/src/utils/enum_class_hash.hpp @@ -0,0 +1,24 @@ +// Copyright (C) 2018-2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include + +namespace ov { +namespace intel_cpu { + +/** + * Workaround for c++11 defect, where hashing support + * is missed for enum classes + */ +struct EnumClassHash { + template + int operator()(T t) const { + return static_cast(t); + } +}; + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/utils/precision_support.cpp b/src/plugins/intel_cpu/src/utils/precision_support.cpp index ebd71290624cfb..4a89002e63da48 100644 --- a/src/plugins/intel_cpu/src/utils/precision_support.cpp +++ b/src/plugins/intel_cpu/src/utils/precision_support.cpp @@ -5,26 +5,26 @@ #include "precision_support.h" #include "cpu/x64/cpu_isa_traits.hpp" +#include "openvino/core/type/element_type.hpp" #include "openvino/core/visibility.hpp" namespace ov { namespace intel_cpu { -bool hasHardwareSupport(const ov::element::Type& precision) { - switch (precision) { - case ov::element::f16: { +static bool hasFP16HardwareSupport(const ov::element::Type& precision) { #if defined(OPENVINO_ARCH_X86_64) - if (dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx512_core_fp16) || - dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx2_vnni_2)) - return true; - return false; + if (dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx512_core_fp16) || + dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx2_vnni_2)) + return true; + return false; #elif defined(OV_CPU_ARM_ENABLE_FP16) - return true; // @todo add runtime check for arm as well + return true; // @todo add runtime check for arm as well #else - return false; + return false; #endif - } - case ov::element::bf16: { +} + +static bool hasBF16HardwareSupport(const ov::element::Type& precision) { #if defined(OPENVINO_ARCH_X86_64) if (dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx512_core) || dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx2_vnni_2)) @@ -33,11 +33,26 @@ bool hasHardwareSupport(const ov::element::Type& precision) { #else return false; #endif - } +} + +bool hasHardwareSupport(const ov::element::Type& precision) { + switch (precision) { + case ov::element::f16: + return hasFP16HardwareSupport(precision); + case ov::element::bf16: + return hasBF16HardwareSupport(precision); default: return true; } } -} // namespace intel_cpu -} // namespace ov +ov::element::Type defaultFloatPrecision() { + if (hasHardwareSupport(ov::element::f16)) + return ov::element::f16; + if (hasHardwareSupport(ov::element::bf16)) + return ov::element::bf16; + return ov::element::f32; +} + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/utils/precision_support.h b/src/plugins/intel_cpu/src/utils/precision_support.h index f5d4c4907a6326..ef381fbf30face 100644 --- a/src/plugins/intel_cpu/src/utils/precision_support.h +++ b/src/plugins/intel_cpu/src/utils/precision_support.h @@ -10,6 +10,7 @@ namespace ov { namespace intel_cpu { bool hasHardwareSupport(const ov::element::Type& precision); +ov::element::Type defaultFloatPrecision(); } // namespace intel_cpu } // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/CMakeLists.txt b/src/plugins/intel_cpu/tests/functional/CMakeLists.txt index b753edd33bb3f8..db5ae8d01c2d93 100644 --- a/src/plugins/intel_cpu/tests/functional/CMakeLists.txt +++ b/src/plugins/intel_cpu/tests/functional/CMakeLists.txt @@ -21,23 +21,23 @@ endif() if(NOT (ARM OR AARCH64)) list(APPEND EXCLUDED_SOURCE_PATHS - ${CMAKE_CURRENT_SOURCE_DIR}/single_layer_tests/instances/arm - ${CMAKE_CURRENT_SOURCE_DIR}/subgraph_tests/src/arm - ${CMAKE_CURRENT_SOURCE_DIR}/test_utils/arm) + ${CMAKE_CURRENT_SOURCE_DIR}/custom/single_layer_tests/instances/arm + ${CMAKE_CURRENT_SOURCE_DIR}/custom/subgraph_tests/src/arm + ${CMAKE_CURRENT_SOURCE_DIR}/utils/arm) else() list(APPEND EXCLUDED_SOURCE_PATHS - ${CMAKE_CURRENT_SOURCE_DIR}/single_layer_tests/instances/x64 - ${CMAKE_CURRENT_SOURCE_DIR}/subgraph_tests/src/x64 - ${CMAKE_CURRENT_SOURCE_DIR}/test_utils/x64) + ${CMAKE_CURRENT_SOURCE_DIR}/custom/single_layer_tests/instances/x64 + ${CMAKE_CURRENT_SOURCE_DIR}/custom/subgraph_tests/src/x64 + ${CMAKE_CURRENT_SOURCE_DIR}/utils/x64) # temporary disable all custom tests for ARM list(APPEND EXCLUDED_SOURCE_PATHS - ${CMAKE_CURRENT_SOURCE_DIR}/single_layer_tests - ${CMAKE_CURRENT_SOURCE_DIR}/subgraph_tests) + ${CMAKE_CURRENT_SOURCE_DIR}/custom/single_layer_tests + ${CMAKE_CURRENT_SOURCE_DIR}/custom/subgraph_tests) # except ones which already enabled - file(GLOB_RECURSE TMP_LIST_OF_TEST_CLASSES ${CMAKE_CURRENT_SOURCE_DIR}/single_layer_tests/classes/*.cpp) - file(GLOB_RECURSE TMP_LIST_OF_COMMON_TEST_INSTANCES ${CMAKE_CURRENT_SOURCE_DIR}/single_layer_tests/instances/common/*.cpp) - file(GLOB_RECURSE TMP_LIST_OF_ARM_TEST_INSTANCES ${CMAKE_CURRENT_SOURCE_DIR}/single_layer_tests/instances/arm/*.cpp) - file(GLOB_RECURSE TMP_LIST_OF_ARM_SUBGRAPH_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/subgraph_tests/arm/*.cpp) + file(GLOB_RECURSE TMP_LIST_OF_TEST_CLASSES ${CMAKE_CURRENT_SOURCE_DIR}/custom/single_layer_tests/classes/*.cpp) + file(GLOB_RECURSE TMP_LIST_OF_COMMON_TEST_INSTANCES ${CMAKE_CURRENT_SOURCE_DIR}/custom/single_layer_tests/instances/common/*.cpp) + file(GLOB_RECURSE TMP_LIST_OF_ARM_TEST_INSTANCES ${CMAKE_CURRENT_SOURCE_DIR}/custom/single_layer_tests/instances/arm/*.cpp) + file(GLOB_RECURSE TMP_LIST_OF_ARM_SUBGRAPH_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/custom/subgraph_tests/arm/*.cpp) list(APPEND TMP_LIST_OF_EXPLICITLY_ENABLED_TESTS ${TMP_LIST_OF_TEST_CLASSES} ${TMP_LIST_OF_COMMON_TEST_INSTANCES} ${TMP_LIST_OF_ARM_TEST_INSTANCES} ${TMP_LIST_OF_ARM_SUBGRAPH_TESTS}) set(TMP_EXPLICITLY_ENABLED_TESTS "${TMP_LIST_OF_EXPLICITLY_ENABLED_TESTS}") @@ -45,8 +45,8 @@ endif() if(NOT X86_64) list(APPEND EXCLUDED_SOURCE_PATHS - ${CMAKE_CURRENT_SOURCE_DIR}/single_layer_tests/instances/x64 - ${CMAKE_CURRENT_SOURCE_DIR}/subgraph_tests/src/x64) + ${CMAKE_CURRENT_SOURCE_DIR}/custom/single_layer_tests/instances/x64 + ${CMAKE_CURRENT_SOURCE_DIR}/custom/subgraph_tests/src/x64) endif() ov_add_test_target( @@ -64,8 +64,8 @@ ov_add_test_target( ov_set_threading_interface_for(${TARGET_NAME}) -include(specific_tests.cmake) -include(target_per_test.cmake) +include(cmake/specific_tests.cmake) +include(cmake/target_per_test.cmake) # exclude 'ov_cpu_func_tests' from target 'all' if specific tests path was specified if(DEFINED ENABLE_CPU_SPECIFIC_TESTS_PATH) diff --git a/src/plugins/intel_cpu/tests/functional/specific_tests.cmake b/src/plugins/intel_cpu/tests/functional/cmake/specific_tests.cmake similarity index 81% rename from src/plugins/intel_cpu/tests/functional/specific_tests.cmake rename to src/plugins/intel_cpu/tests/functional/cmake/specific_tests.cmake index 8093a682f0bc57..c0de3d4a949dff 100644 --- a/src/plugins/intel_cpu/tests/functional/specific_tests.cmake +++ b/src/plugins/intel_cpu/tests/functional/cmake/specific_tests.cmake @@ -25,25 +25,22 @@ if(DEFINED ENABLE_CPU_SUBSET_TESTS_PATH) # exclude every other test file set(EXCLUDED_SOURCE_PATHS_FOR_SUBSET_TEST - ${CMAKE_CURRENT_SOURCE_DIR}/behavior - ${CMAKE_CURRENT_SOURCE_DIR}/extension - ${CMAKE_CURRENT_SOURCE_DIR}/single_layer_tests - ${CMAKE_CURRENT_SOURCE_DIR}/shared_tests_instances - ${CMAKE_CURRENT_SOURCE_DIR}/subgraph_tests/src) + ${CMAKE_CURRENT_SOURCE_DIR}/custom + ${CMAKE_CURRENT_SOURCE_DIR}/shared_tests_instances) # list of object files required for each test set(REQUIRED_OBJECT_FILES ${CMAKE_CURRENT_SOURCE_DIR}/shared_tests_instances/core_config.cpp ${CMAKE_CURRENT_SOURCE_DIR}/shared_tests_instances/skip_tests_config.cpp ${CMAKE_CURRENT_SOURCE_DIR}/shared_tests_instances/set_device_name.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/test_utils/cpu_test_utils.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/test_utils/fusing_test_utils.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/utils/cpu_test_utils.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/utils/fusing_test_utils.cpp ${CPU_SUBSET_TEST_ABS_PATH}) if(NOT (ARM OR AARCH64)) - list(APPEND EXCLUDED_SOURCE_PATHS_FOR_SUBSET_TEST ${CMAKE_CURRENT_SOURCE_DIR}/test_utils/arm) + list(APPEND EXCLUDED_SOURCE_PATHS_FOR_SUBSET_TEST ${CMAKE_CURRENT_SOURCE_DIR}/utils/arm) elseif(NOT X86_64) - list(APPEND EXCLUDED_SOURCE_PATHS_FOR_SUBSET_TEST ${CMAKE_CURRENT_SOURCE_DIR}/test_utils/x64) + list(APPEND EXCLUDED_SOURCE_PATHS_FOR_SUBSET_TEST ${CMAKE_CURRENT_SOURCE_DIR}/utils/x64) endif() ov_add_test_target( diff --git a/src/plugins/intel_cpu/tests/functional/target_per_test.cmake b/src/plugins/intel_cpu/tests/functional/cmake/target_per_test.cmake similarity index 91% rename from src/plugins/intel_cpu/tests/functional/target_per_test.cmake rename to src/plugins/intel_cpu/tests/functional/cmake/target_per_test.cmake index 2251b0ab5a9587..3ff2be21ab39e9 100644 --- a/src/plugins/intel_cpu/tests/functional/target_per_test.cmake +++ b/src/plugins/intel_cpu/tests/functional/cmake/target_per_test.cmake @@ -13,16 +13,16 @@ function(create_target_per_test_for_directory TEST_DIR TARGET_PREFIX) ${CMAKE_CURRENT_SOURCE_DIR}/shared_tests_instances/core_config.cpp ${CMAKE_CURRENT_SOURCE_DIR}/shared_tests_instances/skip_tests_config.cpp ${CMAKE_CURRENT_SOURCE_DIR}/shared_tests_instances/set_device_name.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/test_utils/cpu_test_utils.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/test_utils/fusing_test_utils.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/utils/cpu_test_utils.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/utils/fusing_test_utils.cpp ) if(X86_64) list(APPEND REQUIRED_OBJECT_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/test_utils/x64/filter_cpu_info.cpp) + ${CMAKE_CURRENT_SOURCE_DIR}/utils/x64/filter_cpu_info.cpp) elseif(ARM OR AARCH64) list(APPEND REQUIRED_OBJECT_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/test_utils/arm/filter_cpu_info.cpp) + ${CMAKE_CURRENT_SOURCE_DIR}/utils/arm/filter_cpu_info.cpp) endif() file(GLOB LIST_OF_TEST_FILES ${TEST_DIR}/*.cpp) @@ -93,8 +93,8 @@ endif() endfunction() if(ENABLE_CPU_SPECIFIC_TARGET_PER_TEST) - create_target_per_test_for_directory(${CMAKE_CURRENT_SOURCE_DIR}/subgraph_tests/src ov_cpu_func_subgraph) - create_target_per_test_for_directory(${CMAKE_CURRENT_SOURCE_DIR}/single_layer_tests ov_cpu_func_slt) + create_target_per_test_for_directory(${CMAKE_CURRENT_SOURCE_DIR}/custom/subgraph_tests/src ov_cpu_func_subgraph) + create_target_per_test_for_directory(${CMAKE_CURRENT_SOURCE_DIR}/custom/single_layer_tests ov_cpu_func_slt) endif() # examples of targets: diff --git a/src/plugins/intel_cpu/tests/functional/behavior/export_import.cpp b/src/plugins/intel_cpu/tests/functional/custom/behavior/export_import.cpp similarity index 100% rename from src/plugins/intel_cpu/tests/functional/behavior/export_import.cpp rename to src/plugins/intel_cpu/tests/functional/custom/behavior/export_import.cpp diff --git a/src/plugins/intel_cpu/tests/functional/behavior/ov_executable_network/properties.cpp b/src/plugins/intel_cpu/tests/functional/custom/behavior/ov_executable_network/properties.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/behavior/ov_executable_network/properties.cpp rename to src/plugins/intel_cpu/tests/functional/custom/behavior/ov_executable_network/properties.cpp index fb17f6dfef3b46..fca4580d592d53 100644 --- a/src/plugins/intel_cpu/tests/functional/behavior/ov_executable_network/properties.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/behavior/ov_executable_network/properties.cpp @@ -4,7 +4,7 @@ #include -#include "test_utils/properties_test.hpp" +#include "utils/properties_test.hpp" #include "openvino/runtime/system_conf.hpp" #include "openvino/runtime/core.hpp" #include "openvino/runtime/compiled_model.hpp" diff --git a/src/plugins/intel_cpu/tests/functional/behavior/ov_plugin/properties.cpp b/src/plugins/intel_cpu/tests/functional/custom/behavior/ov_plugin/properties.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/behavior/ov_plugin/properties.cpp rename to src/plugins/intel_cpu/tests/functional/custom/behavior/ov_plugin/properties.cpp index 69f670b5f6d493..3b758f928e0871 100644 --- a/src/plugins/intel_cpu/tests/functional/behavior/ov_plugin/properties.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/behavior/ov_plugin/properties.cpp @@ -5,7 +5,7 @@ #include #include -#include "test_utils/properties_test.hpp" +#include "utils/properties_test.hpp" #include "common_test_utils/test_assertions.hpp" #include "openvino/runtime/properties.hpp" #include "openvino/runtime/core.hpp" @@ -197,12 +197,10 @@ TEST_F(OVClassConfigTestCPU, smoke_PluginSetConfigHintInferencePrecision) { ASSERT_NO_THROW(value = ie.get_property("CPU", ov::hint::inference_precision)); ASSERT_EQ(value, forcedPrecision); - OPENVINO_SUPPRESS_DEPRECATED_START const auto forced_precision_deprecated = ov::element::f32; ASSERT_NO_THROW(ie.set_property("CPU", ov::hint::inference_precision(forced_precision_deprecated))); ASSERT_NO_THROW(value = ie.get_property("CPU", ov::hint::inference_precision)); ASSERT_EQ(value, forced_precision_deprecated); - OPENVINO_SUPPRESS_DEPRECATED_END } TEST_F(OVClassConfigTestCPU, smoke_PluginSetConfigEnableProfiling) { diff --git a/src/plugins/intel_cpu/tests/functional/extension/extension.cpp b/src/plugins/intel_cpu/tests/functional/custom/extension/extension.cpp similarity index 94% rename from src/plugins/intel_cpu/tests/functional/extension/extension.cpp rename to src/plugins/intel_cpu/tests/functional/custom/extension/extension.cpp index 46b62c605e5065..7357b9be723d55 100644 --- a/src/plugins/intel_cpu/tests/functional/extension/extension.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/extension/extension.cpp @@ -2,13 +2,14 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "openvino/frontend/extension.hpp" + #include #include "common_test_utils/file_utils.hpp" #include "common_test_utils/test_assertions.hpp" -#include "file_utils.h" -#include "openvino/frontend/extension.hpp" #include "openvino/runtime/core.hpp" +#include "openvino/util/file_util.hpp" using testing::ElementsAreArray; @@ -65,8 +66,8 @@ static void infer_model(ov::Core& core, } static std::string model_full_path(const char* path) { - return FileUtils::makePath( - FileUtils::makePath(ov::test::utils::getExecutableDirectory(), TEST_MODELS), path); + return ov::util::make_path(ov::util::make_path(ov::test::utils::getExecutableDirectory(), TEST_MODELS), + path); } TEST(Extension, XmlModelWithCustomAbs) { @@ -122,8 +123,8 @@ TEST(Extension, XmlModelWithCustomAbs) { static std::string get_extension_path() { - return FileUtils::makePluginLibraryName(ov::test::utils::getExecutableDirectory(), - std::string("openvino_template_extension") + OV_BUILD_POSTFIX); + return ov::util::make_plugin_library_name(ov::test::utils::getExecutableDirectory(), + std::string("openvino_template_extension") + OV_BUILD_POSTFIX); } TEST(Extension, smoke_XmlModelWithExtensionFromDSO) { diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/adaptive_pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/adaptive_pooling.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/adaptive_pooling.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/adaptive_pooling.cpp index d7df67e2eb9d06..2ced69d91e0728 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/adaptive_pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/adaptive_pooling.cpp @@ -5,7 +5,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "ov_models/utils/ov_helpers.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/augru_cell.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/augru_cell.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/augru_cell.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/augru_cell.cpp index 2c5f131cbbe448..95c9d5ca98b7a9 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/augru_cell.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/augru_cell.cpp @@ -5,7 +5,7 @@ #include "common_test_utils/node_builders/augru_cell.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/augru_sequence.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/augru_sequence.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/augru_sequence.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/augru_sequence.cpp index 3940d3bd77b6fb..ab1333e04c737b 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/augru_sequence.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/augru_sequence.cpp @@ -4,7 +4,7 @@ #include "common_test_utils/node_builders/augru_cell.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "transformations/op_conversions/bidirectional_sequences_decomposition.hpp" #include "transformations/op_conversions/convert_sequences_to_tensor_iterator.hpp" diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/batch_to_space.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/batch_to_space.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/batch_to_space.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/batch_to_space.cpp index 388b30e06163e3..f0196b93ec3941 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/batch_to_space.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/batch_to_space.cpp @@ -5,7 +5,7 @@ #include #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/broadcast.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/broadcast.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/broadcast.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/broadcast.cpp index 6521bf17cdfbd2..6159d854d29f7b 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/broadcast.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/broadcast.cpp @@ -5,7 +5,7 @@ #include #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/bucketize.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/bucketize.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/bucketize.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/bucketize.cpp index 9f9a99d6fef5a9..8ab46dd4d4b643 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/bucketize.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/bucketize.cpp @@ -5,7 +5,7 @@ #include #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/activation.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/activation.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/activation.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/activation.cpp index 132450682059e5..726f23dcf32687 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/activation.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/activation.cpp @@ -4,7 +4,7 @@ #include "activation.hpp" #include "gtest/gtest.h" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "common_test_utils/node_builders/activation.hpp" #include "shared_test_classes/single_op/activation.hpp" diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/activation.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/activation.hpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/activation.hpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/activation.hpp index 91353f982414cc..f380fc4477d886 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/activation.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/activation.hpp @@ -7,7 +7,7 @@ #include "shared_test_classes/base/ov_subgraph.hpp" #include "common_test_utils/ov_tensor_utils.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "gtest/gtest.h" namespace ov { diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/conversion.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/conversion.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/conversion.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/conversion.cpp index 2e0e0d603fd00e..881a4e26128141 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/conversion.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/conversion.cpp @@ -5,7 +5,7 @@ #include "conversion.hpp" #include "gtest/gtest.h" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/conversion.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/conversion.hpp similarity index 97% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/conversion.hpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/conversion.hpp index 1d978c625b6703..4e04afd2413403 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/conversion.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/conversion.hpp @@ -6,7 +6,7 @@ #include "shared_test_classes/base/ov_subgraph.hpp" #include "common_test_utils/ov_tensor_utils.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "gtest/gtest.h" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/convolution.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/convolution.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/convolution.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/convolution.cpp index 3cb45936f4709f..688a585ed39cad 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/convolution.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/convolution.cpp @@ -5,7 +5,7 @@ #include "convolution.hpp" #include "gtest/gtest.h" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "utils/general_utils.h" using namespace CPUTestUtils; @@ -196,11 +196,6 @@ TEST_P(ConvolutionLayerCPUTest, CompareWithRefs) { } if (!priority.empty()) { - // Skip all the brgconv avx2 tests for now. Current brgconv_avx2 is disabled due to perf regression[CVS-105756]. - // This convolution test code has already covered brgconv avx2 primitive. - // @todo: Remove this once brgconv_avx2 is enabled for convolution node. - if (priority[0].find("brgconv_avx2") != std::string::npos) - GTEST_SKIP() << "Disabled test due to the brgconv_avx2 is not enabled." << std::endl; // Skip tests for brgconv convolution where kernel size = 1x1 if (one_of(priority[0], "brgconv_avx512", "brgconv_avx512_amx", "brgconv_avx2")) { bool is_1x1 = true; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/convolution.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/convolution.hpp similarity index 97% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/convolution.hpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/convolution.hpp index 0228f18942744f..7b8e4ba3385233 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/convolution.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/convolution.hpp @@ -9,9 +9,9 @@ #include "ov_models/utils/ov_helpers.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" #include "shared_test_classes/single_op/convolution.hpp" -#include "test_utils/convolution_params.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "utils/convolution_params.hpp" +#include "utils/cpu_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" using namespace CPUTestUtils; @@ -25,7 +25,7 @@ typedef std::tuple< ElementType, // Input precision ElementType, // Output precision InputShape, // Input shape - LayerTestsUtils::TargetDevice // Device name + ov::test::TargetDevice // Device name > convLayerTestParamsSet; typedef std::tuple< diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/eltwise.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/eltwise.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/eltwise.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/eltwise.cpp index 212fd853391d89..9ba3f110605139 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/eltwise.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/eltwise.cpp @@ -10,7 +10,7 @@ #include "internal_properties.hpp" #include "openvino/core/type/element_type.hpp" #include "openvino/runtime/properties.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/eltwise.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/eltwise.hpp similarity index 96% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/eltwise.hpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/eltwise.hpp index f1af5e6f890d24..977c33d603cd27 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/eltwise.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/eltwise.hpp @@ -8,8 +8,8 @@ #include "shared_test_classes/base/ov_subgraph.hpp" #include "shared_test_classes/single_op/eltwise.hpp" #include "common_test_utils/ov_tensor_utils.hpp" -#include "test_utils/fusing_test_utils.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "gtest/gtest.h" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/matmul.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/matmul.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/matmul.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/matmul.cpp index 614e85a3afae4e..aa9e1ab95216d7 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/matmul.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/matmul.cpp @@ -6,7 +6,7 @@ #include "gtest/gtest.h" #include "openvino/core/type/element_type.hpp" #include "openvino/runtime/properties.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "common_test_utils/ov_tensor_utils.hpp" using namespace CPUTestUtils; @@ -57,7 +57,7 @@ std::string MatMulLayerCPUTest::getTestCaseName(const testing::TestParamInfo() << ":"; + result << configEntry.first << "=" << configEntry.second.as() << "_"; } result << ")"; result << CpuTestWithFusing::getTestCaseName(fusingParams); diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/matmul.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/matmul.hpp similarity index 97% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/matmul.hpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/matmul.hpp index 5470a2453bcc99..e470715539c99b 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/matmul.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/matmul.hpp @@ -5,7 +5,7 @@ #pragma once #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/mvn.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/mvn.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/mvn.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/mvn.cpp index e12a5478b85cef..b0c9486a06bae4 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/mvn.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/mvn.cpp @@ -4,7 +4,7 @@ #include "mvn.hpp" #include "gtest/gtest.h" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/mvn.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/mvn.hpp similarity index 95% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/mvn.hpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/mvn.hpp index 0354d31daf91ba..daa002fe559660 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/mvn.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/mvn.hpp @@ -6,8 +6,8 @@ #include "shared_test_classes/base/ov_subgraph.hpp" #include "common_test_utils/ov_tensor_utils.hpp" -#include "test_utils/fusing_test_utils.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "gtest/gtest.h" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/pooling.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp index 1fdb7c0fb9ac37..83e442f170039a 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp @@ -4,7 +4,7 @@ #include "gtest/gtest.h" #include "pooling.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "common_test_utils/node_builders/fake_quantize.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/pooling.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp similarity index 95% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/pooling.hpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp index 398e3c41ea2c6a..6f9303e7fa9100 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/pooling.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp @@ -4,8 +4,8 @@ #pragma once -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" #include "shared_test_classes/single_op/pooling.hpp" @@ -66,4 +66,4 @@ const std::vector& paramsAvg5D(); const std::vector& paramsMax5D(); } // namespace Pooling } // namespace test -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/random_uniform.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/random_uniform.cpp similarity index 100% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/random_uniform.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/random_uniform.cpp diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/random_uniform.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/random_uniform.hpp similarity index 97% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/random_uniform.hpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/random_uniform.hpp index 2d32426cb0a782..ec58a8cc6b5347 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/random_uniform.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/random_uniform.hpp @@ -5,7 +5,7 @@ #pragma once #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" namespace ov { namespace test { diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/reduce.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/reduce.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/reduce.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/reduce.cpp index 20e32f5c9fd0cb..33323e17414644 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/reduce.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/reduce.cpp @@ -7,7 +7,7 @@ #include "common_test_utils/node_builders/reduce.hpp" #include "gtest/gtest.h" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/reduce.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/reduce.hpp similarity index 96% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/reduce.hpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/reduce.hpp index 6d9913d22f7969..3634e35fb0a882 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/reduce.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/reduce.hpp @@ -5,9 +5,9 @@ #pragma once #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "common_test_utils/ov_tensor_utils.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" using namespace CPUTestUtils; using namespace ov::test; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/scaled_attn.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/scaled_attn.cpp similarity index 91% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/scaled_attn.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/scaled_attn.cpp index 46513a36016620..06b67daaf8f5dd 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/scaled_attn.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/scaled_attn.cpp @@ -6,7 +6,7 @@ #include "gtest/gtest.h" #include "openvino/opsets/opset13.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "transformations/op_conversions/scaled_dot_product_attention_decomposition.hpp" using namespace CPUTestUtils; @@ -124,6 +124,16 @@ void ScaledAttnLayerCPUTest::generate_inputs(const std::vector& targe } TEST_P(ScaledAttnLayerCPUTest, CompareWithRefs) { + CPUSpecificParams cpuParams; + ElementType inType; + std::vector inputShapes; + bool is_causal; + bool has_attn; + bool has_scale; + std::string targetDevice; + std::tie(inType, inputShapes, is_causal, has_attn, has_scale, targetDevice, cpuParams) = this->GetParam(); + if (inType == ElementType::bf16 && !ov::with_cpu_x86_bfloat16()) + GTEST_SKIP(); run(); CheckPluginRelatedResults(compiledModel, "ScaledAttn"); } diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/scaled_attn.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/scaled_attn.hpp similarity index 96% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/scaled_attn.hpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/scaled_attn.hpp index 8ef8834388d19f..bc0b63911fa982 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/scaled_attn.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/scaled_attn.hpp @@ -3,7 +3,7 @@ // #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/softmax.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/softmax.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/softmax.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/softmax.cpp index b1e66874fba03a..fe95030df307ae 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/softmax.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/softmax.cpp @@ -4,7 +4,7 @@ #include "softmax.hpp" #include "gtest/gtest.h" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/softmax.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/softmax.hpp similarity index 95% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/softmax.hpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/softmax.hpp index f31bc35b97b712..4fda482c8ad696 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/softmax.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/softmax.hpp @@ -3,7 +3,7 @@ // #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/transpose.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/transpose.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/transpose.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/transpose.cpp index 2dee8478ac6f19..5f21cb6de14256 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/transpose.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/transpose.cpp @@ -5,7 +5,7 @@ #include "transpose.hpp" #include "gtest/gtest.h" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/transpose.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/transpose.hpp similarity index 97% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/transpose.hpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/transpose.hpp index 44fa33126fdfdd..b06a6ed83ee7e6 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/transpose.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/transpose.hpp @@ -5,7 +5,7 @@ #pragma once #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "gtest/gtest.h" diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/concat.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/concat.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/concat.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/concat.cpp index e7cdc3ef273d62..ca1306bcd9bb66 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/concat.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/concat.cpp @@ -3,7 +3,7 @@ // #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/convert_to_plugin_specific_node.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/convert_to_plugin_specific_node.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/convert_to_plugin_specific_node.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/convert_to_plugin_specific_node.cpp index 11cd267963e236..010f555f596c85 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/convert_to_plugin_specific_node.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/convert_to_plugin_specific_node.cpp @@ -5,7 +5,7 @@ #include "common_test_utils/node_builders/eltwise.hpp" #include "common_test_utils/node_builders/constant.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/convolution_backprop_data.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/convolution_backprop_data.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/convolution_backprop_data.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/convolution_backprop_data.cpp index 6d2ce8ccda51e8..5f6ca8906852bf 100755 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/convolution_backprop_data.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/convolution_backprop_data.cpp @@ -9,10 +9,10 @@ #include "cpu_shape.h" #include "openvino/core/preprocess/pre_post_process.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/convolution_params.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/filter_cpu_info.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "utils/convolution_params.hpp" +#include "utils/cpu_test_utils.hpp" +#include "utils/filter_cpu_info.hpp" +#include "utils/fusing_test_utils.hpp" using namespace CPUTestUtils; namespace ov { diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/ctc_greedy_decoder.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/ctc_greedy_decoder.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/ctc_greedy_decoder.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/ctc_greedy_decoder.cpp index bbb4c9b05ac6b0..f711a3d01c16e9 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/ctc_greedy_decoder.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/ctc_greedy_decoder.cpp @@ -6,7 +6,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; namespace ov { diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/ctc_greedy_decoder_seq_len.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/ctc_greedy_decoder_seq_len.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/ctc_greedy_decoder_seq_len.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/ctc_greedy_decoder_seq_len.cpp index 22ec4c1a97f4a4..e378290a7f9e39 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/ctc_greedy_decoder_seq_len.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/ctc_greedy_decoder_seq_len.cpp @@ -6,7 +6,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; namespace ov { diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/ctc_loss.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/ctc_loss.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/ctc_loss.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/ctc_loss.cpp index 9404fdce874b68..9ac16bbdf0022c 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/ctc_loss.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/ctc_loss.cpp @@ -6,7 +6,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; namespace ov { diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/cum_sum.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/cum_sum.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/cum_sum.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/cum_sum.cpp index 336a4d06989d65..ea954088289b07 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/cum_sum.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/cum_sum.cpp @@ -3,7 +3,7 @@ // #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; namespace ov { diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/custom_op_internal_dyn.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/custom_op_internal_dyn.cpp similarity index 100% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/custom_op_internal_dyn.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/custom_op_internal_dyn.cpp diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/deformable_convolution.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/deformable_convolution.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/deformable_convolution.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/deformable_convolution.cpp index d3e30ce286120d..2480ab2fe30621 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/deformable_convolution.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/deformable_convolution.cpp @@ -4,7 +4,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; namespace ov { diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/depth_to_space.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/depth_to_space.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/depth_to_space.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/depth_to_space.cpp index 3f3bf2a9e017f0..48b4837c391bcb 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/depth_to_space.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/depth_to_space.cpp @@ -4,8 +4,8 @@ #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/filter_cpu_info.hpp" +#include "utils/cpu_test_utils.hpp" +#include "utils/filter_cpu_info.hpp" using namespace CPUTestUtils; namespace ov { diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/detection_output.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/detection_output.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/detection_output.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/detection_output.cpp index 954f16bce20cee..5e5d6aeb9ea23e 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/detection_output.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/detection_output.cpp @@ -4,7 +4,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" namespace DetectionOutput { static std::ostream& operator<<(std::ostream& result, const ov::op::v0::DetectionOutput::Attributes& attrs) { diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/embedding_bag_offsets_sum.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/embedding_bag_offsets_sum.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/embedding_bag_offsets_sum.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/embedding_bag_offsets_sum.cpp index e84af61c1e7617..2b3dc2dd3398b3 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/embedding_bag_offsets_sum.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/embedding_bag_offsets_sum.cpp @@ -5,7 +5,7 @@ #include "common_test_utils/node_builders/embedding_bag_offsets_sum.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; namespace ov { @@ -23,7 +23,7 @@ typedef std::tuple + ov::test::TargetDevice> embeddingBagOffsetsSumLayerTestParamsSet; class EmbeddingBagOffsetsSumLayerCPUTest : public testing::WithParamInterface, diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/embedding_bag_packed_sum.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/embedding_bag_packed_sum.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/embedding_bag_packed_sum.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/embedding_bag_packed_sum.cpp index 6a01ce8f52dc97..f976441d6351b3 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/embedding_bag_packed_sum.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/embedding_bag_packed_sum.cpp @@ -5,7 +5,7 @@ #include "common_test_utils/node_builders/embedding_bag_packed_sum.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; namespace ov { @@ -20,7 +20,7 @@ typedef std::tuple + ov::test::TargetDevice> embeddingBagPackedSumLayerTestParamsSet; class EmbeddingBagPackedSumLayerCPUTest : public testing::WithParamInterface, diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/embedding_segments_sum.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/embedding_segments_sum.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/embedding_segments_sum.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/embedding_segments_sum.cpp index 5b3cf8bcb917b3..50b57b7a6dd822 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/embedding_segments_sum.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/embedding_segments_sum.cpp @@ -5,7 +5,7 @@ #include "common_test_utils/node_builders/embedding_segments_sum.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; namespace ov { @@ -24,7 +24,7 @@ typedef std::tuple + ov::test::TargetDevice> embeddingSegmentsSumLayerTestParamsSet; class EmbeddingSegmentsSumLayerCPUTest : public testing::WithParamInterface, diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/extract_image_patches.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/extract_image_patches.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/extract_image_patches.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/extract_image_patches.cpp index 17df64a4f5d31a..2218c18807d623 100755 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/extract_image_patches.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/extract_image_patches.cpp @@ -3,7 +3,7 @@ // #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; namespace ov { diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/eye.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/eye.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/eye.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/eye.cpp index 053261035cebe8..84ffeeff9be710 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/eye.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/eye.cpp @@ -4,7 +4,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; namespace ov { diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/fake_quantize.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/fake_quantize.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/fake_quantize.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/fake_quantize.cpp index d57e77b068f160..f96c19333f067e 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/fake_quantize.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/fake_quantize.cpp @@ -5,7 +5,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "common_test_utils/node_builders/constant.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; namespace ov { diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/gather.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/gather.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/gather.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/gather.cpp index 3362bda02fdb78..b07b339da0c3fa 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/gather.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/gather.cpp @@ -4,7 +4,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; namespace ov { @@ -128,7 +128,7 @@ class GatherLayerTestCPU : public testing::WithParamInterfaceget_friendly_name() == "data") { diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/gather_elements.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/gather_elements.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/gather_elements.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/gather_elements.cpp index e1cc152ffbcad3..6676ae89845451 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/gather_elements.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/gather_elements.cpp @@ -4,7 +4,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/gather_nd.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/gather_nd.cpp similarity index 100% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/gather_nd.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/gather_nd.cpp diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/gather_tree.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/gather_tree.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/gather_tree.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/gather_tree.cpp index b24d1f6d445792..dc1a16cd4231f8 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/gather_tree.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/gather_tree.cpp @@ -5,7 +5,7 @@ #include "common_test_utils/node_builders/constant.hpp" #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/grid_sample.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/grid_sample.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/grid_sample.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/grid_sample.cpp index 3ef7ef621e0f3d..0e9ef3bd2486c4 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/grid_sample.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/grid_sample.cpp @@ -4,7 +4,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; @@ -136,7 +136,7 @@ class GridSampleLayerTestCPU : public testing::WithParamInterfaceget_friendly_name() == "data") { diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/grn.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/grn.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/grn.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/grn.cpp index 41bf75ba92168e..a70f946a2c8bc5 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/grn.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/grn.cpp @@ -3,7 +3,7 @@ // #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; namespace ov { diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/group_convolution.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/group_convolution.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/group_convolution.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/group_convolution.cpp index 18ae356d62ae05..9fddcd46134328 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/group_convolution.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/group_convolution.cpp @@ -6,10 +6,10 @@ #include "common_test_utils/node_builders/group_convolution.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/convolution_params.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/filter_cpu_info.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "utils/convolution_params.hpp" +#include "utils/cpu_test_utils.hpp" +#include "utils/filter_cpu_info.hpp" +#include "utils/fusing_test_utils.hpp" using namespace CPUTestUtils; namespace ov { diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/group_convolution_backprop_data.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/group_convolution_backprop_data.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/group_convolution_backprop_data.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/group_convolution_backprop_data.cpp index 6f8b939fc9b179..e09b17a3e4235e 100755 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/group_convolution_backprop_data.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/group_convolution_backprop_data.cpp @@ -8,10 +8,10 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "openvino/core/preprocess/pre_post_process.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/convolution_params.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/filter_cpu_info.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "utils/convolution_params.hpp" +#include "utils/cpu_test_utils.hpp" +#include "utils/filter_cpu_info.hpp" +#include "utils/fusing_test_utils.hpp" using namespace CPUTestUtils; namespace ov { diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/gru_cell.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/gru_cell.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/gru_cell.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/gru_cell.cpp index 495d97e6271940..740e1168007af5 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/gru_cell.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/gru_cell.cpp @@ -5,7 +5,7 @@ #include "common_test_utils/node_builders/gru_cell.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; namespace ov { diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/gru_sequence.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/gru_sequence.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/gru_sequence.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/gru_sequence.cpp index 9481f04b8ec9ce..ffc071cf57bb7e 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/gru_sequence.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/gru_sequence.cpp @@ -3,7 +3,7 @@ // #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "transformations/op_conversions/bidirectional_sequences_decomposition.hpp" #include "transformations/op_conversions/convert_sequences_to_tensor_iterator.hpp" #include "common_test_utils/node_builders/gru_cell.hpp" diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/arm/conversion.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/arm/conversion.cpp similarity index 91% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/arm/conversion.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/arm/conversion.cpp index 97459a350a66c8..11e0440b2e3618 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/arm/conversion.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/arm/conversion.cpp @@ -2,8 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/classes/conversion.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "custom/single_layer_tests/classes/conversion.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; @@ -29,4 +29,4 @@ INSTANTIATE_TEST_SUITE_P(smoke_ConvertCPULayerTest_7D_Static, ConvertCPULayerTes } // namespace Conversion } // namespace test -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/arm/eltwise.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/arm/eltwise.cpp similarity index 97% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/arm/eltwise.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/arm/eltwise.cpp index d35e6c4810967e..3b9a841e41f322 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/arm/eltwise.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/arm/eltwise.cpp @@ -2,9 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/classes/eltwise.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "custom/single_layer_tests/classes/eltwise.hpp" +#include "utils/cpu_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/activation.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/activation.cpp similarity index 96% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/activation.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/activation.cpp index 08e19d1e305b2d..7fae7516eff95f 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/activation.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/activation.cpp @@ -2,8 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/classes/activation.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "custom/single_layer_tests/classes/activation.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/conversion.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/conversion.cpp similarity index 94% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/conversion.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/conversion.cpp index 2db999e74a4df5..fb589a4674b8d1 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/conversion.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/conversion.cpp @@ -2,8 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/classes/conversion.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "custom/single_layer_tests/classes/conversion.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/convolution.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/convolution.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/convolution.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/convolution.cpp index 5a9ee27aa959f4..b6518f8e8f48f1 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/convolution.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/convolution.cpp @@ -2,9 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/classes/convolution.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/filter_cpu_info.hpp" +#include "custom/single_layer_tests/classes/convolution.hpp" +#include "utils/cpu_test_utils.hpp" +#include "utils/filter_cpu_info.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/eltwise.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/eltwise.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/eltwise.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/eltwise.cpp index b6a6d4012a715a..2efdec2559e6c3 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/eltwise.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/eltwise.cpp @@ -2,9 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/classes/eltwise.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "custom/single_layer_tests/classes/eltwise.hpp" +#include "utils/cpu_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/matmul.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/matmul.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/matmul.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/matmul.cpp index 1f02bfef466264..934a0f4bc95f18 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/matmul.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/matmul.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/classes/matmul.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/filter_cpu_info.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "custom/single_layer_tests/classes/matmul.hpp" +#include "utils/cpu_test_utils.hpp" +#include "utils/filter_cpu_info.hpp" +#include "utils/fusing_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/multinomial.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/multinomial.cpp similarity index 100% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/multinomial.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/multinomial.cpp diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/mvn.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/mvn.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/mvn.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/mvn.cpp index 6a8391a58861f4..5aebaf4b5d9e83 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/mvn.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/mvn.cpp @@ -2,9 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/classes/mvn.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "custom/single_layer_tests/classes/mvn.hpp" +#include "utils/cpu_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/nms_rotated.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/nms_rotated.cpp similarity index 100% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/nms_rotated.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/nms_rotated.cpp diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/pooling.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp index 077327096701ef..cab1f0ff4dcd2b 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp @@ -2,9 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/classes/pooling.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "custom/single_layer_tests/classes/pooling.hpp" +#include "utils/cpu_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/random_uniform.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/random_uniform.cpp similarity index 97% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/random_uniform.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/random_uniform.cpp index 61101375bb5598..f0a2e5e8efd39f 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/random_uniform.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/random_uniform.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/classes/random_uniform.hpp" +#include "custom/single_layer_tests/classes/random_uniform.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/reduce.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/reduce.cpp similarity index 97% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/reduce.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/reduce.cpp index 433e378f8803e6..cd2f14949f3ac8 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/reduce.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/reduce.cpp @@ -2,9 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/classes/reduce.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "custom/single_layer_tests/classes/reduce.hpp" +#include "utils/cpu_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/softmax.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/softmax.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/softmax.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/softmax.cpp index 6a17df004e92ce..f7ca27086bace0 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/softmax.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/softmax.cpp @@ -2,8 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/classes/softmax.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "custom/single_layer_tests/classes/softmax.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/transpose.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/transpose.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/transpose.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/transpose.cpp index 1224e25083cca6..8f370c411432d7 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/transpose.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/transpose.cpp @@ -2,8 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/classes/transpose.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "custom/single_layer_tests/classes/transpose.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/activation.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/activation.cpp similarity index 97% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/activation.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/activation.cpp index 81445af9e47c93..0be196740e85f7 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/activation.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/activation.cpp @@ -2,8 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/classes/activation.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "custom/single_layer_tests/classes/activation.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; using namespace ov::test::utils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/conversion.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/conversion.cpp similarity index 96% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/conversion.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/conversion.cpp index 10db7a7db1f3f9..bd4574b6d1411c 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/conversion.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/conversion.cpp @@ -2,8 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/classes/conversion.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "custom/single_layer_tests/classes/conversion.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/convolution.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/convolution.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/convolution.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/convolution.cpp index f322e1088edb62..8073b67b726eb8 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/convolution.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/convolution.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/classes/convolution.hpp" +#include "custom/single_layer_tests/classes/convolution.hpp" #include "shared_test_classes/single_op/convolution.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/filter_cpu_info.hpp" +#include "utils/cpu_test_utils.hpp" +#include "utils/filter_cpu_info.hpp" using namespace CPUTestUtils; @@ -237,7 +237,7 @@ const auto convParams_ExplicitPadding_1D = ::testing::Combine( ::testing::Values(ov::op::PadType::EXPLICIT) ); -const std::vector CPUParams_1D = { +const std::vector CPUParams_1D_f32 = { conv_sse42_1D, conv_avx2_1D, conv_avx512_1D, @@ -248,6 +248,17 @@ const std::vector CPUParams_1D = { conv_avx512_1D_nspc_brgconv }; +//Current avx2 I8 fall back on JIT avx2 implement when having src zero point.Not enabling conv_avx2_1D_nspc_brgconv for I8 precision. +const std::vector CPUParams_1D_I8 = { + conv_sse42_1D, + conv_avx2_1D, + conv_avx512_1D, + conv_sse42_1D_nspc, + conv_avx2_1D_nspc, + conv_avx512_1D_nspc, + conv_avx512_1D_nspc_brgconv +}; + INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D_FP32, ConvolutionLayerCPUTest, ::testing::Combine( ::testing::Combine( @@ -257,7 +268,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D_FP32, ConvolutionLayerCPUTest, ::testing::Values(ElementType::undefined), ::testing::ValuesIn(inputShapes1d()), ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfo(CPUParams_1D)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_1D_f32)), ::testing::ValuesIn(fusingParamsSetWithEmpty()), ::testing::Values(empty_plugin_config)), ConvolutionLayerCPUTest::getTestCaseName); @@ -286,7 +297,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D_I8, ConvolutionLayerCPUTest, ::testing::Values(ElementType::undefined), ::testing::ValuesIn(inputShapes1d()), ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfo(CPUParams_1D)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_1D_I8)), ::testing::Values(fusingSum), ::testing::Values(empty_plugin_config)), ConvolutionLayerCPUTest::getTestCaseName); diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/eltwise.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/eltwise.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/eltwise.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/eltwise.cpp index 9391001d9a2888..e88492d625e82b 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/eltwise.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/eltwise.cpp @@ -2,10 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/classes/eltwise.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/fusing_test_utils.hpp" -#include "common_test_utils/ov_tensor_utils.hpp" +#include "custom/single_layer_tests/classes/eltwise.hpp" +#include "utils/cpu_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" using namespace CPUTestUtils; @@ -696,4 +695,4 @@ INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_4D_Bitwise_NOT_i32, EltwiseLayerC } // namespace } // namespace Eltwise } // namespace test -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/matmul.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/matmul.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/matmul.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/matmul.cpp index 878176c900e101..ae1101fbba9f12 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/matmul.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/matmul.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/classes/matmul.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/filter_cpu_info.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "custom/single_layer_tests/classes/matmul.hpp" +#include "utils/cpu_test_utils.hpp" +#include "utils/filter_cpu_info.hpp" +#include "utils/fusing_test_utils.hpp" using namespace CPUTestUtils; @@ -838,4 +838,4 @@ INSTANTIATE_TEST_SUITE_P( } // namespace } // namespace MatMul } // namespace test -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/mlas/matmul.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/mlas/matmul.cpp similarity index 97% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/mlas/matmul.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/mlas/matmul.cpp index 0b9cc54afd63d2..108b45e50deb06 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/mlas/matmul.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/mlas/matmul.cpp @@ -2,9 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/classes/matmul.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "custom/single_layer_tests/classes/matmul.hpp" +#include "utils/cpu_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/mvn.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/mvn.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/mvn.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/mvn.cpp index cc9e3f0f64864a..25893c2fb6efe7 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/mvn.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/mvn.cpp @@ -2,9 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/classes/mvn.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "custom/single_layer_tests/classes/mvn.hpp" +#include "utils/cpu_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" #include "common_test_utils/ov_tensor_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp similarity index 96% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/pooling.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp index 8374fe43f37ef1..e11a9c0c572d34 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/classes/pooling.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/filter_cpu_info.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "custom/single_layer_tests/classes/pooling.hpp" +#include "utils/cpu_test_utils.hpp" +#include "utils/filter_cpu_info.hpp" +#include "utils/fusing_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/random_uniform.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/random_uniform.cpp similarity index 96% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/random_uniform.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/random_uniform.cpp index bb6c6282c1fc9a..8d35c4bcc1e0e5 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/random_uniform.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/random_uniform.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/classes/random_uniform.hpp" +#include "custom/single_layer_tests/classes/random_uniform.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/reduce.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/reduce.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/reduce.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/reduce.cpp index dcb589e7965292..ceae4d450b789f 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/reduce.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/reduce.cpp @@ -2,9 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/classes/reduce.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "custom/single_layer_tests/classes/reduce.hpp" +#include "utils/cpu_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" #include "ov_lpt_models/common/builders.hpp" #include "common_test_utils/node_builders/fake_quantize.hpp" diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/scaled_attn.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/scaled_attn.cpp similarity index 96% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/scaled_attn.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/scaled_attn.cpp index 40539f63b9732d..ad48de2765ad2c 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/scaled_attn.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/scaled_attn.cpp @@ -2,8 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/classes/scaled_attn.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "custom/single_layer_tests/classes/scaled_attn.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/transpose.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/transpose.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/transpose.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/transpose.cpp index babf90b3ad4a30..e1f0d559cf2f03 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/transpose.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/transpose.cpp @@ -2,8 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/classes/transpose.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "custom/single_layer_tests/classes/transpose.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/interpolate.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/interpolate.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/interpolate.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/interpolate.cpp index 123cf64e3979e8..e37cf565a6b0d2 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/interpolate.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/interpolate.cpp @@ -5,8 +5,8 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "openvino/core/preprocess/pre_post_process.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" #include "transformations/op_conversions/convert_interpolate11_downgrade.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/log_softmax.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/log_softmax.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/log_softmax.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/log_softmax.cpp index 8a5fe083cb1537..8f799ff0a603cd 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/log_softmax.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/log_softmax.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/logical.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/logical.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/logical.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/logical.cpp index 1a333305cb6d1e..6ffd701b0c387a 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/logical.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/logical.cpp @@ -7,7 +7,7 @@ #include "common_test_utils/node_builders/logical.hpp" #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/loop.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/loop.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/loop.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/loop.cpp index 7070ba36602a7c..2d70c38be9d877 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/loop.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/loop.cpp @@ -381,8 +381,8 @@ class LoopForConcatLayerCPUTest : public LoopLayerCPUTest { class StaticLoopDynamicSubgraphCPUTest : public SubgraphBaseTest { void SetUp() override { - InputShape input_shape = {{25, 1, 1}, {{25, 1, 1}}}; - InputShape input_exec_flag_shape = {{1}, {{1}}}; + InputShape input_shape = {{25, 1, 1}, {{25, 1, 1}, {25, 1, 1}}}; // infer more than once + InputShape input_exec_flag_shape = {{1}, {{1}, {1}}}; targetDevice = ov::test::utils::DEVICE_CPU; ElementType netType = ov::element::f32; init_input_shapes({input_shape, input_exec_flag_shape}); diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/lrn.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/lrn.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/lrn.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/lrn.cpp index 2e0e5b9541338e..ed254e9e8bd5ac 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/lrn.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/lrn.cpp @@ -4,7 +4,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/lstm_cell.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/lstm_cell.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/lstm_cell.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/lstm_cell.cpp index 83a0126444f36a..195b51771d09bb 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/lstm_cell.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/lstm_cell.cpp @@ -5,7 +5,7 @@ #include "common_test_utils/node_builders/lstm_cell.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/lstm_sequence.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/lstm_sequence.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/lstm_sequence.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/lstm_sequence.cpp index e32d08bdd845fb..d58de0114ec8ae 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/lstm_sequence.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/lstm_sequence.cpp @@ -4,7 +4,7 @@ #include "common_test_utils/node_builders/lstm_cell.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "transformations/op_conversions/bidirectional_sequences_decomposition.hpp" #include "transformations/op_conversions/convert_sequences_to_tensor_iterator.hpp" diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/matmul_sparse.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/matmul_sparse.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/matmul_sparse.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/matmul_sparse.cpp index a0118f1a602fbb..e51c75d54d2d4b 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/matmul_sparse.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/matmul_sparse.cpp @@ -8,7 +8,7 @@ #include "ov_ops/type_relaxed.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" #include "shared_test_classes/base/utils/generate_inputs.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/non_max_suppression.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/non_max_suppression.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/non_max_suppression.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/non_max_suppression.cpp index 00b7c82bd1be15..bfff16edd89efa 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/non_max_suppression.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/non_max_suppression.cpp @@ -6,7 +6,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" #include "shared_test_classes/base/utils/ranges.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; @@ -96,7 +96,7 @@ class NmsLayerCPUTest : public testing::WithParamInterface, virtual p auto node = funcInputs[2].get_node_shared_ptr(); auto it = inputs.find(node); if (it == inputs.end()) return; - auto tensor = ov::runtime::Tensor(node->get_element_type(), targetInputStaticShapes[2], &maxOutBoxesPerClass); + auto tensor = ov::Tensor(node->get_element_type(), targetInputStaticShapes[2], &maxOutBoxesPerClass); inputs[node] = tensor; } diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/nonzero.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/nonzero.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/nonzero.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/nonzero.cpp index b3b47e3d12c2ec..330eaf6a15bbbf 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/nonzero.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/nonzero.cpp @@ -4,7 +4,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/normalize.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/normalize.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/normalize.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/normalize.cpp index bacab7398e0155..a07789744b6c19 100755 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/normalize.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/normalize.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "test_utils/fusing_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" #include "common_test_utils/ov_tensor_utils.hpp" diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/one_hot.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/one_hot.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/one_hot.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/one_hot.cpp index 52fa4d4ba2a77c..2549b86f9093b3 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/one_hot.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/one_hot.cpp @@ -2,8 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "common_test_utils/ov_tensor_utils.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include +#include +#include "utils/cpu_test_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/pad.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/pad.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/pad.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/pad.cpp index daa572fd43c7a7..ac50e9351d6300 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/pad.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/pad.cpp @@ -6,7 +6,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "openvino/op/pad.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/prior_box.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/prior_box.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/prior_box.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/prior_box.cpp index 7d689ab7ec4feb..de109f0200ffdd 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/prior_box.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/prior_box.cpp @@ -5,7 +5,7 @@ #include "openvino/core/partial_shape.hpp" #include "shared_test_classes/base/layer_test_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/prior_box_clustered.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/prior_box_clustered.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/prior_box_clustered.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/prior_box_clustered.cpp index 5aa4df776dd752..eb17754d90037c 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/prior_box_clustered.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/prior_box_clustered.cpp @@ -5,7 +5,7 @@ #include "openvino/core/partial_shape.hpp" #include "shared_test_classes/base/layer_test_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/proposal.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/proposal.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/proposal.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/proposal.cpp index 6f6c1c270d7d1a..65804e7d0e61fc 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/proposal.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/proposal.cpp @@ -3,7 +3,7 @@ // #include "common_test_utils/ov_tensor_utils.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/psroi_pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/psroi_pooling.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/psroi_pooling.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/psroi_pooling.cpp index 4f5a2acb8f8a5b..1c535bdbd9f5ff 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/psroi_pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/psroi_pooling.cpp @@ -3,7 +3,7 @@ // #include "common_test_utils/node_builders/constant.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/range.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/range.cpp similarity index 63% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/range.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/range.cpp index 207bb6bb2adb6f..985456e52fdaeb 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/range.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/range.cpp @@ -2,43 +2,43 @@ //// SPDX-License-Identifier: Apache-2.0 //// // -//#include "test_utils/cpu_test_utils.hpp" +//#include "utils/cpu_test_utils.hpp" // ////#include "ov_models/utils/ov_helpers.hpp" // -//using namespace InferenceEngine; -//using namespace CPUTestUtils; +// using namespace InferenceEngine; +// using namespace CPUTestUtils; // -//namespace CPULayerTestsDefinitions { -//typedef std::tuple< -// std::pair, std::vector>>, // input shape +// namespace CPULayerTestsDefinitions { +// typedef std::tuple< +// std::pair, std::vector>>, // input shape // std::tuple, // start, limit, delta // Precision // output type //> RangeSpecificParams; // -//typedef std::tuple< +// typedef std::tuple< // RangeSpecificParams, // InferenceEngine::Precision, // Net precision -// LayerTestsUtils::TargetDevice // Device name +// ov::test::TargetDevice // Device name //> RangeLayerTestParams; // -//typedef std::tuple< +// typedef std::tuple< // CPULayerTestsDefinitions::RangeLayerTestParams, // CPUSpecificParams> RangeLayerCPUTestParamsSet; // -//class RangeLayerCPUTest : public testing::WithParamInterface, +// class RangeLayerCPUTest : public testing::WithParamInterface, // virtual public LayerTestsUtils::LayerTestsCommon, public CPUTestsBase { // float start = 0; // float stop = 0; // float step = 0; -//public: +// public: // static std::string getTestCaseName(testing::TestParamInfo obj) { // CPULayerTestsDefinitions::RangeLayerTestParams basicParamsSet; // CPUSpecificParams cpuParams; // std::tie(basicParamsSet, cpuParams) = obj.param; // std::string td; // Precision netPrc = Precision::FP32; -// std::pair, std::vector>> shapes; +// std::pair, std::vector>> shapes; // // RangeSpecificParams rangePar; // std::tie(rangePar, netPrc, td) = basicParamsSet; @@ -60,7 +60,7 @@ // result << ov::test::utils::vec2str(shapes.second[0]) << "_"; // return result.str(); // } -//protected: +// protected: // void GenerateInputs() override { // // for correct work of fill_data_random() method // size_t blobFillingRange = (inPrc == Precision::FP32 ? 0 : 1); @@ -98,7 +98,7 @@ // std::tie(basicParamsSet, cpuParams) = this->GetParam(); // std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; // CPULayerTestsDefinitions::RangeSpecificParams rangeParams; -// std::pair, std::vector>> shapes; +// std::pair, std::vector>> shapes; // std::tie(rangeParams, inPrc, targetDevice) = basicParamsSet; // std::tuple rangeInputs; // @@ -111,9 +111,9 @@ // step = std::get<2>(rangeInputs); // auto ngOutPr = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(outPrc); // auto ngNetPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inPrc); -// auto startPar = std::make_shared(ngNetPrc, ngraph::Shape{}); -// auto stopPar = std::make_shared(ngNetPrc, ngraph::Shape{}); -// auto stepPar = std::make_shared(ngNetPrc, ngraph::Shape{}); +// auto startPar = std::make_shared(ngNetPrc, ov::Shape{}); +// auto stopPar = std::make_shared(ngNetPrc, ov::Shape{}); +// auto stepPar = std::make_shared(ngNetPrc, ov::Shape{}); // auto range = std::make_shared(startPar, stopPar, stepPar, ngOutPr); // range->get_rt_info() = getCPUInfo(); // selectedType = std::string("ref_any_") + (inPrc == outPrc ? inPrc.name() : "FP32"); @@ -122,77 +122,79 @@ // stepPar->set_friendly_name("step"); // // const ngraph::ResultVector results{std::make_shared(range)}; -// function = std::make_shared(results, ngraph::ParameterVector { +// function = std::make_shared(results, ov::ParameterVector { // startPar, stopPar, stepPar}, "Range"); // functionRefs = ngraph::clone_function(*function); // } //}; // -//TEST_P(RangeLayerCPUTest, CompareWithRefs) { +// TEST_P(RangeLayerCPUTest, CompareWithRefs) { // run(); // CheckPluginRelatedResults(executableNetwork, "Range"); //} // -//namespace { +// namespace { // ///* CPU PARAMS */ -//std::vector filterCPUInfoForDevice() { -// return std::vector {CPUSpecificParams{{}, {x}, {}, {}}}; -//} -// -//const std::vector netPrecisions = { -// InferenceEngine::Precision::FP32, -// InferenceEngine::Precision::I32 -//}; -//const std::vector outputType = { -// InferenceEngine::Precision::FP32, -// InferenceEngine::Precision::I32 -//}; -// -//std::vector, std::vector>>> inShapesDynamic = { -// {{ngraph::PartialShape(), ngraph::PartialShape(), ngraph::PartialShape()}, -// {{ngraph::Shape{}, ngraph::Shape{}, ngraph::Shape{}}, {ngraph::Shape{}, ngraph::Shape{}, ngraph::Shape{}}}} -//}; -//std::vector, std::vector>>> inShapesPseudoStatic = { -// {{}, {{ngraph::Shape{}, ngraph::Shape{}, ngraph::Shape{}}}} -//}; -// -//const std::vector> rangeInputValues = { -// std::tuple {1.0, -5.0, -1.0}, -// std::tuple {1.0, 10.0, 1.2}, -// std::tuple {1.1, 12.2, 1.1}, -// std::tuple {1.1, -5.1, -1.1}, -// std::tuple {1.0, 5.0, 2.0}, -// std::tuple {10.0, 6.0, -3.0}, -// std::tuple {5, 35, 5} -//}; -//const auto rangeParDynamic = ::testing::Combine( -// ::testing::ValuesIn(inShapesDynamic), -// ::testing::ValuesIn(rangeInputValues), -// ::testing::ValuesIn(outputType) +// std::vector filterCPUInfoForDevice() { +// return std::vector {CPUSpecificParams{{}, {x}, {}, {}}}; +// } +// +// const std::vector netPrecisions = { +// InferenceEngine::Precision::FP32, +// InferenceEngine::Precision::I32 +// }; +// const std::vector outputType = { +// InferenceEngine::Precision::FP32, +// InferenceEngine::Precision::I32 +// }; +// +// std::vector, std::vector>>> inShapesDynamic = +// { +// {{ngraph::PartialShape(), ngraph::PartialShape(), ngraph::PartialShape()}, +// {{ov::Shape{}, ov::Shape{}, ov::Shape{}}, {ov::Shape{}, ov::Shape{}, ov::Shape{}}}} +// }; +// std::vector, std::vector>>> +// inShapesPseudoStatic = { +// {{}, {{ov::Shape{}, ov::Shape{}, ov::Shape{}}}} +// }; +// +// const std::vector> rangeInputValues = { +// std::tuple {1.0, -5.0, -1.0}, +// std::tuple {1.0, 10.0, 1.2}, +// std::tuple {1.1, 12.2, 1.1}, +// std::tuple {1.1, -5.1, -1.1}, +// std::tuple {1.0, 5.0, 2.0}, +// std::tuple {10.0, 6.0, -3.0}, +// std::tuple {5, 35, 5} +// }; +// const auto rangeParDynamic = ::testing::Combine( +// ::testing::ValuesIn(inShapesDynamic), +// ::testing::ValuesIn(rangeInputValues), +// ::testing::ValuesIn(outputType) //); -//const auto rangeParStatic = ::testing::Combine( -// ::testing::ValuesIn(inShapesPseudoStatic), -// ::testing::ValuesIn(rangeInputValues), -// ::testing::ValuesIn(outputType) +// const auto rangeParStatic = ::testing::Combine( +// ::testing::ValuesIn(inShapesPseudoStatic), +// ::testing::ValuesIn(rangeInputValues), +// ::testing::ValuesIn(outputType) //); -//const auto params3dDynamic = ::testing::Combine( -// ::testing::Combine( -// rangeParDynamic, -// ::testing::ValuesIn(netPrecisions), -// ::testing::Values(ov::test::utils::DEVICE_CPU)), -// ::testing::ValuesIn(filterCPUInfoForDevice())); -//const auto params3dPseudoStatic = ::testing::Combine( -// ::testing::Combine( -// rangeParStatic, -// ::testing::ValuesIn(netPrecisions), -// ::testing::Values(ov::test::utils::DEVICE_CPU)), -// ::testing::ValuesIn(filterCPUInfoForDevice())); +// const auto params3dDynamic = ::testing::Combine( +// ::testing::Combine( +// rangeParDynamic, +// ::testing::ValuesIn(netPrecisions), +// ::testing::Values(ov::test::utils::DEVICE_CPU)), +// ::testing::ValuesIn(filterCPUInfoForDevice())); +// const auto params3dPseudoStatic = ::testing::Combine( +// ::testing::Combine( +// rangeParStatic, +// ::testing::ValuesIn(netPrecisions), +// ::testing::Values(ov::test::utils::DEVICE_CPU)), +// ::testing::ValuesIn(filterCPUInfoForDevice())); //// We don't check static case, because of constant folding, but we can use static shape for test infrastructure, //// however Range node will be dynamic, since inputs are parameters, not a constants -//INSTANTIATE_TEST_SUITE_P(smoke_RangePseudoStaticLayoutTest, RangeLayerCPUTest, -// params3dPseudoStatic, RangeLayerCPUTest::getTestCaseName); -//INSTANTIATE_TEST_SUITE_P(smoke_RangeDynamicLayoutTest, RangeLayerCPUTest, -// params3dDynamic, RangeLayerCPUTest::getTestCaseName); -//} // namespace -//} // namespace CPULayerTestsDefinitions +// INSTANTIATE_TEST_SUITE_P(smoke_RangePseudoStaticLayoutTest, RangeLayerCPUTest, +// params3dPseudoStatic, RangeLayerCPUTest::getTestCaseName); +// INSTANTIATE_TEST_SUITE_P(smoke_RangeDynamicLayoutTest, RangeLayerCPUTest, +// params3dDynamic, RangeLayerCPUTest::getTestCaseName); +// } // namespace +// } // namespace CPULayerTestsDefinitions diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/rdft.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/rdft.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/rdft.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/rdft.cpp index 18471afff43294..c30d4c60a0b7fe 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/rdft.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/rdft.cpp @@ -3,7 +3,7 @@ // #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "common_test_utils/ov_tensor_utils.hpp" using namespace CPUTestUtils; @@ -152,21 +152,21 @@ class RDFTTestCPU : public testing::WithParamInterfaceinputs(); auto funcInput = funcInputs.begin(); inputs.clear(); - runtime::Tensor data_tensor = test::utils::create_and_fill_tensor_normal_distribution(funcInput->get_element_type(), + ov::Tensor data_tensor = test::utils::create_and_fill_tensor_normal_distribution(funcInput->get_element_type(), targetInputStaticShapes[0], 0, 1, 0); inputs.insert({funcInput->get_node_shared_ptr(), data_tensor}); funcInput++; if (!constAxes && funcInput != funcInputs.end()) { ASSERT_TRUE(inputIdx < axes.size()); - auto tensor = ov::runtime::Tensor{funcInput->get_element_type(), Shape{axes[inputIdx].size()}}; + auto tensor = ov::Tensor{funcInput->get_element_type(), Shape{axes[inputIdx].size()}}; std::memcpy(tensor.data(), axes[inputIdx].data(), axes[inputIdx].size() * sizeof(axes[0][0])); inputs.insert({funcInput->get_node_shared_ptr(), tensor}); funcInput++; } if (!constSignalSizes && funcInput != funcInputs.end()) { ASSERT_TRUE(inputIdx < signalSizes.size()); - auto tensor = ov::runtime::Tensor{funcInput->get_element_type(), Shape{signalSizes[inputIdx].size()}}; + auto tensor = ov::Tensor{funcInput->get_element_type(), Shape{signalSizes[inputIdx].size()}}; std::memcpy(tensor.data(), signalSizes[inputIdx].data(), signalSizes[inputIdx].size() * sizeof(signalSizes[0][0])); inputs.insert({funcInput->get_node_shared_ptr(), tensor}); } diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/region_yolo.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/region_yolo.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/region_yolo.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/region_yolo.cpp index 9fb1b65ab95392..c25dbe12333d2b 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/region_yolo.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/region_yolo.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/reorg_yolo.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/reorg_yolo.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/reorg_yolo.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/reorg_yolo.cpp index 91d97d9e679b40..18ce5d7ae47347 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/reorg_yolo.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/reorg_yolo.cpp @@ -4,7 +4,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/reverse_sequence.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/reverse_sequence.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/reverse_sequence.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/reverse_sequence.cpp index dca121bb396809..a3368c6759391b 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/reverse_sequence.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/reverse_sequence.cpp @@ -5,7 +5,7 @@ #include "common_test_utils/node_builders/constant.hpp" #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/rnn_cell.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/rnn_cell.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/rnn_cell.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/rnn_cell.cpp index e8d9bb2359417e..b30534bd95864c 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/rnn_cell.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/rnn_cell.cpp @@ -4,7 +4,7 @@ #include "common_test_utils/node_builders/rnn_cell.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/rnn_sequence.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/rnn_sequence.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/rnn_sequence.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/rnn_sequence.cpp index 41bed3e3b5d171..d4fb474b88d58f 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/rnn_sequence.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/rnn_sequence.cpp @@ -5,7 +5,7 @@ #include "shared_test_classes/base/ov_subgraph.hpp" #include "ov_models/utils/ov_helpers.hpp" #include "common_test_utils/node_builders/rnn_cell.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "transformations/op_conversions/bidirectional_sequences_decomposition.hpp" #include "transformations/op_conversions/convert_sequences_to_tensor_iterator.hpp" diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/roi_pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/roi_pooling.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/roi_pooling.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/roi_pooling.cpp index 7fd574feb01bf6..8d67ee0724ceb2 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/roi_pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/roi_pooling.cpp @@ -7,7 +7,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "common_test_utils/data_utils.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "utils/bfloat16.hpp" using namespace CPUTestUtils; @@ -23,7 +23,7 @@ using roiPoolingParams = std::tuple; // Device name + ov::test::TargetDevice>; // Device name using ROIPoolingCPUTestParamsSet = std::tuple; using ROIAlignLayerCPUTestParamsSet = std::tuple< diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/roll.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/roll.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/roll.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/roll.cpp index e010dfeaca195a..1d9dab6bdf65aa 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/roll.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/roll.cpp @@ -3,7 +3,7 @@ // #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/scatter_ND_update.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/scatter_ND_update.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/scatter_ND_update.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/scatter_ND_update.cpp index 33dce880d9c8f9..11ec7b0bde1853 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/scatter_ND_update.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/scatter_ND_update.cpp @@ -4,7 +4,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; namespace ov { diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/scatter_elements_update.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/scatter_elements_update.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/scatter_elements_update.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/scatter_elements_update.cpp index 9d384723f6eff1..f252d613ea0e47 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/scatter_elements_update.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/scatter_elements_update.cpp @@ -4,7 +4,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; namespace ov { diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/scatter_update.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/scatter_update.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/scatter_update.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/scatter_update.cpp index fdf408ded1e676..c95b8cf46a7888 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/scatter_update.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/scatter_update.cpp @@ -3,7 +3,7 @@ // #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/select.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/select.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/select.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/select.cpp index 0bda49805341c1..7103632417be79 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/select.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/select.cpp @@ -4,7 +4,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" using namespace CPUTestUtils; namespace ov { diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/shape_ops.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/shape_ops.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/shape_ops.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/shape_ops.cpp index 576869d3fec977..e34db7a025c1ef 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/shape_ops.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/shape_ops.cpp @@ -5,7 +5,7 @@ #include "common_test_utils/node_builders/constant.hpp" #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; @@ -83,11 +83,11 @@ class ShapeOpsCPUTest : public testing::WithParamInterface, const auto& funcInputs = function->inputs(); for (size_t i = 0; i < funcInputs.size(); ++i) { const auto& funcInput = funcInputs[i]; - ov::runtime::Tensor tensor; + ov::Tensor tensor; if (i == 1) { #define RESHAPE_TEST_CASE(INT_TYPE) \ case ov::element::Type_t::INT_TYPE: { \ - tensor = ov::runtime::Tensor{ov::element::INT_TYPE, targetInputStaticShapes[i]}; \ + tensor = ov::Tensor{ov::element::INT_TYPE, targetInputStaticShapes[i]}; \ auto inputData = tensor.data::value_type>(); \ ASSERT_TRUE(idx < data.size()); \ for (size_t j = 0lu; j < data[idx].size(); ++j) { \ diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/shapeof.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/shapeof.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/shapeof.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/shapeof.cpp index 55950826850220..6a54e35487f1d7 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/shapeof.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/shapeof.cpp @@ -4,7 +4,7 @@ #include "ov_models/utils/ov_helpers.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/shuffle_channels.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/shuffle_channels.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/shuffle_channels.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/shuffle_channels.cpp index 129eb341bf8026..511b1751d85035 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/shuffle_channels.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/shuffle_channels.cpp @@ -6,7 +6,7 @@ #include "ov_models/utils/ov_helpers.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; namespace ov { diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/slice.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/slice.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/slice.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/slice.cpp index 3629c5b28c2993..19c272d2ed9d32 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/slice.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/slice.cpp @@ -5,7 +5,7 @@ #include #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; using namespace ov::test; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/space_to_batch.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/space_to_batch.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/space_to_batch.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/space_to_batch.cpp index cba7b2bd6e5bf0..80631f84008ff7 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/space_to_batch.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/space_to_batch.cpp @@ -4,7 +4,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/space_to_depth.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/space_to_depth.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/space_to_depth.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/space_to_depth.cpp index a9923fae3d89fa..b6e592f0ea725a 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/space_to_depth.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/space_to_depth.cpp @@ -3,8 +3,8 @@ // #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/filter_cpu_info.hpp" +#include "utils/cpu_test_utils.hpp" +#include "utils/filter_cpu_info.hpp" using namespace CPUTestUtils; using namespace ov::test; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/split.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/split.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/split.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/split.cpp index 37ad0093dfece2..7db2c68000a232 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/split.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/split.cpp @@ -3,7 +3,7 @@ // #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace ov::test; using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/strided_slice.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/strided_slice.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/strided_slice.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/strided_slice.cpp index 6b04f843ca7860..6b0b64a320447d 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/strided_slice.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/strided_slice.cpp @@ -4,7 +4,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; using namespace ov; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/tensor_iterator.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/tensor_iterator.cpp similarity index 100% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/tensor_iterator.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/tensor_iterator.cpp diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/tile.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/tile.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/tile.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/tile.cpp index 0586c655150aa9..a562df499c7065 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/tile.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/tile.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/topk.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/topk.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/topk.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/topk.cpp index 4b6b05a293c37b..5e3d38ce758d7e 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/topk.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/topk.cpp @@ -4,7 +4,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; using namespace ov::test; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/unique.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/unique.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/unique.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/unique.cpp index 9ad0401f789ade..ee4bb5b6819215 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/unique.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/unique.cpp @@ -4,7 +4,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; using namespace ov::test; @@ -120,7 +120,7 @@ class UniqueLayerTestCPU : public testing::WithParamInterfaceget_friendly_name() == "data") { int32_t range = std::accumulate(targetInputStaticShapes[0].begin(), targetInputStaticShapes[0].end(), 1, std::multiplies()); diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/variadic_split.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/variadic_split.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/single_layer_tests/variadic_split.cpp rename to src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/variadic_split.cpp index de04d053932260..1e55ab8e619bdb 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/variadic_split.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/variadic_split.cpp @@ -4,7 +4,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace ov::test; using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/include/conv_concat.hpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/include/conv_concat.hpp similarity index 97% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/include/conv_concat.hpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/include/conv_concat.hpp index 327afb4848f92b..54e485d0dc6008 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/include/conv_concat.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/include/conv_concat.hpp @@ -8,7 +8,7 @@ #include #include -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" #include "ov_models/utils/ov_helpers.hpp" diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/include/conv_with_zero_point_fuse.hpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/include/conv_with_zero_point_fuse.hpp similarity index 97% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/include/conv_with_zero_point_fuse.hpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/include/conv_with_zero_point_fuse.hpp index 8a3ee8b0244818..51a4f3519d3ef6 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/include/conv_with_zero_point_fuse.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/include/conv_with_zero_point_fuse.hpp @@ -10,7 +10,7 @@ #include "ov_models/utils/ov_helpers.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/include/fuse_muladd_ewsimple.hpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/include/fuse_muladd_ewsimple.hpp similarity index 97% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/include/fuse_muladd_ewsimple.hpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/include/fuse_muladd_ewsimple.hpp index c92a60441d8b58..40f88cfa894090 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/include/fuse_muladd_ewsimple.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/include/fuse_muladd_ewsimple.hpp @@ -9,7 +9,7 @@ #include #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" namespace ov { namespace test { diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/include/fuse_transpose_reorder.hpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/include/fuse_transpose_reorder.hpp similarity index 97% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/include/fuse_transpose_reorder.hpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/include/fuse_transpose_reorder.hpp index b6951613f3695c..2dcfbcda3cb6f9 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/include/fuse_transpose_reorder.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/include/fuse_transpose_reorder.hpp @@ -8,7 +8,7 @@ #include #include -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "ov_models/utils/ov_helpers.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/add_convert_to_reorder.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/add_convert_to_reorder.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/add_convert_to_reorder.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/add_convert_to_reorder.cpp index 12d3419e261e9b..db58c6f1b488b1 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/add_convert_to_reorder.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/add_convert_to_reorder.cpp @@ -3,7 +3,7 @@ // #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/align_matmul_input_ranks.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/align_matmul_input_ranks.cpp similarity index 97% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/align_matmul_input_ranks.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/align_matmul_input_ranks.cpp index 67734a2b575ad3..e60b043b07ab01 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/align_matmul_input_ranks.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/align_matmul_input_ranks.cpp @@ -7,8 +7,8 @@ #include "common_test_utils/common_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/any_layout.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/any_layout.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/any_layout.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/any_layout.cpp index c37704699216d6..c19b3bbecccefc 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/any_layout.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/any_layout.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "openvino/core/preprocess/pre_post_process.hpp" namespace ov { diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/arm/convert_group_conv.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/arm/convert_group_conv.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/arm/convert_group_conv.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/arm/convert_group_conv.cpp index 2a631c344162f2..f3afefd6bde56d 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/arm/convert_group_conv.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/arm/convert_group_conv.cpp @@ -4,7 +4,7 @@ #include "common_test_utils/node_builders/group_convolution.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/arm/convert_group_conv1d.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/arm/convert_group_conv1d.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/arm/convert_group_conv1d.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/arm/convert_group_conv1d.cpp index 9beb3be72f5882..930158b6207908 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/arm/convert_group_conv1d.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/arm/convert_group_conv1d.cpp @@ -7,7 +7,7 @@ #include "common_test_utils/node_builders/group_convolution.hpp" #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/arm/convert_reduce_multi_axis.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/arm/convert_reduce_multi_axis.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/arm/convert_reduce_multi_axis.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/arm/convert_reduce_multi_axis.cpp index 2b837a4fd275c4..4238e720e8e7da 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/arm/convert_reduce_multi_axis.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/arm/convert_reduce_multi_axis.cpp @@ -6,7 +6,7 @@ #include "common_test_utils/node_builders/reduce.hpp" #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/broadcast_eltwise.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/broadcast_eltwise.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/broadcast_eltwise.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/broadcast_eltwise.cpp index 60d3d866a6ed17..05103091b8c2ac 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/broadcast_eltwise.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/broadcast_eltwise.cpp @@ -5,7 +5,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/layer_test_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; namespace ov { diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_const_inplace.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/concat_const_inplace.cpp similarity index 95% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_const_inplace.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/concat_const_inplace.cpp index 9dadd4b7a6ba31..bb12b5de29b23d 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_const_inplace.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/concat_const_inplace.cpp @@ -4,7 +4,7 @@ #include "ov_models/utils/ov_helpers.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; @@ -52,7 +52,9 @@ class ConcatConstantInPlaceTest : public testing::WithParamInterface weightValuesFP32(12); ov::Shape convFilterShape = {1, 12, 1, 1}; - FuncTestUtils::fillInputsBySinValues(weightValuesFP32.data(), weightValuesFP32.size()); + for (size_t i = 0; i < weightValuesFP32.size(); i++) { + weightValuesFP32.data()[i] = sin(static_cast(i)); + } auto weightsNode = std::make_shared(ov::element::f32, convFilterShape, weightValuesFP32); std::shared_ptr conv = std::make_shared(concat, weightsNode, diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_conv_sum_inplace.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/concat_conv_sum_inplace.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_conv_sum_inplace.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/concat_conv_sum_inplace.cpp index 98009d0941da3c..5c40651d1a11a2 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_conv_sum_inplace.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/concat_conv_sum_inplace.cpp @@ -6,7 +6,7 @@ #include "common_test_utils/node_builders/convolution.hpp" #include "ov_models/utils/ov_helpers.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_multiple_query_sdp.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/concat_multiple_query_sdp.cpp similarity index 82% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_multiple_query_sdp.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/concat_multiple_query_sdp.cpp index f108d3c76e3d6b..9072b63d87906c 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_multiple_query_sdp.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/concat_multiple_query_sdp.cpp @@ -6,7 +6,7 @@ #include "transformations/op_conversions/scaled_dot_product_attention_decomposition.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "common_test_utils/include/common_test_utils/ov_tensor_utils.hpp" using namespace ov::test; @@ -282,14 +282,16 @@ class ConcatMultiQuerySDPTest : public testing::WithParamInterfaceGetParam(); + if (qkvType == ElementType::bf16 && !ov::with_cpu_x86_bfloat16()) + GTEST_SKIP(); auto actualOutputs = run_test(function); CheckNumberOfNodesWithType(compiledModel, "ScaledDotProductAttention", 1); CheckNumberOfNodesWithType(compiledModel, "Concatenation", 0); - if (configuration[ov::hint::inference_precision.name()] == ov::element::bf16) { - CheckNumberOfNodesWithType(compiledModel, "Reorder", 5); - } else { - CheckNumberOfNodesWithType(compiledModel, "Reorder", 0); - } + CheckNumberOfNodesWithType(compiledModel, "Reorder", 0); CheckNumberOfNodesWithType(compiledModel, "Transpose", 1); CheckNumberOfNodesWithType(compiledModel, "Gather", 0); auto expectedOutputs = run_test(functionRefs); @@ -303,11 +305,61 @@ namespace { const std::vector inputShapeAndReorders = {{ {// inputShapes ChatGLM, greedy search { - // L1, B, H, S - {{-1, 1, 8, 64}, {{10, 1, 8, 64}, {1, 1, 8, 64}, {1, 1, 8, 64}, {20, 1, 8, 64}, {1, 1, 8, 64}}}, - {{-1, 1, 2, 64}, {{10, 1, 2, 64}, {1, 1, 2, 64}, {1, 1, 2, 64}, {20, 1, 2, 64}, {1, 1, 2, 64}}}, + // L1, B, H, S small odd 1st token length < M_blk + {{-1, 1, 8, 64}, {{5, 1, 8, 64}, {1, 1, 8, 64}, {1, 1, 8, 64}, {1, 1, 8, 64}, {1, 1, 8, 64}}}, + {{-1, 1, 2, 64}, {{5, 1, 2, 64}, {1, 1, 2, 64}, {1, 1, 2, 64}, {1, 1, 2, 64}, {1, 1, 2, 64}}}, + // L0, B, H, S + {{-1, 1, 2, 64}, {{0, 1, 2, 64}, {6, 1, 2, 64}, {7, 1, 2, 64}, {8, 1, 2, 64}, {9, 1, 2, 64}}}, + }, + // transposeOrder + {1, 2, 0, 3}}, + {// inputShapes ChatGLM, greedy search + { + // L1, B, H, S small even 1st token length < M_blk + {{-1, 1, 8, 64}, {{16, 1, 8, 64}, {1, 1, 8, 64}, {1, 1, 8, 64}, {1, 1, 8, 64}, {1, 1, 8, 64}}}, + {{-1, 1, 2, 64}, {{16, 1, 2, 64}, {1, 1, 2, 64}, {1, 1, 2, 64}, {1, 1, 2, 64}, {1, 1, 2, 64}}}, + // L0, B, H, S + {{-1, 1, 2, 64}, {{0, 1, 2, 64}, {17, 1, 2, 64}, {18, 1, 2, 64}, {19, 1, 2, 64}, {20, 1, 2, 64}}}, + }, + // transposeOrder + {1, 2, 0, 3}}, + {// inputShapes ChatGLM, greedy search + { + // L1, B, H, S odd 1st token length > M_blk + {{-1, 1, 8, 64}, {{33, 1, 8, 64}, {1, 1, 8, 64}, {1, 1, 8, 64}, {1, 1, 8, 64}, {1, 1, 8, 64}}}, + {{-1, 1, 2, 64}, {{33, 1, 2, 64}, {1, 1, 2, 64}, {1, 1, 2, 64}, {1, 1, 2, 64}, {1, 1, 2, 64}}}, + // L0, B, H, S + {{-1, 1, 2, 64}, {{0, 1, 2, 64}, {34, 1, 2, 64}, {35, 1, 2, 64}, {36, 1, 2, 64}, {37, 1, 2, 64}}}, + }, + // transposeOrder + {1, 2, 0, 3}}, + {// inputShapes ChatGLM, greedy search + { + // L1, B, H, S even 1st token length = M_blk + {{-1, 1, 8, 64}, {{32, 1, 8, 64}, {1, 1, 8, 64}, {1, 1, 8, 64}, {1, 1, 8, 64}, {1, 1, 8, 64}}}, + {{-1, 1, 2, 64}, {{32, 1, 2, 64}, {1, 1, 2, 64}, {1, 1, 2, 64}, {1, 1, 2, 64}, {1, 1, 2, 64}}}, + // L0, B, H, S + {{-1, 1, 2, 64}, {{0, 1, 2, 64}, {33, 1, 2, 64}, {34, 1, 2, 64}, {35, 1, 2, 64}, {36, 1, 2, 64}}}, + }, + // transposeOrder + {1, 2, 0, 3}}, + {// inputShapes ChatGLM, even 1st token greedy search + { + // L1, B, H, S even 1st token length = 2 * M_blk + {{-1, 1, 8, 64}, {{64, 1, 8, 64}, {1, 1, 8, 64}, {1, 1, 8, 64}, {1, 1, 8, 64}, {1, 1, 8, 64}}}, + {{-1, 1, 2, 64}, {{64, 1, 2, 64}, {1, 1, 2, 64}, {1, 1, 2, 64}, {1, 1, 2, 64}, {1, 1, 2, 64}}}, + // L0, B, H, S + {{-1, 1, 2, 64}, {{0, 1, 2, 64}, {65, 1, 2, 64}, {66, 1, 2, 64}, {67, 1, 2, 64}, {68, 1, 2, 64}}}, + }, + // transposeOrder + {1, 2, 0, 3}}, + {// inputShapes ChatGLM, even 1st token greedy search + { + // L1, B, H, S odd 1st token length > 2 * M_blk + {{-1, 1, 8, 64}, {{65, 1, 8, 64}, {1, 1, 8, 64}, {1, 1, 8, 64}, {1, 1, 8, 64}, {1, 1, 8, 64}}}, + {{-1, 1, 2, 64}, {{65, 1, 2, 64}, {1, 1, 2, 64}, {1, 1, 2, 64}, {1, 1, 2, 64}, {1, 1, 2, 64}}}, // L0, B, H, S - {{-1, 1, 2, 64}, {{0, 1, 2, 64}, {10, 1, 2, 64}, {11, 1, 2, 64}, {12, 1, 2, 64}, {32, 1, 2, 64}}}, + {{-1, 1, 2, 64}, {{0, 1, 2, 64}, {66, 1, 2, 64}, {67, 1, 2, 64}, {68, 1, 2, 64}, {69, 1, 2, 64}}}, }, // transposeOrder {1, 2, 0, 3}}, @@ -323,10 +375,9 @@ const std::vector inputShapeAndReorders = {{ {1, 2, 0, 3}}, }}; -// TODO: BF16 test is disabled due to CI machine limitation INSTANTIATE_TEST_SUITE_P(smoke_ConcatMultiQuerySDPTest, ConcatMultiQuerySDPTest, - ::testing::Combine(::testing::Values(ElementType::f32), + ::testing::Combine(::testing::Values(ElementType::f32, ElementType::bf16), ::testing::ValuesIn(inputShapeAndReorders), ::testing::Values(true, false)), ConcatMultiQuerySDPTest::getTestCaseName); diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_reorder_inplace.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/concat_reorder_inplace.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_reorder_inplace.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/concat_reorder_inplace.cpp index e72590de5e48d4..b5de44f626b952 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_reorder_inplace.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/concat_reorder_inplace.cpp @@ -5,7 +5,7 @@ #include "common_test_utils/node_builders/constant.hpp" #include "ov_models/utils/ov_helpers.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_reshape_concat.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/concat_reshape_concat.cpp similarity index 100% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_reshape_concat.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/concat_reshape_concat.cpp diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_sdp.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/concat_sdp.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_sdp.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/concat_sdp.cpp index f5514c623172ec..40db8b8f8661b5 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_sdp.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/concat_sdp.cpp @@ -7,7 +7,7 @@ #include "ov_models/utils/ov_helpers.hpp" #include "shared_test_classes/base/layer_test_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "common_test_utils/ov_tensor_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_transpose_sdp_transpose.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/concat_transpose_sdp_transpose.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_transpose_sdp_transpose.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/concat_transpose_sdp_transpose.cpp index 61ddf873aec6f1..d48be1bd53cc01 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_transpose_sdp_transpose.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/concat_transpose_sdp_transpose.cpp @@ -6,7 +6,7 @@ #include "transformations/op_conversions/scaled_dot_product_attention_decomposition.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "common_test_utils/include/common_test_utils/ov_tensor_utils.hpp" using namespace ov::test; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/conv3d_reshape.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/conv3d_reshape.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/conv3d_reshape.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/conv3d_reshape.cpp index 89b01eda98426e..fcf90d97e5d1db 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/conv3d_reshape.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/conv3d_reshape.cpp @@ -5,7 +5,7 @@ #include "common_test_utils/node_builders/convolution.hpp" #include "common_test_utils/node_builders/group_convolution.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/conv_concat.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/conv_concat.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/conv_concat.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/conv_concat.cpp index 796cfea709eb8f..1230b7919a13b6 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/conv_concat.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/conv_concat.cpp @@ -2,14 +2,14 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "subgraph_tests/include/conv_concat.hpp" +#include "custom/subgraph_tests/include/conv_concat.hpp" #include "common_test_utils/node_builders/convolution.hpp" #include "common_test_utils/node_builders/convolution_backprop_data.hpp" #include "common_test_utils/node_builders/group_convolution.hpp" #include "common_test_utils/node_builders/group_convolution_backprop_data.hpp" -#include "test_utils/convolution_params.hpp" -#include "test_utils/filter_cpu_info.hpp" +#include "utils/convolution_params.hpp" +#include "utils/filter_cpu_info.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/conv_dw_conv.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/conv_dw_conv.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/conv_dw_conv.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/conv_dw_conv.cpp index 56196a2ddb9fe3..64712c4be1de25 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/conv_dw_conv.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/conv_dw_conv.cpp @@ -6,7 +6,7 @@ #include "common_test_utils/node_builders/convolution.hpp" #include "common_test_utils/node_builders/group_convolution.hpp" #include "ov_models/utils/ov_helpers.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "shared_test_classes/base/layer_test_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/conv_maxpool_activ.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/conv_maxpool_activ.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/conv_maxpool_activ.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/conv_maxpool_activ.cpp index 2d992909584e2d..d9ff88e44e85ac 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/conv_maxpool_activ.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/conv_maxpool_activ.cpp @@ -4,7 +4,7 @@ #include "common_test_utils/node_builders/convolution.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/conv_sum_broadcast.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/conv_sum_broadcast.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/conv_sum_broadcast.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/conv_sum_broadcast.cpp index 9695fbeca8e92e..6f462a55dc76cf 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/conv_sum_broadcast.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/conv_sum_broadcast.cpp @@ -10,8 +10,8 @@ #include "ov_models/utils/ov_helpers.hpp" #include "ov_ops/type_relaxed.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/convolution_params.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "utils/convolution_params.hpp" +#include "utils/fusing_test_utils.hpp" #include diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/conv_with_zero_point_fuse.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/conv_with_zero_point_fuse.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/conv_with_zero_point_fuse.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/conv_with_zero_point_fuse.cpp index af90b10dc3bbef..dbced6b68e9e2b 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/conv_with_zero_point_fuse.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/conv_with_zero_point_fuse.cpp @@ -2,13 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "subgraph_tests/include/conv_with_zero_point_fuse.hpp" +#include "custom/subgraph_tests/include/conv_with_zero_point_fuse.hpp" #include "common_test_utils/node_builders/constant.hpp" #include "common_test_utils/node_builders/convolution.hpp" #include "common_test_utils/node_builders/group_convolution.hpp" #include "common_test_utils/node_builders/fake_quantize.hpp" -#include "test_utils/convolution_params.hpp" +#include "utils/convolution_params.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/convert_fq_rnn_to_quantized_rnn.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/convert_fq_rnn_to_quantized_rnn.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/convert_fq_rnn_to_quantized_rnn.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/convert_fq_rnn_to_quantized_rnn.cpp index a2f6798a7b5eb3..d5107865045cff 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/convert_fq_rnn_to_quantized_rnn.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/convert_fq_rnn_to_quantized_rnn.cpp @@ -10,8 +10,8 @@ #include "openvino/core/type/element_type.hpp" #include "openvino/runtime/tensor.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" #include #include diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/convert_range.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/convert_range.cpp similarity index 77% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/convert_range.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/convert_range.cpp index e06008fbacb950..d6238186c02471 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/convert_range.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/convert_range.cpp @@ -2,9 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "utils/cpu_test_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/utils/ov_helpers.hpp" -#include "test_utils/cpu_test_utils.hpp" #include using namespace CPUTestUtils; @@ -30,16 +29,29 @@ namespace test { \ | / / Range / | / - \ / - \ / - \ / - MatMul - | - Result + /\ / + / \ / + (No reorder) \ / + / \ / + Convert MatMul + | | + (INT) Result + const | + | | + (FP32) | + \ / + Gather() + | + MatMul + | + Result This test is needed to cover logic that allows to avoid computational error for subgraph: "[I32] -> Convert -> [F32] -> Range" due to precision lowering for floating point path inside "EnforceInferencePrecision" pass". TODO: Incorrect subgraph is generated by ONNX FE + ticket 117861. + + Also test logic to avoid enforcing F32 input of convert to lower precision in subgraph :" Range -> [F32] -> Convert -> + [I32]" in ticket 129874 */ using ConvertRangeSubgraphCPUTestParams = std::tuple< @@ -100,17 +112,35 @@ class ConvertRangeSubgraphCPUTest: public testing::WithParamInterface(range, input_params[1], false, true); auto result = std::make_shared(matmul); result->set_friendly_name("output"); - ov::ResultVector output_results = {result}; + + // second branch ensure convert after range doesn't use low-precision float as input + auto convert2 = std::make_shared(range, ov::element::i32); + convert2->set_friendly_name("convert_to_i32"); + auto const0 = std::make_shared(ov::element::f32, ov::Shape{}, 0.1f); + auto data = std::make_shared(const0, shapeof); + auto gather2 = std::make_shared(data, convert2, one); + auto matmul2 = std::make_shared(gather2, input_params[1], false, true); + auto result2 = std::make_shared(matmul2); + ov::ResultVector output_results = {result, result2}; function = std::make_shared(output_results, input_params, "convert_range"); }; void checkResults() { + bool found_range = false; + bool found_convert = false; for (const auto& n : compiledModel.get_runtime_model()->get_ordered_ops()) { if (n->get_friendly_name() == "float32_range") { ASSERT_EQ(n->get_input_element_type(1), ElementType::f32); + found_range = true; + } + if (n->get_friendly_name() == "convert_to_i32") { + ASSERT_EQ(n->get_input_element_type(0), ElementType::f32); + found_convert = true; } } + ASSERT_TRUE(found_range); + ASSERT_TRUE(found_convert); } }; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/convs_and_sums.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/convs_and_sums.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/convs_and_sums.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/convs_and_sums.cpp index b5170bb7933605..9f5e0333f1a9bb 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/convs_and_sums.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/convs_and_sums.cpp @@ -8,7 +8,7 @@ #include "common_test_utils/node_builders/constant.hpp" #include "ov_models/utils/ov_helpers.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" namespace ov { namespace test { diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/custom_op_insert_convert_i64.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/custom_op_insert_convert_i64.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/custom_op_insert_convert_i64.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/custom_op_insert_convert_i64.cpp index 603c1f5481311b..7bcd661d2ac9c2 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/custom_op_insert_convert_i64.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/custom_op_insert_convert_i64.cpp @@ -5,7 +5,8 @@ #include #include #include -#include "test_utils/cpu_test_utils.hpp" +#include +#include "utils/cpu_test_utils.hpp" using namespace ov::test; using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/custom_op_scalar.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/custom_op_scalar.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/custom_op_scalar.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/custom_op_scalar.cpp index 4b6b237886ade3..de8cad515561b3 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/custom_op_scalar.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/custom_op_scalar.cpp @@ -5,7 +5,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "openvino/op/op.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/custom_op_string.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/custom_op_string.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/custom_op_string.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/custom_op_string.cpp index ddbe84860038e8..006743553c5a94 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/custom_op_string.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/custom_op_string.cpp @@ -24,7 +24,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; using namespace ov::test; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/denormal_check.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/denormal_check.cpp similarity index 100% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/denormal_check.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/denormal_check.cpp diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/eltwise_caching.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/eltwise_caching.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/eltwise_caching.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/eltwise_caching.cpp index d7c262e753aa81..78effb95085bb7 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/eltwise_caching.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/eltwise_caching.cpp @@ -36,7 +36,7 @@ #include "common_test_utils/node_builders/eltwise.hpp" #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "common_test_utils/node_builders/constant.hpp" #include "common_test_utils/node_builders/fake_quantize.hpp" diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/eltwise_chain.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/eltwise_chain.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/eltwise_chain.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/eltwise_chain.cpp index e49e40f9c512b4..a9adad4fd48c24 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/eltwise_chain.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/eltwise_chain.cpp @@ -12,7 +12,7 @@ #include "common_test_utils/node_builders/fake_quantize.hpp" #include "common_test_utils/common_utils.hpp" #include "common_test_utils/ov_tensor_utils.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "common_test_utils/node_builders/eltwise.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fq_caching.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/fq_caching.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fq_caching.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/fq_caching.cpp index 9c39483885f0d8..053ce0edeea919 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fq_caching.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/fq_caching.cpp @@ -30,7 +30,7 @@ #include "shared_test_classes/base/ov_subgraph.hpp" #include "common_test_utils/node_builders/constant.hpp" #include "common_test_utils/ov_tensor_utils.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "internal_properties.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fq_fused_with_ss.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/fq_fused_with_ss.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fq_fused_with_ss.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/fq_fused_with_ss.cpp index 966eabe890f9fe..2c064efc488ee4 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fq_fused_with_ss.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/fq_fused_with_ss.cpp @@ -5,7 +5,7 @@ #include "common_test_utils/node_builders/eltwise.hpp" #include "common_test_utils/node_builders/fake_quantize.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fq_layer_dq_bias.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/fq_layer_dq_bias.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fq_layer_dq_bias.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/fq_layer_dq_bias.cpp index fe43b815a901ef..c064145bfa0be3 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fq_layer_dq_bias.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/fq_layer_dq_bias.cpp @@ -5,8 +5,8 @@ #include "ov_lpt_models/markup_bias.hpp" #include "ov_models/utils/ov_helpers.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fullyconnected_strided_inputs_outputs.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/fullyconnected_strided_inputs_outputs.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fullyconnected_strided_inputs_outputs.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/fullyconnected_strided_inputs_outputs.cpp index bc7000b6c25c25..b0a5855fd4de5c 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fullyconnected_strided_inputs_outputs.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/fullyconnected_strided_inputs_outputs.cpp @@ -5,7 +5,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "openvino/core/partial_shape.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fuse_conv_fq_with_shared_constants.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/fuse_conv_fq_with_shared_constants.cpp similarity index 97% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fuse_conv_fq_with_shared_constants.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/fuse_conv_fq_with_shared_constants.cpp index c294ce17ac7f73..122bb9b5740e7c 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fuse_conv_fq_with_shared_constants.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/fuse_conv_fq_with_shared_constants.cpp @@ -5,8 +5,8 @@ #include "common_test_utils/node_builders/convolution.hpp" #include "ov_models/utils/ov_helpers.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fuse_muladd_ewsimple.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/fuse_muladd_ewsimple.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fuse_muladd_ewsimple.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/fuse_muladd_ewsimple.cpp index e43e9ce240344f..9a2054b52f0244 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fuse_muladd_ewsimple.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/fuse_muladd_ewsimple.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "subgraph_tests/include/fuse_muladd_ewsimple.hpp" +#include "custom/subgraph_tests/include/fuse_muladd_ewsimple.hpp" #include "common_test_utils/node_builders/activation.hpp" #include "common_test_utils/node_builders/eltwise.hpp" diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fuse_non0_output_port.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/fuse_non0_output_port.cpp similarity index 100% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fuse_non0_output_port.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/fuse_non0_output_port.cpp diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fuse_scaleshift_and_fakequantize.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/fuse_scaleshift_and_fakequantize.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fuse_scaleshift_and_fakequantize.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/fuse_scaleshift_and_fakequantize.cpp index 08c28580946119..a2ae60e526afa7 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fuse_scaleshift_and_fakequantize.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/fuse_scaleshift_and_fakequantize.cpp @@ -3,7 +3,7 @@ // #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "openvino/util/common_util.hpp" #include "common_test_utils/node_builders/fake_quantize.hpp" diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fuse_split_concat_pair_to_interpolate.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/fuse_split_concat_pair_to_interpolate.cpp similarity index 97% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fuse_split_concat_pair_to_interpolate.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/fuse_split_concat_pair_to_interpolate.cpp index 788a49fdcad4c5..d5ea93174122a8 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fuse_split_concat_pair_to_interpolate.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/fuse_split_concat_pair_to_interpolate.cpp @@ -3,9 +3,7 @@ // #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" - -using FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc; +#include "utils/cpu_test_utils.hpp" namespace ov { namespace test { diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fuse_transpose_reorder.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/fuse_transpose_reorder.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fuse_transpose_reorder.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/fuse_transpose_reorder.cpp index 2cfe15488aa0b2..0610dcda662bcd 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fuse_transpose_reorder.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/fuse_transpose_reorder.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "subgraph_tests/include/fuse_transpose_reorder.hpp" +#include "custom/subgraph_tests/include/fuse_transpose_reorder.hpp" #include "common_test_utils/node_builders/constant.hpp" #include "common_test_utils/node_builders/convolution.hpp" #include "ov_models/preprocess/preprocess_builders.hpp" diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/gather_add_avgpool.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/gather_add_avgpool.cpp similarity index 100% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/gather_add_avgpool.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/gather_add_avgpool.cpp diff --git a/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/gather_weights_decompression.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/gather_weights_decompression.cpp new file mode 100644 index 00000000000000..eb3f52ddecc6e2 --- /dev/null +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/gather_weights_decompression.cpp @@ -0,0 +1,202 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "common_test_utils/node_builders/constant.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" +#include "utils/fusing_test_utils.hpp" +#include "transformations/rt_info/decompression.hpp" + +using namespace CPUTestUtils; + +namespace ov { +namespace test { + +/* + * WP - weights precision + * DP - decompression precision + * IP - input precision + * OP - output precision + * + * Weights(WP) Subtract_const(WP) + * | / + * Convert(DP) Convert(DP) + * \ / + * Subtract(DP) + * \ Multiply_const(DP) + * \ / + * Multiply + * / + * Data(IP) Convert(OP) + * \ / + * Gather(OP) Weights(OP) + * \ / + * MatMul(OP) (Add MatMul in order to test OP==bf16 in SPR) + */ + +struct InputAndWeigthsShapeParams { + InputAndWeigthsShapeParams() = default; + InputAndWeigthsShapeParams(InputShape _data_shape, ov::Shape _weights_shape) + : data_shape(std::move(_data_shape)), + weights_shape(std::move(_weights_shape)) {} + + InputShape data_shape; + ov::Shape weights_shape; +}; + +using GatherWeightsDecompressParams = std::tuple; // should use decompression implementation + +class GatherWeightsDecompression : public testing::WithParamInterface, + virtual public SubgraphBaseTest, + public CpuTestWithFusing { +public: + static std::string getTestCaseName(testing::TestParamInfo obj) { + InputAndWeigthsShapeParams shape_params; + ov::AnyMap additional_config; + fusingSpecificParams fusing_params; + bool should_fuse; + + std::tie(shape_params, additional_config, fusing_params, should_fuse) = obj.param; + + std::ostringstream result; + result << "data_shape=" << shape_params.data_shape << "_"; + result << "weights_shape=" << shape_params.weights_shape << "_"; + + result << "config=("; + for (const auto& configEntry : additional_config) { + result << configEntry.first << ", " << configEntry.second.as() << ":"; + } + result << ")"; + result << CpuTestWithFusing::getTestCaseName(fusing_params); + + return result.str(); + } + +protected: + std::shared_ptr initDecompressionWeights(const ov::Shape& weights_shape, + const ov::element::Type weights_precision) { + auto weights = ov::test::utils::make_constant(weights_precision, + weights_shape, + ov::test::utils::InputGenerateData{0, 255}); + weights->set_friendly_name("Compressed_weights"); + auto weights_convert = std::make_shared(weights, ov::element::f16); + + std::shared_ptr zp_const = ov::test::utils::make_constant(ov::element::u8, + ov::Shape{weights_shape[0], 1}, + ov::test::utils::InputGenerateData{}); + auto zp_convert = std::make_shared(zp_const, ov::element::f16); + + std::shared_ptr scale_const = + ov::test::utils::make_constant(ov::element::f16, + ov::Shape{weights_shape[0], 1}, + ov::test::utils::InputGenerateData{}); + auto subtract = std::make_shared(weights_convert, zp_convert); + auto multiply = std::make_shared(subtract, scale_const); + auto last_node = std::make_shared(multiply, ov::element::f32); + return last_node; + } + + std::shared_ptr initSubgraph(const ov::PartialShape& data_shape, + const ov::Shape& weights_shape, + const ov::element::Type data_precision) { + ov::ParameterVector params{std::make_shared(ov::element::i64, data_shape)}; + auto params_convert = std::make_shared(params[0], ov::element::i32); + auto axis = ov::op::v0::Constant::create(element::i32, Shape{1}, {0}); + + const auto weights_subgraph = initDecompressionWeights(weights_shape, + ov::element::u8); + + auto gather = std::make_shared(weights_subgraph, params_convert, axis); + gather->set_friendly_name("GatherCompression"); + + auto matB = ov::op::v0::Constant::create(element::f32, Shape{weights_shape[1], 1}, {1}); + auto matMul = std::make_shared(gather, matB, false, false); + return makeNgraphFunction(data_precision, params, matMul, "GatherWeightsDecompression"); + } + + void SetUp() override { + targetDevice = ov::test::utils::DEVICE_CPU; + + InputAndWeigthsShapeParams shape_params; + ov::AnyMap additional_config; + fusingSpecificParams fusing_params; + bool should_fuse; + + std::tie(shape_params, additional_config, fusing_params, should_fuse) = GetParam(); + + configuration.insert(additional_config.begin(), additional_config.end()); + std::tie(postOpMgrPtr, fusedOps) = fusing_params; + init_input_shapes({shape_params.data_shape, {{}, {{shape_params.weights_shape}}}}); + + ElementType netType = ov::element::f32; + inType = outType = netType; + + function = initSubgraph(inputDynamicShapes[0], shape_params.weights_shape, netType); + } + + void check_results() { + bool weights_found = false; + for (const auto& n : compiledModel.get_runtime_model()->get_ordered_ops()) { + if (n->get_friendly_name() == "Compressed_weights") { + ASSERT_EQ(n->get_output_element_type(0), ov::element::u8); + weights_found = true; + } + } + ASSERT_TRUE(weights_found); + + bool gather_found = false; + for (const auto& n : compiledModel.get_runtime_model()->get_ordered_ops()) { + if (n->get_friendly_name() == "GatherCompression") { + ASSERT_EQ(n->get_input_element_type(0), ov::element::u8); + ASSERT_EQ(n->get_output_element_type(0), ov::element::f32); + gather_found = true; + } + } + ASSERT_TRUE(gather_found); + + CheckNumberOfNodesWithType(compiledModel, "Convert", 1); + CheckNumberOfNodesWithType(compiledModel, "Subtract", 0); + CheckNumberOfNodesWithType(compiledModel, "Multiply", 0); + CheckNumberOfNodesWithType(compiledModel, "Subgraph", 0); + } +}; + +TEST_P(GatherWeightsDecompression, CompareWithRefs) { + SKIP_IF_CURRENT_TEST_IS_DISABLED() + run(); + check_results(); +} + +namespace { + +std::vector filter_additional_config() { + std::vector additional_config = {}; + additional_config.push_back({{ov::hint::inference_precision(ov::element::f32)}}); + if (ov::with_cpu_x86_bfloat16()) { + additional_config.push_back({{ov::hint::inference_precision(ov::element::bf16)}}); + } + + return additional_config; +} + +const std::vector input_weights_shapes = { + {{{-1, -1}, {{1, 1}}}, {16, 32}}, + {{{-1, -1}, {{1, 8}}}, {16, 64}}, + {{{}, {{2, 1}}}, {16, 33}} +}; + +const std::vector fs_params{emptyFusingSpec, fusingBias}; + +INSTANTIATE_TEST_SUITE_P(smoke_GatherCompressedWeights_basic, + GatherWeightsDecompression, + ::testing::Combine(::testing::ValuesIn(input_weights_shapes), + ::testing::ValuesIn(filter_additional_config()), + ::testing::ValuesIn(fs_params), + ::testing::Values(true)), + GatherWeightsDecompression::getTestCaseName); +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/init_state_inplace_conflicts.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/init_state_inplace_conflicts.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/init_state_inplace_conflicts.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/init_state_inplace_conflicts.cpp index 6dc2a56095b13d..45c403f426d86e 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/init_state_inplace_conflicts.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/init_state_inplace_conflicts.cpp @@ -3,7 +3,7 @@ // #include -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; using namespace ov::test; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/inplace_edge.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/inplace_edge.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/inplace_edge.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/inplace_edge.cpp index 1e977895f2e7d8..8f7f6780048827 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/inplace_edge.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/inplace_edge.cpp @@ -4,7 +4,7 @@ #include "common_test_utils/node_builders/eltwise.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; namespace ov { diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/input_noreorder_eltwise_bf16.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/input_noreorder_eltwise_bf16.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/input_noreorder_eltwise_bf16.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/input_noreorder_eltwise_bf16.cpp index b44fa07a8191f4..bd4e12f8ebd54e 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/input_noreorder_eltwise_bf16.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/input_noreorder_eltwise_bf16.cpp @@ -6,7 +6,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "ov_models/utils/ov_helpers.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/input_output_tensor_reuse.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/input_output_tensor_reuse.cpp similarity index 100% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/input_output_tensor_reuse.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/input_output_tensor_reuse.cpp diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/input_tensor_roi.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/input_tensor_roi.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/input_tensor_roi.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/input_tensor_roi.cpp index 32095fbbc7d546..2a7e3647258ec8 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/input_tensor_roi.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/input_tensor_roi.cpp @@ -3,7 +3,7 @@ // #include "functional_test_utils/ov_plugin_cache.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/interaction.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/interaction.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/interaction.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/interaction.cpp index a23fb6953a2aa4..35ff1e7cf228e0 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/interaction.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/interaction.cpp @@ -5,7 +5,7 @@ #include "common_test_utils/common_utils.hpp" #include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; using namespace ov::test; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_decompress_convert.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/matmul_decompress_convert.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_decompress_convert.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/matmul_decompress_convert.cpp index 22e89df313694d..bedb8411b391fa 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_decompress_convert.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/matmul_decompress_convert.cpp @@ -4,7 +4,7 @@ #include "common_test_utils/node_builders/constant.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" #include "transformations/rt_info/decompression.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_quantized_subgraph.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/matmul_quantized_subgraph.cpp similarity index 97% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_quantized_subgraph.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/matmul_quantized_subgraph.cpp index e80b5845d38a55..474b9bcb478ff8 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_quantized_subgraph.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/matmul_quantized_subgraph.cpp @@ -2,15 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" #include "common_test_utils/node_builders/constant.hpp" -#include "common_test_utils/common_utils.hpp" #include "common_test_utils/node_builders/fake_quantize.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" #include -#include using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_strided_inputs_outputs.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/matmul_strided_inputs_outputs.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_strided_inputs_outputs.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/matmul_strided_inputs_outputs.cpp index 4e049b2449da0d..c2eb3f6e2104ed 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_strided_inputs_outputs.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/matmul_strided_inputs_outputs.cpp @@ -3,7 +3,7 @@ // #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_weights_decompression.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/matmul_weights_decompression.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_weights_decompression.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/matmul_weights_decompression.cpp index e91025ba0e1d21..5eb99cbd9d35bd 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_weights_decompression.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/matmul_weights_decompression.cpp @@ -4,7 +4,7 @@ #include "common_test_utils/node_builders/constant.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" #include "transformations/rt_info/decompression.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/memory_sharing_test.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/memory_sharing_test.cpp similarity index 96% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/memory_sharing_test.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/memory_sharing_test.cpp index e693270a807b99..93eb300eee61e6 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/memory_sharing_test.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/memory_sharing_test.cpp @@ -4,8 +4,8 @@ #include "common_test_utils/node_builders/convolution.hpp" #include "openvino/openvino.hpp" -#include "test_utils/convolution_params.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/convolution_params.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; @@ -78,7 +78,7 @@ TEST_F(EdgeWithSameNameInTwoModels, smoke_CompareWithRef) { // model compilation std::map config; auto& device_config = config[targetDevice]; - device_config[targetDevice + "_THROUGHPUT_STREAMS"] = 4; + device_config[ov::num_streams.name()] = 4; ov::Core core; for (auto&& item : config) { diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/mha.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/mha.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/mha.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/mha.cpp index c8f400f0146e0e..7d481fb3d1402f 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/mha.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/mha.cpp @@ -9,7 +9,7 @@ #include "functional_test_utils/skip_tests_config.hpp" #include "internal_properties.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/ngram.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/ngram.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/ngram.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/ngram.cpp index 25e7703c92f418..703eca68cfe05c 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/ngram.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/ngram.cpp @@ -6,7 +6,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "internal_properties.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/not_fused_conv_simple_op.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/not_fused_conv_simple_op.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/not_fused_conv_simple_op.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/not_fused_conv_simple_op.cpp index 4e293180a20b8e..4da55f51b04764 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/not_fused_conv_simple_op.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/not_fused_conv_simple_op.cpp @@ -6,7 +6,7 @@ #include "common_test_utils/node_builders/convolution.hpp" #include "common_test_utils/node_builders/eltwise.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" namespace ov { namespace test { diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/remove_convert.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/remove_convert.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/remove_convert.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/remove_convert.cpp index ef5a8929b115c6..4f98fc7c746d15 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/remove_convert.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/remove_convert.cpp @@ -5,8 +5,8 @@ #include "common_test_utils/node_builders/activation.hpp" #include "common_test_utils/node_builders/constant.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/reshape_chain.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/reshape_chain.cpp similarity index 100% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/reshape_chain.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/reshape_chain.cpp diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/reshape_fc.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/reshape_fc.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/reshape_fc.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/reshape_fc.cpp index b08125cdd63e2a..df8a317fbfc6da 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/reshape_fc.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/reshape_fc.cpp @@ -5,7 +5,7 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "common_test_utils/node_builders/constant.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" using namespace CPUTestUtils; namespace ov { diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/reshape_inplace.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/reshape_inplace.cpp similarity index 97% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/reshape_inplace.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/reshape_inplace.cpp index 7a6ed5be8aa8b5..52c588f962c42e 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/reshape_inplace.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/reshape_inplace.cpp @@ -57,9 +57,9 @@ class InPlaceReshapeFromConstantCheck : public SubgraphBaseTest { const auto& funcInputs = function->inputs(); for (size_t i = 0; i < funcInputs.size(); ++i) { const auto& funcInput = funcInputs[i]; - ov::runtime::Tensor tensor; + ov::Tensor tensor; if (i == 1) { - tensor = ov::runtime::Tensor{ov::element::i32, targetInputStaticShapes[i]}; + tensor = ov::Tensor{ov::element::i32, targetInputStaticShapes[i]}; auto inputData = tensor.data::value_type>(); const std::vector data = {38, 38, 15, 4}; for (size_t j = 0lu; j < data.size(); ++j) { diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/reshape_permute_conv_permute_reshape_act.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/reshape_permute_conv_permute_reshape_act.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/reshape_permute_conv_permute_reshape_act.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/reshape_permute_conv_permute_reshape_act.cpp index a70c81c0bf124e..27445b4ae879da 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/reshape_permute_conv_permute_reshape_act.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/reshape_permute_conv_permute_reshape_act.cpp @@ -47,4 +47,4 @@ INSTANTIATE_TEST_SUITE_P(smoke_basic, ConvReshapeAct::getTestCaseName); } // namespace } // namespace test -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/rotary_pos_emb.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/rotary_pos_emb.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/rotary_pos_emb.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/rotary_pos_emb.cpp index 966cea6281b8a9..054619b1e873e2 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/rotary_pos_emb.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/rotary_pos_emb.cpp @@ -12,8 +12,8 @@ #include "common_test_utils/common_utils.hpp" #include "functional_test_utils/skip_tests_config.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" +#include "utils/fusing_test_utils.hpp" #include "utils/gen_pattern.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/sdpa_group_beam_search.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/sdpa_group_beam_search.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/sdpa_group_beam_search.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/sdpa_group_beam_search.cpp index 13de6c5dc11e9e..41687a6d9d20e1 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/sdpa_group_beam_search.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/sdpa_group_beam_search.cpp @@ -4,10 +4,8 @@ #include "openvino/opsets/opset13.hpp" #include "transformations/op_conversions/scaled_dot_product_attention_decomposition.hpp" -#include "ov_models/utils/ov_helpers.hpp" -#include "shared_test_classes/base/layer_test_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "common_test_utils/ov_tensor_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/seq_native_order.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/seq_native_order.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/seq_native_order.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/seq_native_order.cpp index 5c20ec3a6440cd..e3d190e58499d3 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/seq_native_order.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/seq_native_order.cpp @@ -6,7 +6,7 @@ #include "common_test_utils/node_builders/lstm_cell.hpp" #include "common_test_utils/node_builders/rnn_cell.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "transformations/op_conversions/bidirectional_sequences_decomposition.hpp" #include "transformations/op_conversions/convert_sequences_to_tensor_iterator.hpp" diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/shape_infer_subgraph.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/shape_infer_subgraph.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/shape_infer_subgraph.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/shape_infer_subgraph.cpp index c7ec18bfcc93a1..428bbc5f0fe827 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/shape_infer_subgraph.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/shape_infer_subgraph.cpp @@ -3,7 +3,7 @@ // #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/shapeof_any_layout.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/shapeof_any_layout.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/shapeof_any_layout.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/shapeof_any_layout.cpp index 543a789f4661d2..9a41f572b4730a 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/shapeof_any_layout.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/shapeof_any_layout.cpp @@ -5,7 +5,7 @@ #include "common_test_utils/node_builders/activation.hpp" #include "ov_models/utils/ov_helpers.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/split_concat_add.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/split_concat_add.cpp similarity index 100% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/split_concat_add.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/split_concat_add.cpp diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/split_matmul_concat.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/split_matmul_concat.cpp similarity index 99% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/split_matmul_concat.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/split_matmul_concat.cpp index d7ccc1bd5c0b14..b89cb2afeb1c24 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/split_matmul_concat.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/split_matmul_concat.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "test_utils/fusing_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "common_test_utils/node_builders/constant.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/static_zero_dims.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/static_zero_dims.cpp similarity index 100% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/static_zero_dims.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/static_zero_dims.cpp diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/strided_slice_zero_dims.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/strided_slice_zero_dims.cpp similarity index 100% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/strided_slice_zero_dims.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/strided_slice_zero_dims.cpp diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/subgraph_serialize.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/subgraph_serialize.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/subgraph_serialize.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/subgraph_serialize.cpp index 320d14fde805f4..48a05573915c29 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/subgraph_serialize.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/subgraph_serialize.cpp @@ -2,10 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "openvino/openvino.hpp" +#include "openvino/core/model.hpp" #include "openvino/opsets/opset9.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/convolution_params.hpp" +#include "utils/cpu_test_utils.hpp" #include "snippets/op/subgraph.hpp" using namespace CPUTestUtils; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/subgraph_with_blocked_format.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/subgraph_with_blocked_format.cpp similarity index 98% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/subgraph_with_blocked_format.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/subgraph_with_blocked_format.cpp index 195826d7f1de8a..9b51dde4609ee3 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/subgraph_with_blocked_format.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/subgraph_with_blocked_format.cpp @@ -4,7 +4,7 @@ #include "common_test_utils/node_builders/constant.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" #include "openvino/opsets/opset8.hpp" namespace ov { diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/tile_with_two_output_edges.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/tile_with_two_output_edges.cpp similarity index 97% rename from src/plugins/intel_cpu/tests/functional/subgraph_tests/src/tile_with_two_output_edges.cpp rename to src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/tile_with_two_output_edges.cpp index 92500bf1454381..a422737512610e 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/tile_with_two_output_edges.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/tile_with_two_output_edges.cpp @@ -5,7 +5,7 @@ #include "common_test_utils/node_builders/constant.hpp" #include "common_test_utils/node_builders/eltwise.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" namespace ov { namespace test { diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/behavior/ov_infer_request/memory_states.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/behavior/ov_infer_request/memory_states.cpp index 57533fdc278211..3cac277e7c9ee9 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/behavior/ov_infer_request/memory_states.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/behavior/ov_infer_request/memory_states.cpp @@ -16,7 +16,7 @@ std::vector memoryStateTestCases = { memoryStateParams(OVInferRequestVariableStateTest::get_network(), {"c_1-3", "r_1-3"}, ov::test::utils::DEVICE_HETERO, - {{MULTI_CONFIG_KEY(DEVICE_PRIORITIES), ov::test::utils::DEVICE_CPU}})}; + {ov::device::priorities(ov::test::utils::DEVICE_CPU)})}; INSTANTIATE_TEST_SUITE_P(smoke_VariableState, OVInferRequestVariableStateTest, diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/core_config.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/core_config.cpp index 0d574c8e407506..7d30811f7a4332 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/core_config.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/core_config.cpp @@ -2,23 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "functional_test_utils/core_config.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -void CoreConfiguration(LayerTestsUtils::LayerTestsCommon* test) { - // Within the test scope we don't need any implicit bf16 optimisations, so let's run the network as is. - auto& configuration = test->GetConfiguration(); - if (!configuration.count(InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16)) { - configuration.insert({InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::NO}); - } - #if defined(OV_CPU_ARM_ENABLE_FP16) - //force fp32 inference precision if it is not configured specially - if (!configuration.count(ov::hint::inference_precision.name())) { - configuration.insert({ov::hint::inference_precision.name(), ov::element::f32.to_string()}); - } - #endif -} - namespace ov { namespace test { diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/execution_graph_tests/disable_lowering_precision.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/execution_graph_tests/disable_lowering_precision.cpp new file mode 100644 index 00000000000000..70a00425bfa5a9 --- /dev/null +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/execution_graph_tests/disable_lowering_precision.cpp @@ -0,0 +1,27 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "execution_graph_tests/disable_lowering_precision.hpp" +#include "common_test_utils/test_constants.hpp" +#include "openvino/runtime/system_conf.hpp" + +using namespace ExecutionGraphTests; + +namespace { + +const std::vector disableLoweringPrecisionTestParams = { + {true, "CPU", ov::element::bf16}, + {false, "CPU", ov::element::bf16}, +}; + +INSTANTIATE_TEST_SUITE_P(smoke_ExecGraph, ExecGraphDisableLoweringPrecision, + // Only run tests on CPU with avx512_core ISA + ::testing::ValuesIn(ov::with_cpu_x86_avx512_core() ? + disableLoweringPrecisionTestParams : + std::vector{}), + ExecGraphDisableLoweringPrecision::getTestCaseName); + +} // namespace diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/low_precision_transformations/mvn_transformation.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/low_precision_transformations/mvn_transformation.cpp index 3eebef6330e9a1..a1701082f4a989 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/low_precision_transformations/mvn_transformation.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/low_precision_transformations/mvn_transformation.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -15,7 +15,7 @@ const std::vector inputAndQuantizationShapes = { { 1ul, 4ul, 16ul, 16ul }, }; -const std::vector reductionAxes = { { 2, 3 }, { 1, 2, 3 } }; +const std::vector reductionAxes = {{2, 3}, {1, 2, 3}}; const std::vector normalizeVariance = { true, false }; diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp index 34d7ad6ea2ecf7..6d5301e8fb9a36 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp @@ -163,6 +163,16 @@ const std::vector params = { "Reshape", "f32" }, + + // int16 is not supported: no dequantization after Reshape: Reshape => Output + { + { 1, 3, 32 }, + { 1, 3, 4, 8 }, + { 65536ul, ov::Shape{ 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, + "Reshape", + "f32", + { "Reshape", "Output" } + }, }; INSTANTIATE_TEST_SUITE_P(smoke_LPT, ReshapeTransformation, diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/eltwise.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/eltwise.cpp index ff7e75adf0f264..3abe82596cb61b 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/eltwise.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/eltwise.cpp @@ -156,7 +156,7 @@ std::vector eltwise_op_typesSingleThread = { }; ov::AnyMap additional_config_single_thread = { - {"CPU_THREADS_NUM", "1"} + ov::inference_num_threads(1), }; const auto single_thread_params = ::testing::Combine( diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/is_inf.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/is_inf.cpp index ce45353ab90e50..68cb80285b117e 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/is_inf.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/is_inf.cpp @@ -43,7 +43,7 @@ std::vector detect_positive = { true, false }; -std::map additional_config = {}; +ov::AnyMap additional_config = {}; const auto is_inf_params = ::testing::Combine( ::testing::ValuesIn(input_shapes_static), diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/softmax.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/softmax.cpp index ff058cecf6fc35..ad68b01bc2184f 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/softmax.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/softmax.cpp @@ -4,7 +4,7 @@ #include -#include "single_layer_tests/softmax.hpp" +#include "single_op_tests/softmax.hpp" #include "common_test_utils/test_constants.hpp" using namespace ov::test::subgraph; diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/skip_tests_config.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/skip_tests_config.cpp index ddff2c7d345de3..08805d4e586c51 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/skip_tests_config.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/skip_tests_config.cpp @@ -362,5 +362,25 @@ std::vector disabledTestPatterns() { retVector.emplace_back(R"(.*smoke_Snippets_MHAEnforceBF16.*)"); } + if (ov::with_cpu_x86_avx512_core_amx()) { + // Issue: 130463 + retVector.emplace_back(R"(smoke_Conv_1D_GEMM_BF16/ConvolutionLayerCPUTest.*K\(1\)_S\(1\)_PB\(0\)_PE\(0\).*O=6.*_Fused=Add\(PerChannel\).*)"); + // Issue: 130466 + retVector.emplace_back(R"(smoke_Conv_1D_BF16/ConvolutionLayerCPUTest.*IS=\[\].*K\(3\).*S\(2\).*PE\(0\).*D=\(1\).*O=6(3|4).*brgconv_avx512_amx.*)"); + // Issue: 130467 + retVector.emplace_back(R"(smoke_MM_Brgemm_Amx_.*/MatMulLayerCPUTest.*TS=\(\(10\.10\.10\)\).*bf16.*_primitive=brgemm_avx512_amx.*)"); + retVector.emplace_back(R"(smoke_MM_Brgemm_Amx_.*/MatMulLayerCPUTest.*IS=\[1.*TS=\(\(10\.10\.10\).*bf16.*_primitive=brgemm_avx512_amx.*)"); + retVector.emplace_back(R"(smoke_MM_Brgemm_Amx_.*/MatMulLayerCPUTest.*TS=\(\(55\.12\)\).*bf16.*_primitive=brgemm_avx512_amx.*)"); + // Issue: 130471 + retVector.emplace_back(R"(smoke_JIT_AVX512_DW_GroupConv/GroupConvolutionLayerCPUTest.*inFmts=nCdhw16c.*INFERENCE_PRECISION_HINT=bf16.*)"); + } + + if (ov::with_cpu_x86_avx512_core_fp16()) { + // Issue: 130473 + retVector.emplace_back(R"(smoke_CompareWithRefs_4D.*/EltwiseLayerCPUTest.*Sub_secondary.*INFERENCE_PRECISION_HINT=f16.*FakeQuantize.*enforceSnippets=1.*)"); + retVector.emplace_back(R"(smoke_Reduce.*/ReduceCPULayerTest.*axes=\((0.1|1)\).*Prod_KeepDims.*INFERENCE_PRECISION_HINT=f16.*)"); + retVector.emplace_back(R"(smoke_ConvertRangeSubgraphCPUTest/ConvertRangeSubgraphCPUTest\.CompareWithRefs.*Prc=f16.*)"); + } + return retVector; } diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha.cpp index b7212404cc3f83..b3eef5dc9a7c9e 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha.cpp @@ -6,7 +6,8 @@ #include "common_test_utils/test_constants.hpp" #include "internal_properties.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "utils/cpu_test_utils.hpp" +#include "openvino/runtime/system_conf.hpp" namespace ov { namespace test { diff --git a/src/plugins/intel_cpu/tests/functional/test_utils/arm/filter_cpu_info.cpp b/src/plugins/intel_cpu/tests/functional/utils/arm/filter_cpu_info.cpp similarity index 85% rename from src/plugins/intel_cpu/tests/functional/test_utils/arm/filter_cpu_info.cpp rename to src/plugins/intel_cpu/tests/functional/utils/arm/filter_cpu_info.cpp index 21a3e8d76b8529..e3144986ee147d 100644 --- a/src/plugins/intel_cpu/tests/functional/test_utils/arm/filter_cpu_info.cpp +++ b/src/plugins/intel_cpu/tests/functional/utils/arm/filter_cpu_info.cpp @@ -2,11 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/filter_cpu_info.hpp" -#include "openvino/core/type/element_type.hpp" -#include "utils/rt_info/memory_formats_attribute.hpp" -#include "utils/general_utils.h" +#include "utils/cpu_test_utils.hpp" +#include "utils/filter_cpu_info.hpp" namespace CPUTestUtils { diff --git a/src/plugins/intel_cpu/tests/functional/test_utils/convolution_params.hpp b/src/plugins/intel_cpu/tests/functional/utils/convolution_params.hpp similarity index 100% rename from src/plugins/intel_cpu/tests/functional/test_utils/convolution_params.hpp rename to src/plugins/intel_cpu/tests/functional/utils/convolution_params.hpp diff --git a/src/plugins/intel_cpu/tests/functional/test_utils/cpu_test_utils.cpp b/src/plugins/intel_cpu/tests/functional/utils/cpu_test_utils.cpp similarity index 100% rename from src/plugins/intel_cpu/tests/functional/test_utils/cpu_test_utils.cpp rename to src/plugins/intel_cpu/tests/functional/utils/cpu_test_utils.cpp diff --git a/src/plugins/intel_cpu/tests/functional/test_utils/cpu_test_utils.hpp b/src/plugins/intel_cpu/tests/functional/utils/cpu_test_utils.hpp similarity index 100% rename from src/plugins/intel_cpu/tests/functional/test_utils/cpu_test_utils.hpp rename to src/plugins/intel_cpu/tests/functional/utils/cpu_test_utils.hpp diff --git a/src/plugins/intel_cpu/tests/functional/test_utils/filter_cpu_info.hpp b/src/plugins/intel_cpu/tests/functional/utils/filter_cpu_info.hpp similarity index 100% rename from src/plugins/intel_cpu/tests/functional/test_utils/filter_cpu_info.hpp rename to src/plugins/intel_cpu/tests/functional/utils/filter_cpu_info.hpp diff --git a/src/plugins/intel_cpu/tests/functional/test_utils/fusing_test_utils.cpp b/src/plugins/intel_cpu/tests/functional/utils/fusing_test_utils.cpp similarity index 100% rename from src/plugins/intel_cpu/tests/functional/test_utils/fusing_test_utils.cpp rename to src/plugins/intel_cpu/tests/functional/utils/fusing_test_utils.cpp diff --git a/src/plugins/intel_cpu/tests/functional/test_utils/fusing_test_utils.hpp b/src/plugins/intel_cpu/tests/functional/utils/fusing_test_utils.hpp similarity index 100% rename from src/plugins/intel_cpu/tests/functional/test_utils/fusing_test_utils.hpp rename to src/plugins/intel_cpu/tests/functional/utils/fusing_test_utils.hpp diff --git a/src/plugins/intel_cpu/tests/functional/test_utils/properties_test.hpp b/src/plugins/intel_cpu/tests/functional/utils/properties_test.hpp similarity index 100% rename from src/plugins/intel_cpu/tests/functional/test_utils/properties_test.hpp rename to src/plugins/intel_cpu/tests/functional/utils/properties_test.hpp diff --git a/src/plugins/intel_cpu/tests/functional/test_utils/x64/filter_cpu_info.cpp b/src/plugins/intel_cpu/tests/functional/utils/x64/filter_cpu_info.cpp similarity index 89% rename from src/plugins/intel_cpu/tests/functional/test_utils/x64/filter_cpu_info.cpp rename to src/plugins/intel_cpu/tests/functional/utils/x64/filter_cpu_info.cpp index ebcf58012b38f6..5efc97c7409ff4 100644 --- a/src/plugins/intel_cpu/tests/functional/test_utils/x64/filter_cpu_info.cpp +++ b/src/plugins/intel_cpu/tests/functional/utils/x64/filter_cpu_info.cpp @@ -2,12 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/filter_cpu_info.hpp" -#include "openvino/core/type/element_type.hpp" -#include "utils/rt_info/memory_formats_attribute.hpp" -#include "utils/general_utils.h" -#include +#include "utils/cpu_test_utils.hpp" +#include "utils/filter_cpu_info.hpp" namespace CPUTestUtils { diff --git a/src/plugins/intel_cpu/tests/unit/CMakeLists.txt b/src/plugins/intel_cpu/tests/unit/CMakeLists.txt index a5247b8209ffd7..2310d6b2313366 100644 --- a/src/plugins/intel_cpu/tests/unit/CMakeLists.txt +++ b/src/plugins/intel_cpu/tests/unit/CMakeLists.txt @@ -23,7 +23,8 @@ if(NOT X86_64) ${CMAKE_CURRENT_SOURCE_DIR}/registers_pool.cpp ${CMAKE_CURRENT_SOURCE_DIR}/transformations/x64 ${CMAKE_CURRENT_SOURCE_DIR}/snippets_transformations - ${CMAKE_CURRENT_SOURCE_DIR}/nodes/eltwise_node_test.cpp) + ${CMAKE_CURRENT_SOURCE_DIR}/nodes/eltwise_node_test.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/brgemm_executor_test.cpp) endif() if (NOT ENABLE_MLAS_FOR_CPU) diff --git a/src/plugins/intel_cpu/tests/unit/brgemm_executor_test.cpp b/src/plugins/intel_cpu/tests/unit/brgemm_executor_test.cpp new file mode 100644 index 00000000000000..1ffe7a4a85e919 --- /dev/null +++ b/src/plugins/intel_cpu/tests/unit/brgemm_executor_test.cpp @@ -0,0 +1,54 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include +#include +#include "nodes/kernels/x64/brgemm_kernel.hpp" +#include "openvino/core/parallel.hpp" +#include "openvino/runtime/system_conf.hpp" + +TEST(BrgemmKernel, simple_gemm_test) { + if (!ov::with_cpu_x86_bfloat16()) + GTEST_SKIP(); + size_t M = 33; + size_t N = 32; + size_t K = 33; + ov::intel_cpu::BrgemmKernel gemm(M, N, K, K, N, N, false); + std::vector a_data(M * K, (1.0f/33)); + std::vector b_data(K * N, 4.0f); + size_t nthr = 8; + std::vector c_data(nthr * M * N, 0.0f); + std::vector wsp(nthr * 4 * 1024, 0.0f); + std::vector b_scracth(gemm.get_scratch_b_size(), 0.0f); + std::vector a_scracth(gemm.get_scratch_a_size(), 0.0f); + + gemm.copy_buffer_b(b_data.data(), b_scracth.data()); + auto m_block_size = gemm.get_mblk_size(); + auto m_blocks = (M + gemm.get_mblk_size() - 1) / m_block_size; + ov::parallel_for2d(nthr, m_blocks, [&](size_t i, size_t m_blk) { + auto m_start = m_blk * m_block_size; + auto m_end = std::min(m_start + m_block_size, M); + auto m_cnt = m_end - m_start; + gemm.executeGemmPackedB(m_cnt < m_block_size, + a_data.data() + m_start * K, + b_scracth.data(), + c_data.data() + i * M * N + m_start * N, + wsp.data() + i * 4 * 1024, + a_scracth.data()); + }); + ov::parallel_for(nthr, [&](size_t i){ + for (size_t m = 0; m < M; m++) { + for (size_t n = 0; n < N; n++) { + float expected_value = 4.0f; + double abs = std::fabs(expected_value - c_data[i * M * N + m * N + n]); + double rel = expected_value ? (abs / std::fabs(expected_value)) : abs; + if (rel > 0.01f) { + std::ostringstream out_stream; + out_stream << "actual " << c_data[m * N + n] << "|expected|" << expected_value << std::endl; + throw std::runtime_error(out_stream.str()); + } + } + } + }); +} \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/unit/cpu_tensor_test.cpp b/src/plugins/intel_cpu/tests/unit/cpu_tensor_test.cpp index cbd8e419f09ce0..9d792e47499109 100644 --- a/src/plugins/intel_cpu/tests/unit/cpu_tensor_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/cpu_tensor_test.cpp @@ -10,6 +10,7 @@ #include #include #include +#include "memory_desc/blocked_memory_desc.h" #include "openvino/core/except.hpp" #include "openvino/core/partial_shape.hpp" @@ -253,4 +254,4 @@ TEST_F(CPUTensorTest, canSyncMemoryAndTensor) { ASSERT_EQ(memptr->getDescPtr()->getShape().toPartialShape().to_shape(), t->get_shape()); ASSERT_EQ(byte_strides(memptr->getDescWithType()->getStrides(), t->get_element_type()), t->get_strides()); } -} \ No newline at end of file +} diff --git a/src/plugins/intel_cpu/tests/unit/cpu_tensor_test_ext.cpp b/src/plugins/intel_cpu/tests/unit/cpu_tensor_test_ext.cpp index a11f04a73c8605..36aba72465eae5 100644 --- a/src/plugins/intel_cpu/tests/unit/cpu_tensor_test_ext.cpp +++ b/src/plugins/intel_cpu/tests/unit/cpu_tensor_test_ext.cpp @@ -10,6 +10,7 @@ #include #include #include +#include "memory_desc/cpu_blocked_memory_desc.h" #include "openvino/core/except.hpp" #include "openvino/core/partial_shape.hpp" @@ -152,4 +153,4 @@ TEST_F(CPUTensorExtTest, canSyncMemoryAndTensor) { ASSERT_EQ(memptr->getDescPtr()->getShape().toPartialShape().to_shape(), t->get_shape()); ASSERT_EQ(byteStrides(memptr->getDescWithType()->getStrides(), t->get_element_type()), t->get_strides()); } -} \ No newline at end of file +} diff --git a/src/plugins/intel_cpu/tests/unit/dnnl_memory_test.cpp b/src/plugins/intel_cpu/tests/unit/dnnl_memory_test.cpp index 39b469662f90da..3bab4621bf4010 100644 --- a/src/plugins/intel_cpu/tests/unit/dnnl_memory_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/dnnl_memory_test.cpp @@ -2,13 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 // -#include #include #include -#include +#include #include -#include using namespace ov::intel_cpu; diff --git a/src/plugins/intel_cpu/tests/unit/graph/dummy_node.hpp b/src/plugins/intel_cpu/tests/unit/graph/dummy_node.hpp index 7ffa5c9279ddaf..3ac1b06505952b 100644 --- a/src/plugins/intel_cpu/tests/unit/graph/dummy_node.hpp +++ b/src/plugins/intel_cpu/tests/unit/graph/dummy_node.hpp @@ -4,10 +4,11 @@ #pragma once +#include "cpu_shape.h" #include "node.h" -#include "graph.h" +#include "graph_context.h" #include "edge.h" - +#include "openvino/core/shape.hpp" namespace ov { namespace intel_cpu { @@ -15,20 +16,25 @@ namespace cpu_unit_test { class DummyNode : public Node { public: + // dummy node of the same shape and precision to both input and output. DummyNode(const ov::Shape& shape, - const ov::element::Type_t& prc, - const std::string& name, - const std::string& type, - const GraphContext::CPtr context, - LayoutType layout = LayoutType::ncsp, - int in_place_direction = Edge::LOOK::LOOK_UP, - bool is_executable = false) : - Node(type, name, context), m_layout(layout), m_inplace(in_place_direction), m_is_executable(is_executable) { - // dummy node of the same shape and precision to both input and output. - outputShapes.emplace_back(shape); - inputShapes.emplace_back(shape); - addOriginalOutputPrecision(prc); - addOriginalInputPrecision(prc); + const ov::element::Type_t& prc, + const std::string& name, + const std::string& type, + const GraphContext::CPtr context, + LayoutType layout = LayoutType::ncsp, + int in_place_direction = Edge::LOOK::LOOK_UP, + bool is_executable = false) : + Node(type, + {ov::intel_cpu::Shape(shape)}, + {ov::intel_cpu::Shape(shape)}, + {prc}, + {prc}, + name, + context), + m_layout(layout), + m_inplace(in_place_direction), + m_is_executable(is_executable) { } void getSupportedDescriptors() override { diff --git a/src/plugins/intel_cpu/tests/unit/graph/memory_state.cpp b/src/plugins/intel_cpu/tests/unit/graph/memory_state.cpp index 0c65a4a87706d6..ed1957002ccc34 100644 --- a/src/plugins/intel_cpu/tests/unit/graph/memory_state.cpp +++ b/src/plugins/intel_cpu/tests/unit/graph/memory_state.cpp @@ -5,10 +5,14 @@ #include "dummy_node.hpp" +#include "graph.h" #include "nodes/memory.hpp" #include "nodes/softmax.h" #include "nodes/shapeof.h" #include "nodes/convert.h" +#include "openvino/op/convert.hpp" +#include "openvino/op/shape_of.hpp" +#include "openvino/op/softmax.hpp" using namespace ov::intel_cpu; @@ -153,8 +157,8 @@ TEST(MemStateGraphTest, smoke_Check_Memory_Modification_Guard) { auto memory_output = find_node_type(graph, Type::MemoryOutput); - auto second_dummy_out_mem = second_dummy->getChildEdgeAt(0)->getMemoryPtr()->getData(); - auto memory_output_inp_mem = memory_output->getParentEdgeAt(0)->getMemoryPtr()->getData(); + auto second_dummy_out_mem = second_dummy->getDstDataAtPort(0); + auto memory_output_inp_mem = memory_output->getSrcDataAtPort(0); //otherwise the memory will be modified by the dummy_look_up ASSERT_NE(second_dummy_out_mem, memory_output_inp_mem); @@ -185,8 +189,8 @@ TEST(MemStateGraphTest, smoke_Check_Memory_Modification_Guard) { auto memory_output = find_node_type(graph, Type::MemoryOutput); - auto second_dummy_out_mem = second_dummy->getChildEdgeAt(0)->getMemoryPtr()->getData(); - auto memory_output_inp_mem = memory_output->getParentEdgeAt(0)->getMemoryPtr()->getData(); + auto second_dummy_out_mem = second_dummy->getDstDataAtPort(0); + auto memory_output_inp_mem = memory_output->getSrcDataAtPort(0); //otherwise the memory will be modified by the dummy_look_up ASSERT_NE(second_dummy_out_mem, memory_output_inp_mem); @@ -306,4 +310,4 @@ TEST(MemStateGraphTest, smoke_ShapeOf_no_Inplace_Conflicts) { [](const NodePtr& node){ return Type::Reorder == node->getType(); }); ASSERT_EQ(itr, nodes.end()); -} \ No newline at end of file +} diff --git a/src/plugins/intel_cpu/tests/unit/graph/merge_transpose_reorder_test.cpp b/src/plugins/intel_cpu/tests/unit/graph/merge_transpose_reorder_test.cpp index fe43a4301a0268..1dd1c177e16813 100644 --- a/src/plugins/intel_cpu/tests/unit/graph/merge_transpose_reorder_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/graph/merge_transpose_reorder_test.cpp @@ -4,10 +4,15 @@ #include #include "dummy_node.hpp" +#include "graph.h" #include "nodes/reorder.h" #include "nodes/input.h" #include "nodes/transpose.h" +#include "openvino/op/transpose.hpp" +#include "openvino/op/result.hpp" +#include "openvino/op/parameter.hpp" + #include "common_test_utils/node_builders/constant.hpp" using namespace ov::intel_cpu; diff --git a/src/plugins/intel_cpu/tests/unit/graph/resolve_edge_conflicts_test.cpp b/src/plugins/intel_cpu/tests/unit/graph/resolve_edge_conflicts_test.cpp index f574e73876f51e..79ace4c13d5e3f 100644 --- a/src/plugins/intel_cpu/tests/unit/graph/resolve_edge_conflicts_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/graph/resolve_edge_conflicts_test.cpp @@ -4,9 +4,12 @@ #include #include "dummy_node.hpp" +#include "graph.h" #include "nodes/input.h" #include "nodes/concat.h" - +#include "openvino/op/concat.hpp" +#include "openvino/op/parameter.hpp" +#include "openvino/op/result.hpp" using namespace ov::intel_cpu; diff --git a/src/plugins/intel_cpu/tests/unit/nodes/eltwise_node_test.cpp b/src/plugins/intel_cpu/tests/unit/nodes/eltwise_node_test.cpp index f95ac227f96636..7acd73a4999ad3 100644 --- a/src/plugins/intel_cpu/tests/unit/nodes/eltwise_node_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/nodes/eltwise_node_test.cpp @@ -4,7 +4,6 @@ #include #include -#include "ie_common.h" #include "nodes/eltwise.h" using namespace ov::intel_cpu; diff --git a/src/plugins/intel_cpu/tests/unit/nodes/reorder_node_test.cpp b/src/plugins/intel_cpu/tests/unit/nodes/reorder_node_test.cpp index ff528d8e65dc74..bc87c69cd84281 100644 --- a/src/plugins/intel_cpu/tests/unit/nodes/reorder_node_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/nodes/reorder_node_test.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include @@ -104,7 +103,7 @@ struct ReorderCPUTestParamSet { class ReorderCPUTestGraph { public: void buildReorderGraph(const ov::intel_cpu::CpuBlockedMemoryDesc& inputDesc, - const ov::intel_cpu::CpuBlockedMemoryDesc& outputDesc) { + const ov::intel_cpu::CpuBlockedMemoryDesc& outputDesc) { Config conf; conf.rtCacheCapacity = 100; auto context = std::make_shared(conf, @@ -116,7 +115,7 @@ class ReorderCPUTestGraph { "Reorder_Input", "Parameter", context); - reorderNode = std::make_shared("Reorder", context); + reorderNode = std::make_shared(inputDesc, outputDesc, "Reorder", context); outputNode = std::make_shared(outputDesc.clone(), "Reorder_Output", "Result", @@ -135,7 +134,6 @@ class ReorderCPUTestGraph { parentEdge->reuse(parentMemory); childEdge->reuse(childMemory); - reorderNode->setDescs(inputDesc, outputDesc); std::array, 3> nodes{inputNode, reorderNode, outputNode}; for (auto& n : nodes) { n->init(); diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/fullconnect.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/fullconnect.cpp index b8aedecdc94992..55fddb2d300ad6 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/fullconnect.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/fullconnect.cpp @@ -3,6 +3,8 @@ // #include + +#include "openvino/op/parameter.hpp" #include "transformations/cpu_opset/common/op/fully_connected.hpp" #include "custom_shape_infer.hpp" namespace ov { diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/ngram.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/ngram.cpp index 6a6689ae5441f8..4c0a3278a5b8a9 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/ngram.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/ngram.cpp @@ -3,8 +3,11 @@ // #include + +#include "openvino/op/parameter.hpp" #include "transformations/cpu_opset/common/op/ngram.hpp" #include "custom_shape_infer.hpp" + namespace ov { namespace intel_cpu { namespace unit_test { diff --git a/src/plugins/intel_cpu/tests/unit/streams_info/streams_e2e_test.cpp b/src/plugins/intel_cpu/tests/unit/streams_info/streams_e2e_test.cpp index 9e8081c0b89896..a24762782d6d0f 100644 --- a/src/plugins/intel_cpu/tests/unit/streams_info/streams_e2e_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/streams_info/streams_e2e_test.cpp @@ -8,6 +8,7 @@ #include "cpu_map_scheduling.hpp" #include "cpu_streams_calculation.hpp" #include "openvino/runtime/system_conf.hpp" +#include "os/cpu_map_info.hpp" using namespace testing; using namespace ov; @@ -20,6 +21,7 @@ struct StreamGenerateionTestCase { int input_thread; int input_request; int input_model_prefer; + int input_socket_id; ov::hint::SchedulingCoreType input_type; bool input_ht_value; bool input_ht_changed; @@ -45,9 +47,10 @@ void make_config(StreamGenerateionTestCase& test_data, ov::intel_cpu::Config& co config.hintPerfMode = test_data.input_pm_hint; config.latencyThreadingMode = test_data.input_latency_threading_mode; config.hintNumRequests = test_data.input_request; - config.streamExecutorConfig._streams = test_data.input_stream; - config.streamExecutorConfig._streams_changed = test_data.input_stream_changed; - config.streamExecutorConfig._threads = test_data.input_thread; + config.streams = test_data.input_stream_changed ? test_data.input_stream + : (test_data.input_stream == 0 ? 1 : test_data.input_stream); + config.streamsChanged = test_data.input_stream_changed; + config.threads = test_data.input_thread; } class StreamGenerationTests : public ov::test::TestsCommon, @@ -58,15 +61,19 @@ class StreamGenerationTests : public ov::test::TestsCommon, ov::intel_cpu::Config config; make_config(test_data, config); + CPU& cpu = cpu_info(); + cpu._proc_type_table = test_data.input_proc_type_table; + auto proc_type_table = ov::intel_cpu::generate_stream_info(test_data.input_stream, + test_data.input_socket_id, nullptr, config, test_data.input_proc_type_table, test_data.input_model_prefer); - ASSERT_EQ(test_data.output_stream_info_table, config.streamExecutorConfig._streams_info_table); + ASSERT_EQ(test_data.output_stream_info_table, config.streamExecutorConfig.get_streams_info_table()); ASSERT_EQ(test_data.output_proc_type_table, proc_type_table); - ASSERT_EQ(test_data.output_cpu_value, config.streamExecutorConfig._cpu_reservation); + ASSERT_EQ(test_data.output_cpu_value, config.streamExecutorConfig.get_cpu_reservation()); ASSERT_EQ(test_data.output_ht_value, config.enableHyperThreading); ASSERT_EQ(test_data.output_type, config.schedulingCoreType); ASSERT_EQ(test_data.output_pm_hint, config.hintPerfMode); @@ -81,6 +88,7 @@ StreamGenerateionTestCase generation_latency_1sockets_14cores_1_pinning = { 0, // param[in]: simulated setting for threads number 0, // param[in]: simulated setting for inference request number 0, // param[in]: simulated setting for model prefer threads number + 0, // param[in]: simulated setting for socket id of running thread ov::hint::SchedulingCoreType::ANY_CORE, // param[in]: simulated setting for scheduling core type // (PCORE_ONLY/ECORE_ONLY/ANY_CORE) true, // param[in]: simulated setting for enableHyperThreading @@ -111,6 +119,7 @@ StreamGenerateionTestCase generation_latency_1sockets_14cores_2_pinning = { 0, 0, 0, + 0, ov::hint::SchedulingCoreType::ANY_CORE, true, true, @@ -133,6 +142,7 @@ StreamGenerateionTestCase generation_tput_1sockets_14cores_1_pinning = { 0, 0, 0, + 0, ov::hint::SchedulingCoreType::ANY_CORE, true, true, @@ -155,6 +165,7 @@ StreamGenerateionTestCase generation_latency_1sockets_14cores_1_unpinning = { 0, 0, 0, + 0, ov::hint::SchedulingCoreType::ANY_CORE, true, true, @@ -180,6 +191,7 @@ StreamGenerateionTestCase generation_latency_1sockets_14cores_2_unpinning = { 0, 0, 0, + 0, ov::hint::SchedulingCoreType::ANY_CORE, true, true, @@ -202,6 +214,7 @@ StreamGenerateionTestCase generation_tput_1sockets_14cores_1_unpinning = { 0, 0, 0, + 0, ov::hint::SchedulingCoreType::ANY_CORE, true, true, @@ -224,6 +237,7 @@ StreamGenerateionTestCase generation_latency_1sockets_14cores_3 = { 0, 0, 0, + 0, ov::hint::SchedulingCoreType::PCORE_ONLY, true, true, @@ -246,6 +260,7 @@ StreamGenerateionTestCase generation_latency_1sockets_14cores_4 = { 0, 0, 0, + 0, ov::hint::SchedulingCoreType::PCORE_ONLY, true, true, @@ -268,6 +283,7 @@ StreamGenerateionTestCase generation_latency_1sockets_14cores_5 = { 0, 0, 0, + 0, ov::hint::SchedulingCoreType::PCORE_ONLY, false, true, @@ -290,6 +306,7 @@ StreamGenerateionTestCase generation_latency_2sockets_48cores_6 = { 0, 0, 0, + 0, ov::hint::SchedulingCoreType::PCORE_ONLY, false, true, @@ -312,6 +329,7 @@ StreamGenerateionTestCase generation_latency_2sockets_48cores_7 = { 0, 0, 0, + 0, ov::hint::SchedulingCoreType::PCORE_ONLY, true, true, @@ -334,6 +352,7 @@ StreamGenerateionTestCase generation_latency_2sockets_48cores_8 = { 0, 0, 0, + 0, ov::hint::SchedulingCoreType::PCORE_ONLY, false, true, @@ -356,6 +375,7 @@ StreamGenerateionTestCase generation_latency_2sockets_48cores_9 = { 0, 0, 0, + 0, ov::hint::SchedulingCoreType::PCORE_ONLY, true, true, @@ -378,6 +398,7 @@ StreamGenerateionTestCase generation_tput_1sockets_14cores_2 = { 0, 0, 0, + 0, ov::hint::SchedulingCoreType::PCORE_ONLY, false, true, @@ -400,6 +421,7 @@ StreamGenerateionTestCase generation_tput_1sockets_14cores_3 = { 0, 0, 0, + 0, ov::hint::SchedulingCoreType::PCORE_ONLY, true, true, @@ -422,6 +444,7 @@ StreamGenerateionTestCase generation_tput_1sockets_14cores_4 = { 10, 0, 0, + 0, ov::hint::SchedulingCoreType::PCORE_ONLY, true, true, @@ -444,6 +467,7 @@ StreamGenerateionTestCase generation_tput_2sockets_48cores_5 = { 0, 0, 0, + 0, ov::hint::SchedulingCoreType::ANY_CORE, true, true, @@ -469,6 +493,7 @@ StreamGenerateionTestCase generation_tput_2sockets_48cores_6 = { 0, 0, 0, + 0, ov::hint::SchedulingCoreType::ANY_CORE, false, true, @@ -491,6 +516,7 @@ StreamGenerateionTestCase generation_tput_2sockets_48cores_7 = { 0, 0, 0, + 0, ov::hint::SchedulingCoreType::ANY_CORE, false, true, @@ -513,6 +539,7 @@ StreamGenerateionTestCase generation_tput_2sockets_48cores_8 = { 20, 0, 1, + 0, ov::hint::SchedulingCoreType::ANY_CORE, false, true, @@ -535,6 +562,7 @@ StreamGenerateionTestCase generation_tput_2sockets_48cores_9 = { 0, 0, 1, + 0, ov::hint::SchedulingCoreType::ANY_CORE, true, false, @@ -556,6 +584,7 @@ StreamGenerateionTestCase generation_latency_1sockets_96cores_pinning = { 0, 0, 0, + 0, ov::hint::SchedulingCoreType::ANY_CORE, false, false, @@ -577,6 +606,7 @@ StreamGenerateionTestCase generation_tput_1sockets_96cores_pinning = { 0, 0, 0, + 0, ov::hint::SchedulingCoreType::ANY_CORE, false, false, @@ -598,6 +628,7 @@ StreamGenerateionTestCase generation_tput_1sockets_96cores_2_pinning = { 0, 0, 0, + 0, ov::hint::SchedulingCoreType::PCORE_ONLY, true, true, @@ -619,6 +650,7 @@ StreamGenerateionTestCase generation_latency_1sockets_96cores_unpinning = { 0, 0, 0, + 0, ov::hint::SchedulingCoreType::ANY_CORE, false, false, @@ -640,6 +672,7 @@ StreamGenerateionTestCase generation_tput_1sockets_96cores_unpinning = { 0, 0, 0, + 0, ov::hint::SchedulingCoreType::ANY_CORE, false, false, @@ -661,6 +694,7 @@ StreamGenerateionTestCase generation_tput_1sockets_96cores_2_unpinning = { 0, 0, 0, + 0, ov::hint::SchedulingCoreType::PCORE_ONLY, true, true, diff --git a/src/plugins/intel_cpu/tests/unit/streams_info/streams_info_table_test.cpp b/src/plugins/intel_cpu/tests/unit/streams_info/streams_info_table_test.cpp index 186d6df9b1d220..1fce6e02e96f8f 100644 --- a/src/plugins/intel_cpu/tests/unit/streams_info/streams_info_table_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/streams_info/streams_info_table_test.cpp @@ -20,6 +20,7 @@ struct StreamsCalculationTestCase { int input_threads; int input_infer_requests; int model_prefer_threads; + int input_socket_id; std::string input_perf_hint; ov::intel_cpu::Config::LatencyThreadingMode latencyThreadingMode; std::vector> proc_type_table; @@ -38,6 +39,7 @@ class StreamsCalculationTests : public ov::test::TestsCommon, test_data.input_threads, test_data.input_infer_requests, test_data.model_prefer_threads, + test_data.input_socket_id, test_data.input_perf_hint, test_data.latencyThreadingMode, test_data.proc_type_table); @@ -54,6 +56,7 @@ StreamsCalculationTestCase _2sockets_104cores_latency_platform_1 = { 0, // param[in]: the number of threads in this simulation 0, // param[in]: the number of infer requests in this simulation 0, // param[in]: the model preferred number of threads in this simulation + 0, // param[in]: the current socket id of the running thread in this simulation "LATENCY", // param[in]: the performance hint in this simulation ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, // param[in]: the LatencyThreadingMode in this // simulation @@ -74,6 +77,7 @@ StreamsCalculationTestCase _2sockets_104cores_latency_platform_2 = { 0, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{104, 104, 0, 0, -1, -1}, {52, 52, 0, 0, 0, 0}, {52, 52, 0, 0, 1, 1}}, @@ -85,6 +89,7 @@ StreamsCalculationTestCase _2sockets_104cores_latency_platform_3 = { 0, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{208, 104, 0, 104, -1, -1}, @@ -108,6 +113,7 @@ StreamsCalculationTestCase _2sockets_104cores_latency_platform_4 = { 0, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{104, 104, 0, 0, -1, -1}, {26, 26, 0, 0, 0, 0}, {26, 26, 0, 0, 1, 0}, {26, 26, 0, 0, 2, 1}, {26, 26, 0, 0, 3, 1}}, @@ -123,6 +129,7 @@ StreamsCalculationTestCase _2sockets_104cores_latency_socket_1 = { 0, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, @@ -134,6 +141,7 @@ StreamsCalculationTestCase _2sockets_104cores_latency_socket_2 = { 0, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, {{104, 104, 0, 0, -1, -1}, {52, 52, 0, 0, 0, 0}, {52, 52, 0, 0, 1, 1}}, @@ -145,6 +153,7 @@ StreamsCalculationTestCase _2sockets_104cores_latency_socket_3 = { 0, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, {{208, 104, 0, 104, -1, -1}, @@ -164,6 +173,7 @@ StreamsCalculationTestCase _2sockets_104cores_latency_socket_4 = { 0, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, {{104, 104, 0, 0, -1, -1}, {26, 26, 0, 0, 0, 0}, {26, 26, 0, 0, 1, 0}, {26, 26, 0, 0, 2, 1}, {26, 26, 0, 0, 3, 1}}, @@ -175,10 +185,11 @@ StreamsCalculationTestCase _2sockets_104cores_latency_socket_5 = { 0, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, {{60, 60, 0, 0, -1, -1}, {10, 10, 0, 0, 0, 0}, {10, 10, 0, 0, 1, 0}, {20, 20, 0, 0, 2, 1}, {20, 20, 0, 0, 3, 1}}, - {{1, ALL_PROC, 40, -1, 1}, {0, MAIN_CORE_PROC, 20, 2, 1}, {0, MAIN_CORE_PROC, 20, 3, 1}}, + {{1, ALL_PROC, 20, -1, 0}, {0, MAIN_CORE_PROC, 10, 0, 0}, {0, MAIN_CORE_PROC, 10, 1, 0}}, }; StreamsCalculationTestCase _2sockets_104cores_latency_socket_6 = { 1, @@ -186,10 +197,11 @@ StreamsCalculationTestCase _2sockets_104cores_latency_socket_6 = { 0, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, {{60, 60, 0, 0, -1, -1}, {10, 10, 0, 0, 0, 0}, {20, 20, 0, 0, 1, 1}, {10, 10, 0, 0, 2, 0}, {20, 20, 0, 0, 3, 1}}, - {{1, ALL_PROC, 40, -1, 1}, {0, MAIN_CORE_PROC, 20, 1, 1}, {0, MAIN_CORE_PROC, 20, 3, 1}}, + {{1, ALL_PROC, 20, -1, 0}, {0, MAIN_CORE_PROC, 10, 0, 0}, {0, MAIN_CORE_PROC, 10, 2, 0}}, }; StreamsCalculationTestCase _2sockets_104cores_latency_socket_7 = { 1, @@ -197,6 +209,7 @@ StreamsCalculationTestCase _2sockets_104cores_latency_socket_7 = { 0, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, {{104, 104, 0, 0, -1, -1}, {26, 26, 0, 0, 0, 0}, {26, 26, 0, 0, 1, 0}, {26, 26, 0, 0, 2, 1}, {26, 26, 0, 0, 3, 1}}, @@ -208,13 +221,14 @@ StreamsCalculationTestCase _2sockets_104cores_latency_socket_8 = { 208, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, {{1, ALL_PROC, 208, -1, -1}, {0, MAIN_CORE_PROC, 52, 0, 0}, - {0, MAIN_CORE_PROC, 52, 1, 1}, {0, HYPER_THREADING_PROC, 52, 0, 0}, + {0, MAIN_CORE_PROC, 52, 1, 1}, {0, HYPER_THREADING_PROC, 52, 1, 1}}, }; StreamsCalculationTestCase _2sockets_104cores_latency_socket_9 = { @@ -223,10 +237,11 @@ StreamsCalculationTestCase _2sockets_104cores_latency_socket_9 = { 104, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, - {{1, ALL_PROC, 104, -1, -1}, {0, MAIN_CORE_PROC, 52, 0, 0}, {0, MAIN_CORE_PROC, 52, 1, 1}}, + {{1, ALL_PROC, 104, 0, 0}, {0, MAIN_CORE_PROC, 52, 0, 0}, {0, HYPER_THREADING_PROC, 52, 0, 0}}, }; StreamsCalculationTestCase _2sockets_104cores_latency_socket_10 = { 1, @@ -234,6 +249,7 @@ StreamsCalculationTestCase _2sockets_104cores_latency_socket_10 = { 52, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, @@ -245,6 +261,7 @@ StreamsCalculationTestCase _2sockets_104cores_latency_node_1 = { 0, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_NUMA_NODE, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, @@ -256,6 +273,7 @@ StreamsCalculationTestCase _2sockets_104cores_latency_node_2 = { 0, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_NUMA_NODE, {{104, 104, 0, 0, -1, -1}, {52, 52, 0, 0, 0, 0}, {52, 52, 0, 0, 1, 1}}, @@ -267,6 +285,7 @@ StreamsCalculationTestCase _2sockets_104cores_latency_node_3 = { 0, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_NUMA_NODE, {{208, 104, 0, 104, -1, -1}, @@ -282,6 +301,7 @@ StreamsCalculationTestCase _2sockets_104cores_latency_node_4 = { 0, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_NUMA_NODE, {{104, 104, 0, 0, -1, -1}, {26, 26, 0, 0, 0, 0}, {26, 26, 0, 0, 1, 0}, {26, 26, 0, 0, 2, 1}, {26, 26, 0, 0, 3, 1}}, @@ -293,6 +313,7 @@ StreamsCalculationTestCase _2sockets_104cores_latency_node_5 = { 0, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_NUMA_NODE, {{104, 104, 0, 0, -1, -1}, {26, 26, 0, 0, 0, 0}, {26, 26, 0, 0, 1, 0}, {26, 26, 0, 0, 2, 1}, {26, 26, 0, 0, 3, 1}}, @@ -304,6 +325,7 @@ StreamsCalculationTestCase _2sockets_104cores_latency_node_6 = { 104, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_NUMA_NODE, {{104, 104, 0, 0, -1, -1}, {26, 26, 0, 0, 0, 0}, {26, 26, 0, 0, 1, 0}, {26, 26, 0, 0, 2, 1}, {26, 26, 0, 0, 3, 1}}, @@ -319,10 +341,11 @@ StreamsCalculationTestCase _2sockets_104cores_latency_node_7 = { 52, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_NUMA_NODE, {{104, 104, 0, 0, -1, -1}, {26, 26, 0, 0, 0, 0}, {26, 26, 0, 0, 1, 0}, {26, 26, 0, 0, 2, 1}, {26, 26, 0, 0, 3, 1}}, - {{1, ALL_PROC, 52, -1, -1}, {0, MAIN_CORE_PROC, 26, 0, 0}, {0, MAIN_CORE_PROC, 26, 1, 0}}, + {{1, ALL_PROC, 52, -1, 0}, {0, MAIN_CORE_PROC, 26, 0, 0}, {0, MAIN_CORE_PROC, 26, 1, 0}}, }; StreamsCalculationTestCase _2sockets_104cores_latency_node_8 = { 1, @@ -330,6 +353,7 @@ StreamsCalculationTestCase _2sockets_104cores_latency_node_8 = { 26, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_NUMA_NODE, {{104, 104, 0, 0, -1, -1}, {26, 26, 0, 0, 0, 0}, {26, 26, 0, 0, 1, 0}, {26, 26, 0, 0, 2, 1}, {26, 26, 0, 0, 3, 1}}, @@ -341,6 +365,7 @@ StreamsCalculationTestCase _2sockets_104cores_latency_1 = { 20, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, @@ -352,6 +377,7 @@ StreamsCalculationTestCase _2sockets_104cores_latency_2 = { 20, 5, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, @@ -363,13 +389,14 @@ StreamsCalculationTestCase _2sockets_104cores_latency_3 = { 208, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, {{1, ALL_PROC, 208, -1, -1}, {0, MAIN_CORE_PROC, 52, 0, 0}, - {0, MAIN_CORE_PROC, 52, 1, 1}, {0, HYPER_THREADING_PROC, 52, 0, 0}, + {0, MAIN_CORE_PROC, 52, 1, 1}, {0, HYPER_THREADING_PROC, 52, 1, 1}}, }; StreamsCalculationTestCase _2sockets_104cores_latency_4 = { @@ -378,6 +405,7 @@ StreamsCalculationTestCase _2sockets_104cores_latency_4 = { 20, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, @@ -389,6 +417,7 @@ StreamsCalculationTestCase _2sockets_104cores_latency_5 = { 20, 5, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, @@ -400,13 +429,14 @@ StreamsCalculationTestCase _2sockets_104cores_latency_6 = { 208, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, {{1, ALL_PROC, 208, -1, -1}, {0, MAIN_CORE_PROC, 52, 0, 0}, - {0, MAIN_CORE_PROC, 52, 1, 1}, {0, HYPER_THREADING_PROC, 52, 0, 0}, + {0, MAIN_CORE_PROC, 52, 1, 1}, {0, HYPER_THREADING_PROC, 52, 1, 1}}, }; StreamsCalculationTestCase _2sockets_104cores_tput_1 = { @@ -415,6 +445,7 @@ StreamsCalculationTestCase _2sockets_104cores_tput_1 = { 0, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, @@ -429,6 +460,7 @@ StreamsCalculationTestCase _2sockets_104cores_tput_2 = { 0, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, @@ -445,6 +477,7 @@ StreamsCalculationTestCase _2sockets_104cores_tput_3 = { 20, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, @@ -456,6 +489,7 @@ StreamsCalculationTestCase _2sockets_104cores_tput_4 = { 20, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, @@ -467,6 +501,7 @@ StreamsCalculationTestCase _2sockets_104cores_tput_5 = { 0, 0, 1, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, @@ -481,6 +516,7 @@ StreamsCalculationTestCase _2sockets_104cores_tput_6 = { 0, 0, 2, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, @@ -495,6 +531,7 @@ StreamsCalculationTestCase _2sockets_104cores_tput_7 = { 0, 0, 8, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, @@ -515,6 +552,7 @@ StreamsCalculationTestCase _2sockets_104cores_tput_7_1 = { 0, 0, 8, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, @@ -535,6 +573,7 @@ StreamsCalculationTestCase _2sockets_104cores_tput_7_2 = { 0, 0, 4, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{208, 104, 0, 104, -1, -1}, @@ -556,6 +595,7 @@ StreamsCalculationTestCase _2sockets_104cores_tput_8 = { 40, 0, 8, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, @@ -568,6 +608,7 @@ StreamsCalculationTestCase _2sockets_104cores_tput_9 = { 20, 2, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, @@ -580,6 +621,7 @@ StreamsCalculationTestCase _2sockets_104cores_tput_10 = { 0, 2, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, @@ -597,6 +639,7 @@ StreamsCalculationTestCase _2sockets_104cores_tput_11 = { 0, 5, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, @@ -614,6 +657,7 @@ StreamsCalculationTestCase _2sockets_104cores_tput_12 = { 0, 2, 2, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{208, 104, 0, 104, -1, -1}, {104, 52, 0, 52, 0, 0}, {104, 52, 0, 52, 1, 1}}, @@ -631,6 +675,7 @@ StreamsCalculationTestCase _2sockets_104cores_tput_13 = { 0, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{104, 104, 0, 0, -1, -1}, {52, 52, 0, 0, 0, 0}, {52, 52, 0, 0, 1, 1}}, @@ -643,6 +688,7 @@ StreamsCalculationTestCase _2sockets_104cores_tput_14 = { 0, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{104, 104, 0, 0, -1, -1}, {52, 52, 0, 0, 0, 0}, {52, 52, 0, 0, 1, 1}}, @@ -655,6 +701,7 @@ StreamsCalculationTestCase _2sockets_104cores_tput_15 = { 0, 0, 1, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{104, 104, 0, 0, -1, -1}, {52, 52, 0, 0, 0, 0}, {52, 52, 0, 0, 1, 1}}, @@ -667,6 +714,7 @@ StreamsCalculationTestCase _2sockets_104cores_tput_16 = { 0, 0, 2, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{104, 104, 0, 0, -1, -1}, {52, 52, 0, 0, 0, 0}, {52, 52, 0, 0, 1, 1}}, @@ -679,6 +727,7 @@ StreamsCalculationTestCase _2sockets_104cores_tput_17 = { 0, 0, 8, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{104, 104, 0, 0, -1, -1}, {52, 52, 0, 0, 0, 0}, {52, 52, 0, 0, 1, 1}}, @@ -695,6 +744,7 @@ StreamsCalculationTestCase _2sockets_104cores_tput_18 = { 0, 2, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{104, 104, 0, 0, -1, -1}, {52, 52, 0, 0, 0, 0}, {52, 52, 0, 0, 1, 1}}, @@ -707,6 +757,7 @@ StreamsCalculationTestCase _2sockets_104cores_tput_19 = { 0, 5, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{104, 104, 0, 0, -1, -1}, {52, 52, 0, 0, 0, 0}, {52, 52, 0, 0, 1, 1}}, @@ -719,6 +770,7 @@ StreamsCalculationTestCase _2sockets_104cores_tput_20 = { 0, 2, 2, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{104, 104, 0, 0, -1, -1}, {52, 52, 0, 0, 0, 0}, {52, 52, 0, 0, 1, 1}}, @@ -731,17 +783,31 @@ StreamsCalculationTestCase _2sockets_48cores_latency_1 = { 0, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{48, 48, 0, 0, -1, -1}, {24, 24, 0, 0, 0, 0}, {24, 24, 0, 0, 1, 1}}, {{1, ALL_PROC, 48, -1, -1}, {0, MAIN_CORE_PROC, 24, 0, 0}, {0, MAIN_CORE_PROC, 24, 1, 1}}, }; StreamsCalculationTestCase _2sockets_48cores_latency_2 = { + 1, + false, + 0, + 0, + 0, + 0, + "LATENCY", + ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, + {{48, 48, 0, 0, -1, -1}, {24, 24, 0, 0, 0, 0}, {24, 24, 0, 0, 1, 1}}, + {{1, MAIN_CORE_PROC, 24, 0, 0}}, +}; +StreamsCalculationTestCase _2sockets_48cores_latency_3 = { 1, false, 96, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, {{48, 48, 0, 0, -1, -1}, {24, 24, 0, 0, 0, 0}, {24, 24, 0, 0, 1, 1}}, @@ -753,6 +819,7 @@ StreamsCalculationTestCase _2sockets_48cores_tput_1 = { 0, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{48, 48, 0, 0, -1, -1}, {24, 24, 0, 0, 0, 0}, {24, 24, 0, 0, 1, 1}}, @@ -765,6 +832,7 @@ StreamsCalculationTestCase _2sockets_48cores_tput_2 = { 0, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{48, 48, 0, 0, -1, -1}, {24, 24, 0, 0, 0, 0}, {24, 24, 0, 0, 1, 1}}, @@ -777,6 +845,7 @@ StreamsCalculationTestCase _2sockets_48cores_tput_3 = { 100, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{48, 48, 0, 0, -1, -1}, {24, 24, 0, 0, 0, 0}, {24, 24, 0, 0, 1, 1}}, @@ -789,6 +858,7 @@ StreamsCalculationTestCase _2sockets_48cores_tput_4 = { 20, 0, 1, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{48, 48, 0, 0, -1, -1}, {24, 24, 0, 0, 0, 0}, {24, 24, 0, 0, 1, 1}}, @@ -801,6 +871,7 @@ StreamsCalculationTestCase _2sockets_20cores_tput_1 = { 0, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 20, 0, 0, -1, -1}, {10, 10, 0, 0, 0, 0}, {10, 10, 0, 0, 1, 1}}, @@ -813,6 +884,7 @@ StreamsCalculationTestCase _1sockets_14cores_latency_1 = { 0, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{14, 6, 8, 0, 0, 0}}, @@ -825,6 +897,7 @@ StreamsCalculationTestCase _1sockets_14cores_latency_2 = { 10, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, @@ -837,6 +910,7 @@ StreamsCalculationTestCase _1sockets_14cores_latency_3 = { 0, 0, 6, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, @@ -849,6 +923,7 @@ StreamsCalculationTestCase _1sockets_14cores_latency_4 = { 0, 0, 14, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, @@ -864,6 +939,7 @@ StreamsCalculationTestCase _1sockets_14cores_latency_5 = { 0, 2, 14, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, @@ -879,6 +955,7 @@ StreamsCalculationTestCase _1sockets_14cores_latency_6 = { 0, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, @@ -894,6 +971,7 @@ StreamsCalculationTestCase _1sockets_14cores_latency_7 = { 0, 0, 6, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{14, 6, 8, 0, 0, 0}}, @@ -906,6 +984,7 @@ StreamsCalculationTestCase _1sockets_14cores_latency_8 = { 0, 0, 14, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{14, 6, 8, 0, 0, 0}}, @@ -918,6 +997,7 @@ StreamsCalculationTestCase _1sockets_14cores_latency_9 = { 0, 2, 14, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{14, 6, 8, 0, 0, 0}}, @@ -930,6 +1010,7 @@ StreamsCalculationTestCase _1sockets_14cores_latency_10 = { 0, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{14, 6, 8, 0, 0, 0}}, @@ -942,6 +1023,7 @@ StreamsCalculationTestCase _1sockets_14cores_latency_11 = { 10, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, @@ -954,6 +1036,7 @@ StreamsCalculationTestCase _1sockets_14cores_latency_12 = { 0, 0, 6, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, @@ -966,6 +1049,7 @@ StreamsCalculationTestCase _1sockets_14cores_latency_13 = { 0, 0, 14, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, @@ -981,6 +1065,7 @@ StreamsCalculationTestCase _1sockets_14cores_latency_14 = { 0, 2, 14, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, @@ -996,6 +1081,7 @@ StreamsCalculationTestCase _1sockets_14cores_latency_15 = { 0, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, @@ -1011,6 +1097,7 @@ StreamsCalculationTestCase _1sockets_14cores_latency_16 = { 0, 0, 6, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{14, 6, 8, 0, 0, 0}}, @@ -1023,6 +1110,7 @@ StreamsCalculationTestCase _1sockets_14cores_latency_17 = { 0, 0, 14, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{14, 6, 8, 0, 0, 0}}, @@ -1035,6 +1123,7 @@ StreamsCalculationTestCase _1sockets_14cores_latency_18 = { 0, 2, 14, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{14, 6, 8, 0, 0, 0}}, @@ -1047,6 +1136,7 @@ StreamsCalculationTestCase _1sockets_14cores_tput_1 = { 0, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, @@ -1059,6 +1149,7 @@ StreamsCalculationTestCase _1sockets_14cores_tput_2 = { 0, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, @@ -1071,6 +1162,7 @@ StreamsCalculationTestCase _1sockets_14cores_tput_3 = { 0, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, @@ -1083,6 +1175,7 @@ StreamsCalculationTestCase _1sockets_14cores_tput_4 = { 12, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, @@ -1095,6 +1188,7 @@ StreamsCalculationTestCase _1sockets_14cores_tput_5 = { 0, 0, 1, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, @@ -1107,6 +1201,7 @@ StreamsCalculationTestCase _1sockets_14cores_tput_6 = { 0, 0, 2, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, @@ -1119,6 +1214,7 @@ StreamsCalculationTestCase _1sockets_14cores_tput_7 = { 0, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, @@ -1131,6 +1227,7 @@ StreamsCalculationTestCase _1sockets_14cores_tput_8 = { 100, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, @@ -1143,6 +1240,7 @@ StreamsCalculationTestCase _1sockets_14cores_tput_9 = { 0, 8, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, @@ -1155,6 +1253,7 @@ StreamsCalculationTestCase _1sockets_14cores_tput_10 = { 0, 4, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, @@ -1167,6 +1266,7 @@ StreamsCalculationTestCase _1sockets_14cores_tput_11 = { 0, 2, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, @@ -1179,6 +1279,7 @@ StreamsCalculationTestCase _1sockets_14cores_tput_12 = { 0, 2, 2, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, @@ -1191,6 +1292,7 @@ StreamsCalculationTestCase _1sockets_14cores_tput_13 = { 1, 0, 1, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, @@ -1203,6 +1305,7 @@ StreamsCalculationTestCase _1sockets_14cores_tput_14 = { 9, 0, 1, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, @@ -1215,6 +1318,7 @@ StreamsCalculationTestCase _1sockets_14cores_tput_15 = { 12, 0, 1, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, @@ -1227,6 +1331,7 @@ StreamsCalculationTestCase _1sockets_14cores_tput_16 = { 15, 0, 1, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, @@ -1239,6 +1344,7 @@ StreamsCalculationTestCase _1sockets_14cores_tput_17 = { 14, 0, 6, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 8, 6, 0, 0}}, @@ -1251,6 +1357,7 @@ StreamsCalculationTestCase _1sockets_10cores_latency_1 = { 0, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 2, 8, 2, 0, 0}}, @@ -1266,6 +1373,7 @@ StreamsCalculationTestCase _1sockets_10cores_latency_2 = { 8, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 2, 8, 2, 0, 0}}, @@ -1278,6 +1386,7 @@ StreamsCalculationTestCase _1sockets_10cores_latency_3 = { 0, 0, 2, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 2, 8, 2, 0, 0}}, @@ -1290,6 +1399,7 @@ StreamsCalculationTestCase _1sockets_10cores_latency_4 = { 0, 0, 10, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 2, 8, 2, 0, 0}}, @@ -1305,6 +1415,7 @@ StreamsCalculationTestCase _1sockets_10cores_latency_5 = { 0, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{10, 2, 8, 0, 0, 0}}, @@ -1317,6 +1428,7 @@ StreamsCalculationTestCase _1sockets_10cores_latency_6 = { 0, 0, 2, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{10, 2, 8, 0, 0, 0}}, @@ -1329,6 +1441,7 @@ StreamsCalculationTestCase _1sockets_10cores_latency_7 = { 0, 0, 10, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{10, 2, 8, 0, 0, 0}}, @@ -1341,6 +1454,7 @@ StreamsCalculationTestCase _1sockets_10cores_tput_1 = { 0, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 2, 8, 2, 0, 0}}, @@ -1353,6 +1467,7 @@ StreamsCalculationTestCase _1sockets_10cores_tput_2 = { 0, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 2, 8, 2, 0, 0}}, @@ -1365,6 +1480,7 @@ StreamsCalculationTestCase _1sockets_10cores_tput_3 = { 0, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 2, 8, 2, 0, 0}}, @@ -1377,6 +1493,7 @@ StreamsCalculationTestCase _1sockets_10cores_tput_4 = { 6, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 2, 8, 2, 0, 0}}, @@ -1389,6 +1506,7 @@ StreamsCalculationTestCase _1sockets_10cores_tput_5 = { 0, 0, 1, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 2, 8, 2, 0, 0}}, @@ -1401,6 +1519,7 @@ StreamsCalculationTestCase _1sockets_10cores_tput_6 = { 0, 0, 2, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 2, 8, 2, 0, 0}}, @@ -1413,6 +1532,7 @@ StreamsCalculationTestCase _1sockets_8cores_latency_1 = { 0, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 4, 4, 4, 0, 0}}, @@ -1428,6 +1548,7 @@ StreamsCalculationTestCase _1sockets_8cores_latency_2 = { 100, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 4, 4, 4, 0, 0}}, @@ -1443,6 +1564,7 @@ StreamsCalculationTestCase _1sockets_8cores_latency_3 = { 0, 0, 4, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 4, 4, 4, 0, 0}}, @@ -1455,6 +1577,7 @@ StreamsCalculationTestCase _1sockets_8cores_latency_4 = { 0, 0, 8, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 4, 4, 4, 0, 0}}, @@ -1470,6 +1593,7 @@ StreamsCalculationTestCase _1sockets_8cores_latency_5 = { 0, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{8, 4, 4, 0, 0, 0}}, @@ -1482,6 +1606,7 @@ StreamsCalculationTestCase _1sockets_8cores_latency_6 = { 0, 0, 4, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{8, 4, 4, 0, 0, 0}}, @@ -1494,6 +1619,7 @@ StreamsCalculationTestCase _1sockets_8cores_latency_7 = { 0, 0, 8, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{8, 4, 4, 0, 0, 0}}, @@ -1506,6 +1632,7 @@ StreamsCalculationTestCase _1sockets_8cores_tput_1 = { 0, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 4, 4, 4, 0, 0}}, @@ -1518,6 +1645,7 @@ StreamsCalculationTestCase _1sockets_8cores_tput_2 = { 0, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 4, 4, 4, 0, 0}}, @@ -1530,6 +1658,7 @@ StreamsCalculationTestCase _1sockets_8cores_tput_3 = { 0, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 4, 4, 4, 0, 0}}, @@ -1542,6 +1671,7 @@ StreamsCalculationTestCase _1sockets_8cores_tput_4 = { 0, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 4, 4, 4, 0, 0}}, @@ -1554,6 +1684,7 @@ StreamsCalculationTestCase _1sockets_8cores_tput_5 = { 6, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 4, 4, 4, 0, 0}}, @@ -1566,6 +1697,7 @@ StreamsCalculationTestCase _1sockets_8cores_tput_6 = { 8, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 4, 4, 4, 0, 0}}, @@ -1578,6 +1710,7 @@ StreamsCalculationTestCase _1sockets_8cores_tput_7 = { 0, 0, 1, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 4, 4, 4, 0, 0}}, @@ -1590,6 +1723,7 @@ StreamsCalculationTestCase _1sockets_8cores_tput_8 = { 0, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{8, 4, 4, 0, 0, 0}}, @@ -1602,6 +1736,7 @@ StreamsCalculationTestCase _1sockets_6cores_latency_1 = { 0, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 6, 0, 6, 0, 0}}, @@ -1614,6 +1749,7 @@ StreamsCalculationTestCase _1sockets_6cores_latency_2 = { 100, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 6, 0, 6, 0, 0}}, @@ -1626,6 +1762,7 @@ StreamsCalculationTestCase _1sockets_6cores_latency_3 = { 0, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{6, 6, 0, 0, 0, 0}}, @@ -1638,6 +1775,7 @@ StreamsCalculationTestCase _1sockets_6cores_tput_1 = { 0, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 6, 0, 6, 0, 0}}, @@ -1650,6 +1788,7 @@ StreamsCalculationTestCase _1sockets_6cores_tput_2 = { 0, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 6, 0, 6, 0, 0}}, @@ -1662,6 +1801,7 @@ StreamsCalculationTestCase _1sockets_6cores_tput_3 = { 8, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 6, 0, 6, 0, 0}}, @@ -1674,6 +1814,7 @@ StreamsCalculationTestCase _1sockets_6cores_tput_4 = { 0, 0, 1, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{12, 6, 0, 6, 0, 0}}, @@ -1686,6 +1827,7 @@ StreamsCalculationTestCase _1sockets_ecores_latency_1 = { 0, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{16, 0, 16, 0, 0, 0}}, @@ -1698,6 +1840,7 @@ StreamsCalculationTestCase _1sockets_ecores_latency_2 = { 4, 0, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{16, 0, 16, 0, 0, 0}}, @@ -1710,6 +1853,7 @@ StreamsCalculationTestCase _1sockets_ecores_latency_3 = { 0, 4, 0, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{16, 0, 16, 0, 0, 0}}, @@ -1722,6 +1866,7 @@ StreamsCalculationTestCase _1sockets_ecores_latency_4 = { 0, 0, 4, + 0, "LATENCY", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{16, 0, 16, 0, 0, 0}}, @@ -1734,6 +1879,7 @@ StreamsCalculationTestCase _1sockets_ecores_tput_1 = { 0, 0, 1, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{16, 0, 16, 0, 0, 0}}, @@ -1746,6 +1892,7 @@ StreamsCalculationTestCase _1sockets_ecores_tput_2 = { 0, 0, 4, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{16, 0, 16, 0, 0, 0}}, @@ -1758,6 +1905,7 @@ StreamsCalculationTestCase _1sockets_ecores_tput_3 = { 0, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{16, 0, 16, 0, 0, 0}}, @@ -1770,6 +1918,7 @@ StreamsCalculationTestCase _1sockets_ecores_tput_4 = { 0, 4, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{16, 0, 16, 0, 0, 0}}, @@ -1782,6 +1931,7 @@ StreamsCalculationTestCase _1sockets_ecores_tput_5 = { 0, 0, 4, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{16, 0, 16, 0, 0, 0}}, @@ -1794,6 +1944,7 @@ StreamsCalculationTestCase _1sockets_mock_tput_1 = { 15, 0, 1, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{20, 6, 7, 6, 0, 0}}, @@ -1806,6 +1957,7 @@ StreamsCalculationTestCase _1sockets_mock_tput_2 = { 0, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{27, 27, 0, 0, -1, -1}, {19, 19, 0, 0, 0, 0}, {8, 8, 0, 0, 1, 1}}, @@ -1818,11 +1970,322 @@ StreamsCalculationTestCase _1sockets_mock_tput_3 = { 0, 0, 0, + 0, "THROUGHPUT", ov::intel_cpu::Config::LatencyThreadingMode::PER_PLATFORM, {{19, 19, 0, 0, -1, -1}, {11, 11, 0, 0, 0, 0}, {8, 8, 0, 0, 1, 1}}, {{5, MAIN_CORE_PROC, 2, 0, 0}, {4, MAIN_CORE_PROC, 2, 1, 1}}, }; +StreamsCalculationTestCase _2sockets_mock_latency_1 = { + 1, + false, + 20, + 0, + 0, + 0, + "LATENCY", + ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, + {{60, 60, 0, 0, -1, -1}, {10, 10, 0, 0, 0, 0}, {20, 20, 0, 0, 1, 0}, {10, 10, 0, 0, 2, 1}, {20, 20, 0, 0, 3, 1}}, + {{1, MAIN_CORE_PROC, 20, 1, 0}}, +}; +StreamsCalculationTestCase _2sockets_mock_latency_2 = { + 1, + false, + 0, + 0, + 0, + 1, + "LATENCY", + ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, + {{60, 60, 0, 0, -1, -1}, {40, 40, 0, 0, 0, 0}, {20, 20, 0, 0, 1, 1}}, + {{1, MAIN_CORE_PROC, 20, 1, 1}}, +}; +StreamsCalculationTestCase _2sockets_mock_latency_3 = { + 1, + true, + 0, + 0, + 0, + 1, + "THROUGHPUT", + ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, + {{60, 60, 0, 0, -1, -1}, {40, 40, 0, 0, 0, 0}, {20, 20, 0, 0, 1, 1}}, + {{1, MAIN_CORE_PROC, 20, 1, 1}}, +}; +StreamsCalculationTestCase _2sockets_mock_latency_4 = { + 1, + false, + 10, + 0, + 0, + 1, + "LATENCY", + ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, + {{60, 60, 0, 0, -1, -1}, {40, 40, 0, 0, 0, 0}, {20, 20, 0, 0, 1, 1}}, + {{1, MAIN_CORE_PROC, 10, 1, 1}}, +}; +StreamsCalculationTestCase _2sockets_mock_latency_5 = { + 1, + false, + 50, + 0, + 0, + 1, + "LATENCY", + ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, + {{60, 60, 0, 0, -1, -1}, {40, 40, 0, 0, 0, 0}, {20, 20, 0, 0, 1, 1}}, + {{1, ALL_PROC, 50, -1, -1}, {0, MAIN_CORE_PROC, 20, 1, 1}, {0, MAIN_CORE_PROC, 30, 0, 0}}, +}; +StreamsCalculationTestCase _2sockets_mock_latency_6 = { + 1, + false, + 0, + 0, + 0, + 1, + "LATENCY", + ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, + {{60, 0, 60, 0, -1, -1}, {40, 0, 40, 0, 0, 0}, {20, 0, 20, 0, 1, 1}}, + {{1, EFFICIENT_CORE_PROC, 20, 1, 1}}, +}; +StreamsCalculationTestCase _2sockets_mock_latency_7 = { + 1, + true, + 0, + 0, + 0, + 1, + "THROUGHPUT", + ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, + {{60, 0, 60, 0, -1, -1}, {40, 0, 40, 0, 0, 0}, {20, 0, 20, 0, 1, 1}}, + {{1, EFFICIENT_CORE_PROC, 20, 1, 1}}, +}; +StreamsCalculationTestCase _2sockets_mock_latency_8 = { + 1, + false, + 10, + 0, + 0, + 1, + "LATENCY", + ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, + {{60, 0, 60, 0, -1, -1}, {40, 0, 40, 0, 0, 0}, {20, 0, 20, 0, 1, 1}}, + {{1, EFFICIENT_CORE_PROC, 10, 1, 1}}, +}; +StreamsCalculationTestCase _2sockets_mock_latency_9 = { + 1, + false, + 50, + 0, + 0, + 1, + "LATENCY", + ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, + {{60, 0, 60, 0, -1, -1}, {40, 0, 40, 0, 0, 0}, {20, 0, 20, 0, 1, 1}}, + {{1, ALL_PROC, 50, -1, -1}, {0, EFFICIENT_CORE_PROC, 20, 1, 1}, {0, EFFICIENT_CORE_PROC, 30, 0, 0}}, +}; +StreamsCalculationTestCase _2sockets_mock_latency_10 = { + 1, + false, + 0, + 0, + 0, + 1, + "LATENCY", + ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, + {{60, 30, 0, 30, -1, -1}, {40, 20, 0, 20, 0, 0}, {20, 10, 0, 10, 1, 1}}, + {{1, ALL_PROC, 20, 1, 1}, {0, MAIN_CORE_PROC, 10, 1, 1}, {0, HYPER_THREADING_PROC, 10, 1, 1}}, +}; +StreamsCalculationTestCase _2sockets_mock_latency_11 = { + 1, + true, + 0, + 0, + 0, + 1, + "THROUGHPUT", + ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, + {{60, 30, 0, 30, -1, -1}, {40, 20, 0, 20, 0, 0}, {20, 10, 0, 10, 1, 1}}, + {{1, ALL_PROC, 20, 1, 1}, {0, MAIN_CORE_PROC, 10, 1, 1}, {0, HYPER_THREADING_PROC, 10, 1, 1}}, +}; +StreamsCalculationTestCase _2sockets_mock_latency_12 = { + 1, + false, + 15, + 0, + 0, + 1, + "LATENCY", + ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, + {{60, 30, 0, 30, -1, -1}, {40, 20, 0, 20, 0, 0}, {20, 10, 0, 10, 1, 1}}, + {{1, ALL_PROC, 15, 1, 1}, {0, MAIN_CORE_PROC, 10, 1, 1}, {0, HYPER_THREADING_PROC, 5, 1, 1}}, +}; +StreamsCalculationTestCase _2sockets_mock_latency_13 = { + 1, + false, + 50, + 0, + 0, + 1, + "LATENCY", + ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, + {{60, 30, 0, 30, -1, -1}, {40, 20, 0, 20, 0, 0}, {20, 10, 0, 10, 1, 1}}, + {{1, ALL_PROC, 50, -1, -1}, + {0, MAIN_CORE_PROC, 10, 1, 1}, + {0, HYPER_THREADING_PROC, 10, 1, 1}, + {0, MAIN_CORE_PROC, 20, 0, 0}, + {0, HYPER_THREADING_PROC, 10, 0, 0}}, +}; +StreamsCalculationTestCase _2sockets_mock_latency_14 = { + 1, + false, + 0, + 0, + 0, + 3, + "LATENCY", + ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, + {{200, 100, 0, 100, -1, -1}, + {80, 40, 0, 40, 0, 0}, + {60, 30, 0, 30, 1, 1}, + {40, 20, 0, 20, 2, 2}, + {20, 10, 0, 10, 3, 3}}, + {{1, ALL_PROC, 20, 3, 3}, {0, MAIN_CORE_PROC, 10, 3, 3}, {0, HYPER_THREADING_PROC, 10, 3, 3}}, +}; +StreamsCalculationTestCase _2sockets_mock_latency_15 = { + 1, + true, + 0, + 0, + 0, + 3, + "THROUGHPUT", + ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, + {{200, 100, 0, 100, -1, -1}, + {80, 40, 0, 40, 0, 0}, + {60, 30, 0, 30, 1, 1}, + {40, 20, 0, 20, 2, 2}, + {20, 10, 0, 10, 3, 3}}, + {{1, ALL_PROC, 20, 3, 3}, {0, MAIN_CORE_PROC, 10, 3, 3}, {0, HYPER_THREADING_PROC, 10, 3, 3}}, +}; +StreamsCalculationTestCase _2sockets_mock_latency_16 = { + 1, + false, + 15, + 0, + 0, + 3, + "LATENCY", + ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, + {{200, 100, 0, 100, -1, -1}, + {80, 40, 0, 40, 0, 0}, + {60, 30, 0, 30, 1, 1}, + {40, 20, 0, 20, 2, 2}, + {20, 10, 0, 10, 3, 3}}, + {{1, ALL_PROC, 15, 3, 3}, {0, MAIN_CORE_PROC, 10, 3, 3}, {0, HYPER_THREADING_PROC, 5, 3, 3}}, +}; +StreamsCalculationTestCase _2sockets_mock_latency_17 = { + 1, + false, + 50, + 0, + 0, + 3, + "LATENCY", + ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, + {{200, 100, 0, 100, -1, -1}, + {80, 40, 0, 40, 0, 0}, + {60, 30, 0, 30, 1, 1}, + {40, 20, 0, 20, 2, 2}, + {20, 10, 0, 10, 3, 3}}, + {{1, ALL_PROC, 50, -1, -1}, + {0, MAIN_CORE_PROC, 10, 3, 3}, + {0, HYPER_THREADING_PROC, 10, 3, 3}, + {0, MAIN_CORE_PROC, 30, 0, 0}}, +}; +StreamsCalculationTestCase _2sockets_mock_latency_18 = { + 1, + false, + 0, + 0, + 0, + 6, + "LATENCY", + ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, + {{440, 220, 0, 220, -1, -1}, + {90, 45, 0, 45, 0, 0}, + {70, 35, 0, 35, 1, 1}, + {50, 25, 0, 25, 2, 2}, + {30, 15, 0, 15, 3, 3}, + {80, 40, 0, 40, 4, 4}, + {60, 30, 0, 30, 5, 5}, + {40, 20, 0, 20, 6, 6}, + {20, 10, 0, 10, 7, 7}}, + {{1, ALL_PROC, 40, 6, 6}, {0, MAIN_CORE_PROC, 20, 6, 6}, {0, HYPER_THREADING_PROC, 20, 6, 6}}, +}; +StreamsCalculationTestCase _2sockets_mock_latency_19 = { + 1, + true, + 0, + 0, + 0, + 6, + "THROUGHPUT", + ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, + {{440, 220, 0, 220, -1, -1}, + {90, 45, 0, 45, 0, 0}, + {70, 35, 0, 35, 1, 1}, + {50, 25, 0, 25, 2, 2}, + {30, 15, 0, 15, 3, 3}, + {80, 40, 0, 40, 4, 4}, + {60, 30, 0, 30, 5, 5}, + {40, 20, 0, 20, 6, 6}, + {20, 10, 0, 10, 7, 7}}, + {{1, ALL_PROC, 40, 6, 6}, {0, MAIN_CORE_PROC, 20, 6, 6}, {0, HYPER_THREADING_PROC, 20, 6, 6}}, +}; +StreamsCalculationTestCase _2sockets_mock_latency_20 = { + 1, + false, + 25, + 0, + 0, + 6, + "LATENCY", + ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, + {{440, 220, 0, 220, -1, -1}, + {90, 45, 0, 45, 0, 0}, + {70, 35, 0, 35, 1, 1}, + {50, 25, 0, 25, 2, 2}, + {30, 15, 0, 15, 3, 3}, + {80, 40, 0, 40, 4, 4}, + {60, 30, 0, 30, 5, 5}, + {40, 20, 0, 20, 6, 6}, + {20, 10, 0, 10, 7, 7}}, + {{1, ALL_PROC, 25, 6, 6}, {0, MAIN_CORE_PROC, 20, 6, 6}, {0, HYPER_THREADING_PROC, 5, 6, 6}}, +}; +StreamsCalculationTestCase _2sockets_mock_latency_21 = { + 1, + false, + 50, + 0, + 0, + 6, + "LATENCY", + ov::intel_cpu::Config::LatencyThreadingMode::PER_SOCKET, + {{440, 220, 0, 220, -1, -1}, + {90, 45, 0, 45, 0, 0}, + {70, 35, 0, 35, 1, 1}, + {50, 25, 0, 25, 2, 2}, + {30, 15, 0, 15, 3, 3}, + {80, 40, 0, 40, 4, 4}, + {60, 30, 0, 30, 5, 5}, + {40, 20, 0, 20, 6, 6}, + {20, 10, 0, 10, 7, 7}}, + {{1, ALL_PROC, 50, -1, -1}, + {0, MAIN_CORE_PROC, 20, 6, 6}, + {0, HYPER_THREADING_PROC, 20, 6, 6}, + {0, MAIN_CORE_PROC, 10, 0, 0}}, +}; TEST_P(StreamsCalculationTests, StreamsCalculation) {} @@ -1880,6 +2343,7 @@ INSTANTIATE_TEST_SUITE_P(StreamsInfoTable, _2sockets_104cores_tput_20, _2sockets_48cores_latency_1, _2sockets_48cores_latency_2, + _2sockets_48cores_latency_3, _2sockets_48cores_tput_1, _2sockets_48cores_tput_2, _2sockets_48cores_tput_3, @@ -1966,6 +2430,27 @@ INSTANTIATE_TEST_SUITE_P(StreamsInfoTable, _1sockets_ecores_tput_5, _1sockets_mock_tput_1, _1sockets_mock_tput_2, - _1sockets_mock_tput_3)); + _1sockets_mock_tput_3, + _2sockets_mock_latency_1, + _2sockets_mock_latency_2, + _2sockets_mock_latency_3, + _2sockets_mock_latency_4, + _2sockets_mock_latency_5, + _2sockets_mock_latency_6, + _2sockets_mock_latency_7, + _2sockets_mock_latency_8, + _2sockets_mock_latency_9, + _2sockets_mock_latency_10, + _2sockets_mock_latency_11, + _2sockets_mock_latency_12, + _2sockets_mock_latency_13, + _2sockets_mock_latency_14, + _2sockets_mock_latency_15, + _2sockets_mock_latency_16, + _2sockets_mock_latency_17, + _2sockets_mock_latency_18, + _2sockets_mock_latency_19, + _2sockets_mock_latency_20, + _2sockets_mock_latency_21)); } // namespace \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/unit/transformations/state_concat_sdpa.cpp b/src/plugins/intel_cpu/tests/unit/transformations/state_concat_sdpa.cpp index ffa562ba4d86a1..df38e268068deb 100644 --- a/src/plugins/intel_cpu/tests/unit/transformations/state_concat_sdpa.cpp +++ b/src/plugins/intel_cpu/tests/unit/transformations/state_concat_sdpa.cpp @@ -13,25 +13,32 @@ #include #include #include -#include +#include #include "common_test_utils/ov_test_utils.hpp" +#include "utils/gen_pattern.hpp" +#include "utils/print_model.hpp" using namespace testing; -using namespace ov::intel_cpu; using namespace ov; +using namespace ov::intel_cpu; +using namespace ov::gen_pattern; -static std::shared_ptr makeSDPA(const ov::PartialShape& inputShape, bool isRef = false, bool hasConvert = false) { +static std::shared_ptr makeSDPA(const ov::PartialShape& inputShape, bool isRef = false, bool hasConvert = false, bool hasMultiquery = false) { auto q = std::make_shared(element::f32, inputShape); - auto k = std::make_shared(element::f32, inputShape); - auto v = std::make_shared(element::f32, inputShape); + auto kvInputShape = inputShape; + if (hasMultiquery) { + kvInputShape[1] = inputShape[1] / 4; + } + auto k = std::make_shared(element::f32, kvInputShape); + auto v = std::make_shared(element::f32, kvInputShape); auto init = std::make_shared(element::f32, inputShape); auto beam_idx = std::make_shared(element::i32, ov::PartialShape{-1}); auto var_k = std::make_shared( - ov::op::util::VariableInfo{inputShape, element::f32, "pastk"}); + ov::op::util::VariableInfo{kvInputShape, element::f32, "pastk"}); std::shared_ptr pastk = std::make_shared(k, var_k); auto var_v = std::make_shared( - ov::op::util::VariableInfo{inputShape, element::f32, "pastv"}); + ov::op::util::VariableInfo{kvInputShape, element::f32, "pastv"}); std::shared_ptr pastv = std::make_shared(v, var_v); Output concatK, concatV, sdp; if (hasConvert) { @@ -50,7 +57,31 @@ static std::shared_ptr makeSDPA(const ov::PartialShape& inputShape, b pastv = std::make_shared(pastv, beam_idx, op::v0::Constant::create(element::i32, {1}, {0})); concatK = std::make_shared(OutputVector{pastk, k}, 2); concatV = std::make_shared(OutputVector{pastv, v}, 2); - sdp = std::make_shared(q, concatK, concatV, false); + if (hasMultiquery) { + auto make_multi_query = [&] (const Output& conat) { + auto beam_idx_shape = makeOP>({beam_idx}, + {{"type_relax", true}, {"input_data_types", {}}, {"output_data_types", {element::i32}}}); + auto unsqueeze_concat = makeOP({conat, 2}); + auto concat_shape = makeOP>( + {conat}, + {{"type_relax", true}, {"input_data_types", {}}, {"output_data_types", {element::i32}}}); + auto gather_ls = makeOP({concat_shape, {2, 3}, 0}, {{"batch_dims", 0}}); + auto expected_group_shape = makeOP({beam_idx_shape, {inputShape[1] / 4}, {4}, gather_ls}, {{"axis", 0}}); + auto expand_Abs = makeOP({expected_group_shape}); + auto axis_mapping = makeConst(element::u8, ov::Shape({}), 0); + auto expand_ones = makeOP({{1.0f}, + expand_Abs, + axis_mapping}, {{"mode", "numpy"}}); + auto expand_Broadcast = makeOP({unsqueeze_concat, + expand_ones}, {{"auto_broadcast", "numpy"}}); + auto expected_shape = makeOP({beam_idx_shape, {inputShape[1]}, gather_ls}, {{"axis", 0}}); + auto reshape_Reshape = makeOP({expand_Broadcast, expected_shape}, {{"special_zero", false}}); + return reshape_Reshape; + }; + sdp = std::make_shared(q, make_multi_query(concatK), make_multi_query(concatV), false); + } else { + sdp = std::make_shared(q, concatK, concatV, false); + } } if (hasConvert) { concatK = std::make_shared(concatK, element::f32); @@ -106,3 +137,24 @@ TEST(TransformationTests, StateConcatSDPAWithConvert) { ASSERT_TRUE(res.first) << res.second; } } + +TEST(TransformationTests, StateConcatSDPAMixtral) { + std::shared_ptr f(nullptr), f_ref(nullptr); + { + using namespace ov; + auto inputShape = ov::PartialShape{-1, 32, -1, 64}; + { + f = makeSDPA(inputShape, false, false, true); + pass::Manager m; + m.register_pass(); + m.register_pass(); + m.run_passes(f); + } + //construct ref interaction + { + f_ref = makeSDPA(inputShape, true, false, true); + } + auto res = compare_functions(f, f_ref); + ASSERT_TRUE(res.first) << res.second; + } +} diff --git a/src/plugins/intel_cpu/tests/unit/transformations/x64/convert_to_interaction.cpp b/src/plugins/intel_cpu/tests/unit/transformations/x64/convert_to_interaction.cpp index 13b8bba7f848f8..9aab52c866c1f1 100644 --- a/src/plugins/intel_cpu/tests/unit/transformations/x64/convert_to_interaction.cpp +++ b/src/plugins/intel_cpu/tests/unit/transformations/x64/convert_to_interaction.cpp @@ -17,7 +17,6 @@ #include #include #include "ov_ops/type_relaxed.hpp" -#include #include "common_test_utils/ov_test_utils.hpp" diff --git a/src/plugins/intel_cpu/thirdparty/onednn b/src/plugins/intel_cpu/thirdparty/onednn index c28d7021d63e93..19bb9f2d95ea5e 160000 --- a/src/plugins/intel_cpu/thirdparty/onednn +++ b/src/plugins/intel_cpu/thirdparty/onednn @@ -1 +1 @@ -Subproject commit c28d7021d63e93c470efc7b1a2c85b14da349ba4 +Subproject commit 19bb9f2d95ea5eca877dbf68334aaf49d24b5b4d diff --git a/src/plugins/intel_cpu/tools/commit_slider/commit_slider.py b/src/plugins/intel_cpu/tools/commit_slider/commit_slider.py index efea2c39856429..632bfed3e52e1f 100644 --- a/src/plugins/intel_cpu/tools/commit_slider/commit_slider.py +++ b/src/plugins/intel_cpu/tools/commit_slider/commit_slider.py @@ -1,20 +1,27 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + import subprocess import os import shutil import sys -from shutil import copytree +from distutils.dir_util import copy_tree from utils.helpers import safeClearDir, getParams args, cfgData, customCfgPath = getParams() -if args.__dict__["isWorkingDir"]: +if args.utility != "no_utility": + from utils.helpers import runUtility + runUtility(cfgData, args) + +elif args.isWorkingDir: # rerun script from work directory from utils.modes import Mode from utils.helpers import CfgError from utils.helpers import checkArgAndGetCommits commitList = [] - if args.__dict__["commitSeq"] is None: + if args.commitSeq is None: if "getCommitListCmd" in cfgData["runConfig"]["commitList"]: commitListCmd = cfgData["runConfig"]["commitList"] commitListCmd = commitListCmd["getCommitListCmd"] @@ -31,7 +38,7 @@ else: raise CfgError("Commit list is mandatory") else: - commitList = checkArgAndGetCommits(args.__dict__["commitSeq"], cfgData) + commitList = checkArgAndGetCommits(args.commitSeq, cfgData) commitList.reverse() p = Mode.factory(cfgData) @@ -45,7 +52,7 @@ else: safeClearDir(workPath, cfgData) curPath = os.getcwd() - copytree(curPath, workPath) + copy_tree(curPath, workPath) scriptName = os.path.basename(__file__) argString = " ".join(sys.argv) formattedCmd = "{py} {workPath}/{argString} -wd".format( @@ -57,16 +64,21 @@ tempLogPath = cfgData["logPath"].format(workPath=workPath) permLogPath = cfgData["logPath"].format(workPath=curPath) safeClearDir(permLogPath, cfgData) - copytree(tempLogPath, permLogPath) + copy_tree(tempLogPath, permLogPath) tempCachePath = cfgData["cachePath"].format(workPath=workPath) permCachePath = cfgData["cachePath"].format(workPath=curPath) safeClearDir(permCachePath, cfgData) - copytree(tempCachePath, permCachePath) + copy_tree(tempCachePath, permCachePath) + + try: + shutil.copyfile( + os.path.join(workPath, customCfgPath), + os.path.join(curPath, customCfgPath), + follow_symlinks=True, + ) + except shutil.SameFileError: + # prevent exception raising if cfg set up from outer location + pass - shutil.copyfile( - os.path.join(workPath, customCfgPath), - os.path.join(curPath, customCfgPath), - follow_symlinks=True, - ) safeClearDir(workPath, cfgData) diff --git a/src/plugins/intel_cpu/tools/commit_slider/tests/__init__.py b/src/plugins/intel_cpu/tools/commit_slider/tests/__init__.py new file mode 100644 index 00000000000000..e1fb161f858720 --- /dev/null +++ b/src/plugins/intel_cpu/tools/commit_slider/tests/__init__.py @@ -0,0 +1,10 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + + +skip_commit_slider_devtest = pytest.mark.skip( + reason="Test is used to check stability of commit_slider after development changes" + "and does not suppose regular checks.") + diff --git a/src/plugins/intel_cpu/tools/commit_slider/tests/commit_slider_test.py b/src/plugins/intel_cpu/tools/commit_slider/tests/commit_slider_test.py new file mode 100644 index 00000000000000..3b7b86077f1330 --- /dev/null +++ b/src/plugins/intel_cpu/tools/commit_slider/tests/commit_slider_test.py @@ -0,0 +1,29 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import sys +from unittest import TestCase +from tests import skip_commit_slider_devtest + +sys.path.append('./') +from test_util import getExpectedCommit +from test_util import getActualCommit +from test_data import TestData + + +class CommitSliderTest(TestCase): + @skip_commit_slider_devtest + def testFirstValidVersion(self): + breakCommit, updatedData = getExpectedCommit( + TestData(TestData.TestCase.FirstValidVersion)) + actualCommit = getActualCommit(updatedData) + + self.assertEqual(breakCommit, actualCommit) + + @skip_commit_slider_devtest + def testFirstBadVersion(self): + breakCommit, updatedData = getExpectedCommit( + TestData(TestData.TestCase.FirstBadVersion)) + actualCommit = getActualCommit(updatedData) + + self.assertEqual(breakCommit, actualCommit) diff --git a/src/plugins/intel_cpu/tools/commit_slider/tests/test_data.py b/src/plugins/intel_cpu/tools/commit_slider/tests/test_data.py new file mode 100644 index 00000000000000..90ee2f90bc8e57 --- /dev/null +++ b/src/plugins/intel_cpu/tools/commit_slider/tests/test_data.py @@ -0,0 +1,97 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +from enum import Enum +import json + +class TestData(): + __test__ = False + actualDataReceived = False # prevent slider running before config actualized + + def getTestCase(): + return TestData.TestCase.DeadTest + + def getTestName(): + raise NotImplementedError("getTestName() is not implemented") + + def fillActualData(self, markedVersionList): + # redefine for non trivial cases + self.start=markedVersionList[0]['commit'] + self.end=markedVersionList[-1]['commit'] + + def formatConfig(self, content): + # redefine for non trivial cases + return content.format( + appCmd="./{}".format(self.repoName), + appPath="tests/{}/build".format(self.repoName), + buildPath="tests/{}/build".format(self.repoName), + gitPath="tests/{}".format(self.repoName), + start=self.start, + end=self.end + ) + + @staticmethod + def checkTestSet(): + testCases = [td.getTestCase() for td in TestData.__subclasses__()] + if len(testCases) != len(set(testCases)): + raise TestError("Test cases don't differ correctly") + elif TestData.TestCase.DeadTest in testCases: + raise TestError("Test containing undefined getTestCase() found") + + @staticmethod + def getTestByCase(tc): + TestData.checkTestSet() + foundTest = [td for td in TestData.__subclasses__() + if td.getTestCase() == tc] + if not foundTest: + raise TestError("Test {} is not found".format(tc)) + return foundTest[0] + + @staticmethod + def factory(testCase): + return TestData.getTestByCase(testCase)(testCase) + + class TestCase(Enum): + DeadTest = 0, + FirstBadVersion = 1, + FirstValidVersion = 2 + + def __init__(self, testCase): + # mapping json to test data holder + with open("tests_res/tests_res.json") as cfgFile: + rsc = json.load(cfgFile) + self.testName = TestData.getTestByCase(testCase).getTestName() + self.commonRsc = rsc['CommonRes'] + [setattr(self, key, rsc[self.testName][key]) for key in [ + 'testCfg', 'patchedFile', 'repoName' + ]] + [setattr(self, key, self.commonRsc[key]) for key in [ + 'repoStructure', 'cachePath', 'logPath', + 'mainFile', 'repoPath' + ]] + self.patternPrefix = self.commonRsc['patchGeneratorPrefix'] + self.patternPostfix = self.commonRsc['patchGeneratorPostfix'] + self.pattern = "{pre}(.+?){post}".format( + pre=self.patternPrefix, + post=self.patternPostfix) + + +class FirstBadVersionData(TestData): + def getTestCase(): + return TestData.TestCase.FirstBadVersion + + def getTestName(): + return "FirstBadVersion" + + +class FirstValidVersion(TestData): + def getTestCase(): + return TestData.TestCase.FirstValidVersion + + def getTestName(): + return "FirstValidVersion" + + +class TestError(Exception): + __test__ = False + pass \ No newline at end of file diff --git a/src/plugins/intel_cpu/tools/commit_slider/tests/test_util.py b/src/plugins/intel_cpu/tools/commit_slider/tests/test_util.py new file mode 100644 index 00000000000000..54610ebcbfecc7 --- /dev/null +++ b/src/plugins/intel_cpu/tools/commit_slider/tests/test_util.py @@ -0,0 +1,187 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import os +import subprocess +import re +import json +import sys +import shutil +from os import path +from test_data import TestData +from test_data import TestError + +sys.path.append('../') +from utils.helpers import getMeaningfullCommitTail + +def getVersionList(td: TestData): + with open(td.patchedFile, 'r') as file: + data = file.read() + + # extract patch list + stats_re = re.compile(td.pattern, re.MULTILINE | re.DOTALL) + patchJSONList = stats_re.findall(data) + if not patchJSONList: + raise Exception("Wrong patchlist in {}".format(td.patchedFile)) + + patchJSONList = patchJSONList[0] + patchList = json.loads(patchJSONList) + prefixPos = re.search(td.patternPrefix, data, re.DOTALL).span()[0] + postfixPos = re.search(td.patternPostfix, data, re.DOTALL).span()[1] + + # apply patches and fill version list + versionList = [] + for patch in patchList: + state = 'EMPTY' + if 'state' in patch: + state = patch['state'] + sub = patch['str'] + newData = data[:prefixPos] + sub + "\n" + data[postfixPos + 1:] + newVersion = { + "content": newData, + "state": state, + "comment": patch['comment']} + versionList.append(newVersion) + + return versionList + + +def makeRepoContent(td: TestData): + fullPath = path.join(td.repoPath, td.repoName) + + td.repoStructure['files'] = formatJSON( + td.repoStructure['files'], + td, + lambda content: content.format( + repoName=td.repoName, + mainFile=td.mainFile) + ) + for file in td.repoStructure['files']: + filePath = path.join(fullPath, file['name']) + with open(filePath, "w") as textFile: + textFile.write(file['content']) + + for dir in td.repoStructure['dirs']: + dir = path.join(fullPath, dir) + if os.path.exists(dir): + shutil.rmtree(dir) + os.makedirs(dir) + +def runCmd(cmd, cwd, verbose=False): + if verbose: + print("run command: {}".format(cmd)) + + proc = subprocess.Popen( + cmd.split(), + cwd=cwd, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + encoding="utf-8",errors="replace" + ) + + output = [] + for line in proc.stdout: + if verbose: + sys.stdout.write(line) + output.append(line) + proc.wait() + proc.communicate() + return output + + +def formatJSON(content, td: TestData, formatLambda): + if isinstance(content, dict): + for k, value in content.items(): + content[k] = formatJSON(value, td, formatLambda) + elif isinstance(content, list): + for id, item in enumerate(content): + content[id] = formatJSON(item, td, formatLambda) + elif isinstance(content, str): + content = formatLambda(content) + else: + # bool or digit object + pass + return content + + +def createRepo(td: TestData): + repoName = td.repoName + repoPath = td.repoPath + repoPath = os.path.abspath(repoPath) + runCmd("mkdir {}".format(repoName), repoPath) + innerPath = path.join(repoPath, repoName) + runCmd("git init", innerPath) + + makeRepoContent(td) + + for file in td.repoStructure['files']: + cmd = "git add {}".format(file['name']) + runCmd(cmd, innerPath) + + return commitPatchList(getVersionList(td), innerPath, td.mainFile) + +def commitPatchList(versionList, innerPath, fileName): + markedVersionList = [] + + for version in versionList: + with open(path.join(innerPath, fileName), "w") as textFile: + textFile.write(version['content']) + + runCmd("git add {}".format(fileName), innerPath) + runCmd("git commit -m \"{}\"".format(version['comment']), innerPath) + hash = runCmd("git rev-parse HEAD", innerPath)[0] + + markedVersion = { + "commit": hash.strip(), + "state": version['state'], + "comment": version['comment'] + } + markedVersionList.append(markedVersion) + + return markedVersionList + + +def getExpectedCommit(td: TestData): + markedVersionList = createRepo(td) + breakCommit = markedVersionList[[ + i for i in range( + len(markedVersionList) + ) if markedVersionList[i]['state'] == 'BREAK'][0]]['commit'] + breakCommit = getMeaningfullCommitTail(breakCommit) + + td.fillActualData(markedVersionList) + td.actualDataReceived = True + + return breakCommit, td + +def getActualCommit(td: TestData): + if not td.actualDataReceived: + raise TestError("Running actual commit before expected.") + + # prepare config + cfg = formatJSON(td.testCfg, td, td.formatConfig) + testCfg = "test_cfg.json" + + with open(testCfg, "w+") as customCfg: + customCfg.truncate(0) + json.dump(cfg, customCfg) + customCfg.close() + + # run slider and check output + sliderOutput = runCmd( + "python3.8 commit_slider.py -cfg tests/{}".format(testCfg), + "../") + + sliderOutput = '\n'.join(map(str, sliderOutput)) + foundCommit = re.search( + "Break commit: (.*),", sliderOutput, flags=re.MULTILINE + ).group(1) + + # clear temp data + [shutil.rmtree(dir) for dir in [ + td.repoName, + td.cachePath, + td.logPath]] + os.remove(testCfg) + + return foundCommit \ No newline at end of file diff --git a/src/plugins/intel_cpu/tools/commit_slider/tests/tests_res/fbv_main.cpp b/src/plugins/intel_cpu/tools/commit_slider/tests/tests_res/fbv_main.cpp new file mode 100644 index 00000000000000..ee753b0f8b72ac --- /dev/null +++ b/src/plugins/intel_cpu/tools/commit_slider/tests/tests_res/fbv_main.cpp @@ -0,0 +1,26 @@ +#include + +int main () { + const char *patchGenerator = R"V0G0N( +[ + { + "str": "std::cout << \"prefix\\nsuccess_1\\n\";", + "comment": "success_1" + }, + { + "str": "std::cout << \"prefix\\nsuccess_2\\n\";", + "comment": "success_2" + }, + { + "str": "std::cout << \"prefix\\nfailed_1\\n\";", + "comment": "error_1", + "state": "BREAK" + }, + { + "str": "std::cout << \"prefix\\nfailed_2\\n\";", + "comment": "error_2" + } +] +)V0G0N"; + return 0; +} \ No newline at end of file diff --git a/src/plugins/intel_cpu/tools/commit_slider/tests/tests_res/fvv_main.cpp b/src/plugins/intel_cpu/tools/commit_slider/tests/tests_res/fvv_main.cpp new file mode 100644 index 00000000000000..3465ea516969ee --- /dev/null +++ b/src/plugins/intel_cpu/tools/commit_slider/tests/tests_res/fvv_main.cpp @@ -0,0 +1,26 @@ +#include + +int main () { + const char *patchGenerator = R"V0G0N( +[ + { + "str": "std::cout << \"prefix\\nfailed_1\\n\";", + "comment": "error_1" + }, + { + "str": "std::cout << \"prefix\\nfailed_2\\n\";", + "comment": "error_2" + }, + { + "str": "std::cout << \"prefixsuccess_1\\n\\n\";", + "comment": "success_1", + "state": "BREAK" + }, + { + "str": "std::cout << \"prefix\\nsuccess_2\\n\";", + "comment": "success_2" + } +] +)V0G0N"; + return 0; +} \ No newline at end of file diff --git a/src/plugins/intel_cpu/tools/commit_slider/tests/tests_res/tests_res.json b/src/plugins/intel_cpu/tools/commit_slider/tests/tests_res/tests_res.json new file mode 100644 index 00000000000000..1a620c6fa74cc0 --- /dev/null +++ b/src/plugins/intel_cpu/tools/commit_slider/tests/tests_res/tests_res.json @@ -0,0 +1,56 @@ +{ + "CommonRes": { + "repoPath": "./", + "cachePath": "../slider_cache", + "logPath": "../log", + "patchGeneratorPrefix": "const char \\*patchGenerator = R\"V0G0N\\(", + "patchGeneratorPostfix": "\\)V0G0N\";", + "mainFile": "main.cpp", + "repoStructure": { + "files": [ + {"name": "CMakeLists.txt", "content": "cmake_minimum_required(VERSION 3.10)\nset(CMAKE_CXX_STANDARD 17)\nset(CMAKE_CXX_STANDARD_REQUIRED ON)\n\nproject({repoName} VERSION 1.0)\nadd_executable(\"${{PROJECT_NAME}}\" \"{mainFile}\")"}, + {"name": ".gitignore", "content": "/build\n"}, + {"name": "{mainFile}", "content": ""} + ], + "dirs": ["build"] + } + }, + "FirstBadVersion": { + "repoName": "firstBadVersion", + "patchedFile": "tests_res/fbv_main.cpp", + "testCfg": { + "appCmd" : "{appCmd}", + "appPath": "{appPath}", + "gitPath" : "{gitPath}", + "buildPath" : "{buildPath}", + "verboseOutput": false, + "runConfig" : { + "commitList" : { + "getCommitListCmd" : "git log {start}..{end} --boundary --pretty=\"%h\"" + }, + "mode" : "checkOutput", + "traversal" : "firstFailedVersion", + "stopPattern" : "(.)*failed(.)*" + } + } + }, + "FirstValidVersion": { + "repoName": "firstValidVersion", + "patchedFile": "tests_res/fvv_main.cpp", + "testCfg": { + "appCmd" : "{appCmd}", + "appPath": "{appPath}", + "gitPath" : "{gitPath}", + "buildPath" : "{buildPath}", + "verboseOutput": false, + "runConfig" : { + "commitList" : { + "getCommitListCmd" : "git log {start}..{end} --boundary --pretty=\"%h\"" + }, + "mode" : "checkOutput", + "traversal" : "firstFixedVersion", + "stopPattern" : "(.)*failed(.)*" + } + } + } +} \ No newline at end of file diff --git a/src/plugins/intel_cpu/tools/commit_slider/utils/cfg.json b/src/plugins/intel_cpu/tools/commit_slider/utils/cfg.json index e20d9bdf44d9ef..10559c8d81356c 100644 --- a/src/plugins/intel_cpu/tools/commit_slider/utils/cfg.json +++ b/src/plugins/intel_cpu/tools/commit_slider/utils/cfg.json @@ -11,12 +11,16 @@ "allBreaks" : "AllBreakVersions", "bruteForce" : "BruteForce" }, + "utilMap" : { + "map_builder" : "printMap", + "log_parser" : "logParser" + }, "extendBuildCommand" : false, "commandList" : [ {"cmd" : "git checkout -- .", "catchMsg" : "(.)*error: (.)*", "path" : "{gitPath}"}, {"cmd" : "git clean -fxd", "path" : "{gitPath}", "tag" : "clean"}, {"cmd" : "mkdir -p build", "path" : "{gitPath}"}, - {"cmd" : "git checkout {commit}", "catchMsg" : "error", "path" : "{gitPath}"}, + {"cmd" : "git checkout {commit}", "catchMsg" : "(.)*error: (.)*", "path" : "{gitPath}"}, {"cmd" : "git submodule init", "path" : "{gitPath}"}, {"cmd" : "git submodule update --recursive", "path" : "{buildPath}"}, {"cmd" : "{makeCmd}", "catchMsg" : "CMake Error", "path" : "{buildPath}"}, @@ -69,8 +73,9 @@ "winWorkPath" : "%tmp%\\commit_slider", "clearCache" : false, "checkIfBordersDiffer" : true, - "printCSV" : false, + "printCSV" : true, "usePrevRunCache" : false, + "verboseOutput": false, "serviceConfig" : { "comment" : "For inner purpose. Data will be overwritten during script running." }, @@ -80,11 +85,14 @@ "appPath" : "path, substituted by job" }, "cachedPathConfig": { - "enabled" : true, + "enabled" : false, "scheme" : "optional | mandatory", "comment" : "'mandatory' skips lacking hash-appPath pair for given key, 'optional' tries to handle it by building", "passCmdList": true, "changeAppPath": true, + "generateMap": false, + "commonPath": "", + "subPath": "", "cashMap" : {} } } \ No newline at end of file diff --git a/src/plugins/intel_cpu/tools/commit_slider/utils/common_mode.py b/src/plugins/intel_cpu/tools/commit_slider/utils/common_mode.py index 6d2180ff03eee6..f4e0c8531a5fba 100644 --- a/src/plugins/intel_cpu/tools/commit_slider/utils/common_mode.py +++ b/src/plugins/intel_cpu/tools/commit_slider/utils/common_mode.py @@ -1,5 +1,9 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + from abc import ABC import utils.helpers as util +import utils.map_builder as mapBuilder import json import os from enum import Enum @@ -30,6 +34,9 @@ def __init__(self, cfg) -> None: "commonLogger", logPath, "common_log.log" ) + def isPerformanceBased(self): + return False + def createCash(self): # In common case we use json. # Create cash is overrided if we need special algo for caching. @@ -98,7 +105,7 @@ def prepareRun(self, list, cfg): canReduce, newList = util.getReducedInterval(list, cfg) if canReduce: if (self.traversal.isComparative() and - self.mode.checkIfListBordersDiffer(newList, cfg) or + self.checkIfListBordersDiffer(newList, cfg) or not self.traversal.isComparative()): self.commonLogger.info( "Initial interval reduced to cashed {c1}..{c2}".format( @@ -112,6 +119,11 @@ def prepareRun(self, list, cfg): def normalizeCfg(self, cfg): if not self.traversal.isComparative(): cfg["checkIfBordersDiffer"] = False + cashCfg = cfg["cachedPathConfig"] + if (cashCfg["enabled"] and cashCfg["generateMap"]): + cfg["cachedPathConfig"]["cashMap"] = mapBuilder( + cashCfg["commonPath"], cashCfg["subPath"] + ) if "modeName" in cfg["skipMode"]: errorHandlingMode = cfg["skipMode"]["modeName"] if errorHandlingMode == "skip": @@ -130,7 +142,9 @@ def normalizeCfg(self, cfg): def postRun(self, list): util.returnToActualVersion(self.cfg) - if "printCSV" in self.cfg and self.cfg["printCSV"]: + if "printCSV" in self.cfg\ + and self.cfg["printCSV"]\ + and self.isPerformanceBased(): fields = ['linId', 'logId', 'hash', 'value'] rows = [] linearId = 0 @@ -267,9 +281,9 @@ def prepBypass(self, curList, list, cfg): # try to reduce interval by cashed borders canReduce, newList = util.getReducedInterval(curList, cfg) if canReduce: - if (self.traversal.isComparative() and + if (self.isComparative() and self.mode.checkIfListBordersDiffer(newList, cfg) or - not self.traversal.isComparative()): + not self.isComparative()): self.mode.commonLogger.info( "Interval {c1}..{c2} reduced to cashed {c1_}..{c2_}".format( c1=curList[0], c2=curList[-1], @@ -338,7 +352,7 @@ def bypass(self, curList, list, cfg) -> int: if "sampleCommit" in cfg["serviceConfig"]: sampleCommit = cfg["serviceConfig"]["sampleCommit"] if curLen <= 2: - isBad = self.mode.compareCommits( + isBad = not self.mode.compareCommits( sampleCommit, curList[0], list, cfg) breakCommit = curList[-1] if isBad else curList[0] pc = Mode.CommitPath.PathCommit( @@ -349,7 +363,7 @@ def bypass(self, curList, list, cfg) -> int: self.mode.commitPath.accept(self, pc) return mid = (int)((curLen - 1) / 2) - isBad = self.mode.compareCommits( + isBad = not self.mode.compareCommits( sampleCommit, curList[mid], list, cfg) if isBad: self.wrappedBypass( diff --git a/src/plugins/intel_cpu/tools/commit_slider/utils/helpers.py b/src/plugins/intel_cpu/tools/commit_slider/utils/helpers.py index aa12097f1079b7..af61c27691e88f 100644 --- a/src/plugins/intel_cpu/tools/commit_slider/utils/helpers.py +++ b/src/plugins/intel_cpu/tools/commit_slider/utils/helpers.py @@ -1,3 +1,6 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + import importlib import shutil import os @@ -31,15 +34,32 @@ def getParams(): action="store_true", help="flag if current directory is working", ) - args = parser.parse_args() + parser.add_argument( + "-u", + "--utility", + dest="utility", + help="run utility with specified name", + default="no_utility", + ) + args, additionalArgs = parser.parse_known_args() + + argHolder = DictHolder(args.__dict__) presetCfgPath = "utils/cfg.json" customCfgPath = "" - customCfgPath = args.__dict__["configuration"] + customCfgPath = argHolder.configuration presetCfgData = None with open(presetCfgPath) as cfgFile: presetCfgData = json.load(cfgFile) cfgFile.close() + + if argHolder.utility != "no_utility": + it = iter(additionalArgs) + addDict = dict(zip(it, it)) + mergedArgs = {**(args.__dict__), **addDict} + argHolder = DictHolder(mergedArgs) + return argHolder, presetCfgData, presetCfgPath + customCfgData = None with open(customCfgPath) as cfgFile: customCfgData = json.load(cfgFile) @@ -50,7 +70,7 @@ def getParams(): presetCfgData[key] = newVal presetCfgData = absolutizePaths(presetCfgData) - return args, presetCfgData, customCfgPath + return argHolder, presetCfgData, customCfgPath def getBlobDiff(file1, file2): @@ -205,7 +225,8 @@ def runCommandList(commit, cfgData): encoding="utf-8", errors="replace" ) for line in proc.stdout: - sys.stdout.write(line) + if cfgData["verboseOutput"]: + sys.stdout.write(line) commitLogger.info(line) if "catchMsg" in cmd: isErrFound = re.search(cmd["catchMsg"], line) @@ -424,6 +445,18 @@ def safeClearDir(path, cfg): return +def runUtility(cfg, args): + modName = args.utility + try: + mod = importlib.import_module( + "utils.{un}".format(un=modName)) + utilName = checkAndGetUtilityByName(cfg, modName) + utility = getattr(mod, utilName) + utility(args) + except ModuleNotFoundError as e: + raise CfgError("No utility {} found".format(modName)) + + class CfgError(Exception): pass @@ -473,9 +506,27 @@ def checkAndGetClassnameByConfig(cfg, mapName, specialCfg): return map[keyName] +def checkAndGetUtilityByName(cfg, utilName): + if not (utilName in cfg["utilMap"]): + raise CfgError( + "{utilName} is not registered in config".format( + utilName=utilName + ) + ) + else: + return cfg["utilMap"][utilName] + + def checkAndGetSubclass(clName, parentClass): cl = [cl for cl in parentClass.__subclasses__() if cl.__name__ == clName] if not (cl.__len__() == 1): raise CfgError("Class {clName} doesn't exist".format(clName=clName)) else: return cl[0] + + +class DictHolder: + def __init__(self, dict: dict = None): + if dict is not None: + for k, v in dict.items(): + setattr(self, k, v) diff --git a/src/plugins/intel_cpu/tools/commit_slider/utils/log_parser.py b/src/plugins/intel_cpu/tools/commit_slider/utils/log_parser.py new file mode 100644 index 00000000000000..20e08ee77613bf --- /dev/null +++ b/src/plugins/intel_cpu/tools/commit_slider/utils/log_parser.py @@ -0,0 +1,110 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import re +import zipfile +import os +import csv +import shutil +from utils.helpers import CfgError + + +def getMap(hashPatternList, intervalPatternList): + intervalPos = 2 # as in 'Check interval i1..i2' pattern + hashMap = {} + + for i, x in enumerate(intervalPatternList): + leftHash = hashPatternList[i].split()\ + [intervalPos].split("..")[0] + rightHash = hashPatternList[i].split()\ + [intervalPos].split("..")[1] + + leftInd = (x.split()[2]).split("..")[0] + rightInd = (x.split()[2]).split("..")[1] + + hashMap[leftInd] = leftHash + hashMap[rightInd] = rightHash + + return hashMap + +def extractPatterns(dirName): + data = "" + + with open(os.path.join(dirName, "logcommon_log.log")) as file: + data = file.read() + intervalPattern = "[A-Za-z0-9]*\.\.[A-Za-z0-9]*" + + pattern = "Check commits {}".format(intervalPattern) + stats_re = re.compile(pattern, re.MULTILINE | re.DOTALL) + hashPatternList = stats_re.findall(data) + + pattern = "Check interval {}".format(intervalPattern) + stats_re = re.compile(pattern, re.MULTILINE | re.DOTALL) + intervalPatternList = stats_re.findall(data) + + return hashPatternList, intervalPatternList + +def prepareCSVData(hashMap, dirName): + throughputPattern = "Throughput:\s*([0-9]*[.][0-9]*)\s*FPS" + csvData = [] + + for k, v in hashMap.items(): + logFileName = "logcommit_{}.log".format(v) + + if logFileName not in os.listdir(dirName): + raise LookupError("No {} in logs".format(logFileName)) + + with open(os.path.join(dirName, logFileName)) as logFile: + data = logFile.read() + + foundThroughput = re.search( + throughputPattern, data, flags=re.MULTILINE + ).group(1) + + csvData.append({ + "id": k, + "hash": v, + "throughput": foundThroughput + }) + + csvData.sort(key=lambda x: int(x['id'])) + + return csvData + +def makeCSV(csvData): + fields = ['id', 'hash', 'throughput'] + rows = [] + + for item in csvData: + row = [item['id'], item['hash'], item['throughput']] + rows.append(row) + + with open("csv_report.csv", 'w') as csvfile: + csvwriter = csv.writer(csvfile) + csvwriter.writerow(fields) + csvwriter.writerows(rows) + +def logParser(args, zipName="archive", dirName = "artifacts"): + if "-path" not in args: + raise CfgError("No 'path' for log parser provided") + elif "-zip_name" in args: + zipName = args["-zip_name"] + path = str(args["-path"]) + + clearArtifacts = False + + if path.endswith('.zip'): + clearArtifacts = True + with zipfile.ZipFile(path, 'r') as zip_ref: + zip_ref.extractall(dirName) + dirName = os.path.join(dirName, zipName) + else: + dirName = path + + hashPatternList, intervalPatternList = extractPatterns(dirName) + hashMap = getMap(hashPatternList, intervalPatternList) + csvData = prepareCSVData(hashMap, dirName) + makeCSV(csvData) + + if clearArtifacts: + shutil.rmtree(dirName) diff --git a/src/plugins/intel_cpu/tools/commit_slider/utils/map_builder.py b/src/plugins/intel_cpu/tools/commit_slider/utils/map_builder.py new file mode 100644 index 00000000000000..40c022111a18bb --- /dev/null +++ b/src/plugins/intel_cpu/tools/commit_slider/utils/map_builder.py @@ -0,0 +1,27 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +from os import walk, path +import json +from utils.helpers import CfgError + +def buildMap(commonPath, subPath=None): + precomPath = commonPath + items = next(walk(precomPath), (None, None, []))[1] + map = {} + for item in items: + item = item.replace('"', '') + curPath = path.join(precomPath, item) + if (subPath is not None and subPath): + curPath = path.join(curPath, subPath) + map[item] = curPath + return json.dumps(map) + + +def printMap(args): + if "-path" not in args: + raise CfgError("No 'path' for map builder provided") + if "-subPath" in args: + print(buildMap(args["-path"], args["-subPath"])) + else: + print(buildMap(args["-path"])) diff --git a/src/plugins/intel_cpu/tools/commit_slider/utils/modes.py b/src/plugins/intel_cpu/tools/commit_slider/utils/modes.py index 4ccc05c3c40dff..9d615f0cb359ed 100644 --- a/src/plugins/intel_cpu/tools/commit_slider/utils/modes.py +++ b/src/plugins/intel_cpu/tools/commit_slider/utils/modes.py @@ -1,3 +1,6 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + import os from utils.helpers import fetchAppOutput, getActualPath from utils.helpers import getMeaningfullCommitTail @@ -39,7 +42,7 @@ def checkCfg(self, cfg): raise CfgError("stopPattern is not configured") def compareCommits(self, lCommit, rCommit, list, cfg): - isLeftBorderFailed = self.getPseudoMetric(lCommit, cfg) + isLeftBorderFailed = bool(self.getPseudoMetric(lCommit, cfg)) isRightBorderGood = not self.getPseudoMetric(rCommit, cfg) curCommit = rCommit.replace('"', "") commitLogger = getCommitLogger(cfg, curCommit) @@ -82,6 +85,9 @@ def __init__(self, cfg): self.perfRel = 0 self.createCash() + def isPerformanceBased(self): + return True + def prepareRun(self, list, cfg): super().prepareRun(list, cfg) sampleCommit = list[0] diff --git a/src/plugins/intel_gpu/docs/gpu_debug_utils.md b/src/plugins/intel_gpu/docs/gpu_debug_utils.md index 942a2309fb412e..831240c5d44e08 100644 --- a/src/plugins/intel_gpu/docs/gpu_debug_utils.md +++ b/src/plugins/intel_gpu/docs/gpu_debug_utils.md @@ -227,7 +227,7 @@ For troubleshooting the accuracy, you may want to compare the results of GPU plu As Gen9 HW does not have hardware acceleration, low-precision transformations are disabled by default. Therefore, quantized networks are executed in full precision (FP16 or FP32), with explicit execution of quantize operations. If you do not have Gen12 HW, but want to debug the network's accuracy or performance of simple operations (which does not require dp4a support), then you can enable low precision pipeline on Gen9, with one of the following approaches: -1. Add `{PluginConfigInternalParams::KEY_LP_TRANSFORMS_MODE, PluginConfigParams::YES}` option to the plugin config. +1. Add `ov::intel_gpu::enable_lp_transformations(true)` option to the plugin config. 2. Enforce `supports_imad = true` [here](https://github.com/openvinotoolkit/openvino/blob/master/inference-engine/thirdparty/clDNN/src/gpu/device_info.cpp#L226) 3. Enforce `conf.enableInt8 = true` [here](https://github.com/openvinotoolkit/openvino/blob/master/inference-engine/src/cldnn_engine/cldnn_engine.cpp#L366) diff --git a/src/plugins/intel_gpu/include/intel_gpu/op/swiglu.hpp b/src/plugins/intel_gpu/include/intel_gpu/op/swiglu.hpp new file mode 100644 index 00000000000000..249bfff3287184 --- /dev/null +++ b/src/plugins/intel_gpu/include/intel_gpu/op/swiglu.hpp @@ -0,0 +1,53 @@ +// Copyright (C) 2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "openvino/op/op.hpp" + +namespace ov { +namespace intel_gpu { +namespace op { + +/// \brief Operator performing Swish Gated Linear Unit Activation +/// This operation performs gated linear unit activation that combines swish activation function +class SwiGLU : public ov::op::Op { +public: + OPENVINO_OP("SwiGLU", "gpu_opset"); + + SwiGLU() = default; + /// \brief Constructs an SwiGLU operation. + /// + /// \param data Input tensor with data + /// \param axis The index of an axis in "data" along which to perform the split + /// \param split_lenghts A list containing the sizes of each output tensor along the split "axis" + /// \param output_type Output element type + SwiGLU(const Output& data, + int64_t axis, + int64_t split_lengths, + const ov::element::Type output_type = ov::element::undefined); + + bool visit_attributes(ov::AttributeVisitor& visitor) override; + + void validate_and_infer_types() override; + + std::shared_ptr clone_with_new_inputs(const ov::OutputVector& new_args) const override; + + int64_t get_axis() const { return m_axis; } + int64_t get_split_lengths() const { return m_split_lengths; } + + void set_axis(int64_t axis) { m_axis = axis; } + void set_split_lengths(int64_t split_lengths) { m_split_lengths = split_lengths; } + +private: + int64_t m_axis; + int64_t m_split_lengths; + ov::element::Type m_output_type; +}; + +std::vector shape_infer(const SwiGLU* op, std::vector input_shapes); + +} // namespace op +} // namespace intel_gpu +} // namespace ov diff --git a/src/plugins/intel_gpu/include/intel_gpu/plugin/primitives_list.hpp b/src/plugins/intel_gpu/include/intel_gpu/plugin/primitives_list.hpp index 75bf7f51c19000..af0497c0e9d5d4 100644 --- a/src/plugins/intel_gpu/include/intel_gpu/plugin/primitives_list.hpp +++ b/src/plugins/intel_gpu/include/intel_gpu/plugin/primitives_list.hpp @@ -276,3 +276,4 @@ REGISTER_FACTORY(internal, GatherCompressed); REGISTER_FACTORY(internal, KVCache); REGISTER_FACTORY(internal, ReadValue); REGISTER_FACTORY(internal, Gemm); +REGISTER_FACTORY(internal, SwiGLU); diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/adaptive_pooling.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/adaptive_pooling.hpp index 06c34eba3c2962..39d191246f1a17 100644 --- a/src/plugins/intel_gpu/include/intel_gpu/primitives/adaptive_pooling.hpp +++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/adaptive_pooling.hpp @@ -49,6 +49,35 @@ struct adaptive_pooling : public primitive_base { indices_output{indices_output}, index_element_type{index_element_type} {} + /// @brief Constructs AdaptiveAvgPooling primitive for dynamic shape. + /// @param id This primitive id. + /// @param input Input primitive id. + /// @param output_shape Output shape (pooled vector) primitive id. + adaptive_pooling(const primitive_id &id, + const input_info &input, + const input_info &output_shape) + : primitive_base(id, {input, output_shape}), + mode{adaptive_pooling_mode::average}, + output_size{tensor(0)} {} + + /// @brief Constructs AdaptiveMaxPooling primitive for dynamic shape. + /// @param id This primitive id. + /// @param input Input primitive id. + /// @param output_shape Output shape (pooled vector) primitive id. + /// @param index_element_type Data type of indices output. + adaptive_pooling(const primitive_id &id, + const input_info &input, + const input_info &output_shape, + data_types index_element_type, + const padding& output_padding = padding(), + data_types output_data_type = data_types::i32, + const size_t num_outputs = 1) + : primitive_base(id, {input, output_shape}, {output_padding}, {optional_data_type{output_data_type}}, num_outputs), + mode{adaptive_pooling_mode::max}, + output_size{tensor(0)}, + indices_output{""}, + index_element_type{index_element_type} {} + adaptive_pooling_mode mode; tensor output_size; primitive_id indices_output; diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/swiglu.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/swiglu.hpp new file mode 100644 index 00000000000000..6602f9ddd18aeb --- /dev/null +++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/swiglu.hpp @@ -0,0 +1,67 @@ +// Copyright (C) 2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once +#include "primitive.hpp" + +namespace cldnn { + +/// @brief Swish Gated Linear Unit Activation primitive +/// @details Performs gated linear unit activation that combines swish activation function +struct swiglu : public primitive_base { + CLDNN_DECLARE_PRIMITIVE(swiglu); + + swiglu() : primitive_base("", {}) {} + + /// @brief Constructs swiglu primitive + /// @param id This primitive id + /// @param input Input primitive id + /// @param axis The index of an axis in data along which to perform the split + /// @param split_lengths A list containing the sizes of each output tensor along the split axis + /// @param output_size Output data size of the primitive + swiglu(const primitive_id& id, + const input_info& input, + const int64_t& axis, + const int64_t& split_lengths, + const tensor output_size, + const padding& output_padding = padding()) + : primitive_base(id, {input}, {output_padding}), + axis(axis), + split_lengths(split_lengths), + output_size(output_size) {} + + int64_t axis; + int64_t split_lengths; + tensor output_size; + + size_t hash() const override { + size_t seed = primitive::hash(); + seed = hash_combine(seed, axis); + seed = hash_combine(seed, split_lengths); + return seed; + } + + bool operator==(const primitive& rhs) const override { + if (!compare_common_params(rhs)) + return false; + + auto rhs_casted = downcast(rhs); + return axis == rhs_casted.axis && split_lengths == rhs_casted.split_lengths; + } + + void save(BinaryOutputBuffer& ob) const override { + primitive_base::save(ob); + ob << axis; + ob << split_lengths; + ob << output_size; + } + + void load(BinaryInputBuffer& ib) override { + primitive_base::load(ib); + ib >> axis; + ib >> split_lengths; + ib >> output_size; + } +}; +} // namespace cldnn diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/format.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/format.hpp index 0d66106523eaa5..dc756006c18264 100644 --- a/src/plugins/intel_gpu/include/intel_gpu/runtime/format.hpp +++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/format.hpp @@ -156,6 +156,8 @@ struct format { is_os_yx_isv16_osv8, ///< format used for weights for blocked deconvolution is_os_yx_isv16_osv4, ///< format used for weights for blocked deconvolution is_os_yx_isv16_osv2, ///< format used for weights for blocked deconvolution + os_is_yx_isa8_osv16_isv2, ///< format used for weights for blocked 2D onednn convolution + os_is_zyx_isa8_osv16_isv2, ///< format used for weights for blocked 3D onednn convolution os_is_yx_isv8_osv16_isv2, ///< format used for weights for blocked 2D convolution os_is_zyx_isv8_osv16_isv2, ///< format used for weights for blocked 3D convolution ///< os - output feature maps slice, i - input feature maps, diff --git a/src/plugins/intel_gpu/src/graph/adaptive_pooling.cpp b/src/plugins/intel_gpu/src/graph/adaptive_pooling.cpp index 26778bc232ff40..f003d1a44b62a2 100644 --- a/src/plugins/intel_gpu/src/graph/adaptive_pooling.cpp +++ b/src/plugins/intel_gpu/src/graph/adaptive_pooling.cpp @@ -7,16 +7,71 @@ #include "json_object.h" #include +#include "adaptive_avg_pool_shape_inference.hpp" +#include "adaptive_max_pool_shape_inference.hpp" + namespace cldnn { GPU_DEFINE_PRIMITIVE_TYPE_ID(adaptive_pooling) -layout adaptive_pooling_inst::calc_output_layout(const adaptive_pooling_node& node, kernel_impl_params const& impl_param) { +layout adaptive_pooling_inst::calc_output_layout(adaptive_pooling_node const& node, kernel_impl_params const& impl_param) { const auto data_layout = impl_param.get_input_layout(); const auto prim = impl_param.typed_desc(); return {data_layout.data_type, data_layout.format, prim->output_size}; } -std::string adaptive_pooling_inst::to_string(const adaptive_pooling_node& node) { +template +std::vector adaptive_pooling_inst::calc_output_layouts(adaptive_pooling_node const& /*node*/, const kernel_impl_params& impl_param) { + std::vector layouts; + + const auto prim = impl_param.typed_desc(); + auto input0_layout = impl_param.get_input_layout(0); + auto input1_layout = impl_param.get_input_layout(1); + auto output_format = input0_layout.format; + + std::vector input_shapes = { + input0_layout.get(), + input1_layout.get() + }; + std::vector output_shapes = {ShapeType()}; + std::unordered_map const_data; + + auto& memory_deps = impl_param.memory_deps; + + if (memory_deps.count(1)) { + auto pooledVector_mem = memory_deps.at(1); + cldnn::mem_lock pooledVector_lock(pooledVector_mem, impl_param.get_stream()); + + auto pooledVector_tensor = make_tensor(pooledVector_mem->get_layout(), pooledVector_lock.data()); + + const_data.emplace(1, pooledVector_tensor); + } + + const auto tensor_accessor = ov::make_tensor_accessor(const_data); + if (prim->mode == cldnn::adaptive_pooling_mode::max) { + ov::op::v8::AdaptiveMaxPool op; + + output_shapes = ov::op::v8::shape_infer(&op, input_shapes, tensor_accessor); + + auto dt = prim->get_output_data_type(0).value_or(impl_param.get_input_layout(0).data_type); + auto index_dt = prim->index_element_type; + layouts.push_back(layout{output_shapes[0], dt, output_format}); + layouts.push_back(layout{output_shapes[1], index_dt, output_format}); + } else { + ov::op::v8::AdaptiveAvgPool op; + + output_shapes = ov::op::v8::shape_infer(&op, input_shapes, tensor_accessor); + + auto dt = prim->get_output_data_type(0).value_or(impl_param.get_input_layout(0).data_type); + layouts.push_back(layout{output_shapes[0], dt, output_format}); + } + + return layouts; +} + +template std::vector adaptive_pooling_inst::calc_output_layouts(adaptive_pooling_node const& node, + const kernel_impl_params& impl_param); + +std::string adaptive_pooling_inst::to_string(adaptive_pooling_node const& node) { const auto prim = node.get_primitive(); std::stringstream primitive_description; @@ -32,4 +87,6 @@ std::string adaptive_pooling_inst::to_string(const adaptive_pooling_node& node) return primitive_description.str(); } + +adaptive_pooling_inst::typed_primitive_inst(network& network, adaptive_pooling_node const& node) : parent(network, node) {} } // namespace cldnn diff --git a/src/plugins/intel_gpu/src/graph/gemm.cpp b/src/plugins/intel_gpu/src/graph/gemm.cpp index 99e8fd7d674a29..51f984bb6666ea 100644 --- a/src/plugins/intel_gpu/src/graph/gemm.cpp +++ b/src/plugins/intel_gpu/src/graph/gemm.cpp @@ -202,7 +202,7 @@ layout gemm_inst::transform_output_layout(const std::shared_ptr prim auto N = input1_pshape[n_idx]; auto output_pshape = input_layouts[0].get_partial_shape(); - for (size_t i = 0; i != input_layouts.size(); ++i) { + for (size_t i = 0; i != primitive->input_size(); ++i) { auto input_pshape = input_layouts[i].get_partial_shape(); for (size_t j = 0; j != input_pshape.size(); ++j) { ov::Dimension::merge(output_pshape[j], output_pshape[j], input_pshape[j]); diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/fuse_primitives_with_layout.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/fuse_primitives_with_layout.cpp new file mode 100644 index 00000000000000..a5d2ff3a53ebb7 --- /dev/null +++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/fuse_primitives_with_layout.cpp @@ -0,0 +1,66 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "program_helpers.h" +#include "pass_manager.h" + +#include "eltwise_inst.h" +#include "quantize_inst.h" + +#include + +using namespace cldnn; + +static bool eltwise_supports_fusings(eltwise_node& node) { + auto out_layout = node.get_output_layout(); + // This condition refers to optimizied kernel EltwiseKernel_fs_b_yx_fsv32 + if (out_layout.data_type == data_types::f16 && out_layout.batch() > 1 && out_layout.format == format::fs_b_yx_fsv32) { + return false; + } + + return true; +} + +void fuse_primitives_with_layout::run(program& p) { + bool need_recalc_processing_order = false; + std::map>> fusing_history; + + auto itr = p.get_processing_order().begin(); + while (itr != p.get_processing_order().end()) { + auto node_itr = itr++; + auto& node = (*node_itr); + + if (node->is_output() || node->is_constant()) + continue; + + // No optimized Eltwise kernel supports fused-operation for fs_b_yx_fsv32 + // Check fusing quantize to eltwsise for this case + auto func_fuse_quantize = [&](quantize_node& node) { + bool should_fuse = false; + auto out_layout = node.get_output_layout(); + if (out_layout.is_dynamic() || node.is_in_shape_of_subgraph()) + return; + + auto& input_node = node.get_dependency(0); + auto in_layout = input_node.get_output_layout(); + if (input_node.get_users().size() != 1 || input_node.get_dependencies().empty() || + in_layout.is_dynamic() || input_node.is_in_shape_of_subgraph()) + return; + + should_fuse |= input_node.is_type() && eltwise_supports_fusings(input_node.as()); + + if (!should_fuse) + return; + + p.fuse_nodes(input_node, node, &fusing_history); + need_recalc_processing_order = true; + }; + + program_helpers::do_for_types(*node, func_fuse_quantize); + } + + // Need to update processing order when peer node processing number is greater than fused node + if (need_recalc_processing_order) + p.get_processing_order().calc_processing_order(p); +} diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing.cpp index 242da0c35b3a8a..89f37276f7d56d 100644 --- a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing.cpp +++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing.cpp @@ -552,6 +552,7 @@ void prepare_primitive_fusing::fuse_simple_primitives(program &p) { auto eltwise_supports_fusings = [&](eltwise_node& node) -> bool { auto out_layout = node.get_output_layout(); + // Do not fuse if the estimated format is fs_b_yx_fsv32 because the optimized kernel does not support fusion if (out_layout.data_type == data_types::f16 && out_layout.is_static() && out_layout.batch() > 1 && ((_lo.get_optimization_attributes().fs_b_yx_fsv32_network && !_lo.get_optimization_attributes().use_onednn_impls) || diff --git a/src/plugins/intel_gpu/src/graph/impls/common/wait_for_events.cpp b/src/plugins/intel_gpu/src/graph/impls/common/wait_for_events.cpp index b08831e0aade6a..d5640833c523dd 100644 --- a/src/plugins/intel_gpu/src/graph/impls/common/wait_for_events.cpp +++ b/src/plugins/intel_gpu/src/graph/impls/common/wait_for_events.cpp @@ -32,10 +32,6 @@ class wait_for_events_impl : public primitive_impl { void init_kernels(const kernels_cache&, const kernel_impl_params&) override {} void set_arguments(primitive_inst& /*instance*/) override {} void set_arguments(primitive_inst& /*instance*/, kernel_arguments_data& /*args*/) override {} - kernel_arguments_data get_arguments(const primitive_inst& /*instance*/) const override { - kernel_arguments_data args; - return args; - } std::vector get_internal_buffer_layouts() const override { return {}; } event::ptr execute(const std::vector& events, primitive_inst& instance) override { diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/adaptive_pooling.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/adaptive_pooling.cpp index fc4c6d9af09d21..c42d4601a00a8d 100644 --- a/src/plugins/intel_gpu/src/graph/impls/ocl/adaptive_pooling.cpp +++ b/src/plugins/intel_gpu/src/graph/impls/ocl/adaptive_pooling.cpp @@ -22,18 +22,6 @@ struct adaptive_pooling_impl : public typed_primitive_impl_ocl return make_unique(*this); } -protected: - kernel_arguments_data get_arguments(const typed_primitive_inst& instance) const override { - kernel_arguments_data args; - const auto num_inputs = instance.inputs_memory_count(); - for (size_t i = 0; i < num_inputs; ++i) { - args.inputs.push_back(instance.input_memory_ptr(i)); - } - - args.outputs = {instance.output_memory_ptr()}; - return args; - } - public: static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param) { const auto& primitive = impl_param.typed_desc(); @@ -56,8 +44,13 @@ struct adaptive_pooling_impl : public typed_primitive_impl_ocl } default: OPENVINO_ASSERT(false, "[GPU] Not supported index element type"); } - - params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(2))); + bool allow_new_shape_infer = impl_param.get_program().get_config().get_property(ov::intel_gpu::allow_new_shape_infer); + if (allow_new_shape_infer) { + params.outputs_num = 2; + params.outputs.push_back(convert_data_tensor(impl_param.get_output_layout(1))); + } else { + params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(2))); + } } return {params, optional_params}; diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/kernel_selector_helper.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/kernel_selector_helper.cpp index d82832731badb6..fff672088f233e 100644 --- a/src/plugins/intel_gpu/src/graph/impls/ocl/kernel_selector_helper.cpp +++ b/src/plugins/intel_gpu/src/graph/impls/ocl/kernel_selector_helper.cpp @@ -578,6 +578,10 @@ kernel_selector::weights_layout to_weights_layout(format f, bool is_grouped) { return kernel_selector::weights_layout::iy_xs_os_xsv2_osv16__ao32; case format::os_is_osv32_isv32_swizzled_by_4: return kernel_selector::weights_layout::os_is_osv32_isv32_swizzled_by_4; + case format::os_is_zyx_isa8_osv16_isv2: + return kernel_selector::weights_layout::os_is_zyx_isa8_osv16_isv2; + case format::os_is_yx_isa8_osv16_isv2: + return kernel_selector::weights_layout::os_is_yx_isa8_osv16_isv2; case format::os_is_zyx_isv8_osv16_isv2: return kernel_selector::weights_layout::os_is_zyx_isv8_osv16_isv2; case format::os_is_yx_isv8_osv16_isv2: @@ -912,6 +916,10 @@ cldnn::format::type from_weights_layout(kernel_selector::weights_layout l) { return cldnn::format::os_is_yx_osv2_isv32; case kernel_selector::weights_layout::os_is_zyx_osv8_isv4: return cldnn::format::os_is_zyx_osv8_isv4; + case kernel_selector::weights_layout::os_is_zyx_isa8_osv16_isv2: + return cldnn::format::os_is_zyx_isa8_osv16_isv2; + case kernel_selector::weights_layout::os_is_yx_isa8_osv16_isv2: + return cldnn::format::os_is_yx_isa8_osv16_isv2; case kernel_selector::weights_layout::os_is_zyx_isv8_osv16_isv2: return cldnn::format::os_is_zyx_isv8_osv16_isv2; case kernel_selector::weights_layout::os_zyxi_osv16: diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/primitive_base.hpp b/src/plugins/intel_gpu/src/graph/impls/ocl/primitive_base.hpp index d4e4927e200f1a..485a8255f15b17 100644 --- a/src/plugins/intel_gpu/src/graph/impls/ocl/primitive_base.hpp +++ b/src/plugins/intel_gpu/src/graph/impls/ocl/primitive_base.hpp @@ -96,9 +96,6 @@ struct typed_primitive_impl_ocl : public typed_primitive_impl { return make_unique(best_kernel); } -private: - using primitive_impl::get_arguments; - protected: virtual kernel_arguments_data get_arguments(const typed_primitive_inst& instance) const { kernel_arguments_data args; @@ -228,22 +225,6 @@ struct typed_primitive_impl_ocl : public typed_primitive_impl { } } - kernel_arguments_data get_arguments_impl(const typed_primitive_inst& instance) const override { - if (_kernels.size()) { - auto args = get_arguments(instance); - args.scalars = &_kernel_data.kernels[0].params.scalars; - - for (const auto& m : instance.get_intermediates_memories()) { - args.intermediates.push_back(m); - } - - return args; - } - - kernel_arguments_data args; - return args; - } - event::ptr execute_impl(const std::vector& events, typed_primitive_inst& instance) override { stream& stream = instance.get_network().get_stream(); diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/register.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/register.cpp index bb2dba327f15b7..856195f32b43c5 100644 --- a/src/plugins/intel_gpu/src/graph/impls/ocl/register.cpp +++ b/src/plugins/intel_gpu/src/graph/impls/ocl/register.cpp @@ -79,6 +79,7 @@ void register_implementations() { REGISTER_OCL(space_to_depth); REGISTER_OCL(slice); REGISTER_OCL(strided_slice); + REGISTER_OCL(swiglu); REGISTER_OCL(tile); REGISTER_OCL(gather_tree); REGISTER_OCL(resample); diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/register.hpp b/src/plugins/intel_gpu/src/graph/impls/ocl/register.hpp index 6c27c72dc4caae..e338d638e438f3 100644 --- a/src/plugins/intel_gpu/src/graph/impls/ocl/register.hpp +++ b/src/plugins/intel_gpu/src/graph/impls/ocl/register.hpp @@ -68,6 +68,7 @@ #include "intel_gpu/primitives/softmax.hpp" #include "intel_gpu/primitives/space_to_batch.hpp" #include "intel_gpu/primitives/strided_slice.hpp" +#include "intel_gpu/primitives/swiglu.hpp" #include "intel_gpu/primitives/tile.hpp" #include "intel_gpu/primitives/non_zero.hpp" #include "intel_gpu/primitives/eye.hpp" @@ -157,6 +158,7 @@ REGISTER_OCL(softmax); REGISTER_OCL(space_to_batch); REGISTER_OCL(space_to_depth); REGISTER_OCL(strided_slice); +REGISTER_OCL(swiglu); REGISTER_OCL(tile); REGISTER_OCL(gather_tree); REGISTER_OCL(resample); diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/swiglu.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/swiglu.cpp new file mode 100644 index 00000000000000..5e628ff50a6656 --- /dev/null +++ b/src/plugins/intel_gpu/src/graph/impls/ocl/swiglu.cpp @@ -0,0 +1,79 @@ +// Copyright (C) 2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "primitive_base.hpp" +#include "validation_util.hpp" + +#include "swiglu_inst.h" +#include "swiglu/swiglu_kernel_selector.h" +#include "swiglu/swiglu_kernel_ref.h" + +namespace cldnn { +namespace ocl { + +struct swiglu_impl : typed_primitive_impl_ocl { + using parent = typed_primitive_impl_ocl; + using parent::parent; + using kernel_selector_t = kernel_selector::swiglu_kernel_selector; + using kernel_params_t = std::pair; + + DECLARE_OBJECT_TYPE_SERIALIZATION(cldnn::ocl::swiglu_impl); + + std::unique_ptr clone() const override { + return make_unique(*this); + } + + void load(BinaryInputBuffer& ib) override { + parent::load(ib); + if (is_dynamic()) { + auto& kernel_selector = kernel_selector_t::Instance(); + auto kernel_impl = kernel_selector.GetImplementation(_kernel_data.kernelName); + kernel_impl->GetUpdateDispatchDataFunc(_kernel_data); + } + } + + static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param, bool is_shape_agnostic = false) { + const auto& primitive = impl_param.typed_desc(); + auto params = get_default_params(impl_param, is_shape_agnostic); + auto optional_params = get_default_optional_params(impl_param.get_program()); + + auto rank = impl_param.get_input_layout(0).get_partial_shape().rank(); + params.axis = ov::util::normalize(primitive->axis, rank.get_length()); + params.split_length = primitive->split_lengths; + + return {params, optional_params}; + } + + void update_dispatch_data(const kernel_impl_params& impl_param) override { + auto kernel_params = get_kernel_params(impl_param, true); + (_kernel_data.update_dispatch_data_func)(kernel_params.first, _kernel_data); + } +}; + +namespace detail { + +attach_swiglu_impl::attach_swiglu_impl() { + auto types = { + data_types::f32, + data_types::f16 + }; + + auto formats = { + format::bfyx, + format::bfzyx + }; + + implementation_map::add(impl_types::ocl, + shape_types::any, + typed_primitive_impl_ocl::create, + types, + formats); +} + +} // namespace detail +} // namespace ocl +} // namespace cldnn + +BIND_BINARY_BUFFER_WITH_TYPE(cldnn::ocl::swiglu_impl) +BIND_BINARY_BUFFER_WITH_TYPE(cldnn::swiglu) diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/primitive_onednn_base.h b/src/plugins/intel_gpu/src/graph/impls/onednn/primitive_onednn_base.h index f6d5769b77d218..87f129b8b98495 100644 --- a/src/plugins/intel_gpu/src/graph/impls/onednn/primitive_onednn_base.h +++ b/src/plugins/intel_gpu/src/graph/impls/onednn/primitive_onednn_base.h @@ -322,8 +322,6 @@ struct typed_primitive_onednn_impl : public typed_primitive_impl { } private: - using primitive_impl::get_arguments; - std::string get_cache_directory(const ExecutionConfig& config) const { auto path = config.get_property(ov::cache_dir); if (path.empty()) { diff --git a/src/plugins/intel_gpu/src/graph/include/adaptive_pooling_inst.h b/src/plugins/intel_gpu/src/graph/include/adaptive_pooling_inst.h index a5dbe351277c77..59ac50aa567ab0 100644 --- a/src/plugins/intel_gpu/src/graph/include/adaptive_pooling_inst.h +++ b/src/plugins/intel_gpu/src/graph/include/adaptive_pooling_inst.h @@ -8,6 +8,16 @@ #include namespace cldnn { +template <> +struct typed_program_node : public typed_program_node_base { + using parent = typed_program_node_base; + +public: + using parent::parent; + + program_node& input(size_t idx = 0) const { return get_dependency(idx); } + std::vector get_shape_infer_dependencies() const override { return {1}; } +}; using adaptive_pooling_node = typed_program_node; @@ -17,12 +27,13 @@ class typed_primitive_inst : public typed_primitive_inst_base< using parent::parent; public: - static layout calc_output_layout(const adaptive_pooling_node& node, kernel_impl_params const& impl_param); - static std::string to_string(const adaptive_pooling_node& node); + template + static std::vector calc_output_layouts(adaptive_pooling_node const& /*node*/, const kernel_impl_params& impl_param); + static layout calc_output_layout(adaptive_pooling_node const& node, kernel_impl_params const& impl_param); + static std::string to_string(adaptive_pooling_node const& node); - typed_primitive_inst(network& network, const adaptive_pooling_node& node) : parent(network, node) {} + typed_primitive_inst(network& network, adaptive_pooling_node const& node); }; using adaptive_pooling_inst = typed_primitive_inst; - } // namespace cldnn diff --git a/src/plugins/intel_gpu/src/graph/include/pass_manager.h b/src/plugins/intel_gpu/src/graph/include/pass_manager.h index 8c92ec4f5c6886..d667d6ada6810e 100644 --- a/src/plugins/intel_gpu/src/graph/include/pass_manager.h +++ b/src/plugins/intel_gpu/src/graph/include/pass_manager.h @@ -395,4 +395,12 @@ class mark_runtime_skippable_nodes : public base_pass { void run(program& p) override; }; +class fuse_primitives_with_layout : public base_pass { +public: + fuse_primitives_with_layout() : base_pass("fuse_primitives_with_layout") {} + +private: + void run(program& p) override; +}; + } // namespace cldnn diff --git a/src/plugins/intel_gpu/src/graph/include/primitive_inst.h b/src/plugins/intel_gpu/src/graph/include/primitive_inst.h index ebe58eb8eef97f..62840e2b9bbb1f 100644 --- a/src/plugins/intel_gpu/src/graph/include/primitive_inst.h +++ b/src/plugins/intel_gpu/src/graph/include/primitive_inst.h @@ -57,7 +57,6 @@ struct primitive_impl { virtual const std::string& get_type_info() const = 0; virtual void set_arguments(primitive_inst& instance) = 0; virtual void set_arguments(primitive_inst& instance, kernel_arguments_data& args) = 0; - virtual kernel_arguments_data get_arguments(const primitive_inst& instance) const = 0; virtual event::ptr execute(const std::vector& events, primitive_inst& instance) = 0; std::string get_kernel_name() const { return _kernel_name; } @@ -509,16 +508,8 @@ struct typed_primitive_impl : public primitive_impl { return set_arguments_impl(reinterpret_cast&>(instance), args); } - kernel_arguments_data get_arguments(const primitive_inst& instance) const override { - return get_arguments_impl(reinterpret_cast&>(instance)); - } - virtual void set_arguments_impl(typed_primitive_inst& /*instance*/) {} virtual void set_arguments_impl(typed_primitive_inst& /*instance*/, kernel_arguments_data& /*args*/) {} - virtual kernel_arguments_data get_arguments_impl(const typed_primitive_inst& /*instance*/) const { - kernel_arguments_data args; - return args; - } virtual event::ptr execute_impl(const std::vector& event, typed_primitive_inst& instance) = 0; }; diff --git a/src/plugins/intel_gpu/src/graph/include/shape_of_inst.h b/src/plugins/intel_gpu/src/graph/include/shape_of_inst.h index 5d6a8dfd381dc5..aabb0045b91cf3 100644 --- a/src/plugins/intel_gpu/src/graph/include/shape_of_inst.h +++ b/src/plugins/intel_gpu/src/graph/include/shape_of_inst.h @@ -21,6 +21,7 @@ struct typed_program_node : public typed_program_node_base { public: using parent::parent; + std::vector get_shape_infer_dependencies() const override { return {}; } program_node& input() const { return get_dependency(0); } }; diff --git a/src/plugins/intel_gpu/src/graph/include/swiglu_inst.h b/src/plugins/intel_gpu/src/graph/include/swiglu_inst.h new file mode 100644 index 00000000000000..6a5ce08dc54bd2 --- /dev/null +++ b/src/plugins/intel_gpu/src/graph/include/swiglu_inst.h @@ -0,0 +1,42 @@ +// Copyright (C) 2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once +#include "intel_gpu/primitives/swiglu.hpp" +#include "primitive_inst.h" + +#include + +namespace cldnn { + +template <> +struct typed_program_node : public typed_program_node_base { + using parent = typed_program_node_base; + +public: + using parent::parent; + + program_node& input(size_t index = 0) const { return get_dependency(index); } + std::vector get_shape_infer_dependencies() const override { return {}; } +}; + +using swiglu_node = typed_program_node; + +template <> +class typed_primitive_inst : public typed_primitive_inst_base { + using parent = typed_primitive_inst_base; + using parent::parent; + +public: + template + static std::vector calc_output_layouts(swiglu_node const& /*node*/, const kernel_impl_params& impl_params); + static layout calc_output_layout(swiglu_node const& node, kernel_impl_params const& impl_params); + static std::string to_string(swiglu_node const& node); + + typed_primitive_inst(network& network, swiglu_node const& node); +}; + +using swiglu_inst = typed_primitive_inst; + +} // namespace cldnn diff --git a/src/plugins/intel_gpu/src/graph/primitive_inst.cpp b/src/plugins/intel_gpu/src/graph/primitive_inst.cpp index 50e31b12527b73..cd2800f0138614 100644 --- a/src/plugins/intel_gpu/src/graph/primitive_inst.cpp +++ b/src/plugins/intel_gpu/src/graph/primitive_inst.cpp @@ -351,7 +351,7 @@ void primitive_inst::update_shape() { input_shape_changed = true; } - if (!input_shape_changed && !_node->generates_dynamic_output() && _impl_params->get_output_layout().is_static()) + if (!_node->is_type() && !input_shape_changed && !_node->generates_dynamic_output() && _impl_params->get_output_layout().is_static()) return; std::vector dependencies_events; @@ -433,6 +433,14 @@ void primitive_inst::update_shape() { // Custom output layout update as update_output_layout handles paddings incorrectly for optimized out read_value + kv_cache pattern _impl_params->output_layouts[0] = variable_layout; } + + if (get_node().is_type()) { + auto desc = get_node().as().get_primitive(); + auto var_mem_size = get_network().get_variable(desc->variable_info.variable_id).get_actual_mem_size(); + // Need to trigger realloc_if_needed + if (var_mem_size < _impl_params->get_output_layout(0).get_buffer_size().count()) + set_shape_change(); + } } event::ptr primitive_inst::realloc_if_needed() { diff --git a/src/plugins/intel_gpu/src/graph/program.cpp b/src/plugins/intel_gpu/src/graph/program.cpp index 87bf0e747e4913..08f7c5a5060a2a 100644 --- a/src/plugins/intel_gpu/src/graph/program.cpp +++ b/src/plugins/intel_gpu/src/graph/program.cpp @@ -101,21 +101,28 @@ using namespace cldnn; using namespace ov::intel_gpu; static ov::threading::IStreamsExecutor::Config make_task_executor_config(const ExecutionConfig& config, std::string tags, int num_streams = 0) { - ov::threading::IStreamsExecutor::Config task_executor_config(tags, 1); - task_executor_config._streams = (num_streams > 0) ? num_streams : config.get_property(ov::compilation_num_threads); + int streams = (num_streams > 0) ? num_streams : config.get_property(ov::compilation_num_threads); auto priority = config.get_property(ov::intel_gpu::hint::host_task_priority); + auto core_type = ov::threading::IStreamsExecutor::Config::ANY; switch (priority) { - case ov::hint::Priority::LOW: task_executor_config._threadPreferredCoreType = ov::threading::IStreamsExecutor::Config::LITTLE; break; - case ov::hint::Priority::MEDIUM: task_executor_config._threadPreferredCoreType = ov::threading::IStreamsExecutor::Config::ANY; break; - case ov::hint::Priority::HIGH: task_executor_config._threadPreferredCoreType = ov::threading::IStreamsExecutor::Config::BIG; break; + case ov::hint::Priority::LOW: core_type = ov::threading::IStreamsExecutor::Config::LITTLE; break; + case ov::hint::Priority::MEDIUM: core_type = ov::threading::IStreamsExecutor::Config::ANY; break; + case ov::hint::Priority::HIGH: core_type = ov::threading::IStreamsExecutor::Config::BIG; break; default: OPENVINO_ASSERT(false, "[GPU] Can't create task executor: invalid host task priority value: ", priority); } bool enable_cpu_pinning = config.get_property(ov::hint::enable_cpu_pinning); - task_executor_config.update_executor_config(task_executor_config._streams, - 1, - task_executor_config._threadPreferredCoreType, - enable_cpu_pinning); + ov::threading::IStreamsExecutor::Config task_executor_config( + tags, + streams, + 1, + ov::threading::IStreamsExecutor::ThreadBindingType::NONE, + 1, + 0, + 0, + core_type, + {}, + enable_cpu_pinning); return task_executor_config; } @@ -589,6 +596,11 @@ void program::pre_optimize_graph(bool is_internal) { // check if there exists some layout incompatibilities and add an reorder node if required apply_opt_pass(); + // Check fusing primitives based on preferred format or layout optimization + if (optimize_data) { + apply_opt_pass(); + } + // add optimization attributes for onednn primitives apply_opt_pass(); diff --git a/src/plugins/intel_gpu/src/graph/swiglu.cpp b/src/plugins/intel_gpu/src/graph/swiglu.cpp new file mode 100644 index 00000000000000..c3d36e15684610 --- /dev/null +++ b/src/plugins/intel_gpu/src/graph/swiglu.cpp @@ -0,0 +1,69 @@ +// Copyright (C) 2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "intel_gpu/op/swiglu.hpp" +#include "swiglu_inst.h" + +#include "primitive_type_base.h" +#include "json_object.h" +#include + +namespace cldnn { +GPU_DEFINE_PRIMITIVE_TYPE_ID(swiglu); + +layout swiglu_inst::calc_output_layout(swiglu_node const& node, kernel_impl_params const& impl_param) { + auto desc = impl_param.typed_desc(); + auto input_layout = impl_param.get_input_layout(); + auto output_type = impl_param.desc->output_data_types[0].value_or(input_layout.data_type); + auto output_format = input_layout.format; + + return layout(output_type, output_format, desc->output_size); +} + +template +std::vector swiglu_inst::calc_output_layouts(swiglu_node const& /*node*/, const kernel_impl_params& impl_param) { + auto desc = impl_param.typed_desc(); + auto input_layout = impl_param.get_input_layout(); + auto output_type = impl_param.desc->output_data_types[0].value_or(input_layout.data_type); + auto output_format = input_layout.format; + + ov::intel_gpu::op::SwiGLU op; + op.set_axis(desc->axis); + op.set_split_lengths(desc->split_lengths); + + std::vector input_shapes = { + impl_param.get_input_layout(0).get(), + ShapeType(ov::Shape({})), + ShapeType(ov::Shape{2}) + }; + + std::vector output_shapes = shape_infer(&op, input_shapes); + + return { layout(output_shapes[0], output_type, output_format) }; +} + +template std::vector swiglu_inst::calc_output_layouts(swiglu_node const& node, + const kernel_impl_params& impl_param); + +std::string swiglu_inst::to_string(swiglu_node const& node) { + auto desc = node.get_primitive(); + auto node_info = node.desc_to_json(); + auto& input = node.input(); + + std::stringstream primitive_description; + + json_composite swiglu_info; + swiglu_info.add("input_id", input.id()); + swiglu_info.add("axis", desc->axis); + swiglu_info.add("split_lengths", desc->split_lengths); + + node_info->add("swiglu_info", swiglu_info); + node_info->dump(primitive_description); + + return primitive_description.str(); +} + +swiglu_inst::typed_primitive_inst(network& network, swiglu_node const& node) : parent(network, node) {} + +} // namespace cldnn diff --git a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/adaptive_pooling_gpu_ref.cl b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/adaptive_pooling_gpu_ref.cl index f3eaa90f6e5fa9..9ef1748a42526f 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/adaptive_pooling_gpu_ref.cl +++ b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/adaptive_pooling_gpu_ref.cl @@ -16,8 +16,12 @@ KERNEL(adaptive_pooling_gpu)( const __global INPUT0_TYPE* input, __global OUTPUT_TYPE* output #if MAX_POOLING +#if NEW_MULTIPLE_OUTPUTS + , __global OUTPUT1_TYPE* output1 +#else , __global INDICES_TYPE* indices #endif +#endif ) { const uint bf = (uint)get_global_id(2); @@ -36,7 +40,11 @@ KERNEL(adaptive_pooling_gpu)( ACCUMULATOR_TYPE result = INIT_VAL; #if MAX_POOLING +#if NEW_MULTIPLE_OUTPUTS + OUTPUT1_TYPE result_idx = 0; +#else INDICES_TYPE result_idx = 0; +#endif #elif AVG_POOLING uint num_elements = 0; #else @@ -101,6 +109,16 @@ KERNEL(adaptive_pooling_gpu)( #endif #if MAX_POOLING +#if NEW_MULTIPLE_OUTPUTS + #if OUTPUT_DIMS == 5 + const uint index_pos = OUTPUT1_GET_INDEX(b, f, z, y, x); + #else + const uint index_pos = OUTPUT1_GET_INDEX(b, f, y, x); + #endif + + output[output_pos] = result; + output1[index_pos] = result_idx; +#else #if OUTPUT_DIMS == 5 const uint index_pos = INPUT1_GET_INDEX(b, f, z, y, x); #else @@ -109,6 +127,7 @@ KERNEL(adaptive_pooling_gpu)( output[output_pos] = result; indices[index_pos] = result_idx; +#endif #elif AVG_POOLING output[output_pos] = result / TO_ACCUMULATOR_TYPE(max(num_elements, (uint)1)); #else diff --git a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/fully_connected_gpu_bf_tiled.cl b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/fully_connected_gpu_bf_tiled.cl index fe23ffb9d90a32..766fdfb554cb33 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/fully_connected_gpu_bf_tiled.cl +++ b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/fully_connected_gpu_bf_tiled.cl @@ -55,6 +55,7 @@ #define TO_OUTPUT_VEC_TYPE(x) CAT(convert_, OUTPUT_VEC_TYPE)(x) #define TO_ACTIVATION_VEC_TYPE(x) CAT(convert_, ACTIVATION_VEC_TYPE)(x) #define TO_FILTER_VEC_TYPE(x) CAT(convert_, FILTER_VEC_TYPE)(x) +#define TO_ACCUMULATOR_VEC_TYPE(x) CAT(convert_, ACCUMULATOR_VEC_TYPE)(x) #define INPUT_BLOCK_READ(ptr, offset) BLOCK_READN(INPUT0_TYPE, TILE_IFM, ptr, offset) #define FILTER_BLOCK_READ(ptr, offset) BLOCK_READN(FILTER_TYPE, TILE_K_OFM_PACKED, ptr, offset) @@ -184,7 +185,7 @@ inline void FUNC(fc_bf_tiled_kernel_default)( #if COMPRESSED_WEIGHTS && DECOMPRESSION_SCALE_GROUPS_NUM == 1 #if DECOMPRESSION_SCALE_LENGTH > 1 && DECOMPRESSION_SCALE_LENGTH % (TILE_OFM * SIMD) == 0 - ACCUMULATOR_VEC_TYPE d_scale = BLOCK_READN(ACCUMULATOR_TYPE, TILE_OFM, decompression_scale, out_f); + ACCUMULATOR_VEC_TYPE d_scale = TO_ACCUMULATOR_VEC_TYPE(BLOCK_READN(DECOMPRESSION_SCALE_TYPE, TILE_OFM, decompression_scale, out_f)); #elif DECOMPRESSION_SCALE_LENGTH > 1 && DECOMPRESSION_SCALE_LENGTH % (TILE_OFM * SIMD) != 0 ACCUMULATOR_VEC_TYPE d_scale = 0; unroll_for(uint of = 0; of < TILE_OFM; ++of) { @@ -201,7 +202,7 @@ inline void FUNC(fc_bf_tiled_kernel_default)( #if COMPRESSED_WEIGHTS && DECOMPRESSION_ZP_TERM && DECOMPRESSION_ZP_GROUPS_NUM == 1 && !DECOMPRESSION_ZP_SCALAR #if DECOMPRESSION_ZP_LENGTH > 1 && DECOMPRESSION_ZP_LENGTH % (TILE_OFM * SIMD) == 0 - ACCUMULATOR_VEC_TYPE d_zp = BLOCK_READN(ACCUMULATOR_TYPE, TILE_OFM, decompression_zp, out_f); + ACCUMULATOR_VEC_TYPE d_zp = TO_ACCUMULATOR_VEC_TYPE(BLOCK_READN(DECOMPRESSION_ZP_TYPE, TILE_OFM, decompression_zp, out_f)); #elif DECOMPRESSION_ZP_LENGTH > 1 && DECOMPRESSION_ZP_LENGTH % (TILE_OFM * SIMD) != 0 ACCUMULATOR_VEC_TYPE d_zp = 0; unroll_for(uint of = 0; of < TILE_OFM; ++of) { diff --git a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/include/batch_headers/fetch_weights.cl b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/include/batch_headers/fetch_weights.cl index 9274eb5cab193f..492086141aea7d 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/include/batch_headers/fetch_weights.cl +++ b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/include/batch_headers/fetch_weights.cl @@ -326,6 +326,53 @@ inline uint get_os_is_zyx_isv8_osv16_isv2_index(uint g, uint o, uint i, uint z, return idx; } +#define GET_FILTER_OS_IS_YX_ISA8_OSV16_ISV2_INDEX(prefix, o, i, y, x) \ + get_os_is_zyx_isa8_osv16_isv2_index( \ + o, i, 0, y, x, \ + CAT(prefix, _SIZE_X), \ + CAT(prefix, _SIZE_Y), \ + CAT(prefix, _SIZE_Z), \ + CAT(prefix, _IFM_NUM), \ + CAT(prefix, _OFM_NUM), \ + CAT(prefix, _OFFSET) \ + ) + +#define GET_FILTER_OS_IS_ZYX_ISA8_OSV16_ISV2_INDEX(prefix, o, i, z, y, x) \ + get_os_is_zyx_isa8_osv16_isv2_index( \ + o, i, z, y, x, \ + CAT(prefix, _SIZE_X), \ + CAT(prefix, _SIZE_Y), \ + CAT(prefix, _SIZE_Z), \ + CAT(prefix, _IFM_NUM), \ + CAT(prefix, _OFM_NUM), \ + CAT(prefix, _OFFSET) \ + ) + +inline uint get_os_is_zyx_isa8_osv16_isv2_index(uint o, uint i, uint z, uint y, uint x, uint size_x, + uint size_y, uint size_z, uint size_ifm, uint size_ofm, uint offset) +{ + const uint isv2_idx = i % 2; + const uint osv_idx = o % 16; + const uint isv1_idx = (i / 2) % 8; + const uint is_idx = i / 16; + const uint os_idx = o / 16; + + const uint if_16_aligned = ((size_ifm + 15) / 16); + const uint of_16_aligned = ((size_ofm + 15) / 16); + + size_t idx = offset + + isv2_idx + + osv_idx * 2 + + isv1_idx * 16 * 2 + + x * 8 * 16 * 2 + + y * size_x * 8 * 16 * 2 + + z * size_y * size_x * 8 * 16 * 2 + + is_idx * size_z * size_y * size_x * 2 * 16 * 8 + + os_idx * if_16_aligned * size_z * size_y * size_x * 2 * 16 * 8; + + return idx; +} + inline uint get_os_zyxi_osv16_index(uint o, uint i, uint z, uint y, uint x, uint i_size, uint o_size, uint x_size, uint y_size, uint z_size) { const size_t idx = o%16 + (o / 16)*i_size*x_size*y_size*z_size*16 + diff --git a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/include/fully_connected_gpu_bf_tiled_common.cl b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/include/fully_connected_gpu_bf_tiled_common.cl index 98fe1d1082d3c8..962ea0fb39806c 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/include/fully_connected_gpu_bf_tiled_common.cl +++ b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/include/fully_connected_gpu_bf_tiled_common.cl @@ -52,7 +52,7 @@ inline void (FUNC_NAME)( #if COMPRESSED_WEIGHTS && DECOMPRESSION_SCALE_GROUPS_NUM == 1 #if DECOMPRESSION_SCALE_LENGTH > 1 && DECOMPRESSION_SCALE_LENGTH % (TILE_OFM * SIMD) == 0 - ACCUMULATOR_VEC_TYPE d_scale = BLOCK_READN(ACCUMULATOR_TYPE, TILE_OFM, decompression_scale, out_f); + ACCUMULATOR_VEC_TYPE d_scale = TO_ACCUMULATOR_VEC_TYPE(BLOCK_READN(DECOMPRESSION_SCALE_TYPE, TILE_OFM, decompression_scale, out_f)); #elif DECOMPRESSION_SCALE_LENGTH > 1 && DECOMPRESSION_SCALE_LENGTH % (TILE_OFM * SIMD) != 0 ACCUMULATOR_VEC_TYPE d_scale = 0; unroll_for(uint of = 0; of < TILE_OFM; ++of) { @@ -69,7 +69,7 @@ inline void (FUNC_NAME)( #if COMPRESSED_WEIGHTS && DECOMPRESSION_ZP_TERM && DECOMPRESSION_ZP_GROUPS_NUM == 1 && !DECOMPRESSION_ZP_SCALAR #if DECOMPRESSION_ZP_LENGTH > 1 && DECOMPRESSION_ZP_LENGTH % (TILE_OFM * SIMD) == 0 - ACCUMULATOR_VEC_TYPE d_zp = BLOCK_READN(ACCUMULATOR_TYPE, TILE_OFM, decompression_zp, out_f); + ACCUMULATOR_VEC_TYPE d_zp = TO_ACCUMULATOR_VEC_TYPE(BLOCK_READN(DECOMPRESSION_ZP_TYPE, TILE_OFM, decompression_zp, out_f)); #elif DECOMPRESSION_ZP_LENGTH > 1 && DECOMPRESSION_ZP_LENGTH % (TILE_OFM * SIMD) != 0 ACCUMULATOR_VEC_TYPE d_zp = 0; unroll_for(uint of = 0; of < TILE_OFM; ++of) { diff --git a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/reorder_weights.cl b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/reorder_weights.cl index 6fc451580b291a..dbc584eba22714 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/reorder_weights.cl +++ b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/reorder_weights.cl @@ -454,6 +454,10 @@ inline uint FUNC(get_input_index)(uint g, uint o, uint i, uint z, uint y, uint x return GET_FILTER_OS_IS_ZYX_OSV32_ISV16_INDEX(INPUT0, o, i, z, y, x); #elif defined INPUT0_LAYOUT_OS_IS_ZYX_OSV64_ISV16 return GET_FILTER_OS_IS_ZYX_OSV64_ISV16_INDEX(INPUT0, o, i, z, y, x); +#elif defined INPUT0_LAYOUT_OS_IS_YX_ISA8_OSV16_ISV2 + return GET_FILTER_OS_IS_YX_ISA8_OSV16_ISV2_INDEX(INPUT0, o, i, z, y, x); +#elif defined INPUT0_LAYOUT_OS_IS_ZYX_ISA8_OSV16_ISV2 + return GET_FILTER_OS_IS_ZYX_ISA8_OSV16_ISV2_INDEX(INPUT0, o, i, z, y, x); #elif defined INPUT0_LAYOUT_GS_OI_YXS_GSV16_YXSV4 return GET_FILTER_GS_OI_YXS_GSV16_YXSV4_INDEX(INPUT0, g, o, i, y, x); #elif defined INPUT0_LAYOUT_GS_OI_YXS_GSV32_YXSV4 @@ -725,6 +729,10 @@ inline uint FUNC(get_output_index)(uint g, uint o, uint i, uint z, uint y, uint return GET_FILTER_GS_OI_YXS_GSV4_YXSV4_INDEX(OUTPUT, g, o, i, y, x); #elif defined OUTPUT_LAYOUT_G_OS_IS_YX_ISV16_OSV16 return GET_FILTER_G_OS_IS_YX_ISV16_OSV16_INDEX(OUTPUT, g, o, i, y, x, SUB_GROUP_SIZE); +#elif defined OUTPUT_LAYOUT_OS_IS_YX_ISA8_OSV16_ISV2 + return GET_FILTER_OS_IS_YX_ISA8_OSV16_ISV2_INDEX(OUTPUT, o, i, y, x); +#elif defined OUTPUT_LAYOUT_OS_IS_ZYX_ISA8_OSV16_ISV2 + return GET_FILTER_OS_IS_ZYX_ISA8_OSV16_ISV2_INDEX(OUTPUT, o, i, z, y, x); #elif defined OUTPUT_LAYOUT_OS_IS_YX_OSV16_ISV2 return GET_FILTER_OS_IS_YX_OSV16_ISV2_INDEX(OUTPUT, o, i, y, x); #elif defined OUTPUT_LAYOUT_OS_IS_YX_OSV16_ISV16 diff --git a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/swiglu_gpu_ref.cl b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/swiglu_gpu_ref.cl new file mode 100644 index 00000000000000..a943a6e101cea1 --- /dev/null +++ b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/swiglu_gpu_ref.cl @@ -0,0 +1,43 @@ +// Copyright (C) 2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "include/batch_headers/fetch_data.cl" + +KERNEL(swiglu_gpu_ref)( + OPTIONAL_SHAPE_INFO_ARG + const __global INPUT0_TYPE* input, + __global OUTPUT_TYPE* output) +{ +#if OUTPUT_DIMS == 5 + uint data_idx = (uint)get_global_id(GWS_YX); + const uint x = data_idx % OUTPUT_SIZE_X; + data_idx = data_idx / OUTPUT_SIZE_X; + const uint y = data_idx % OUTPUT_SIZE_Y; + data_idx = data_idx / OUTPUT_SIZE_Y; + const uint z = data_idx % OUTPUT_SIZE_Z; +#else // 2D spatial + const uint x = (uint)get_global_id(GWS_YX) % OUTPUT_SIZE_X; + const uint y = (uint)get_global_id(GWS_YX) / OUTPUT_SIZE_X; +#endif + const uint f = (uint)get_global_id(GWS_FEATURE); + const uint b = (uint)get_global_id(GWS_BATCH); + +#if OUTPUT_DIMS == 5 + const uint output_idx = OUTPUT_GET_INDEX(b, f, z, y, x); + const uint gate_idx = INPUT0_GET_INDEX(b, f, z, y, x); + const uint input_idx = INPUT0_GET_INDEX(b, f, z, y, x) + SPLIT_LENGTH; +#else // 2D spatial + const uint output_idx = OUTPUT_GET_INDEX(b, f, y, x); + const uint gate_idx = INPUT0_GET_INDEX(b, f, y, x); + const uint input_idx = INPUT0_GET_INDEX(b, f, y, x) + SPLIT_LENGTH; +#endif + + ACCUMULATOR_TYPE res = ACCUMULATOR_VAL_ZERO; + + res = (ACCUMULATOR_TYPE)input[gate_idx]; + res /= ACCUMULATOR_VAL_ONE + exp(-(ACCUMULATOR_VAL_ONE * res)); + res *= (ACCUMULATOR_TYPE)input[input_idx]; + + output[output_idx] = TO_OUTPUT_TYPE(res); +} diff --git a/src/plugins/intel_gpu/src/kernel_selector/common_types.h b/src/plugins/intel_gpu/src/kernel_selector/common_types.h index 2b6f7be857be8c..0f026a77ae855c 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/common_types.h +++ b/src/plugins/intel_gpu/src/kernel_selector/common_types.h @@ -94,6 +94,7 @@ enum class KernelType { UNIQUE_COUNT, UNIQUE_GATHER, RMS, + SWIGLU, }; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernel_base_opencl.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernel_base_opencl.cpp index 0a5655a4996cff..52853d7012f1cf 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernel_base_opencl.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/kernel_base_opencl.cpp @@ -103,6 +103,7 @@ std::pair KernelBaseOpenCL::CreateJit(const std::strin .decoration_macro("CONST_ARRAY_REF", "", kernel_id); undefs += "#undef KERNEL\n"; + undefs += "#undef KERNEL_ID\n"; undefs += "#undef FUNC\n"; undefs += "#undef FUNC_CALL\n"; undefs += "#undef CONST_ARRAY_DECL\n"; diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernel_selector_common.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernel_selector_common.cpp index 542036ee9b12ad..a56f49b468b7fd 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernel_selector_common.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/kernel_selector_common.cpp @@ -371,6 +371,8 @@ std::string toString(WeightsLayout layout) { case WeightsLayout::is_os_yx_osv8_isv4: return "IS_OS_YX_OSV8_ISV4"; case WeightsLayout::is_os_yx_osa8_isv16_osv4: return "IS_OS_YX_OSA8_ISV16_OSV4"; case WeightsLayout::os_is_yx_isa8_osv8_isv2: return "OS_IS_YX_ISA8_OSV8_ISV2"; + case WeightsLayout::os_is_yx_isa8_osv16_isv2: return "OS_IS_YX_ISA8_OSV16_ISV2"; + case WeightsLayout::os_is_zyx_isa8_osv16_isv2: return "OS_IS_ZYX_ISA8_OSV16_ISV2"; case WeightsLayout::os_is_zyx_isv8_osv16_isv2: return "OS_IS_ZYX_ISV8_OSV16_ISV2"; case WeightsLayout::os_zyxi_osv16: return "OS_ZYXI_OSV16"; case WeightsLayout::os_is_yx_isv8_osv16_isv2: return "OS_IS_YX_ISV8_OSV16_ISV2"; diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/adaptive_pooling/adaptive_pooling_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/adaptive_pooling/adaptive_pooling_kernel_ref.cpp index af9cd1d97db689..d32020fb9f172f 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/adaptive_pooling/adaptive_pooling_kernel_ref.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/adaptive_pooling/adaptive_pooling_kernel_ref.cpp @@ -41,8 +41,9 @@ bool AdaptivePoolingRef::Validate(const Params& p, const optional_params& o) con const auto& params = dynamic_cast(p); const auto& inputs = params.inputs; - if (!((params.mode == PoolType::MAX && inputs.size() == 2) || - (params.mode == PoolType::AVG && inputs.size() == 1))) { + if (!((params.mode == PoolType::AVG && inputs.size() == 1) + || (params.mode == PoolType::MAX && inputs.size() == 2) + || (params.mode == PoolType::MAX && inputs.size() == 1 && params.outputs_num == 2))) { return false; } @@ -86,8 +87,15 @@ KernelsData AdaptivePoolingRef::GetKernelsData(const Params& params, const optio cldnn_jit.AddConstant(MakeJitConstant(toString(new_params.mode) + "_POOLING", 1)); + if (new_params.outputs_num == 2) { + cldnn_jit.AddConstant(MakeJitConstant("NEW_MULTIPLE_OUTPUTS", 1)); + } + if (new_params.mode == PoolType::MAX) { - cldnn_jit.Merge(MakeTypeJitConstants(new_params.poolIndexElementType, "INDICES")); + if (new_params.outputs_num == 1) { + // Legacy code of mutable data + cldnn_jit.Merge(MakeTypeJitConstants(new_params.poolIndexElementType, "INDICES")); + } } const auto accumulator_type = new_params.inputs[0].GetDType(); @@ -105,7 +113,12 @@ KernelsData AdaptivePoolingRef::GetKernelsData(const Params& params, const optio arguments.push_back({ArgumentDescriptor::Types::INPUT, 0}); // input data arguments.push_back({ArgumentDescriptor::Types::OUTPUT, 0}); // output if (new_params.mode == PoolType::MAX) { - arguments.push_back({ArgumentDescriptor::Types::INPUT, 1}); // indices + if (new_params.outputs_num == 2) { + arguments.push_back({ArgumentDescriptor::Types::OUTPUT, 1}); // second output + } else { + // Legacy code of mutable data + arguments.push_back({ArgumentDescriptor::Types::INPUT, 1}); // indices + } } KernelsData kernelsData; diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/adaptive_pooling/adaptive_pooling_kernel_ref.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/adaptive_pooling/adaptive_pooling_kernel_ref.h index 0ba5176da7621d..1c55656d8e8492 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/adaptive_pooling/adaptive_pooling_kernel_ref.h +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/adaptive_pooling/adaptive_pooling_kernel_ref.h @@ -12,6 +12,7 @@ struct adaptive_pooling_params : public base_params { PoolType mode{PoolType::MAX}; Datatype poolIndexElementType = Datatype::INT64; + int64_t outputs_num = 1; }; struct adaptive_pooling_optional_params : public optional_params { diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/swiglu/swiglu_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/swiglu/swiglu_kernel_ref.cpp new file mode 100644 index 00000000000000..fac86e7b2135aa --- /dev/null +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/swiglu/swiglu_kernel_ref.cpp @@ -0,0 +1,115 @@ +// Copyright (C) 2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "swiglu_kernel_ref.h" +#include "kernel_selector_utils.h" +#include + +namespace kernel_selector { +ParamsKey SwiGLUKernelRef::GetSupportedKey() const { + ParamsKey k; + k.EnableInputDataType(Datatype::F16); + k.EnableInputDataType(Datatype::F32); + k.EnableOutputDataType(Datatype::F16); + k.EnableOutputDataType(Datatype::F32); + k.EnableInputLayout(DataLayout::bfyx); + k.EnableInputLayout(DataLayout::bfzyx); + k.EnableOutputLayout(DataLayout::bfyx); + k.EnableOutputLayout(DataLayout::bfzyx); + k.EnableTensorOffset(); + k.EnableTensorPitches(); + k.EnableBatching(); + k.EnableDifferentTypes(); + k.EnableDynamicShapesSupport(); + return k; +} + +JitConstants SwiGLUKernelRef::GetJitConstants(const swiglu_params& params) const { + JitConstants jit = MakeBaseParamsJitConstants(params); + + jit.AddConstants({MakeJitConstant("AXIS", params.axis)}); + jit.AddConstants({MakeJitConstant("SPLIT_LENGTH", params.split_length)}); + jit.Merge(MakeTypeJitConstants(GetAccumulatorType(params), "ACCUMULATOR")); + jit.Merge(GetTensorFriendlyWorkGroupsJit(params.outputs[0])); + + return jit; +} + +CommonDispatchData SwiGLUKernelRef::SetDefault(const swiglu_params& params) const { + CommonDispatchData dispatchData; + + dispatchData.gws = GetTensorFriendlyWorkGroups(params.outputs[0]); + dispatchData.lws = GetOptimalLocalWorkGroupSizes(dispatchData.gws, params.engineInfo); + + return dispatchData; +} + +void SwiGLUKernelRef::GetUpdateDispatchDataFunc(KernelData& kd) const { + kd.update_dispatch_data_func = [this](const Params& params, KernelData& kd) { + const auto& prim_params = static_cast(params); + auto dispatchData = SetDefault(prim_params); + OPENVINO_ASSERT(kd.kernels.size() == 1, "[GPU] Invalid kernels size for update dispatch data func"); + kd.kernels[0].params.workGroups.global = dispatchData.gws; + kd.kernels[0].params.workGroups.local = dispatchData.lws; + kd.kernels[0].skip_execution = KernelData::SkipKernelExecution(prim_params); + }; +} + +KernelsData SwiGLUKernelRef::GetKernelsData(const Params& params, const optional_params& options) const { + assert(params.GetType() == KernelType::SWIGLU); + + if (!Validate(params, options)) + return {}; + + const swiglu_params& orgParams = static_cast(params); + auto dispatchData = SetDefault(orgParams); + + KernelData kd = KernelData::Default(params); + + auto cldnn_jit = GetJitConstants(orgParams); + auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, params, options); + auto jit = CreateJit(kernelName, cldnn_jit, entry_point); + + GetUpdateDispatchDataFunc(kd); + + auto& kernel = kd.kernels[0]; + FillCLKernelData(kernel, + dispatchData, + params.engineInfo, + kernelName, + jit, + entry_point, + EXE_MODE_DEFAULT, + false, + false, + 1, + GetFusedPrimitiveInputsCount(params), + 1, + orgParams.has_dynamic_tensors()); + + return {kd}; +} + +KernelsPriority SwiGLUKernelRef::GetKernelsPriority(const Params& /*params*/, const optional_params& /*options*/) const { + return DONT_USE_IF_HAVE_SOMETHING_ELSE; +} + +Datatype SwiGLUKernelRef::GetAccumulatorType(const swiglu_params& params) const { + Datatype types[] = { Datatype::F32, Datatype::F16, Datatype::INT64, Datatype::INT32, Datatype::UINT32}; + + for (Datatype type : types) + for (auto& in : params.inputs) + if (in.GetDType() == type) + return type; + + return Datatype::F32; +} + +bool SwiGLUKernelRef::Validate(const Params& params, const optional_params& options) const { + if (!KernelBaseOpenCL::Validate(params, options)) + return false; + + return true; +} +} // namespace kernel_selector diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/swiglu/swiglu_kernel_ref.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/swiglu/swiglu_kernel_ref.h new file mode 100644 index 00000000000000..b4b5e4cac87be7 --- /dev/null +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/swiglu/swiglu_kernel_ref.h @@ -0,0 +1,42 @@ +// Copyright (C) 2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "kernel_base_opencl.h" + +namespace kernel_selector { +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// swiglu_params +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +struct swiglu_params : public base_params { + swiglu_params() : base_params(KernelType::SWIGLU), axis(0), split_length(0) {} + int32_t axis; + int32_t split_length; +}; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// swiglu_optional_params +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +struct swiglu_optional_params : optional_params { + swiglu_optional_params() : optional_params(KernelType::SWIGLU) {} +}; + +class SwiGLUKernelRef : public KernelBaseOpenCL { +public: + SwiGLUKernelRef() : KernelBaseOpenCL("swiglu_gpu_ref") {} + virtual ~SwiGLUKernelRef() {} + + virtual JitConstants GetJitConstants(const swiglu_params& params) const; + virtual CommonDispatchData SetDefault(const swiglu_params& params) const; + KernelsData GetKernelsData(const Params& params, const optional_params& options) const override; + KernelsPriority GetKernelsPriority(const Params& params, const optional_params& options) const override; + Datatype GetAccumulatorType(const swiglu_params& params) const; + ParamsKey GetSupportedKey() const override; + +protected: + bool Validate(const Params&, const optional_params&) const override; + void GetUpdateDispatchDataFunc(KernelData& kd) const override; +}; +} // namespace kernel_selector diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/swiglu/swiglu_kernel_selector.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/swiglu/swiglu_kernel_selector.cpp new file mode 100644 index 00000000000000..0287f7c1ae4ddc --- /dev/null +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/swiglu/swiglu_kernel_selector.cpp @@ -0,0 +1,14 @@ +// Copyright (C) 2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "swiglu_kernel_selector.h" +#include "swiglu_kernel_ref.h" + +namespace kernel_selector { +swiglu_kernel_selector::swiglu_kernel_selector() { Attach(); } + +KernelsData swiglu_kernel_selector::GetBestKernels(const Params& params, const optional_params& options) const { + return GetNaiveBestKernel(params, options, KernelType::SWIGLU); +} +} // namespace kernel_selector diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/swiglu/swiglu_kernel_selector.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/swiglu/swiglu_kernel_selector.h new file mode 100644 index 00000000000000..a245a49d11f783 --- /dev/null +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/swiglu/swiglu_kernel_selector.h @@ -0,0 +1,23 @@ +// Copyright (C) 2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "kernel_selector.h" + +namespace kernel_selector { +class swiglu_kernel_selector : public kernel_selector_base { +public: + static swiglu_kernel_selector& Instance() { + static swiglu_kernel_selector instance_; + return instance_; + } + + swiglu_kernel_selector(); + + virtual ~swiglu_kernel_selector() {} + + KernelsData GetBestKernels(const Params& params, const optional_params& options) const override; +}; +} // namespace kernel_selector diff --git a/src/plugins/intel_gpu/src/kernel_selector/tensor_type.cpp b/src/plugins/intel_gpu/src/kernel_selector/tensor_type.cpp index ad2fa28b220e47..f6ca2a01254f27 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/tensor_type.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/tensor_type.cpp @@ -163,6 +163,8 @@ WeightsTensor::WeightsChannelArray WeightsTensor::weightsChannelArray {{ { WeightsLayout::is_os_yx_isa4_osa8_isv8_osv4, { 0, 1, -1, 3, 2, -1 } }, { WeightsLayout::is_os_yx_osa4_isa8_osv8_isv4, { 0, 1, -1, 3, 2, -1 } }, { WeightsLayout::os_is_osv32_isv32_swizzled_by_4, { -1, -1, -1, 0, 1, -1 } }, + { WeightsLayout::os_is_zyx_isa8_osv16_isv2, { 0, 1, 2, 3, 4, -1 } }, + { WeightsLayout::os_is_yx_isa8_osv16_isv2, { 0, 1, -1, 2, 3, -1 } }, { WeightsLayout::os_is_zyx_isv8_osv16_isv2, { 0, 1, 2, 3, 4, -1 } }, { WeightsLayout::os_is_yx_isv8_osv16_isv2, { 0, 1, -1, 2, 3, -1 } }, { WeightsLayout::os_is_zyx_isa8_osv8_isv2, { 0, 1, 2, 3, 4, -1 } }, @@ -833,11 +835,13 @@ NDims WeightsTensor::GetSimpleDims(const std::vector& d, WeightsLayout l newDims[2] = RoundUp(newDims[2], 16); newDims[3] = RoundUp(newDims[3], 2); break; + case os_is_yx_isa8_osv16_isv2: case os_is_yx_isv8_osv16_isv2: assert(newDims.size() == 4); newDims[2] = RoundUp(newDims[2], 16); newDims[3] = RoundUp(newDims[3], 16); break; + case os_is_zyx_isa8_osv16_isv2: case os_is_zyx_isv8_osv16_isv2: assert(newDims.size() == 5); newDims[3] = RoundUp(newDims[3], 16); diff --git a/src/plugins/intel_gpu/src/kernel_selector/tensor_type.h b/src/plugins/intel_gpu/src/kernel_selector/tensor_type.h index 28322dafc8a7a6..d16dee409c91b4 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/tensor_type.h +++ b/src/plugins/intel_gpu/src/kernel_selector/tensor_type.h @@ -109,7 +109,9 @@ enum WeightsLayout { is_os_yx_isv16_osv8, is_os_yx_isv16_osv4, is_os_yx_isv16_osv2, + os_is_zyx_isa8_osv16_isv2, // aligned os_is_zyx_isv8_osv16_isv2, + os_is_yx_isa8_osv16_isv2, // aligned os_is_yx_isv8_osv16_isv2, os_is_yx_isv16_osv16, os_zyxi_osv16, diff --git a/src/plugins/intel_gpu/src/plugin/compiled_model.cpp b/src/plugins/intel_gpu/src/plugin/compiled_model.cpp index 2bed086a94ca8f..543c77734cc492 100644 --- a/src/plugins/intel_gpu/src/plugin/compiled_model.cpp +++ b/src/plugins/intel_gpu/src/plugin/compiled_model.cpp @@ -36,7 +36,7 @@ std::shared_ptr create_task_executor(const std::sh } else if (config.get_property(ov::hint::enable_cpu_pinning)) { auto executor_config = ov::threading::IStreamsExecutor::Config{"Intel GPU plugin executor", - 0, + config.get_property(ov::num_streams), 0, ov::threading::IStreamsExecutor::ThreadBindingType::CORES, 1, @@ -45,8 +45,7 @@ std::shared_ptr create_task_executor(const std::sh ov::threading::IStreamsExecutor::Config::PreferredCoreType::BIG, {{config.get_property(ov::num_streams), MAIN_CORE_PROC, 1, 0, 0}}, true}; - auto post_config = ov::threading::IStreamsExecutor::Config::reserve_cpu_threads(executor_config); - return std::make_shared(post_config); + return std::make_shared(executor_config); } else { return std::make_shared( ov::threading::IStreamsExecutor::Config{"Intel GPU plugin executor", config.get_property(ov::num_streams)}); diff --git a/src/plugins/intel_gpu/src/plugin/ops/adaptive_pooling.cpp b/src/plugins/intel_gpu/src/plugin/ops/adaptive_pooling.cpp index 9f7de35b7cb966..6395535bcc290f 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/adaptive_pooling.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/adaptive_pooling.cpp @@ -20,10 +20,17 @@ static void CreateAdaptiveAvgPoolOp(ProgramBuilder& p, const std::shared_ptrget_output_shape(0))}; - p.add_primitive(*op, poolPrim); + if (p.use_new_shape_infer()) { + const cldnn::adaptive_pooling poolPrim{layer_name, + inputs[0], + inputs[1]}; + p.add_primitive(*op, poolPrim); + } else { + const cldnn::adaptive_pooling poolPrim{layer_name, + inputs[0], + tensor_from_dims(op->get_output_shape(0))}; + p.add_primitive(*op, poolPrim); + } } static void CreateAdaptiveMaxPoolOp(ProgramBuilder& p, const std::shared_ptr& op) { @@ -32,32 +39,65 @@ static void CreateAdaptiveMaxPoolOp(ProgramBuilder& p, const std::shared_ptrget_output_element_type(1); - const auto indices_shape = op->get_output_shape(1); - const cldnn::layout indices_layout{cldnn::element_type_to_data_type(indices_precision), - cldnn::format::get_default_format(indices_shape.size()), - tensor_from_dims(indices_shape)}; - const auto indices_memory = p.get_engine().allocate_memory(indices_layout); - - const cldnn::primitive_id indices_id_w = layer_type_name + "_md_write"; - const cldnn::mutable_data indices_mutable_prim_w{indices_id_w, indices_memory}; - p.add_primitive(*op, indices_mutable_prim_w); - - inputs.push_back(cldnn::input_info(indices_id_w)); - - const cldnn::adaptive_pooling poolPrim{layer_name, - inputs[0], - tensor_from_dims(op->get_output_shape(0)), - inputs.back().pid, - cldnn::element_type_to_data_type(op->get_index_element_type())}; - p.add_primitive(*op, poolPrim); - - const cldnn::primitive_id indices_id_r = layer_type_name + ".out1"; - const cldnn::mutable_data indices_mutable_prim_r{indices_id_r, {cldnn::input_info(layer_name)}, indices_memory}; - p.add_primitive(*op, indices_mutable_prim_r); + + if (p.use_new_shape_infer()) { + size_t num_outputs = op->get_output_size(); + + auto get_output_paddings = [&]() { + std::vector output_paddings; + for (size_t i = 0; i < num_outputs; i++) + output_paddings.push_back(cldnn::padding()); + return output_paddings; + }; + + auto get_output_data_types = [&]() { + std::vector output_data_types; + for (size_t i = 0; i < num_outputs; i++) { + auto type = op->get_output_element_type(i); + output_data_types.push_back(cldnn::element_type_to_data_type(type)); + } + return output_data_types; + }; + + cldnn::adaptive_pooling poolPrim{layer_type_name, + inputs[0], + inputs[1], + cldnn::element_type_to_data_type(op->get_index_element_type()), + cldnn::padding({0, 0, 0, 0}, 0), + cldnn::element_type_to_data_type(op->get_output_element_type(0)), + num_outputs}; + poolPrim.output_paddings = get_output_paddings(); + poolPrim.output_data_types = get_output_data_types(); + p.add_primitive(*op, poolPrim); + + } else { + const auto layer_name = layer_type_name + ".out0"; + + const auto indices_precision = op->get_output_element_type(1); + const auto indices_shape = op->get_output_shape(1); + const cldnn::layout indices_layout{cldnn::element_type_to_data_type(indices_precision), + cldnn::format::get_default_format(indices_shape.size()), + tensor_from_dims(indices_shape)}; + const auto indices_memory = p.get_engine().allocate_memory(indices_layout); + + const cldnn::primitive_id indices_id_w = layer_type_name + "_md_write"; + const cldnn::mutable_data indices_mutable_prim_w{indices_id_w, indices_memory}; + p.add_primitive(*op, indices_mutable_prim_w); + + inputs.push_back(cldnn::input_info(indices_id_w)); + + const cldnn::adaptive_pooling poolPrim{layer_name, + inputs[0], + tensor_from_dims(op->get_output_shape(0)), + inputs.back().pid, + cldnn::element_type_to_data_type(op->get_index_element_type())}; + p.add_primitive(*op, poolPrim); + + const cldnn::primitive_id indices_id_r = layer_type_name + ".out1"; + const cldnn::mutable_data indices_mutable_prim_r{indices_id_r, {cldnn::input_info(layer_name)}, indices_memory}; + p.add_primitive(*op, indices_mutable_prim_r); } + } REGISTER_FACTORY_IMPL(v8, AdaptiveAvgPool); REGISTER_FACTORY_IMPL(v8, AdaptiveMaxPool); diff --git a/src/plugins/intel_gpu/src/plugin/ops/swiglu.cpp b/src/plugins/intel_gpu/src/plugin/ops/swiglu.cpp new file mode 100644 index 00000000000000..def2a52d281de2 --- /dev/null +++ b/src/plugins/intel_gpu/src/plugin/ops/swiglu.cpp @@ -0,0 +1,48 @@ +// Copyright (C) 2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "intel_gpu/op/swiglu.hpp" +#include "intel_gpu/plugin/program_builder.hpp" +#include "intel_gpu/plugin/common_utils.hpp" +#include "intel_gpu/primitives/swiglu.hpp" + +namespace ov { +namespace op { +namespace internal { +using SwiGLU = ov::intel_gpu::op::SwiGLU; +} // namespace internal +} // namespace op +} // namespace ov + +namespace ov { +namespace intel_gpu { + +static void CreateSwiGLUOp(ProgramBuilder& p, const std::shared_ptr& op) { + validate_inputs_count(op, {1}); + auto inputs = p.GetInputInfo(op); + std::string primitive_name = layer_type_name_ID(op); + + if (p.use_new_shape_infer()) { + auto prim = cldnn::swiglu(primitive_name, + inputs[0], + op->get_axis(), + op->get_split_lengths(), + cldnn::tensor()); + prim.output_data_types = get_output_data_types(op); + p.add_primitive(*op, prim); + } else { + auto prim = cldnn::swiglu(primitive_name, + inputs[0], + op->get_axis(), + op->get_split_lengths(), + tensor_from_dims(op->get_output_shape(0))); + prim.output_data_types = get_output_data_types(op); + p.add_primitive(*op, prim); + } +} + +REGISTER_FACTORY_IMPL(internal, SwiGLU); + +} // namespace intel_gpu +} // namespace ov diff --git a/src/plugins/intel_gpu/src/plugin/transformations/op/swiglu.cpp b/src/plugins/intel_gpu/src/plugin/transformations/op/swiglu.cpp new file mode 100644 index 00000000000000..e2d87fae0a24ba --- /dev/null +++ b/src/plugins/intel_gpu/src/plugin/transformations/op/swiglu.cpp @@ -0,0 +1,64 @@ +// Copyright (C) 2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "intel_gpu/op/swiglu.hpp" +#include "validation_util.hpp" +#include "variadic_split_shape_inference.hpp" +#include "openvino/core/partial_shape.hpp" +#include "openvino/op/variadic_split.hpp" + +namespace ov { +namespace intel_gpu { +namespace op { + +SwiGLU::SwiGLU(const Output& data, + int64_t axis, + int64_t split_lengths, + const ov::element::Type output_type) + : Op({data}), m_axis(axis), m_split_lengths(split_lengths), m_output_type(output_type) { + validate_and_infer_types(); +} + +bool SwiGLU::visit_attributes(ov::AttributeVisitor& visitor) { + visitor.on_attribute("axis", m_axis); + visitor.on_attribute("split_lengths", m_split_lengths); + visitor.on_attribute("output_type", m_output_type); + return true; +} + +void SwiGLU::validate_and_infer_types() { + auto output_type = m_output_type == ov::element::undefined ? get_input_element_type(0) : m_output_type; + + std::vector input_shapes = { + get_input_partial_shape(0), + ov::PartialShape(ov::Shape{}), + ov::PartialShape(ov::Shape{2}) + }; + + set_output_type(0, output_type, shape_infer(this, input_shapes)[0]); +} + +std::shared_ptr SwiGLU::clone_with_new_inputs(const ov::OutputVector& new_args) const { + check_new_args_count(this, new_args); + return std::make_shared(new_args.at(0), + m_axis, + m_split_lengths, + m_output_type); +} + +std::vector shape_infer(const SwiGLU* op, std::vector input_shapes) { + ov::op::v1::VariadicSplit variadic_split; + std::vector axis = { op->get_axis() }; + std::vector split_lengths = { op->get_split_lengths(), -1 }; + + std::unordered_map const_data; + const_data.emplace(1, ov::Tensor(ov::element::i64, ov::Shape{}, static_cast(axis.data()))); + const_data.emplace(2, ov::Tensor(ov::element::i64, ov::Shape{split_lengths.size()}, static_cast(split_lengths.data()))); + + return ov::op::v1::shape_infer(&variadic_split, input_shapes, ov::make_tensor_accessor(const_data)); +} + +} // namespace op +} // namespace intel_gpu +} // namespace ov diff --git a/src/plugins/intel_gpu/src/plugin/transformations/swiglu_fusion.cpp b/src/plugins/intel_gpu/src/plugin/transformations/swiglu_fusion.cpp new file mode 100644 index 00000000000000..1307cd5f71c1f3 --- /dev/null +++ b/src/plugins/intel_gpu/src/plugin/transformations/swiglu_fusion.cpp @@ -0,0 +1,94 @@ +// Copyright (C) 2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "swiglu_fusion.hpp" + +#include "intel_gpu/op/swiglu.hpp" + +#include "openvino/core/rt_info.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/multiply.hpp" +#include "openvino/op/swish.hpp" +#include "openvino/op/variadic_split.hpp" +#include "openvino/pass/pattern/op/wrap_type.hpp" +#include "transformations/utils/utils.hpp" + +namespace ov { +namespace intel_gpu { + +SwiGLUFusion::SwiGLUFusion() { + using namespace ov::pass::pattern; + + auto last_dim_static = [](const ov::Output& output) { + auto out_ps = output.get_node()->get_output_partial_shape(0); + return out_ps.rank().is_static() && out_ps[out_ps.rank().get_length() - 1].is_static() && out_ps.size() <= 5; + }; + + // Detect SwiGLU decomposition pattern + // SwiGLU(Xw, Xv, beta) = (Xw * (1.0 + exp(-beta * Xw))) * Xv + auto data_m = any_input(last_dim_static); + + // VariadicSplit(X, axis, split_lengths) = Xw, Xv + auto axis_const_m = wrap_type(); + auto split_lengths_const_m = wrap_type(); + auto variadic_split_m = wrap_type({data_m, axis_const_m, split_lengths_const_m}); + variadic_split_m->set_output_size(2); + + // Swish(Xw) = Xw * (1.0 + exp(-beta * Xw)) + auto swish_m = wrap_type({variadic_split_m->output(0)}); + + // Mul(Xw, Xv) = Swish(Xw) * Xv + auto mul_m = wrap_type({swish_m, variadic_split_m->output(1)}); + + ov::matcher_pass_callback callback = [=](ov::pass::pattern::Matcher& m) { + const auto& pattern_map = m.get_pattern_value_map(); + OPENVINO_ASSERT(pattern_map.count(mul_m)); + OPENVINO_ASSERT(pattern_map.count(swish_m)); + OPENVINO_ASSERT(pattern_map.count(variadic_split_m)); + OPENVINO_ASSERT(pattern_map.count(split_lengths_const_m)); + OPENVINO_ASSERT(pattern_map.count(axis_const_m)); + auto mul = std::dynamic_pointer_cast(pattern_map.at(mul_m).get_node_shared_ptr()); + if (!mul || transformation_callback(mul)) + return false; + if (mul->input_value(1).get_index() != 1) + return false; + + auto variadic_split = std::dynamic_pointer_cast(pattern_map.at(variadic_split_m).get_node_shared_ptr()); + auto variadic_split_in_ps = variadic_split->get_input_partial_shape(0); + auto last_dim = variadic_split_in_ps.rank().get_length() - 1; + + auto axis = std::dynamic_pointer_cast(pattern_map.at(axis_const_m).get_node_shared_ptr()); + bool valid_axis_const_values = ov::op::util::has_constant_value(axis, -1) || + ov::op::util::has_constant_value(axis, last_dim); + if (!valid_axis_const_values) + return false; + auto axis_value = axis->cast_vector()[0]; + + auto split_lengths = std::dynamic_pointer_cast(pattern_map.at(split_lengths_const_m).get_node_shared_ptr()); + auto split_lengths_value = split_lengths->cast_vector()[0]; + // Allow only case that exactly splits in half along the last dimension + auto split_length = variadic_split_in_ps[last_dim].get_length() / 2; + if (split_lengths_value != split_length) + return false; + + auto data = pattern_map.at(data_m); + auto output_type = m.get_match_root()->get_output_element_type(0); + + auto swiglu = std::make_shared(data, + axis_value, + split_lengths_value, + output_type); + swiglu->set_friendly_name(m.get_match_root()->get_friendly_name()); + ov::copy_runtime_info(m.get_matched_nodes(), swiglu); + ov::replace_node(m.get_match_root(), swiglu); + + return true; + }; + + auto m = std::make_shared(mul_m, "SwiGLUFusion"); + this->register_matcher(m, callback); +} + +} // namespace intel_gpu +} // namespace ov diff --git a/src/plugins/intel_gpu/src/plugin/transformations/swiglu_fusion.hpp b/src/plugins/intel_gpu/src/plugin/transformations/swiglu_fusion.hpp new file mode 100644 index 00000000000000..fa0d86e7175490 --- /dev/null +++ b/src/plugins/intel_gpu/src/plugin/transformations/swiglu_fusion.hpp @@ -0,0 +1,19 @@ +// Copyright (C) 2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "openvino/pass/graph_rewrite.hpp" + +namespace ov { +namespace intel_gpu { + +class SwiGLUFusion : public ov::pass::MatcherPass { +public: + OPENVINO_RTTI("SwiGLUFusion", "0"); + SwiGLUFusion(); +}; + +} // namespace intel_gpu +} // namespace ov diff --git a/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp b/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp index 1e90482984d169..f6b3e9ffda7830 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp @@ -125,6 +125,7 @@ #include "plugin/transformations/fc_convert_fusion.hpp" #include "plugin/transformations/clamp_fp16_output.hpp" #include "plugin/transformations/transpose_matmul_fusion.hpp" +#include "plugin/transformations/swiglu_fusion.hpp" #include "transformations/low_precision/mark_dequantization_subgraph.hpp" #include "low_precision/pull_reshape_through_dequantization.hpp" @@ -705,6 +706,7 @@ void TransformationsPipeline::apply(std::shared_ptr func) { manager.register_pass(); if (!device_info.supports_immad) manager.register_pass(); + manager.register_pass(); // This is supposed to be the last pass to ensure that we don't have name collisions until // GPU plugin stops using friendly names for program creation diff --git a/src/plugins/intel_gpu/src/runtime/format.cpp b/src/plugins/intel_gpu/src/runtime/format.cpp index d850837f025dd3..5a4872c19200bd 100644 --- a/src/plugins/intel_gpu/src/runtime/format.cpp +++ b/src/plugins/intel_gpu/src/runtime/format.cpp @@ -151,8 +151,10 @@ static const std::map format_traits_map { FMT_TRAITS(os_is_yx_isa8_osv8_isv4_swizzled_by_4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{1, 32}, {0, 32}}), FMT_TRAITS(os_is_yx_isa8_osv8_isv2, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{1, 8}, {0, 8}, {1, 2}}), FMT_TRAITS(os_is_osv32_isv32_swizzled_by_4, 1, 1, 0, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 32}, {1, 32}}), + FMT_TRAITS(os_is_zyx_isa8_osv16_isv2, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{1, 8}, {0, 16}, {1, 2}}), // aligned FMT_TRAITS(os_is_zyx_isv8_osv16_isv2, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{1, 8}, {0, 16}, {1, 2}}), FMT_TRAITS(os_zyxi_osv16, 1, 1, 3, 0, {0, 2, 3, 4, 1}, "ozyxi", "oixyz", {{0, 16}}), + FMT_TRAITS(os_is_yx_isa8_osv16_isv2, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{1, 8}, {0, 16}, {1, 2}}), // aligned FMT_TRAITS(os_is_yx_isv8_osv16_isv2, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{1, 8}, {0, 16}, {1, 2}}), FMT_TRAITS(os_is_yx_osv16_isv2, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 16}, {1, 2}}), FMT_TRAITS(os_is_yx_osv16_isv16, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 16}, {1, 16}}), diff --git a/src/plugins/intel_gpu/src/runtime/ocl/ocl_engine.cpp b/src/plugins/intel_gpu/src/runtime/ocl/ocl_engine.cpp index b6b1233ceba397..a77a04a50557ce 100644 --- a/src/plugins/intel_gpu/src/runtime/ocl/ocl_engine.cpp +++ b/src/plugins/intel_gpu/src/runtime/ocl/ocl_engine.cpp @@ -127,15 +127,28 @@ allocation_type ocl_engine::detect_usm_allocation_type(const void* memory) const bool ocl_engine::check_allocatable(const layout& layout, allocation_type type) { OPENVINO_ASSERT(supports_allocation(type) || type == allocation_type::cl_mem, "[GPU] Unsupported allocation type: ", type); - auto alloc_mem_size = layout.bytes_count(); - auto max_mem_size = get_device_info().max_alloc_mem_size; - if (alloc_mem_size > max_mem_size) { - auto used_mem = get_used_device_memory(allocation_type::usm_device) + get_used_device_memory(allocation_type::usm_host); - GPU_DEBUG_LOG << "[GPU] Mem size info: " << "Required " << alloc_mem_size << " bytes, already occupied : " - << used_mem << " bytes, available memory size is " << get_max_memory_size() << " bytes, but max allocable memory size is " - << max_mem_size << " bytes." << std::endl; + + OPENVINO_ASSERT(layout.bytes_count() <= get_device_info().max_alloc_mem_size, + "[GPU] Exceeded max size of memory object allocation: ", + "requested ", layout.bytes_count(), " bytes, " + "but max alloc size supported by device is ", get_device_info().max_alloc_mem_size, " bytes.", + "Please try to reduce batch size or use lower precision."); + + auto used_mem = get_used_device_memory(allocation_type::usm_device) + get_used_device_memory(allocation_type::usm_host); +#ifdef __unix__ + // Prevent from being killed by Ooo Killer of Linux + OPENVINO_ASSERT(layout.bytes_count() + used_mem <= get_max_memory_size(), + "[GPU] Exceeded max size of memory allocation: ", + "Required ", layout.bytes_count(), " bytes, already occupied : ", used_mem, " bytes, ", + "but available memory size is ", get_max_memory_size(), " bytes"); +#else + if (layout.bytes_count() + used_mem > get_max_memory_size()) { + GPU_DEBUG_COUT << "[Warning] [GPU] Exceeded max size of memory allocation: " << "Required " << layout.bytes_count() << " bytes, already occupied : " + << used_mem << " bytes, but available memory size is " << get_max_memory_size() << " bytes" << std::endl; + GPU_DEBUG_COUT << "Please note that performance might drop due to memory swap." << std::endl; return false; } +#endif return true; } @@ -143,14 +156,7 @@ bool ocl_engine::check_allocatable(const layout& layout, allocation_type type) { memory::ptr ocl_engine::allocate_memory(const layout& layout, allocation_type type, bool reset) { OPENVINO_ASSERT(!layout.is_dynamic() || layout.has_upper_bound(), "[GPU] Can't allocate memory for dynamic layout"); - bool allocatable = check_allocatable(layout, type); - if (!allocatable) { -#ifdef __unix__ - OPENVINO_ASSERT(allocatable, "[GPU] Exceeded max size of memory allocation, check debug message for size info"); -#else - GPU_DEBUG_COUT << "[Warning][GPU] Please note that performance might drop due to memory swap caused by exceeded mem size alloc." << std::endl; -#endif - } + check_allocatable(layout, type); try { memory::ptr res = nullptr; diff --git a/src/plugins/intel_gpu/tests/functional/dynamic_tests/gpu_dyn_huge_input_range.cpp b/src/plugins/intel_gpu/tests/functional/dynamic_tests/gpu_dyn_huge_input_range.cpp index 0184d08d76ec1f..b86ca197523e48 100644 --- a/src/plugins/intel_gpu/tests/functional/dynamic_tests/gpu_dyn_huge_input_range.cpp +++ b/src/plugins/intel_gpu/tests/functional/dynamic_tests/gpu_dyn_huge_input_range.cpp @@ -118,6 +118,7 @@ class DynamicShapeHugeRangeGPUTest : public testing::WithParamInterface stride; std::vector restInputType; size_t inferRequestNum = 0; + bool exception; void SetUp() override { InputShape shapes; @@ -180,11 +181,17 @@ class DynamicShapeHugeRangeGPUTest : public testing::WithParamInterface(results, params, "result"); + + set_callback_exception([this](const std::exception& exp) { + exception = true; + }); } }; TEST_P(DynamicShapeHugeRangeGPUTest, Inference) { run(); + if (!exception) + FAIL() << "This test case is checking the exception that the object allocation is larger than the max_alloc_mem_size."; } std::map emptyAdditionalConfig; diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_executable_network/exec_net_base.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_executable_network/exec_net_base.cpp index f568096853e6d8..3750255faedc06 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_executable_network/exec_net_base.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_executable_network/exec_net_base.cpp @@ -3,7 +3,6 @@ // #include "behavior/compiled_model/compiled_model_base.hpp" -#include "ie_plugin_config.hpp" using namespace ov::test::behavior; namespace { diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_infer_request/callback.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_infer_request/callback.cpp index 7e99f01c921077..08a9803679eb17 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_infer_request/callback.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_infer_request/callback.cpp @@ -6,7 +6,6 @@ #include "behavior/ov_infer_request/callback.hpp" #include "openvino/runtime/properties.hpp" -#include "ie_plugin_config.hpp" using namespace ov::test::behavior; @@ -19,11 +18,10 @@ auto configs = []() { }; auto autoBatchConfigs = []() { - return std::vector{ - // explicit batch size 4 to avoid fallback to no auto-batching (i.e. plain GPU) - {{CONFIG_KEY(AUTO_BATCH_DEVICE_CONFIG), std::string(ov::test::utils::DEVICE_GPU) + "(4)"}, - // no timeout to avoid increasing the test time - {CONFIG_KEY(AUTO_BATCH_TIMEOUT), "0 "}}}; + return std::vector{// explicit batch size 4 to avoid fallback to no auto-batching (i.e. plain GPU) + {ov::device::priorities(std::string(ov::test::utils::DEVICE_GPU) + "(4)"), + // no timeout to avoid increasing the test time + ov::auto_batch_timeout(0)}}; }; INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, OVInferRequestCallbackTests, diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_infer_request/cancellation.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_infer_request/cancellation.cpp index 29b1e8f52a17bd..bf10bfdd3075c0 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_infer_request/cancellation.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_infer_request/cancellation.cpp @@ -3,7 +3,6 @@ // #include "behavior/ov_infer_request/cancellation.hpp" -#include "ie_plugin_config.hpp" using namespace ov::test::behavior; @@ -15,11 +14,10 @@ auto configs = []() { }; auto autoBatchConfigs = []() { - return std::vector{ - // explicit batch size 4 to avoid fallback to no auto-batching (i.e. plain GPU) - {{CONFIG_KEY(AUTO_BATCH_DEVICE_CONFIG), std::string(ov::test::utils::DEVICE_GPU) + "(4)"}, - // no timeout to avoid increasing the test time - {CONFIG_KEY(AUTO_BATCH_TIMEOUT), "0 "}}}; + return std::vector{// explicit batch size 4 to avoid fallback to no auto-batching (i.e. plain GPU) + {ov::device::priorities(std::string(ov::test::utils::DEVICE_GPU) + "(4)"), + // no timeout to avoid increasing the test time + ov::auto_batch_timeout(0)}}; }; INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, OVInferRequestCancellationTests, diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_infer_request/io_tensor.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_infer_request/io_tensor.cpp index 1d5abcbde1dcdf..90040991dd366b 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_infer_request/io_tensor.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_infer_request/io_tensor.cpp @@ -6,7 +6,6 @@ #include "behavior/ov_infer_request/io_tensor.hpp" #include "openvino/runtime/properties.hpp" -#include "ie_plugin_config.hpp" using namespace ov::test::behavior; diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_infer_request/multithreading.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_infer_request/multithreading.cpp index d400ed1108b23b..906f04bd89fe85 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_infer_request/multithreading.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_infer_request/multithreading.cpp @@ -5,7 +5,6 @@ #include #include "behavior/ov_infer_request/multithreading.hpp" -#include "ie_plugin_config.hpp" using namespace ov::test::behavior; @@ -19,11 +18,10 @@ auto configs = []() { }; auto AutoBatchConfigs = []() { - return std::vector{ - // explicit batch size 4 to avoid fallback to no auto-batching (i.e. plain GPU) - {{CONFIG_KEY(AUTO_BATCH_DEVICE_CONFIG), std::string(ov::test::utils::DEVICE_GPU) + "(4)"}, - // no timeout to avoid increasing the test time - {CONFIG_KEY(AUTO_BATCH_TIMEOUT), "0 "}}}; + return std::vector{// explicit batch size 4 to avoid fallback to no auto-batching (i.e. plain GPU) + {ov::device::priorities(std::string(ov::test::utils::DEVICE_GPU) + "(4)"), + // no timeout to avoid increasing the test time + ov::auto_batch_timeout(0)}}; }; INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, OVInferRequestMultithreadingTests, diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_infer_request/perf_counters.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_infer_request/perf_counters.cpp index 70cd59abbae41a..d0af060b80ec94 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_infer_request/perf_counters.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_infer_request/perf_counters.cpp @@ -3,7 +3,6 @@ // #include "behavior/ov_infer_request/perf_counters.hpp" -#include "ie_plugin_config.hpp" using namespace ov::test::behavior; @@ -13,11 +12,10 @@ auto configs = []() { }; auto AutoBatchConfigs = []() { - return std::vector{ - // explicit batch size 4 to avoid fallback to no auto-batching (i.e. plain GPU) - {{CONFIG_KEY(AUTO_BATCH_DEVICE_CONFIG), std::string(ov::test::utils::DEVICE_GPU) + "(4)"}, - // no timeout to avoid increasing the test time - {CONFIG_KEY(AUTO_BATCH_TIMEOUT), "0 "}}}; + return std::vector{// explicit batch size 4 to avoid fallback to no auto-batching (i.e. plain GPU) + {ov::device::priorities(std::string(ov::test::utils::DEVICE_GPU) + "(4)"), + // no timeout to avoid increasing the test time + ov::auto_batch_timeout(0)}}; }; INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, OVInferRequestPerfCountersTest, diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_infer_request/wait.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_infer_request/wait.cpp index fff7b3331e5c32..93bbb7804c389e 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_infer_request/wait.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_infer_request/wait.cpp @@ -5,7 +5,6 @@ #include #include "behavior/ov_infer_request/wait.hpp" -#include "ie_plugin_config.hpp" using namespace ov::test::behavior; @@ -19,11 +18,10 @@ auto configs = []() { }; auto AutoBatchConfigs = []() { - return std::vector{ - // explicit batch size 4 to avoid fallback to no auto-batching (i.e. plain GPU) - {{CONFIG_KEY(AUTO_BATCH_DEVICE_CONFIG), std::string(ov::test::utils::DEVICE_GPU) + "(4)"}, - // no timeout to avoid increasing the test time - {CONFIG_KEY(AUTO_BATCH_TIMEOUT), "0 "}}}; + return std::vector{// explicit batch size 4 to avoid fallback to no auto-batching (i.e. plain GPU) + {ov::device::priorities(std::string(ov::test::utils::DEVICE_GPU) + "(4)"), + // no timeout to avoid increasing the test time + ov::auto_batch_timeout(0)}}; }; INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, OVInferRequestWaitTests, diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp index fd2f8d344ec83a..5cbe29b4241bc0 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp @@ -7,7 +7,6 @@ #include #include -#include "cpp_interfaces/interface/ie_internal_plugin_config.hpp" #include "intel_gpu/runtime/internal_properties.hpp" #include "openvino/runtime/intel_gpu/properties.hpp" diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_plugin/remote.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_plugin/remote.cpp index ff88abfadf1417..01f02827cab7e3 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_plugin/remote.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_plugin/remote.cpp @@ -4,7 +4,6 @@ #include "behavior/ov_plugin/remote.hpp" #include "common_test_utils/test_constants.hpp" -#include "ie_plugin_config.hpp" using namespace ov::test; @@ -19,9 +18,9 @@ std::vector> generate_remote_params() { auto AutoBatchConfigs = []() { return std::vector{ // explicit batch size 4 to avoid fallback to no auto-batching (i.e. plain GPU) - {{CONFIG_KEY(AUTO_BATCH_DEVICE_CONFIG), std::string(ov::test::utils::DEVICE_GPU) + "(4)"}, + {{ov::device::priorities.name(), std::string(ov::test::utils::DEVICE_GPU) + "(4)"}, // no timeout to avoid increasing the test time - {CONFIG_KEY(AUTO_BATCH_TIMEOUT), "0 "}}}; + {ov::auto_batch_timeout.name(), "0 "}}}; }; INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_BehaviorTests, OVRemoteTest, diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/core_config.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/core_config.cpp index 33bc1ad0f1a991..640b73f28ae0ce 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/core_config.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/core_config.cpp @@ -2,24 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "functional_test_utils/core_config.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -void CoreConfiguration(LayerTestsUtils::LayerTestsCommon* test) { - std::shared_ptr core = PluginCache::get().ie(); - ov::element::Type hint = ov::element::f32; - for (auto& param : test->GetFunction()->get_parameters()) { - if (param->get_output_element_type(0) == ov::element::f16) { - hint = ov::element::f16; - break; - } - } - - // Set inference_precision hint to run fp32 model in fp32 runtime precision as default plugin execution precision may vary - std::map config = {{"INFERENCE_PRECISION_HINT", hint.get_type_name()}}; - core->SetConfig(config, ov::test::utils::DEVICE_GPU); -} - namespace ov { namespace test { diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/low_precision_transformations/mvn_transformation.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/low_precision_transformations/mvn_transformation.cpp index 063323ad6ef7d7..70489f4985f68e 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/low_precision_transformations/mvn_transformation.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/low_precision_transformations/mvn_transformation.cpp @@ -13,7 +13,7 @@ const std::vector inputAndQuantizationShapes = { {1ul, 4ul, 16ul, 16ul}, }; -const std::vector reductionAxes = {{2, 3}, {1, 2, 3}}; +const std::vector reductionAxes = {{2, 3}, {1, 2, 3}}; const std::vector normalizeVariance = {true, false}; diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/broadcast.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/broadcast.cpp index 5513123a7862cb..cbe0417bfa0419 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/broadcast.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/broadcast.cpp @@ -95,7 +95,7 @@ std::vector> input_shapes_2d_static = { INSTANTIATE_TEST_CASE_P(smoke_TestNumpyBroadcast2D, BroadcastLayerTest, ::testing::Combine(::testing::ValuesIn(targetShapesNumpy2D), - ::testing::Values(ngraph::AxisSet{}), // not used in numpy mode + ::testing::Values(ov::AxisSet{}), // not used in numpy mode ::testing::Values(ov::op::BroadcastType::NUMPY), ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(input_shapes_2d_static)), ::testing::ValuesIn(inputPrecisions), diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/experimental_detectron_prior_grid_generator.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/experimental_detectron_prior_grid_generator.cpp index 4abaf5b1198e77..b181d2f0c97877 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/experimental_detectron_prior_grid_generator.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/experimental_detectron_prior_grid_generator.cpp @@ -71,4 +71,4 @@ INSTANTIATE_TEST_SUITE_P(smoke_ExperimentalDetectronPriorGridGenerator_f16, testing::ValuesIn({ov::element::Type_t::f16}), testing::Values(ov::test::utils::DEVICE_GPU)), ExperimentalDetectronPriorGridGeneratorLayerTest::getTestCaseName); -} // namespace +} // namespace \ No newline at end of file diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/group_normalization.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/group_normalization.cpp index 72bb27eba05c54..8f222cc2f36c46 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/group_normalization.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/group_normalization.cpp @@ -1,9 +1,9 @@ // Copyright (C) 2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/group_normalization.hpp" +#include "single_op_tests/group_normalization.hpp" -using namespace ov::test::subgraph; +using namespace ov::test; namespace { diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/is_inf.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/is_inf.cpp index 5f4e9c3f1acd84..fd9be105e3a155 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/is_inf.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/is_inf.cpp @@ -22,7 +22,7 @@ constexpr std::array detectNegative = {true, false}; constexpr std::array detectPositive = {true, false}; -const std::map additional_config = {}; +const ov::AnyMap additional_config = {}; const auto isInfParams = ::testing::Combine(::testing::ValuesIn(inShapesStatic), ::testing::ValuesIn(detectNegative), diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/matrix_nms.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/matrix_nms.cpp index 515aa2ed3c6d1d..eb49ca4fd79189 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/matrix_nms.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/matrix_nms.cpp @@ -2,39 +2,271 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/matrix_nms.hpp" - #include -#include +#include +#include +#include "common_test_utils/common_utils.hpp" +#include "shared_test_classes/base/layer_test_utils.hpp" +#include "shared_test_classes/single_op/matrix_nms.hpp" +#include + +namespace ov { +namespace test { + +class MatrixNmsLayerTestGPU : virtual public MatrixNmsLayerTest { +public: + void generate_inputs(const std::vector& targetInputStaticShapes) override; + void compare(const std::vector &expected, const std::vector &actual) override; + +private: + void GetOutputParams(size_t& numBatches, size_t& maxOutputBoxesPerBatch); + ov::op::v8::MatrixNms::Attributes m_attrs; + +protected: + void SetUp() override; +}; + +void MatrixNmsLayerTestGPU::generate_inputs(const std::vector& targetInputStaticShapes) { + inputs.clear(); + + const auto& funcInputs = function->inputs(); + for (size_t i = 0; i < funcInputs.size(); ++i) { + const auto& funcInput = funcInputs[i]; + ov::Tensor tensor; + + if (i == 1) { + tensor = ov::Tensor(funcInput.get_element_type(), targetInputStaticShapes[i]); + + const size_t range = 1; + const size_t startFrom = 0; + const size_t k = 1000; + const int seed = 1; + std::default_random_engine random(seed); + std::uniform_int_distribution distribution(k * startFrom, k * (startFrom + range)); + + auto *dataPtr = tensor.data(); + for (size_t i = 0; i < tensor.get_size(); i++) { + auto value = static_cast(distribution(random)); + dataPtr[i] = value / static_cast(k); + } + } else { + tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i]); + } + + inputs.insert({funcInput.get_node_shared_ptr(), tensor}); + } +} + +void MatrixNmsLayerTestGPU::GetOutputParams(size_t& numBatches, size_t& maxOutputBoxesPerBatch) { + size_t numBoxes = 0, numClasses = 0; + const auto& funcInputs = function->inputs(); + for (size_t i = 0; i < funcInputs.size(); ++i) { + const auto& funcInput = funcInputs[i]; + const auto& dims = inputs[funcInput.get_node_shared_ptr()].get_shape(); + + if (i == 1) { + numClasses = dims[1]; + } else { + numBatches = dims[0]; + numBoxes = dims[1]; + } + } + + ASSERT_TRUE(numBatches > 0 && numBoxes > 0 && numClasses > 0) + << "Expected numBatches, numBoxes, numClasses > 0, got:" << numBatches << ", " << numBoxes << ", " << numClasses; + + auto realClasses = numClasses; + if (m_attrs.background_class >= 0 && m_attrs.background_class < static_cast(numClasses)) { + realClasses--; + } + + size_t maxOutputBoxesPerClass = 0; + if (m_attrs.nms_top_k >= 0) + maxOutputBoxesPerClass = std::min(numBoxes, static_cast(m_attrs.nms_top_k)); + else + maxOutputBoxesPerClass = numBoxes; -#include "common_test_utils/test_constants.hpp" + maxOutputBoxesPerBatch = maxOutputBoxesPerClass * realClasses; + if (m_attrs.keep_top_k >= 0) + maxOutputBoxesPerBatch = + std::min(maxOutputBoxesPerBatch, static_cast(m_attrs.keep_top_k)); +} -using namespace ov::test::subgraph; -using namespace InferenceEngine; -using namespace ngraph; +void MatrixNmsLayerTestGPU::compare(const std::vector &expectedOutputs, + const std::vector &actualOutputs) { + auto batchIndex = -1; + size_t numBatches(0), maxOutputBoxesPerBatch(0); + GetOutputParams(numBatches, maxOutputBoxesPerBatch); + std::vector numPerBatch(numBatches); + for (int outputIndex = static_cast(expectedOutputs.size()) - 1; outputIndex >= 0 ; outputIndex--) { + const auto& actual = actualOutputs[outputIndex]; + const auto _dims = actual.get_shape(); + if (_dims.size() == 1 && _dims[0] == numBatches) { + batchIndex = outputIndex; + if (actual.get_element_type() == ov::element::i32) { + auto buffer = actual.data(); + std::copy_n(buffer, numBatches, numPerBatch.begin()); + } else { + auto buffer = actual.data(); + std::copy_n(buffer, numBatches, numPerBatch.begin()); + } + } + } + for (int outputIndex = static_cast(expectedOutputs.size()) - 1; outputIndex >= 0 ; outputIndex--) { + const auto& expected = expectedOutputs[outputIndex]; + const auto& actual = actualOutputs[outputIndex]; + const auto actualBuffer = static_cast(actual.data()); + const auto expectedBuffer = static_cast(expected.data()); + + //Compare Selected Outputs & Selected Indices + if (outputIndex != batchIndex) { + if (outputIndex == 2) { + ASSERT_TRUE(expected.get_size() != actual.get_size()) + << "Expected and actual size 3rd output have different size"; + } + +#define CASE(X, Y, _expected_offset, _actual_offset, _size, _threshold) \ + case X: \ + ov::test::utils::compare_raw_data( \ + reinterpret_cast*>(expectedBuffer) + _expected_offset, \ + reinterpret_cast*>(actualBuffer) + _actual_offset, _size, _threshold); \ + break; + + const auto& precision = actual.get_element_type(); + auto expected_offset = 0; + auto actual_offset = 0; + for (size_t i = 0; i < numPerBatch.size(); i++) { + auto validNums = numPerBatch[i]; + switch (precision) { + case ov::element::f32: { + switch (expected.get_element_type()) { + CASE(ov::element::f32, ov::element::f32, expected_offset * 6, actual_offset * 6, validNums *6, 1e-5f) + CASE(ov::element::f64, ov::element::f32, expected_offset * 6, actual_offset * 6, validNums *6, 1e-5f) + default: + break; + } + const auto fBuffer = static_cast(actual.data()); + for (size_t tailing = validNums * 6; tailing < maxOutputBoxesPerBatch * 6; tailing++) { + ASSERT_TRUE(std::abs(fBuffer[(actual_offset * 6 + tailing)] + 1.f) < 1e-5) + << "Invalid default value: " << fBuffer[i] << " at index: " << i; + } + break; + } + case ov::element::i32: { + switch (expected.get_element_type()) { + CASE(ov::element::i32, ov::element::i32, expected_offset, actual_offset, validNums, 0) + CASE(ov::element::i64, ov::element::i32, expected_offset, actual_offset, validNums, 0) + default: + break; + } + const auto iBuffer = actual.data(); + for (size_t tailing = validNums; tailing < maxOutputBoxesPerBatch; tailing++) { + ASSERT_TRUE(iBuffer[actual_offset + tailing] == -1) << "Invalid default value: " << iBuffer[i] << " at index: " << i; + } + break; + } + case ov::element::i64: { + switch (expected.get_element_type()) { + CASE(ov::element::i32, ov::element::i64, expected_offset, actual_offset, validNums, 0) + CASE(ov::element::i64, ov::element::i64, expected_offset, actual_offset, validNums, 0) + default: + break; + } + const auto iBuffer = actual.data(); + for (size_t tailing = validNums; tailing < maxOutputBoxesPerBatch; tailing++) { + ASSERT_TRUE(iBuffer[actual_offset + tailing] == -1) << "Invalid default value: " << iBuffer[i] << " at index: " << i; + } + break; + } + default: + FAIL() << "Comparator for " << precision << " precision isn't supported"; + } + expected_offset += validNums; + actual_offset += maxOutputBoxesPerBatch; + } + } else { + if (outputIndex == 2) { + if (expected.get_size() != actual.get_size()) + throw std::runtime_error("Expected and actual size 3rd output have different size"); + } + + const auto& precision = actual.get_element_type(); + size_t size = expected.get_size(); + switch (precision) { + case ov::element::i32: { + switch (expected.get_element_type()) { + CASE(ov::element::i32, ov::element::i32, 0, 0, size, 0) + CASE(ov::element::i64, ov::element::i32, 0, 0, size, 0) + default: + break; + } + break; + } + case ov::element::i64: { + switch (expected.get_element_type()) { + CASE(ov::element::i32, ov::element::i64, 0, 0, size, 0) + CASE(ov::element::i64, ov::element::i64, 0, 0, size, 0) + default: + break; + } + break; + } + default: + FAIL() << "Comparator for " << precision << " precision isn't supported"; + } + } + } +} + +void MatrixNmsLayerTestGPU::SetUp() { + std::vector shapes; + ov::element::Type model_type; + TopKParams top_k_params; + ThresholdParams threshold_params; + + std::tie(shapes, model_type, m_attrs.sort_result_type, m_attrs.output_type, top_k_params, threshold_params, + m_attrs.background_class, m_attrs.normalized, m_attrs.decay_function, targetDevice) = this->GetParam(); + + std::tie(m_attrs.nms_top_k, m_attrs.keep_top_k) = top_k_params; + std::tie(m_attrs.score_threshold, m_attrs.gaussian_sigma, m_attrs.post_threshold) = threshold_params; + + init_input_shapes(shapes); + + ov::ParameterVector params; + for (auto&& shape : inputDynamicShapes) { + params.push_back(std::make_shared(model_type, shape)); + } + auto nms = std::make_shared(params[0], params[1], m_attrs); + + function = std::make_shared(nms, params, "MatrixNMS"); +} + +TEST_P(MatrixNmsLayerTestGPU, CompareWithRefs) { + run(); +}; + +namespace { const std::vector> inStaticShapeParams = {{{3, 100, 4}, {3, 1, 100}}, {{1, 10, 4}, {1, 100, 10}}}; -const auto inputPrecisions = InputPrecisions{ov::element::f32, ov::element::i32, ov::element::f32}; - const std::vector sortResultType = {ov::op::v8::MatrixNms::SortResultType::CLASSID, - ov::op::v8::MatrixNms::SortResultType::SCORE, - ov::op::v8::MatrixNms::SortResultType::NONE}; + ov::op::v8::MatrixNms::SortResultType::SCORE, + ov::op::v8::MatrixNms::SortResultType::NONE}; const std::vector outType = {ov::element::i32, ov::element::i64}; -const std::vector topKParams = {TopKParams{-1, 5}, TopKParams{100, -1}}; +const std::vector topKParams = {TopKParams{-1, 5}, + TopKParams{100, -1}}; + const std::vector thresholdParams = {ThresholdParams{0.0f, 2.0f, 0.0f}, ThresholdParams{0.1f, 1.5f, 0.2f}}; const std::vector backgroudClass = {-1, 1}; const std::vector normalized = {true, false}; const std::vector decayFunction = {ov::op::v8::MatrixNms::DecayFunction::GAUSSIAN, - ov::op::v8::MatrixNms::DecayFunction::LINEAR}; - -const std::vector outStaticShape = {true}; // only be true as gpu plugin not support nms with internal dynamic yet. + ov::op::v8::MatrixNms::DecayFunction::LINEAR}; const auto nmsParamsStatic = ::testing::Combine(::testing::ValuesIn(ov::test::static_shapes_to_test_representation(inStaticShapeParams)), - ::testing::Values(inputPrecisions), + ::testing::Values(ov::element::f32), ::testing::ValuesIn(sortResultType), ::testing::ValuesIn(outType), ::testing::ValuesIn(topKParams), @@ -42,10 +274,13 @@ const auto nmsParamsStatic = ::testing::ValuesIn(backgroudClass), ::testing::ValuesIn(normalized), ::testing::ValuesIn(decayFunction), - ::testing::ValuesIn(outStaticShape), ::testing::Values(ov::test::utils::DEVICE_GPU)); -INSTANTIATE_TEST_SUITE_P(smoke_MatrixNmsLayerTest_static, - MatrixNmsLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_MatrixNmsLayerTestGPU_static, + MatrixNmsLayerTestGPU, nmsParamsStatic, - MatrixNmsLayerTest::getTestCaseName); + MatrixNmsLayerTestGPU::getTestCaseName); + +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/multiclass_nms.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/multiclass_nms.cpp index 031af8b230647d..8ca141c5ba2d2c 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/multiclass_nms.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/multiclass_nms.cpp @@ -2,16 +2,405 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/multiclass_nms.hpp" - +#include +#include #include -#include "common_test_utils/test_constants.hpp" +#include "ov_models/builders.hpp" +#include "shared_test_classes/base/layer_test_utils.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" + +namespace ov { +namespace test { +namespace GPULayerTestsDefinitions { + +using InputTypes = std::tuple; // iou_threshold, score_threshold, soft_nms_sigma precisions + +using InputfloatVar = std::tuple; // nmsEta + +using InputboolVar = std::tuple; // normalized + +using MulticlassNmsParamsGPU = std::tuple, // Params using to create inputs + InputTypes, // Input precisions + int32_t, // Max output boxes per class + InputfloatVar, // iouThreshold, scoreThreshold, nmsEta + int32_t, // background_class + int32_t, // keep_top_k + ov::element::Type, // Output type + ov::op::util::MulticlassNmsBase::SortResultType, // SortResultType + InputboolVar, // Sort result across batch, normalized + std::string>; + +class MulticlassNmsLayerTestGPU : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseTest { +public: + static std::string getTestCaseName(const testing::TestParamInfo& obj); + +protected: + void compare(const std::vector &expected, const std::vector &actual) override; + void generate_inputs(const std::vector& targetInputStaticShapes) override; + + void SetUp() override; + void GetOutputParams(size_t& numBatches, size_t& maxOutputBoxesPerBatch); + ov::op::util::MulticlassNmsBase::Attributes m_attrs; + bool use_op_v8 = false; +}; + +class MulticlassNmsLayerTestGPU8 : public MulticlassNmsLayerTestGPU { +protected: + void SetUp() override; +}; + +TEST_P(MulticlassNmsLayerTestGPU, Inference) { + run(); +}; + +TEST_P(MulticlassNmsLayerTestGPU8, Inference) { + run(); +}; + +std::string MulticlassNmsLayerTestGPU::getTestCaseName(const testing::TestParamInfo& obj) { + std::vector shapes; + InputTypes input_types; + int32_t nmsTopK, backgroundClass, keepTopK; + ov::element::Type outType; + op::util::MulticlassNmsBase::SortResultType sortResultType; + InputfloatVar inFloatVar; + InputboolVar inboolVar; + std::string targetDevice; + + std::tie(shapes, input_types, nmsTopK, inFloatVar, backgroundClass, keepTopK, outType, sortResultType, inboolVar, targetDevice) = obj.param; + + ov::test::ElementType paramsPrec, roisnumPrec; + std::tie(paramsPrec, roisnumPrec) = input_types; + + float iouThr, scoreThr, nmsEta; + std::tie(iouThr, scoreThr, nmsEta) = inFloatVar; + + bool sortResCB, normalized; + std::tie(sortResCB, normalized) = inboolVar; + + std::ostringstream result; + result << "IS=("; + for (const auto& shape : shapes) { + result << ov::test::utils::partialShape2str({shape.first}) << "_"; + } + result << ")_TS=("; + for (const auto& shape : shapes) { + for (const auto& item : shape.second) { + result << ov::test::utils::vec2str(item) << "_"; + } + } + + using ov::test::utils::operator<<; + result << ")_paramsPrec=" << paramsPrec << "_roisnumPrec=" << roisnumPrec << "_"; + result << "nmsTopK=" << nmsTopK << "_"; + result << "iouThr=" << iouThr << "_scoreThr=" << scoreThr << "_backgroundClass=" << backgroundClass << "_"; + result << "keepTopK=" << keepTopK << "_outType=" << outType << "_"; + result << "sortResultType=" << sortResultType << "_sortResCrossBatch=" << sortResCB << "_nmsEta=" << nmsEta << "_normalized=" << normalized << "_"; + result << "TargetDevice=" << targetDevice; + return result.str(); +} + +void MulticlassNmsLayerTestGPU::generate_inputs(const std::vector& targetInputStaticShapes) { + inputs.clear(); + + const auto& funcInputs = function->inputs(); + ASSERT_TRUE(funcInputs.size() == 2 || funcInputs.size() == 3) << "Expected 3 inputs or 2 inputs."; + for (size_t i = 0; i < funcInputs.size(); ++i) { + const auto& funcInput = funcInputs[i]; + ov::Tensor tensor; + + if (i == 1) { // scores + const size_t range = 1; + const size_t start_from = 0; + const size_t k = 1000; + const int seed = 1; + tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i], + ov::test::utils::InputGenerateData(start_from, range, k, seed)); + } else if (i == 0) { // bboxes + tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i]); + } else { // roisnum + /* sum of rois is no larger than num_bboxes. */ + ASSERT_TRUE(targetInputStaticShapes[i].size() == 1) << "Expected shape size 1 for input roisnum, got: " << targetInputStaticShapes[i]; + + // returns num random values whose sum is max_num. + auto _generate_roisnum = [](int num, int max_num) { + std::vector array; + std::vector results(num); + + array.push_back(0); + for (auto i = 0; i < num-1; i++) { + array.push_back(std::rand() % max_num); + } + array.push_back(max_num); + + std::sort(array.begin(), array.end()); + + for (auto i = 0; i < num; i++) { + results[i] = array[i+1] - array[i]; + } + + return results; + }; + auto roisnum = _generate_roisnum(targetInputStaticShapes[i][0], targetInputStaticShapes[0][1]/*num_bboxes*/); + + tensor = ov::Tensor(funcInput.get_element_type(), targetInputStaticShapes[i]); + if (tensor.get_element_type() == ov::element::i32) { + auto dataPtr = tensor.data(); + for (size_t i = 0; i < roisnum.size(); i++) { + dataPtr[i] = static_cast(roisnum[i]); + } + } else { + auto dataPtr = tensor.data(); + for (size_t i = 0; i < roisnum.size(); i++) { + dataPtr[i] = static_cast(roisnum[i]); + } + } + } + + inputs.insert({funcInput.get_node_shared_ptr(), tensor}); + } +} -using namespace ov::test::subgraph; -using namespace InferenceEngine; -using namespace ngraph; +void MulticlassNmsLayerTestGPU::GetOutputParams(size_t& numBatches, size_t& maxOutputBoxesPerBatch) { + const auto& funcInputs = function->inputs(); + const auto& boxes_dims = inputs[funcInputs[0].get_node_shared_ptr()].get_shape(); + const auto& scores_dims = inputs[funcInputs[1].get_node_shared_ptr()].get_shape(); + + const auto shared = (scores_dims.size() == 3); + if (!shared) { + ASSERT_TRUE(funcInputs.size() > 2) << "Expected 3 inputs when input 'score' is 2D."; + } + + const auto& roisnum_dims = funcInputs.size() >2 ? inputs[funcInputs[2].get_node_shared_ptr()].get_shape() : Shape(); + + const auto numBoxes = shared ? boxes_dims[1] : boxes_dims[1]; + auto numClasses = shared ? scores_dims[1] : boxes_dims[0]; + numBatches = shared ? scores_dims[0] : roisnum_dims[0]; + + ASSERT_TRUE(numBatches > 0 && numBoxes > 0 && numClasses > 0) + << "Expected numBatches, numBoxes, numClasses > 0, got:" << numBatches << ", " << numBoxes << ", " << numClasses; + + auto realClasses = numClasses; + if (m_attrs.background_class >= 0 && m_attrs.background_class < static_cast(numClasses)) { + realClasses = realClasses - 1; + } + + size_t maxOutputBoxesPerClass = 0; + if (m_attrs.nms_top_k >= 0) + maxOutputBoxesPerClass = std::min(numBoxes, static_cast(m_attrs.nms_top_k)); + else + maxOutputBoxesPerClass = numBoxes; + + maxOutputBoxesPerBatch = maxOutputBoxesPerClass * realClasses; + if (m_attrs.keep_top_k >= 0) + maxOutputBoxesPerBatch = + std::min(maxOutputBoxesPerBatch, static_cast(m_attrs.keep_top_k)); +} + +void MulticlassNmsLayerTestGPU::compare(const std::vector &expectedOutputs, + const std::vector &actualOutputs) { + auto batchIndex = -1; // output index for output 'selected_num' + size_t numBatches(0), maxOutputBoxesPerBatch(0); + GetOutputParams(numBatches, maxOutputBoxesPerBatch); + std::vector numPerBatch(numBatches); + + ASSERT_TRUE(expectedOutputs.size() == 3) << "Expect 3 outputs, got: " << expectedOutputs.size(); + + for (int outputIndex = static_cast(expectedOutputs.size()) - 1; outputIndex >= 0; outputIndex--) { + const auto& actual = actualOutputs[outputIndex]; + const auto _dims = actual.get_shape(); + if (_dims.size() == 1) { // 'selected_num' + ASSERT_TRUE(_dims[0] == numBatches) << "Expect output 'selected_num' has shape of " << numBatches << ", got: " << _dims[0]; + batchIndex = outputIndex; + if (actual.get_element_type() == ov::element::i32) { + auto buffer = actual.data(); + std::copy_n(buffer, numBatches, numPerBatch.begin()); + } else { + auto buffer = actual.data(); + std::copy_n(buffer, numBatches, numPerBatch.begin()); + } + + break; + } + } + ASSERT_TRUE(batchIndex > -1) << "Expect to get output index for 'selected_num'"; + + // reserve order could make sure output 'selected_num' get checked first. + for (int outputIndex = static_cast(expectedOutputs.size()) - 1; outputIndex >= 0; outputIndex--) { + const auto& expected = expectedOutputs[outputIndex]; + const auto& actual = actualOutputs[outputIndex]; + const auto actualBuffer = static_cast(actual.data()); + const auto expectedBuffer = static_cast(expected.data()); + + const auto expected_shape = expected.get_shape(); + const auto actual_shape = actual.get_shape(); + + // Compare Selected Outputs & Selected Indices + if (outputIndex != batchIndex) { + ASSERT_TRUE(expected_shape[0] <= actual_shape[0]) << "Expected the compatible shape, got: " << expected_shape << " and " << actual_shape; + + const auto& precision = actual.get_element_type(); + auto expected_offset = 0; + auto actual_offset = 0; + for (size_t i = 0; i < numPerBatch.size(); i++) { + auto validNums = numPerBatch[i]; +#define TENSOR_COMPARE(elem_type, act_type, expected_offset, actual_offset, size, _threshold) \ + case ov::element::Type_t::elem_type: { \ + using tensor_type = ov::fundamental_type_for; \ + using actual_type = ov::fundamental_type_for; \ + ov::test::utils::compare_raw_data(reinterpret_cast(expectedBuffer) + expected_offset, \ + reinterpret_cast(actualBuffer) + actual_offset, \ + size, _threshold); \ + break; \ + } + switch (precision) { + case ov::element::f32: { + switch (expected.get_element_type()) { + TENSOR_COMPARE(f32, f32, expected_offset * 6, actual_offset * 6, validNums * 6, 1e-5f) + TENSOR_COMPARE(f64, f32, expected_offset * 6, actual_offset * 6, validNums * 6, 1e-5f) + default: + break; + } + + const auto fBuffer = static_cast(actual.data()); + for (size_t tailing = validNums * 6; tailing < maxOutputBoxesPerBatch * 6; tailing++) { + ASSERT_TRUE(std::abs(fBuffer[(actual_offset * 6 + tailing)] - -1.f) < 1e-5) + << "Invalid default value: " << fBuffer[i] << " at index: " << i; + } + break; + } + case ov::element::i32: { + switch (expected.get_element_type()) { + TENSOR_COMPARE(i32, i32, expected_offset, actual_offset, validNums, 0) + TENSOR_COMPARE(i64, i32, expected_offset, actual_offset, validNums, 0) + default: + break; + } + const auto iBuffer = actual.data(); + for (size_t tailing = validNums; tailing < maxOutputBoxesPerBatch; tailing++) { + ASSERT_TRUE(iBuffer[actual_offset + tailing] == -1) << "Invalid default value: " << iBuffer[i] << " at index: " << i; + } + break; + } + case ov::element::i64: { + switch (expected.get_element_type()) { + TENSOR_COMPARE(i32, i64, expected_offset, actual_offset, validNums, 0) + TENSOR_COMPARE(i64, i64, expected_offset, actual_offset, validNums, 0) + default: + break; + } + const auto iBuffer = actual.data(); + for (size_t tailing = validNums; tailing < maxOutputBoxesPerBatch; tailing++) { + ASSERT_TRUE(iBuffer[actual_offset + tailing] == -1) << "Invalid default value: " << iBuffer[i] << " at index: " << i; + } + break; + } + default: + FAIL() << "Comparator for " << precision << " precision isn't supported"; + } + expected_offset += validNums; + actual_offset += maxOutputBoxesPerBatch; + } + } else { + ASSERT_TRUE(expected_shape == actual_shape) << "Expected the same shape, got: " << expected_shape << " and " << actual_shape; + + const auto& precision = actual.get_element_type(); + size_t size = expected.get_size(); + switch (precision) { + case ov::element::i32: { + switch (expected.get_element_type()) { + TENSOR_COMPARE(i32, i32, 0, 0, size, 0) + TENSOR_COMPARE(i64, i32, 0, 0, size, 0) + default: + break; + } + break; + } + case ov::element::i64: { + switch (expected.get_element_type()) { + TENSOR_COMPARE(i32, i64, 0, 0, size, 0) + TENSOR_COMPARE(i64, i64, 0, 0, size, 0) + default: + break; + } + break; + } + default: + FAIL() << "Comparator for " << precision << " precision isn't supported"; + } + } + } +} + +void MulticlassNmsLayerTestGPU::SetUp() { + std::vector shapes; + InputTypes input_types; + size_t maxOutBoxesPerClass, backgroundClass, keepTopK; + element::Type outType; + + op::util::MulticlassNmsBase::SortResultType sortResultType; + + InputfloatVar inFloatVar; + InputboolVar inboolVar; + + std::tie(shapes, input_types, maxOutBoxesPerClass, inFloatVar, backgroundClass, keepTopK, outType, sortResultType, inboolVar, targetDevice) + = this->GetParam(); + + init_input_shapes(shapes); + + ElementType paramsPrec, roisnumPrec; + std::tie(paramsPrec, roisnumPrec) = input_types; + + float iouThr, scoreThr, nmsEta; + std::tie(iouThr, scoreThr, nmsEta) = inFloatVar; + + bool sortResCB, normalized; + std::tie(sortResCB, normalized) = inboolVar; + + ov::ParameterVector params {std::make_shared(paramsPrec, inputDynamicShapes.at(0)), + std::make_shared(paramsPrec, inputDynamicShapes.at(1))}; + if (inputDynamicShapes.size() > 2) + params.push_back(std::make_shared(roisnumPrec, inputDynamicShapes.at(2))); + + m_attrs.iou_threshold = iouThr; + m_attrs.score_threshold = scoreThr; + m_attrs.nms_eta = nmsEta; + m_attrs.sort_result_type = sortResultType; + m_attrs.sort_result_across_batch = sortResCB; + m_attrs.output_type = outType; + m_attrs.nms_top_k = maxOutBoxesPerClass; + m_attrs.keep_top_k = keepTopK; + m_attrs.background_class = backgroundClass; + m_attrs.normalized = normalized; + + std::shared_ptr nms; + if (!use_op_v8) { + if (params.size() > 2) { + nms = std::make_shared(params[0], params[1], params[2], m_attrs); + } else { + nms = std::make_shared(params[0], params[1], m_attrs); + } + } else { + nms = std::make_shared(params[0], params[1], m_attrs); + } + + function = std::make_shared(nms, params, "MulticlassNMS"); +} + +void MulticlassNmsLayerTestGPU8::SetUp() { + use_op_v8 = true; + MulticlassNmsLayerTestGPU::SetUp(); +} + +namespace { /* input format #1 with 2 inputs: bboxes N, M, 4, scores N, C, M */ const std::vector> shapes2Inputs = { {{3, 100, 4}, {3, 1, 100}}, @@ -41,14 +430,10 @@ const std::vector sortResDesc = {true, false}; const std::vector nmsEta = {0.6f, 1.0f}; const std::vector normalized = {true, false}; -const std::vector outStaticShape = {true}; // only be true as gpu plugin not support nms with internal dynamic yet. - const auto params_v9_2Inputs = ::testing::Combine( ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(shapes2Inputs)), ::testing::Combine(::testing::Values(ov::element::f32), - ::testing::Values(ov::element::i32), - ::testing::Values(ov::element::i32), - ::testing::Values(ov::element::f32)), + ::testing::Values(ov::element::i32)), ::testing::ValuesIn(nmsTopK), ::testing::Combine(::testing::ValuesIn(iouThreshold), ::testing::ValuesIn(scoreThreshold), ::testing::ValuesIn(nmsEta)), ::testing::ValuesIn(backgroundClass), @@ -56,21 +441,18 @@ const auto params_v9_2Inputs = ::testing::Combine( ::testing::ValuesIn(outType), ::testing::ValuesIn(sortResultType), ::testing::Combine(::testing::ValuesIn(sortResDesc), ::testing::ValuesIn(normalized)), - ::testing::ValuesIn(outStaticShape), ::testing::Values(ov::test::utils::DEVICE_GPU)); INSTANTIATE_TEST_SUITE_P(smoke_MulticlassNmsLayerTest_v9_2inputs, - MulticlassNmsLayerTest, + MulticlassNmsLayerTestGPU, params_v9_2Inputs, - MulticlassNmsLayerTest::getTestCaseName); + MulticlassNmsLayerTestGPU::getTestCaseName); const auto params_v9_3Inputs = ::testing::Combine( ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(shapes3Inputs)), ::testing::Combine(::testing::Values(ov::element::f32), - ::testing::Values(ov::element::i32), - ::testing::Values(ov::element::i32), - ::testing::Values(ov::element::f32)), + ::testing::Values(ov::element::i32)), ::testing::ValuesIn(nmsTopK), ::testing::Combine(::testing::ValuesIn(iouThreshold), ::testing::ValuesIn(scoreThreshold), ::testing::ValuesIn(nmsEta)), ::testing::ValuesIn(backgroundClass), @@ -78,20 +460,17 @@ const auto params_v9_3Inputs = ::testing::Combine( ::testing::ValuesIn(outType), ::testing::ValuesIn(sortResultType), ::testing::Combine(::testing::ValuesIn(sortResDesc), ::testing::ValuesIn(normalized)), - ::testing::ValuesIn(outStaticShape), ::testing::Values(ov::test::utils::DEVICE_GPU)); INSTANTIATE_TEST_SUITE_P(smoke_MulticlassNmsLayerTest_v9_3inputs, - MulticlassNmsLayerTest, + MulticlassNmsLayerTestGPU, params_v9_3Inputs, - MulticlassNmsLayerTest::getTestCaseName); + MulticlassNmsLayerTestGPU::getTestCaseName); const auto params_v8 = ::testing::Combine( ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(shapes2Inputs)), ::testing::Combine(::testing::Values(ov::element::f32), - ::testing::Values(ov::element::i32), - ::testing::Values(ov::element::i32), - ::testing::Values(ov::element::f32)), + ::testing::Values(ov::element::i32)), ::testing::ValuesIn(nmsTopK), ::testing::Combine(::testing::ValuesIn(iouThreshold), ::testing::ValuesIn(scoreThreshold), ::testing::ValuesIn(nmsEta)), ::testing::ValuesIn(backgroundClass), @@ -99,11 +478,15 @@ const auto params_v8 = ::testing::Combine( ::testing::ValuesIn(outType), ::testing::ValuesIn(sortResultType), ::testing::Combine(::testing::ValuesIn(sortResDesc), ::testing::ValuesIn(normalized)), - ::testing::ValuesIn(outStaticShape), ::testing::Values(ov::test::utils::DEVICE_GPU)); INSTANTIATE_TEST_SUITE_P(smoke_MulticlassNmsLayerTest_v8, - MulticlassNmsLayerTest8, + MulticlassNmsLayerTestGPU8, params_v8, - MulticlassNmsLayerTest8::getTestCaseName); + MulticlassNmsLayerTestGPU8::getTestCaseName); + +} // namespace +} // namespace GPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/mvn.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/mvn.cpp index 329ac165b7e9dd..41f38ee730fb59 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/mvn.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/mvn.cpp @@ -11,7 +11,7 @@ namespace { using ov::test::Mvn1LayerTest; using ov::test::Mvn6LayerTest; -const std::vector emptyReductionAxes = {{}}; +const std::vector emptyReductionAxes = {{}}; const std::vector> inputShapes = { {{1, 32, 17}}, diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/nms_rotated.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/nms_rotated.cpp index 830bdd344ce0f3..3f7bbe05bda5d0 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/nms_rotated.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/nms_rotated.cpp @@ -2,39 +2,383 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "ov_models/builders.hpp" +#include "shared_test_classes/base/layer_test_utils.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" +#include "common_test_utils/node_builders/constant.hpp" -#include "single_layer_tests/nms_rotated.hpp" -#include "common_test_utils/test_constants.hpp" +namespace ov { +namespace test { +namespace GPULayerTestsDefinitions { -using namespace LayerTestsDefinitions; -using namespace InferenceEngine; -using namespace ngraph; +typedef std::tuple< + std::vector, // Input shapes + ov::test::ElementType, // Boxes and scores input precisions + ov::test::ElementType, // Max output boxes input precisions + ov::test::ElementType, // Thresholds precisions + ov::test::ElementType, // Output type + int64_t, // Max output boxes per class + float, // IOU threshold + float, // Score threshold + bool, // Sort result descending + bool, // Clockwise + bool, // Is 1st input constant + bool, // Is 2nd input constant + bool, // Is 3rd input constant + bool, // Is 4th input constant + bool, // Is 5th input constant + ov::AnyMap, // Additional configuration + std::string // Device name +> NmsRotatedParamsGPU; -const std::vector inShapeParams = { - InputShapeParams{2, 50, 50}, - InputShapeParams {9, 10, 10} +class NmsRotatedLayerTestGPU : public testing::WithParamInterface, + public ov::test::SubgraphBaseTest { +public: + static std::string getTestCaseName(const testing::TestParamInfo& obj); + +protected: + void SetUp() override; + void compare(const std::vector &expected, const std::vector &actual) override; + void generate_inputs(const std::vector& target_shapes) override; + +private: + int64_t m_max_out_boxes_per_class; + float m_iou_threshold; + float m_score_threshold; +}; + +TEST_P(NmsRotatedLayerTestGPU, CompareWithRefs) { + run(); }; -const std::vector maxOutBoxPerClass = {5, 20}; -const std::vector threshold = {0.3f, 0.7f}; -const std::vector sortResDesc = {true, false}; -const std::vector outType = {ov::element::i32, ov::element::i64}; -const std::vector clockwise = {true, false}; +std::string NmsRotatedLayerTestGPU::getTestCaseName(const testing::TestParamInfo& obj) { + const auto& in_shapes = std::get<0>(obj.param); + + std::ostringstream result; + + result << "IS=("; + for (size_t i = 0lu; i < in_shapes.size(); i++) { + result << utils::partialShape2str({in_shapes[i].first}) << (i < in_shapes.size() - 1lu ? "_" : ""); + } + result << ")_TS="; + for (size_t i = 0lu; i < in_shapes.front().second.size(); i++) { + result << "{"; + for (size_t j = 0lu; j < in_shapes.size(); j++) { + result << utils::vec2str(in_shapes[j].second[i]) << (j < in_shapes.size() - 1lu ? "_" : ""); + } + result << "}_"; + } + result << "_BoxPrc=" << std::get<1>(obj.param); + result << "_MaxPrc=" << std::get<2>(obj.param); + result << "_ThrPrc=" << std::get<3>(obj.param); + result << "_OutPrc=" << std::get<4>(obj.param); + result << "_MaxBox=" << std::get<5>(obj.param); + result << "_IouThr=" << std::get<6>(obj.param); + result << "_ScoreThr=" << std::get<7>(obj.param); + result << "_SortDesc=" << utils::bool2str(std::get<8>(obj.param)); + result << "_Clockwise=" << utils::bool2str(std::get<9>(obj.param)); + result << "_ConstIn={" << utils::bool2str(std::get<10>(obj.param)) << "," + << utils::bool2str(std::get<11>(obj.param)) << "," + << utils::bool2str(std::get<12>(obj.param)) << "," + << utils::bool2str(std::get<13>(obj.param)) << "," + << utils::bool2str(std::get<14>(obj.param)) << "}"; + + const auto& config = std::get<15>(obj.param); + if (!config.empty()) { + result << "_Config={"; + for (const auto& conf_item : config) { + result << "_" << conf_item.first << "="; + conf_item.second.print(result); + } + result << "}"; + } + + result << "_Device=" << std::get<16>(obj.param); + + return result.str(); +} + +void NmsRotatedLayerTestGPU::SetUp() { + const auto& params = this->GetParam(); + const auto& in_shapes = std::get<0>(params); + const auto& boxes_prc = std::get<1>(params); + const auto& max_boxes_prc = std::get<2>(params); + const auto& thresholds_prc = std::get<3>(params); + const auto& out_prc = std::get<4>(params); + m_max_out_boxes_per_class = std::get<5>(params); + m_iou_threshold = std::get<6>(params); + m_score_threshold = std::get<7>(params); + const auto& sort_descending = std::get<8>(params); + const auto& clockwise = std::get<9>(params); + const auto& is_0_in_const = std::get<10>(params); + const auto& is_1_in_const = std::get<11>(params); + const auto& is_2_in_const = std::get<12>(params); + const auto& is_3_in_const = std::get<13>(params); + const auto& is_4_in_const = std::get<14>(params); + configuration = std::get<15>(params); + targetDevice = std::get<16>(params); + + std::vector actual_shapes; + ov::ParameterVector in_params; + std::vector> inputs; + const auto in_shape_1d = InputShape{{1}, {{1}}}; + +#define CONST_CASE(P, S, H, L) \ + case P: \ + inputs.push_back(ov::test::utils::deprecated::make_constant(P, S, std::vector::value_type>{}, true, \ + ov::element_type_traits

::value_type(H), ov::element_type_traits

::value_type(L))); \ + break; + +#define CREATE_INPUT(C, P, S, N, H, L) \ + if (C) { \ + switch (P) { \ + CONST_CASE(ElementType::f32, S.second[0], H, L) \ + CONST_CASE(ElementType::f16, S.second[0], H, L) \ + CONST_CASE(ElementType::bf16, S.second[0], H, L) \ + CONST_CASE(ElementType::i32, S.second[0], H, L) \ + CONST_CASE(ElementType::i64, S.second[0], H, L) \ + default: OPENVINO_THROW("NmsRotated does not support precision ", P, " for the ", N, " input."); \ + } \ + } else { \ + actual_shapes.push_back(S); \ + if (S.first.rank() == 0) { \ + in_params.push_back(std::make_shared(P, S.second.front())); \ + } else { \ + in_params.push_back(std::make_shared(P, S.first)); \ + } \ + in_params.back()->set_friendly_name(N); \ + inputs.push_back(in_params.back()); \ + } + + CREATE_INPUT(is_0_in_const, boxes_prc, in_shapes[0], "Boxes", 30, 10) + CREATE_INPUT(is_1_in_const, boxes_prc, in_shapes[1], "Scores", 1, 0) + CREATE_INPUT(is_2_in_const, max_boxes_prc, in_shape_1d, "MaxOutputBoxesPerClass", m_max_out_boxes_per_class, m_max_out_boxes_per_class) + CREATE_INPUT(is_3_in_const, thresholds_prc, in_shape_1d, "IouThreshold", m_iou_threshold, m_iou_threshold) + CREATE_INPUT(is_4_in_const, thresholds_prc, in_shape_1d, "ScoreThreshold", m_score_threshold, m_score_threshold) + +#undef CONST_CASE +#undef CREATE_INPUT + + init_input_shapes(actual_shapes); + + const auto nms_op = std::make_shared(inputs[0], inputs[1], inputs[2], inputs[3], inputs[4], + sort_descending, out_prc, clockwise); + ov::ResultVector results; + for (size_t i = 0lu; i < nms_op->get_output_size(); i++) { + results.push_back(std::make_shared(nms_op->output(i))); + } + + function = std::make_shared(results, in_params, "NMSRotated"); +} + +void NmsRotatedLayerTestGPU::compare(const std::vector &expectedOutputs, const std::vector &actualOutputs) { + struct OutBox { + OutBox() = default; + + OutBox(int32_t batchId, int32_t classId, int32_t boxId, float score) { + this->batchId = batchId; + this->classId = classId; + this->boxId = boxId; + this->score = score; + } + + bool operator==(const OutBox& rhs) const { + return batchId == rhs.batchId && classId == rhs.classId && boxId == rhs.boxId; + } + + int32_t batchId; + int32_t classId; + int32_t boxId; + float score; + }; -const std::vector inputPrecisions = {Precision::FP32, Precision::FP16}; + std::vector expected; + { + const auto selected_indices_size = expectedOutputs[0].get_size(); + const auto selected_scores_size = expectedOutputs[1].get_size(); + + ASSERT_EQ(selected_indices_size, selected_scores_size); + + const auto boxes_count = selected_indices_size / 3; + expected.resize(boxes_count); + + if (expectedOutputs[0].get_element_type().bitwidth() == 32) { + auto selected_indices_data = reinterpret_cast(expectedOutputs[0].data()); + + for (size_t i = 0; i < selected_indices_size; i += 3) { + expected[i / 3].batchId = selected_indices_data[i + 0]; + expected[i / 3].classId = selected_indices_data[i + 1]; + expected[i / 3].boxId = selected_indices_data[i + 2]; + } + } else { + auto selected_indices_data = reinterpret_cast(expectedOutputs[0].data()); + + for (size_t i = 0; i < selected_indices_size; i += 3) { + expected[i / 3].batchId = static_cast(selected_indices_data[i + 0]); + expected[i / 3].classId = static_cast(selected_indices_data[i + 1]); + expected[i / 3].boxId = static_cast(selected_indices_data[i + 2]); + } + } + + if (expectedOutputs[1].get_element_type().bitwidth() == 32) { + auto selected_scores_data = reinterpret_cast(expectedOutputs[1].data()); + for (size_t i = 0; i < selected_scores_size; i += 3) { + expected[i / 3].score = selected_scores_data[i + 2]; + } + } else { + auto selected_scores_data = reinterpret_cast(expectedOutputs[1].data()); + for (size_t i = 0; i < selected_scores_size; i += 3) { + expected[i / 3].score = static_cast(selected_scores_data[i + 2]); + } + } + } + + std::vector actual; + { + const auto selected_indices_size = actualOutputs[0].get_size(); + const auto selected_scores_data = reinterpret_cast(actualOutputs[1].data()); + if (actualOutputs[0].get_element_type().bitwidth() == 32) { + const auto selected_indices_data = reinterpret_cast(actualOutputs[0].data()); + for (size_t i = 0; i < selected_indices_size; i += 3) { + const int32_t batchId = selected_indices_data[i + 0]; + const int32_t classId = selected_indices_data[i + 1]; + const int32_t boxId = selected_indices_data[i + 2]; + const float score = selected_scores_data[i + 2]; + if (batchId == -1 || classId == -1 || boxId == -1) + break; + + actual.emplace_back(batchId, classId, boxId, score); + } + } else { + const auto selected_indices_data = reinterpret_cast(actualOutputs[0].data()); + for (size_t i = 0; i < selected_indices_size; i += 3) { + const int64_t batchId = selected_indices_data[i + 0]; + const int64_t classId = selected_indices_data[i + 1]; + const int64_t boxId = selected_indices_data[i + 2]; + const float score = selected_scores_data[i + 2]; + if (batchId == -1 || classId == -1 || boxId == -1) + break; + + actual.emplace_back(batchId, classId, boxId, score); + } + } + } + + ASSERT_EQ(expected.size(), actual.size()); + for (size_t i = 0; i < expected.size(); ++i) { + ASSERT_EQ(expected[i], actual[i]) << ", i=" << i; + ASSERT_NEAR(expected[i].score, actual[i].score, abs_threshold) << ", i=" << i; + } +} + +template +void fill_data(TD* dst, const TS* src, size_t len) { + for (size_t i = 0llu; i < len; i++) { + dst[i] = static_cast(src[i]); + } +} + +void NmsRotatedLayerTestGPU::generate_inputs(const std::vector& targetInputStaticShapes) { + inputs.clear(); + const auto& func_inputs = function->inputs(); + + for (size_t i = 0llu; i < func_inputs.size(); ++i) { + const auto& func_input = func_inputs[i]; + const auto& name = func_input.get_node()->get_friendly_name(); + const auto& in_prc = func_input.get_element_type(); + auto tensor = ov::Tensor(in_prc, targetInputStaticShapes[i]); + +#define FILL_DATA(P, S, L) \ +case P : \ +fill_data(tensor.data::value_type>(), S, L); break; + +#define GEN_DATA(P, R, S, K) \ +case P : \ +utils::fill_data_random(tensor.data::value_type>(), shape_size(targetInputStaticShapes[i]), R, S, K); break; + + if (name == "Boxes") { + switch (in_prc) { + GEN_DATA(ElementType::f32, 30, 20, 1) + GEN_DATA(ElementType::f16, 30, 20, 1) + default: + OPENVINO_THROW("NmsRotated does not support precision ", in_prc, " for the Scores input."); + } + } else if (name == "Scores") { + switch (in_prc) { + GEN_DATA(ElementType::f32, 1, 0, 100) + GEN_DATA(ElementType::f16, 1, 0, 100) + default: + OPENVINO_THROW("NmsRotated does not support precision ", in_prc, " for the Scores input."); + } + } else if (name == "MaxOutputBoxesPerClass") { + switch (in_prc) { + FILL_DATA(ElementType::i64, &m_max_out_boxes_per_class, 1) + FILL_DATA(ElementType::i32, &m_max_out_boxes_per_class, 1) + default: + OPENVINO_THROW("NmsRotated does not support precision ", in_prc, " for the MaxOutputBoxesPerClass input."); + } + } else if (name == "IouThreshold") { + switch (in_prc) { + FILL_DATA(ElementType::f32, &m_iou_threshold, 1) + FILL_DATA(ElementType::f16, &m_iou_threshold, 1) + default: + OPENVINO_THROW("NmsRotated does not support precision ", in_prc, " for the IouThreshold input."); + } + } else if (name == "ScoreThreshold") { + switch (in_prc) { + FILL_DATA(ElementType::f32, &m_score_threshold, 1) + FILL_DATA(ElementType::f16, &m_score_threshold, 1) + default: + OPENVINO_THROW("NmsRotated does not support precision ", in_prc, " for the ScoreThreshold input."); + } + } + +#undef GEN_DATA +#undef FILL_DATA + + inputs.insert({func_input.get_node_shared_ptr(), tensor}); + } +} + +namespace { +const std::vector> inShapeParams = { + { + { {}, {{2, 50, 5}} }, + { {}, {{2, 50, 50}} } + }, + { + { {}, {{9, 10, 5}} }, + { {}, {{9, 10, 10}} } + } +}; + +const std::vector outType = {ov::element::i32, ov::element::i64}; +const std::vector inputPrecisions = {ov::element::f32, ov::element::f16}; +const ov::AnyMap empty_plugin_config{}; INSTANTIATE_TEST_SUITE_P(smoke_NmsRotatedLayerTest, - NmsRotatedLayerTest, + NmsRotatedLayerTestGPU, ::testing::Combine(::testing::ValuesIn(inShapeParams), - ::testing::Combine(::testing::ValuesIn(inputPrecisions), - ::testing::Values(Precision::I32), - ::testing::Values(Precision::FP32)), - ::testing::ValuesIn(maxOutBoxPerClass), - ::testing::ValuesIn(threshold), - ::testing::ValuesIn(threshold), - ::testing::ValuesIn(sortResDesc), + ::testing::ValuesIn(inputPrecisions), + ::testing::Values(ov::element::i32), + ::testing::Values(ov::element::f32), ::testing::ValuesIn(outType), - ::testing::ValuesIn(clockwise), + ::testing::Values(5, 20), + ::testing::Values(0.3f, 0.7f), + ::testing::Values(0.3f, 0.7f), + ::testing::Values(true, false), + ::testing::Values(true, false), + ::testing::Values(true), + ::testing::Values(true), + ::testing::Values(true), + ::testing::Values(true), + ::testing::Values(true), + ::testing::Values(empty_plugin_config), ::testing::Values(ov::test::utils::DEVICE_GPU)), - NmsRotatedLayerTest::getTestCaseName); + NmsRotatedLayerTestGPU::getTestCaseName); + +} // namespace +} // namespace GPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/proposal.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/proposal.cpp index f5884d399bb6f2..a6e2b2235f5628 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/proposal.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/proposal.cpp @@ -2,29 +2,26 @@ // SPDX-License-Identifier: Apache-2.0 // -#include - -#include "single_layer_tests/proposal.hpp" -#include "common_test_utils/test_constants.hpp" - -using namespace ngraph::helpers; -using namespace LayerTestsDefinitions; +#include "single_op_tests/proposal.hpp" namespace { +using ov::test::ProposalLayerTest; +using ov::test::proposalSpecificParams; +using ov::test::proposalLayerTestParamsSet; /* ============= Proposal ============= */ -const std::vector base_size_ = {16}; -const std::vector pre_nms_topn_ = {100}; -const std::vector post_nms_topn_ = {100}; -const std::vector nms_thresh_ = {0.7f}; -const std::vector min_size_ = {1}; -const std::vector ratio_ = {{1.0f, 2.0f}}; -const std::vector scale_ = {{1.2f, 1.5f}}; -const std::vector clip_before_nms_ = {false}; -const std::vector clip_after_nms_ = {false}; +const std::vector base_size_ = {16}; +const std::vector pre_nms_topn_ = {100}; +const std::vector post_nms_topn_ = {100}; +const std::vector nms_thresh_ = {0.7f}; +const std::vector min_size_ = {1}; +const std::vector> ratio_ = {{1.0f, 2.0f}}; +const std::vector> scale_ = {{1.2f, 1.5f}}; +const std::vector clip_before_nms_ = {false}; +const std::vector clip_after_nms_ = {false}; // empty string corresponds to Caffe framework -const std::vector framework_ = {""}; +const std::vector framework_ = {""}; const auto proposalParams = ::testing::Combine( ::testing::ValuesIn(base_size_), @@ -42,8 +39,8 @@ const auto proposalParams = ::testing::Combine( INSTANTIATE_TEST_SUITE_P(smoke_Proposal_tests, ProposalLayerTest, ::testing::Combine( proposalParams, + ::testing::ValuesIn({ov::element::f16, ov::element::f32}), ::testing::Values(ov::test::utils::DEVICE_GPU)), - ProposalLayerTest::getTestCaseName -); + ProposalLayerTest::getTestCaseName); } // namespace diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/roi_pooling.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/roi_pooling.cpp index eed2f708e042a7..72a91b240b8549 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/roi_pooling.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/roi_pooling.cpp @@ -2,69 +2,115 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/roi_pooling.hpp" +#include "shared_test_classes/single_op/roi_pooling.hpp" -#include - -#include "common_test_utils/test_constants.hpp" +namespace ov { +namespace test { +class ROIPoolingLayerTestGPU : virtual public ov::test::ROIPoolingLayerTest { +protected: + void SetUp() override; +}; -using namespace LayerTestsDefinitions; +void ROIPoolingLayerTestGPU::SetUp() { + std::vector input_shapes; + ov::Shape pool_shape; + float spatial_scale; + ov::test::utils::ROIPoolingTypes pool_method; + ov::element::Type model_type; + std::string target_device; + std::tie(input_shapes, pool_shape, spatial_scale, pool_method, model_type, targetDevice) = this->GetParam(); + + abs_threshold = 0.08f; + if (model_type == ov::element::f16) { + abs_threshold = 0.15f; + } + + init_input_shapes(input_shapes); + + auto param = std::make_shared(model_type, inputDynamicShapes[0]); + auto coord_param = std::make_shared(model_type, inputDynamicShapes[1]); + std::string pool_method_str; + if (pool_method == ov::test::utils::ROIPoolingTypes::ROI_MAX) { + pool_method_str = "max"; + } else if (pool_method == ov::test::utils::ROIPoolingTypes::ROI_BILINEAR) { + pool_method_str = "bilinear"; + } else { + FAIL() << "Incorrect type of ROIPooling operation"; + } + auto roi_pooling = std::make_shared(param, coord_param, pool_shape, spatial_scale, pool_method_str); + function = std::make_shared(roi_pooling->outputs(), ov::ParameterVector{param, coord_param}, "roi_pooling"); +} + +TEST_P(ROIPoolingLayerTestGPU, Inference) { + run(); +} namespace { -const std::vector> inShapes = { - {1, 3, 8, 8}, - {3, 4, 50, 50}, +const std::vector inShapes = { + {{1, 3, 8, 8}}, + {{3, 4, 50, 50}}, }; -const std::vector> pooledShapes_max = { - {1, 1}, - {2, 2}, - {3, 3}, - {6, 6}, +const std::vector coordShapes = { + {{1, 5}}, + {{3, 5}}, + {{5, 5}}, }; -const std::vector> pooledShapes_bilinear = { - {1, 1}, - {2, 2}, - {3, 3}, - {6, 6}, +auto input_shapes = [](const std::vector& in1, const std::vector& in2) { + std::vector> res; + for (const auto& sh1 : in1) + for (const auto& sh2 : in2) + res.push_back(ov::test::static_shapes_to_test_representation({sh1, sh2})); + return res; +}(inShapes, coordShapes); + +const std::vector pooledShapes_max = { + {{1, 1}}, + {{2, 2}}, + {{3, 3}}, + {{6, 6}}, }; -const std::vector> coordShapes = { - {1, 5}, - {3, 5}, - {5, 5}, +const std::vector pooledShapes_bilinear = { + {{1, 1}}, + {{2, 2}}, + {{3, 3}}, + {{6, 6}}, }; -const std::vector netPRCs = { - InferenceEngine::Precision::FP16, - InferenceEngine::Precision::FP32, +const std::vector netPRCs = { + ov::element::f16, + ov::element::f32, }; const std::vector spatial_scales = {0.625f, 1.f}; -const auto params_max = testing::Combine(testing::ValuesIn(inShapes), - testing::ValuesIn(coordShapes), +const auto params_max = testing::Combine(testing::ValuesIn(input_shapes), testing::ValuesIn(pooledShapes_max), testing::ValuesIn(spatial_scales), - testing::Values(ngraph::helpers::ROIPoolingTypes::ROI_MAX), + testing::Values(ov::test::utils::ROIPoolingTypes::ROI_MAX), testing::ValuesIn(netPRCs), testing::Values(ov::test::utils::DEVICE_GPU)); -const auto params_bilinear = testing::Combine(testing::ValuesIn(inShapes), - testing::ValuesIn(coordShapes), +const auto params_bilinear = testing::Combine(testing::ValuesIn(input_shapes), testing::ValuesIn(pooledShapes_bilinear), testing::Values(spatial_scales[1]), - testing::Values(ngraph::helpers::ROIPoolingTypes::ROI_BILINEAR), + testing::Values(ov::test::utils::ROIPoolingTypes::ROI_BILINEAR), testing::ValuesIn(netPRCs), testing::Values(ov::test::utils::DEVICE_GPU)); -INSTANTIATE_TEST_SUITE_P(smoke_ROIPooling_max, ROIPoolingLayerTest, params_max, ROIPoolingLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_ROIPooling_max, + ROIPoolingLayerTestGPU, + params_max, + ROIPoolingLayerTestGPU::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_ROIPooling_bilinear, - ROIPoolingLayerTest, + ROIPoolingLayerTestGPU, params_bilinear, - ROIPoolingLayerTest::getTestCaseName); + ROIPoolingLayerTestGPU::getTestCaseName); } // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/softmax.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/softmax.cpp index 92da7f1b0b44c8..00b844defb0686 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/softmax.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/softmax.cpp @@ -4,7 +4,7 @@ #include -#include "single_layer_tests/softmax.hpp" +#include "single_op_tests/softmax.hpp" #include "common_test_utils/test_constants.hpp" using namespace ov::test::subgraph; diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/topk.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/topk.cpp index 7c3568ba419855..ff8e64580ff7bf 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/topk.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/topk.cpp @@ -2,149 +2,17 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace GPULayerTestsDefinitions { - -typedef std::tuple - TopKGPUParams; - -class TopKLayerTestGPU : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo& info) const override; - -protected: - void SetUp() override; -}; - -std::string TopKLayerTestGPU::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout; - InferenceEngine::SizeVector inputShape; - std::string targetDevice; - int64_t keepK, axis; - ov::op::TopKMode mode; - ov::op::TopKSortType sort; - bool stable; - std::tie(keepK, axis, mode, sort, stable, netPrecision, inPrc, outPrc, inLayout, inputShape, targetDevice) = - obj.param; - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShape) << "_"; - result << "k=" << keepK << "_"; - result << "axis=" << axis << "_"; - result << "mode=" << mode << "_"; - result << "sort=" << sort << "_"; - result << "stable=" << stable << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "trgDev=" << targetDevice; - return result.str(); -} - -void TopKLayerTestGPU::SetUp() { - InferenceEngine::SizeVector inputShape; - InferenceEngine::Precision netPrecision; - int64_t keepK, axis; - ov::op::TopKMode mode; - ov::op::TopKSortType sort; - bool stable; - std::tie(keepK, axis, mode, sort, stable, netPrecision, inPrc, outPrc, inLayout, inputShape, targetDevice) = - this->GetParam(); - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - - auto k = std::make_shared(ov::element::Type_t::i64, ngraph::Shape{}, &keepK); - auto topk = std::dynamic_pointer_cast( - std::make_shared(params[0], k, axis, mode, sort, ov::element::Type_t::i64, stable)); - - ov::ResultVector results; - for (size_t i = 0; i < topk->get_output_size(); i++) { - results.push_back(std::make_shared(topk->output(i))); - } - function = std::make_shared(results, params, "TopK"); -} - -InferenceEngine::Blob::Ptr TopKLayerTestGPU::GenerateInput(const InferenceEngine::InputInfo& info) const { - IE_ASSERT(InferenceEngine::Precision::FP32 == info.getTensorDesc().getPrecision() || - InferenceEngine::Precision::BF16 == info.getTensorDesc().getPrecision() || - InferenceEngine::Precision::FP16 == info.getTensorDesc().getPrecision()); - - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout; - InferenceEngine::SizeVector inputShape; - std::string targetDevice; - int64_t keepK, axis; - ov::op::TopKMode mode; - ov::op::TopKSortType sort; - bool stable; - std::tie(keepK, axis, mode, sort, stable, netPrecision, inPrc, outPrc, inLayout, inputShape, targetDevice) = - this->GetParam(); - - InferenceEngine::Blob::Ptr blob = make_blob_with_precision(info.getTensorDesc()); - blob->allocate(); - - // For unstable sorting, generate unrepeated input data. - // While for stable sorting repeating values are explicitly set. - - size_t size = blob->size(); - int start = -static_cast(size / 2); - std::vector data(size); - size_t set_size = sort == ov::op::TopKSortType::SORT_VALUES && stable ? size / 2 : size; - std::iota(data.begin(), data.begin() + set_size, start); - if (sort == ov::op::TopKSortType::SORT_VALUES && stable) { - std::copy(data.begin(), data.begin() + set_size, data.begin() + set_size); - } - std::mt19937 gen(0); - std::shuffle(data.begin(), data.end(), gen); - - float divisor = size / 10.0; - if (InferenceEngine::Precision::FP32 == info.getTensorDesc().getPrecision()) { - auto* rawBlobDataPtr = blob->buffer().as(); - for (size_t i = 0; i < size; i++) { - rawBlobDataPtr[i] = static_cast(data[i] / divisor); - } - } else if (InferenceEngine::Precision::BF16 == info.getTensorDesc().getPrecision()) { - auto* rawBlobDataPtr = blob->buffer().as(); - for (size_t i = 0; i < size; i++) { - rawBlobDataPtr[i] = static_cast(data[i] / divisor); - } - } else if (InferenceEngine::Precision::FP16 == info.getTensorDesc().getPrecision()) { - auto* rawBlobDataPtr = blob->buffer().as(); - for (size_t i = 0; i < size; i++) { - rawBlobDataPtr[i] = static_cast(data[i] / divisor); - } - } - - return blob; -} +#include "single_op_tests/topk.hpp" namespace { +using ov::test::TopK11LayerTest; +using ov::test::TopKLayerTest; -const std::vector netPrecisions = { - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::FP16, +std::vector shapes = {{10, 10, 10}}; + +const std::vector netPrecisions = { + ov::element::f32, + ov::element::f16, }; const std::vector axes = { @@ -153,20 +21,20 @@ const std::vector axes = { 2, }; -const std::vector k = { +const std::vector keep = { 1, 5, 10, }; -const std::vector modes = { - ov::op::TopKMode::MIN, - ov::op::TopKMode::MAX, +const std::vector modes = { + ov::op::v1::TopK::Mode::MIN, + ov::op::v1::TopK::Mode::MAX, }; -const std::vector sortTypes = { - ov::op::TopKSortType::SORT_INDICES, - ov::op::TopKSortType::SORT_VALUES, +const std::vector sortTypes = { + ov::op::v1::TopK::SortType::SORT_INDICES, + ov::op::v1::TopK::SortType::SORT_VALUES, }; const std::vector stable = { @@ -174,23 +42,16 @@ const std::vector stable = { true, }; -TEST_P(TopKLayerTestGPU, CompareWithRefs) { - Run(); -} - -INSTANTIATE_TEST_SUITE_P(smoke_TopK, - TopKLayerTestGPU, - ::testing::Combine(::testing::ValuesIn(k), +INSTANTIATE_TEST_SUITE_P(smoke_TopK11, + TopK11LayerTest, + ::testing::Combine(::testing::ValuesIn(keep), ::testing::ValuesIn(axes), ::testing::ValuesIn(modes), ::testing::ValuesIn(sortTypes), - ::testing::ValuesIn(stable), ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector({10, 10, 10})), + ::testing::Values(ov::test::static_shapes_to_test_representation(shapes)), + ::testing::ValuesIn(stable), ::testing::Values(ov::test::utils::DEVICE_GPU)), - TopKLayerTestGPU::getTestCaseName); + TopK11LayerTest::getTestCaseName); + } // namespace -} // namespace GPULayerTestsDefinitions diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/skip_tests_config.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/skip_tests_config.cpp index 906e8276de8c80..aac54a9c72f723 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/skip_tests_config.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/skip_tests_config.cpp @@ -60,8 +60,6 @@ std::vector disabledTestPatterns() { R"(.*smoke_GridSample/GridSampleLayerTest.Inference/.*model_type=f16.*)", // Issue: 119648 R"(.*smoke_LPT/InterpolateTransformation.*)", - // Issue: 128924 - R"(.*OVClassModelTestP/OVClassModelTestP.ImportModelWithNullContextThrows.*)", #if defined(_WIN32) R"(.*KernelCachingSupportCase.*CanCreateCacheDirAndDumpBinariesUnicodePath.*)", #endif diff --git a/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/adaptive_pooling.cpp b/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/adaptive_pooling.cpp new file mode 100644 index 00000000000000..d117e0671921eb --- /dev/null +++ b/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/adaptive_pooling.cpp @@ -0,0 +1,335 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// +#include + +#include "common_test_utils/ov_tensor_utils.hpp" +#include "common_test_utils/test_enums.hpp" +#include "ov_models/utils/ov_helpers.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" + +#include "openvino/op/parameter.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/result.hpp" +#include "openvino/op/adaptive_avg_pool.hpp" +#include "openvino/op/adaptive_max_pool.hpp" + +namespace { +using ov::test::InputShape; +using AdaPoolSpecificParams = std::tuple, // pooled vector + std::vector>; // feature map shape + +using AdaPoolLayerGPUTestParams = std::tuple; // Device name + + +class AdaPoolLayerGPUTest : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseTest { +public: + static std::string getTestCaseName(testing::TestParamInfo obj) { + AdaPoolLayerGPUTestParams basicParamsSet; + basicParamsSet = obj.param; + std::string targetDevice; + ov::element::Type netPr; + bool isStatic; + AdaPoolSpecificParams adaPar; + std::vector pooledSpatialShape; + std::vector inputShape; + std::string mode; + std::tie(adaPar, mode, isStatic, netPr, targetDevice) = basicParamsSet; + std::tie(pooledSpatialShape, inputShape) = adaPar; + std::ostringstream result; + + result << "AdaPoolTest_"; + result << "IS=("; + for (const auto& shape : inputShape) { + result << ov::test::utils::partialShape2str({shape.first}) << "_"; + } + result << ")_TS=("; + for (const auto& shape : inputShape) { + for (const auto& item : shape.second) { + result << ov::test::utils::vec2str(item) << "_"; + } + } + result << "OS=" << ov::test::utils::vec2str(pooledSpatialShape) << "(spat.)_"; + result << netPr << "_"; + result << mode << "_"; + result << "device=" << targetDevice; + + return result.str(); + } + +protected: + void SetUp() override { + AdaPoolLayerGPUTestParams basicParamsSet; + basicParamsSet = this->GetParam(); + + AdaPoolSpecificParams adaPoolParams; + ov::element::Type netPrecision; + bool isStatic; + std::vector inputShape; + std::tie(adaPoolParams, mode, isStatic, netPrecision, targetDevice) = basicParamsSet; + std::tie(pooledVector, inputShape) = adaPoolParams; + + init_input_shapes(inputShape); + if (!isStatic) { + for (auto& target : targetStaticShapes) { + target.push_back({pooledVector.size()}); + } + } + + function = createFunction(isStatic); + if (function->get_parameters().size() == 2) { + generatePooledVector(); + functionRefs = createFunction(true); + } + } + + void generatePooledVector() { + std::random_device rd; + std::uniform_int_distribution distribution(1, 5); + for (size_t i = 0; i < pooledVector.size(); i++) { + pooledVector[i] = distribution(rd); + } + } + + std::shared_ptr createFunction(bool secondInputConst) { + ov::ParameterVector params{std::make_shared(ov::element::f32, inputDynamicShapes[0])}; + params.front()->set_friendly_name("ParamsInput"); + std::shared_ptr secondInput; + if (secondInputConst) { + // ngraph shape infer for adaptive pooling has seg fault when i32 type of second input + secondInput = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{pooledVector.size()}, pooledVector); + } else { + auto pooledParam = + // ngraph shape infer for adaptive pooling has seg fault when i32 type of second input + std::make_shared(ov::element::i64, ov::Shape{pooledVector.size()}); + pooledParam->set_friendly_name("ParamSecondInput"); + params.push_back(pooledParam); + secondInput = pooledParam; + } + + auto adapoolMax = std::make_shared(params[0], secondInput, ov::element::i64); + auto adapoolAvg = std::make_shared(params[0], secondInput); + + auto function = (mode == "max" ? std::make_shared(adapoolMax->outputs(), params, "AdaPoolMax") + : std::make_shared(adapoolAvg->outputs(), params, "AdaPoolAvg")); + return function; + } + + void validate() override { + auto actualOutputs = get_plugin_outputs(); + if (function->get_parameters().size() == 2) { + auto pos = std::find_if(inputs.begin(), + inputs.end(), + [](const std::pair, ov::Tensor>& params) { + return params.first->get_friendly_name() == "ParamSecondInput"; + }); + OPENVINO_ASSERT(pos != inputs.end()); + inputs.erase(pos); + } + auto expectedOutputs = calculate_refs(); + if (expectedOutputs.empty()) { + return; + } + ASSERT_EQ(actualOutputs.size(), expectedOutputs.size()) + << "model interpreter has " << expectedOutputs.size() << " outputs, while IE " << actualOutputs.size(); + + compare(expectedOutputs, actualOutputs); + } + + void generate_inputs(const std::vector& targetInputStaticShapes) override { + inputs.clear(); + const auto& funcInputs = function->inputs(); + for (size_t i = 0; i < funcInputs.size(); ++i) { + const auto& funcInput = funcInputs[i]; + ov::Tensor tensor; + + if (i == 1) { + tensor = ov::Tensor(funcInput.get_element_type(), targetInputStaticShapes[i]); + auto* dataPtr = tensor.data(); + for (size_t i = 0; i < pooledVector.size(); i++) { + // ngraph shape infer for adaptive pooling has seg fault when i32 type of second input + dataPtr[i] = static_cast(pooledVector[i]); + } + } else { + ov::test::utils::InputGenerateData in_data; + in_data.start_from = 0; + in_data.range = 2560; + in_data.resolution = 256; + tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i], in_data); + } + inputs.insert({funcInput.get_node_shared_ptr(), tensor}); + } + } + +private: + std::vector pooledVector; + std::string mode; +}; + +TEST_P(AdaPoolLayerGPUTest, Inference) { + run(); +} + +const std::vector netPrecisions = {ov::element::f32, ov::element::f16}; + +const std::vector> pooled3DVector = {{1}, {3}, {5}}; +const std::vector> pooled4DVector = {{1, 1}, {3, 5}, {5, 5}}; + +const std::vector> pooled5DVector = { + {1, 1, 1}, + {3, 5, 1}, + {3, 5, 3}, +}; + +std::vector> staticInput3DShapeVector = {{{1, 17, 3}, {3, 7, 5}}}; + +const std::vector> input3DShapeVector = { + {{{{-1, 17, -1}, {{1, 17, 3}, {3, 17, 5}, {3, 17, 5}}}}, + {{{{1, 10}, 20, {1, 10}}, {{1, 20, 5}, {2, 20, 4}, {3, 20, 6}}}}}}; + +std::vector> staticInput4DShapeVector = {{{1, 3, 1, 1}, {3, 17, 5, 2}}}; + +const std::vector> input4DShapeVector = { + {{{{-1, 3, -1, -1}, {{1, 3, 1, 1}, {3, 3, 5, 2}, {3, 3, 5, 2}}}}, + {{{{1, 10}, 3, {1, 10}, {1, 10}}, {{2, 3, 10, 6}, {3, 3, 6, 5}, {3, 3, 6, 5}}}}}}; + +std::vector> staticInput5DShapeVector = {{{1, 17, 2, 5, 2}, {3, 17, 4, 5, 4}}}; + +const std::vector> input5DShapeVector = { + {{{{-1, 17, -1, -1, -1}, {{1, 17, 2, 5, 2}, {3, 17, 4, 5, 4}, {3, 17, 4, 5, 4}}}}, + {{{{1, 10}, 3, {1, 10}, {1, 10}, {1, 10}}, {{3, 3, 2, 5, 2}, {1, 3, 4, 5, 4}, {1, 3, 4, 5, 4}}}}}}; + +const auto adaPool3DParams = ::testing::Combine(::testing::ValuesIn(pooled3DVector), // output spatial shape + ::testing::ValuesIn(input3DShapeVector) // feature map shape +); + +const auto adaPool4DParams = ::testing::Combine(::testing::ValuesIn(pooled4DVector), // output spatial shape + ::testing::ValuesIn(input4DShapeVector) // feature map shape +); + +const auto adaPool5DParams = ::testing::Combine(::testing::ValuesIn(pooled5DVector), // output spatial shape + ::testing::ValuesIn(input5DShapeVector) // feature map shape +); + +INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolAvg3DLayoutTest, AdaPoolLayerGPUTest, + ::testing::Combine( + adaPool3DParams, + ::testing::Values("avg"), + ::testing::Values(false), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_GPU)), + AdaPoolLayerGPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolAvg4DLayoutTest, AdaPoolLayerGPUTest, + ::testing::Combine( + adaPool4DParams, + ::testing::Values("avg"), + ::testing::Values(false), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_GPU)), + AdaPoolLayerGPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolAvg5DLayoutTest, AdaPoolLayerGPUTest, + ::testing::Combine( + adaPool5DParams, + ::testing::Values("avg"), + ::testing::Values(false), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_GPU)), + AdaPoolLayerGPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolMax3DLayoutTest, AdaPoolLayerGPUTest, + ::testing::Combine( + adaPool3DParams, + ::testing::Values("max"), + ::testing::Values(false), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_GPU)), + AdaPoolLayerGPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolMax4DLayoutTest, AdaPoolLayerGPUTest, + ::testing::Combine( + adaPool4DParams, + ::testing::Values("max"), + ::testing::Values(false), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_GPU)), + AdaPoolLayerGPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolMax5DLayoutTest, AdaPoolLayerGPUTest, + ::testing::Combine( + adaPool5DParams, + ::testing::Values("max"), + ::testing::Values(false), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_GPU)), + AdaPoolLayerGPUTest::getTestCaseName); + +const auto staticAdaPool3DParams = ::testing::Combine( + ::testing::ValuesIn(pooled3DVector), // output spatial shape + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(staticInput3DShapeVector)) // feature map shape +); + +const auto staticAdaPool4DParams = ::testing::Combine( + ::testing::ValuesIn(pooled4DVector), // output spatial shape + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(staticInput4DShapeVector)) // feature map shape +); + +const auto staticAdaPool5DParams = ::testing::Combine( + ::testing::ValuesIn(pooled5DVector), // output spatial shape + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(staticInput5DShapeVector)) // feature map shape +); + +INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_StaticAdaPoolAvg3DLayoutTest, AdaPoolLayerGPUTest, + ::testing::Combine(staticAdaPool3DParams, + ::testing::Values("avg"), + ::testing::Values(true), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_GPU)), + AdaPoolLayerGPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_StaticAdaPoolAvg4DLayoutTest, AdaPoolLayerGPUTest, + ::testing::Combine(staticAdaPool4DParams, + ::testing::Values("avg"), + ::testing::Values(true), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_GPU)), + AdaPoolLayerGPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_StaticAdaPoolAvg5DLayoutTest, AdaPoolLayerGPUTest, + ::testing::Combine(staticAdaPool5DParams, + ::testing::Values("avg"), + ::testing::Values(true), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_GPU)), + AdaPoolLayerGPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_StaticAdaPoolMax3DLayoutTest, AdaPoolLayerGPUTest, + ::testing::Combine(staticAdaPool3DParams, + ::testing::Values("max"), + ::testing::Values(true), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_GPU)), + AdaPoolLayerGPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_StaticAdaPoolMax4DLayoutTest, AdaPoolLayerGPUTest, + ::testing::Combine(staticAdaPool4DParams, + ::testing::Values("max"), + ::testing::Values(true), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_GPU)), + AdaPoolLayerGPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_StaticAdaPoolMax5DLayoutTest, AdaPoolLayerGPUTest, + ::testing::Combine(staticAdaPool5DParams, + ::testing::Values("max"), + ::testing::Values(true), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_GPU)), + AdaPoolLayerGPUTest::getTestCaseName); +} // namespace diff --git a/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/ctc_greedy_decoder_seq_len.cpp b/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/ctc_greedy_decoder_seq_len.cpp index 1e164c42fda131..213464a594c795 100644 --- a/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/ctc_greedy_decoder_seq_len.cpp +++ b/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/ctc_greedy_decoder_seq_len.cpp @@ -14,7 +14,6 @@ #include "common_test_utils/test_constants.hpp" #include "common_test_utils/ov_tensor_utils.hpp" -using namespace InferenceEngine; using namespace ov::test; namespace GPULayerTestsDefinitions { diff --git a/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/grid_sample.cpp b/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/grid_sample.cpp index 8c432154f730b3..6b0251cb21c4aa 100644 --- a/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/grid_sample.cpp +++ b/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/grid_sample.cpp @@ -99,7 +99,7 @@ class GridSampleLayerTestGPU : public testing::WithParamInterfaceget_friendly_name() == "data") { diff --git a/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/non_max_suppression.cpp b/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/non_max_suppression.cpp index ffda0040d446e4..1937b18bc73460 100644 --- a/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/non_max_suppression.cpp +++ b/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/non_max_suppression.cpp @@ -103,7 +103,7 @@ class NmsLayerGPUTest : public testing::WithParamInterface, auto node = funcInputs[2].get_node_shared_ptr(); auto it = inputs.find(node); if (it == inputs.end()) return; - auto tensor = ov::runtime::Tensor(node->get_element_type(), targetInputStaticShapes[2], &maxOutBoxesPerClass); + auto tensor = ov::Tensor(node->get_element_type(), targetInputStaticShapes[2], &maxOutBoxesPerClass); inputs[node] = tensor; } diff --git a/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/dynamic_smoke_test_with_empty_tensor.cpp b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/dynamic_smoke_test_with_empty_tensor.cpp index 88ceb3ea6db14b..d9407640327cb8 100644 --- a/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/dynamic_smoke_test_with_empty_tensor.cpp +++ b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/dynamic_smoke_test_with_empty_tensor.cpp @@ -54,7 +54,7 @@ class EmptyTensorDynamicGPUTest : public testing::WithParamInterfaceinputs(); for (size_t i = 0; i < funcInputs.size(); ++i) { auto node = funcInputs[i].get_node_shared_ptr(); - auto tensor = ov::runtime::Tensor(node->get_element_type(), targetInputStaticShapes[i]); + auto tensor = ov::Tensor(node->get_element_type(), targetInputStaticShapes[i]); if (i == 0) { // All zero inputs for non_zero op auto tensor_ptr = static_cast(tensor.data()); diff --git a/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/kv_cache.cpp b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/kv_cache.cpp index 599f247210d44c..59da844cab2856 100644 --- a/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/kv_cache.cpp +++ b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/kv_cache.cpp @@ -255,7 +255,8 @@ class KVCacheTests: public ::testing::Test { bool fuse_cache_reorder, bool build_state_initializer, size_t batch = 1, - ov::element::Type model_element_type = ov::element::f16) { + ov::element::Type model_element_type = ov::element::f16, + size_t num_iter = 10) { #if defined(ANDROID) GTEST_SKIP(); #endif @@ -411,10 +412,9 @@ class KVCacheTests: public ::testing::Test { } const size_t input_tokens = 1; - const size_t niters = 10; const ov::Shape new_token_size = {batch, input_tokens, n_heads, n_features}; size_t context_length = cache_size + input_tokens; - for (size_t i = 0; i < niters; i++, context_length += input_tokens) { + for (size_t i = 0; i < num_iter; i++, context_length += input_tokens) { ov::Shape matmul_in_size_loop = {batch, n_heads, input_tokens, context_length}; auto new_token_data = ov::test::utils::create_and_fill_tensor(element_type, new_token_size); auto matmul_data = ov::test::utils::create_and_fill_tensor(element_type, matmul_in_size_loop); @@ -477,8 +477,13 @@ TEST_F(KVCacheTests, smoke_multipleIterations_stateful_gather_with_initializer_c TEST_F(KVCacheTests, smoke_multipleIterations_stateful_gather_with_initializer_f32) { this->test_smoke_multipleIterations_stateful(false, true, true, 1, ov::element::f32); } + TEST_F(KVCacheTests, smoke_multipleIterations_stateful_gather_with_initializer_batch_3) { this->test_smoke_multipleIterations_stateful(false, true, true, 3); } +TEST_F(KVCacheTests, smoke_multipleIterations_stateful_same_shape_after_reset) { + this->test_smoke_multipleIterations_stateful(false, false, false, 1, ov::element::f16, 0); +} + } // namespace diff --git a/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/swiglu_fusion.cpp b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/swiglu_fusion.cpp new file mode 100644 index 00000000000000..3b209010fe7961 --- /dev/null +++ b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/swiglu_fusion.cpp @@ -0,0 +1,123 @@ +// Copyright (C) 2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "common_test_utils/ov_tensor_utils.hpp" +#include "common_test_utils/file_utils.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" + +#include "openvino/op/parameter.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/multiply.hpp" +#include "openvino/op/swish.hpp" +#include "openvino/op/variadic_split.hpp" + +namespace { +using ov::test::InputShape; + +using SwiGLUFusionParams = std::tuple, // input shapes + ov::element::Type>; // input precision + +class SwiGLUFusion : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseTest { +public: + static std::string getTestCaseName(testing::TestParamInfo obj) { + std::vector input_shapes; + ov::element::Type input_precision; + + std::tie(input_shapes, input_precision) = obj.param; + + std::ostringstream result; + result << "IS=("; + for (const auto& shape : input_shapes) { + result << ov::test::utils::partialShape2str({shape.first}) << "_"; + } + result << ")_TS="; + for (const auto& shape : input_shapes) { + result << "("; + if (!shape.second.empty()) { + auto itr = shape.second.begin(); + do { + result << ov::test::utils::vec2str(*itr); + } while (++itr != shape.second.end() && result << "_"); + } + result << ")_"; + } + result << "input_precision=" << input_precision; + return result.str(); + } + +protected: + std::shared_ptr init_subgraph(std::vector& input_shapes, + const ov::Shape& target_shape, + const ov::element::Type input_precision) { + ov::ParameterVector params{std::make_shared(input_precision, input_shapes[0])}; + + // VariadicSplit(X, axis, split_lengths) = Xw, Xv + auto axis_const = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {-1}); + auto split_lengths_const = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{2}, {48, -1}); + auto variadic_split = std::make_shared(params[0], axis_const, split_lengths_const); + + // Swish(Xw) = Xw * (1.0 + exp(-beta * Xw)) + auto swish = std::make_shared(variadic_split->output(0)); + + // Mul(Xw, Xv) = Swish(Xw) * Xv + auto mul = std::make_shared(swish, variadic_split->output(1)); + + return std::make_shared(ov::NodeVector{mul}, params, "SwiGLUFusion"); + } + + void SetUp() override { + targetDevice = ov::test::utils::DEVICE_GPU; + + std::vector input_shapes; + ov::element::Type input_precision; + + std::tie(input_shapes, input_precision) = GetParam(); + + init_input_shapes(input_shapes); + + inType = outType = input_precision; + + function = init_subgraph(inputDynamicShapes, targetStaticShapes.front().front(), input_precision); + } +}; + +TEST_P(SwiGLUFusion, Inference) { + run(); +} + +TEST_P(SwiGLUFusion, Inference_cached) { + std::stringstream ss; + ss << "gpu_model_cache_" << std::hash{}( + std::string(::testing::UnitTest::GetInstance()->current_test_info()->test_suite_name()) + + std::string(::testing::UnitTest::GetInstance()->current_test_info()->name())); + std::string cacheDirName = ss.str(); + { + ov::test::utils::removeFilesWithExt(cacheDirName, "blob"); + ov::test::utils::removeFilesWithExt(cacheDirName, "cl_cache"); + ov::test::utils::removeDir(cacheDirName); + core->set_property(ov::cache_dir(cacheDirName)); + compile_model(); + } + { + run(); + ov::test::utils::removeFilesWithExt(cacheDirName, "blob"); + ov::test::utils::removeFilesWithExt(cacheDirName, "cl_cache"); + ov::test::utils::removeDir(cacheDirName); + } +} + +const std::vector input_precisions = {ov::element::f32, ov::element::f16}; + +const std::vector> input_shapes_dyn = { + {{{-1, -1, 96}, {{20, 1, 96}}}}, + {{{-1, -1, -1}, {{1, 1, 96}}}}, +}; + +INSTANTIATE_TEST_SUITE_P(smoke_SwiGLUFusion_basic, + SwiGLUFusion, + ::testing::Combine(::testing::ValuesIn(input_shapes_dyn), + ::testing::ValuesIn(input_precisions)), + SwiGLUFusion::getTestCaseName); +} // namespace diff --git a/src/plugins/intel_gpu/tests/unit/fusions/eltwise_fusion_test.cpp b/src/plugins/intel_gpu/tests/unit/fusions/eltwise_fusion_test.cpp index 5f75f4e424b857..b79242f981e402 100644 --- a/src/plugins/intel_gpu/tests/unit/fusions/eltwise_fusion_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/fusions/eltwise_fusion_test.cpp @@ -588,3 +588,65 @@ INSTANTIATE_TEST_SUITE_P(fusings_gpu, eltwise_activation, ::testing::ValuesIn(st eltwise_test_params{ CASE_ELTWISE_FP16_FP32_2, 3, 4 }, eltwise_test_params{ CASE_ELTWISE_FP16_FP32_3, 3, 4 } })); + + +class eltwise_quantize_fs_b_yx_fsv32 : public EltwiseFusingTest {}; +TEST_P(eltwise_quantize_fs_b_yx_fsv32, fusing_eltwise_quantize_layout) { + auto p = GetParam(); + create_topologies( + input_layout("input", get_input_layout(p)), + input_layout("input2", get_input_layout2(p)), + data("in_lo", get_mem(get_per_channel_layout(p), min_random, 0)), + data("in_hi", get_mem(get_per_channel_layout(p), 1, max_random)), + data("out_lo", get_mem(get_single_element_layout(p), -128)), + data("out_hi", get_mem(get_single_element_layout(p), 127)), + eltwise("eltwise", { input_info("input"), input_info("input2") }, p.mode, p.default_type), + quantize("quantize", input_info("eltwise"), input_info("in_lo"), input_info("in_hi"), + input_info("out_lo"), input_info("out_hi"), 256, p.input_type), + reorder("out", input_info("quantize"), format::bfyx, data_types::f32) + ); + + tolerance = default_tolerance(data_types::i8); + execute(p); +} + +#define CASE_ELTWISE_FP16_FS_B_YX { 1, 32, 4, 4 }, data_types::f16, data_types::f16, format::fs_b_yx_fsv32, data_types::f16, format::fs_b_yx_fsv32, eltwise_mode::sum +#define CASE_ELTWISE_FP16_BATCH_FS_B { 8, 32, 4, 4 }, data_types::f16, data_types::f16, format::fs_b_yx_fsv32, data_types::f16, format::fs_b_yx_fsv32, eltwise_mode::sum +#define CASE_ELTWISE_FP16_B_FS_YX { 1, 32, 4, 4 }, data_types::f16, data_types::f16, format::b_fs_yx_fsv16, data_types::f16, format::b_fs_yx_fsv16, eltwise_mode::sum +#define CASE_ELTWISE_FP16_BATCH_B_FS { 8, 32, 4, 4 }, data_types::f16, data_types::f16, format::b_fs_yx_fsv16, data_types::f16, format::b_fs_yx_fsv16, eltwise_mode::sum + +INSTANTIATE_TEST_SUITE_P(fusings_gpu, eltwise_quantize_fs_b_yx_fsv32, ::testing::ValuesIn(std::vector{ + eltwise_test_params{ CASE_ELTWISE_FP16_FS_B_YX, 3, 4 }, + eltwise_test_params{ CASE_ELTWISE_FP16_B_FS_YX, 3, 4 }, + eltwise_test_params{ CASE_ELTWISE_FP16_BATCH_FS_B, 4, 4 }, + eltwise_test_params{ CASE_ELTWISE_FP16_BATCH_B_FS, 3, 4 }, +})); + +class eltwise_quantize_fs_b_yx_fsv32_exception : public EltwiseFusingTest {}; +TEST_P(eltwise_quantize_fs_b_yx_fsv32_exception, fusing_eltwise_quantize_layout_exception) { + auto p = GetParam(); + create_topologies( + input_layout("input", get_input_layout(p)), + input_layout("input2", get_input_layout2(p)), + data("in_lo", get_mem(get_per_channel_layout(p), min_random, 0)), + data("in_hi", get_mem(get_per_channel_layout(p), 1, max_random)), + data("out_lo", get_mem(get_single_element_layout(p), -128)), + data("out_hi", get_mem(get_single_element_layout(p), 127)), + eltwise("eltwise", { input_info("input"), input_info("input2") }, p.mode, p.default_type), + quantize("quantize", input_info("eltwise"), input_info("in_lo"), input_info("in_hi"), + input_info("out_lo"), input_info("out_hi"), 256, p.input_type), + activation("activation", input_info("eltwise"), activation_func::negative), + eltwise("eltwise_second", { input_info("quantize"), input_info("activation") }, p.mode, p.default_type), + reorder("out", input_info("eltwise_second"), format::bfyx, data_types::f32) + ); + + tolerance = default_tolerance(data_types::i8); + execute(p); +} + +INSTANTIATE_TEST_SUITE_P(fusings_gpu, eltwise_quantize_fs_b_yx_fsv32_exception, ::testing::ValuesIn(std::vector{ + eltwise_test_params{ CASE_ELTWISE_FP16_FS_B_YX, 6, 6 }, + eltwise_test_params{ CASE_ELTWISE_FP16_B_FS_YX, 6, 6 }, + eltwise_test_params{ CASE_ELTWISE_FP16_BATCH_FS_B, 6, 6 }, + eltwise_test_params{ CASE_ELTWISE_FP16_BATCH_B_FS, 6, 6 }, +})); \ No newline at end of file diff --git a/src/plugins/intel_gpu/tests/unit/fusions/gemm_fusion_test.cpp b/src/plugins/intel_gpu/tests/unit/fusions/gemm_fusion_test.cpp index 68d444094f331b..6780b65f67c3be 100644 --- a/src/plugins/intel_gpu/tests/unit/fusions/gemm_fusion_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/fusions/gemm_fusion_test.cpp @@ -118,6 +118,7 @@ class GemmFusingTest : public ::BaseFusingTest { #define CASE_GEMM_2IN_FP16_3 { { 1, 1, 64, 64 }, { 1, 1, 64, 64 } }, { 1, 1, 64, 64 }, data_types::f16, data_types::f16, data_types::f16, format::bfyx, data_types::f16, format::bfyx #define CASE_GEMM_2IN_FP16_4 { { 1, 2, 128, 64 }, { 1, 2, 64, 256 } }, { 1, 2, 128, 256 }, data_types::f16, data_types::f16, data_types::f16, format::bfyx, data_types::f16, format::bfyx #define CASE_GEMM_2IN_FP16_5 { { 2, 3, 2, 2 }, { 2, 3, 2, 2 } }, { 2, 3, 2, 2 }, data_types::f16, data_types::f16, data_types::f16, format::bfyx, data_types::f16, format::bfyx +#define CASE_GEMM_2IN_FP16_3D_1 { { 16, 8, 64 }, { 16, 64, 8 }, { 16, 1, 8 } }, { 16, 8, 8 }, data_types::f16, data_types::f16, data_types::f16, format::bfyx, data_types::f16, format::bfyx #define CASE_GEMM_2IN_FP16_5D_1 { { 2, 3, 5, 6, 4 }, { 2, 3, 5, 4, 6} }, { 2, 3, 5, 6, 6 }, data_types::f16, data_types::f16, data_types::f16, format::bfzyx, data_types::f16, format::bfzyx #define CASE_GEMM_2IN_FP16_6D_1 { { 2, 3, 2, 3, 5, 7 }, { 2, 3, 2, 3, 7, 5 } }, { 2, 3, 2, 3, 5, 5 }, data_types::f16, data_types::f16, data_types::f16, format::bfwzyx, data_types::f16, format::bfwzyx @@ -406,6 +407,53 @@ INSTANTIATE_TEST_SUITE_P(fusings_gpu, gemm_2in_add, ::testing::ValuesIn(std::vec gemm_test_params{ CASE_GEMM_2IN_FP16_6D_1, 3, 4, "", broadcast_kinds::feature, eltwise_mode::sub }, })); +class gemm_2in_dynamic_add : public gemm_2in_add {}; +TEST_P(gemm_2in_dynamic_add, add) { + auto p = GetParam(); + + if (engine.get_device_info().supports_immad) + p.expected_fused_primitives++; + + cfg_fused.set_property(ov::intel_gpu::allow_new_shape_infer(true)); + cfg_not_fused.set_property(ov::intel_gpu::allow_new_shape_infer(true)); + + auto eltwise_layout = get_output_layout(p); + auto eltwise_shape = ov::PartialShape::dynamic(eltwise_layout.get_partial_shape().size()); + if (p.broadcast_kind == broadcast_kinds::batch) + eltwise_shape[0] = 1; + else if (p.broadcast_kind == broadcast_kinds::feature) + eltwise_shape[1] = 1; + eltwise_layout.set_partial_shape(eltwise_shape); + + auto in_layout0 = get_input_layout(p, 0); + auto in_layout1 = get_input_layout(p, 1); + + auto in0_pshape = ov::PartialShape::dynamic(p.in_shapes[0].size()); + in0_pshape[2] = p.in_shapes[0][2]; + auto in1_pshape = ov::PartialShape::dynamic(p.in_shapes[1].size()); + in1_pshape[1] = p.in_shapes[1][1]; + + in_layout0.set_partial_shape(in0_pshape); + in_layout1.set_partial_shape(in1_pshape); + + create_topologies( + input_layout("input0", in_layout0), + input_layout("input1", in_layout1), + input_layout("input2", eltwise_layout), + gemm("gemm_prim", { input_info("input0"), input_info("input1") }, data_types::f32, false, false, 1.f, 0.f, in0_pshape.size(), in1_pshape.size()), + eltwise("add_prim", { input_info("gemm_prim"), input_info("input2") }, p.eltwise_m, p.default_type), + reorder("reorder_bfyx", input_info("add_prim"), p.default_format, data_types::f32) + ); + + tolerance = default_tolerance(p.default_type); + execute(p, true); +} + +INSTANTIATE_TEST_SUITE_P(fusings_gpu, gemm_2in_dynamic_add, ::testing::ValuesIn(std::vector{ + gemm_test_params{ CASE_GEMM_2IN_FP16_3D_1, 4, 5, "", broadcast_kinds::batch, eltwise_mode::sum }, + gemm_test_params{ CASE_GEMM_2IN_FP16_3D_1, 4, 5, "", broadcast_kinds::feature, eltwise_mode::sum }, +})); + class gemm_2in_act_scale_quantize_i8 : public GemmFusingTest {}; TEST_P(gemm_2in_act_scale_quantize_i8, basic) { // TODO: Fix me, refer PR(#15873) diff --git a/src/plugins/intel_gpu/tests/unit/passes/kernels_cache_test.cpp b/src/plugins/intel_gpu/tests/unit/passes/kernels_cache_test.cpp index bbdb553d6098a8..66788a16f149bf 100644 --- a/src/plugins/intel_gpu/tests/unit/passes/kernels_cache_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/passes/kernels_cache_test.cpp @@ -94,8 +94,7 @@ TEST(kernels_cache, reuse_kernel_for_static_model_01) { TEST(kernels_cache, sub_kernel_ordering_test) { auto& engine = get_test_engine(); ExecutionConfig config = get_test_default_config(engine); - ov::threading::IStreamsExecutor::Config task_executor_config("sub_kernel_ordering_test", 1); - task_executor_config._streams = 2; + ov::threading::IStreamsExecutor::Config task_executor_config("sub_kernel_ordering_test", 2); auto executor = std::make_shared(task_executor_config); const size_t num_kernels = 9; auto _kernels_cache = std::unique_ptr(new kernels_cache(engine, config, 0, executor)); diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/fully_connected_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/fully_connected_gpu_test.cpp index 3962a9f1f6ec16..4c3d741a499bf4 100644 --- a/src/plugins/intel_gpu/tests/unit/test_cases/fully_connected_gpu_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/test_cases/fully_connected_gpu_test.cpp @@ -1131,6 +1131,75 @@ class fully_connected_gpu_tests: public ::testing::Test { ASSERT_NEAR(output_ptr_ref[i], output_ptr[i], 5.0) << "i = " << i; } + void test_compressed_int8_scale_zp_bias(bool is_caching_test) { + auto& engine = get_test_engine(); + + auto input_mem = engine.allocate_memory({ {1, 1, 2}, data_types::f16, format::bfyx }); + auto weights_mem = engine.allocate_memory({ {32, 2}, data_types::u8, format::bfyx }); + auto bias_mem = engine.allocate_memory({ {1, 1, 32}, data_types::f16, format::bfyx }); + auto scale_mem = engine.allocate_memory({ {32, 1}, data_types::f32, format::bfyx }); + auto zp_mem = engine.allocate_memory({ {32, 1}, data_types::f32, format::bfyx }); + + set_values(input_mem, { -0.5f, 2.0f, 0.5f, 1.0f }); + set_values(weights_mem, { 1, 2, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 0, + 15, 14, 13, 12, 11, 10, 9, 8, + 7, 6, 5, 4, 3, 2, 1, 0, + 1, 2, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 0, + 15, 14, 13, 12, 11, 10, 9, 8, + 7, 6, 5, 4, 3, 2, 1, 0 }); + + set_values(bias_mem, { 1.0f, -2.0f, 3.0f, -4.0f, 5.0f, -6.0f, 7.0f, 2.0f, + 2.0f, -1.0f, 4.0f, -3.0f, 6.0f, -5.0f, 8.0f, 3.0f, + 0.0f, -3.0f, 2.0f, -5.0f, 4.0f, -5.0f, 6.0f, 1.0f, + 1.0f, -2.0f, 3.0f, -4.0f, 5.0f, -6.0f, 7.0f, 2.0f }); + set_values(scale_mem, { 2.0f, 4.0f, -2.0f, -4.0f, 0.5f, -0.5f, 2.0f, 2.0f, + 3.0f, 5.0f, -1.0f, -3.0f, 1.5f, 0.5f, 3.0f, 3.0f, + 1.0f, 5.0f, -1.0f, -3.0f, -0.5f, -1.5f, 1.0f, 1.0f, + 2.0f, 4.0f, -2.0f, -4.0f, 0.5f, -0.5f, 2.0f, 2.0f }); + set_values(zp_mem, { 1.0f, 2.0f, 2.0f, 1.0f, 4.0f, 1.0f, 6.0f, 2.0f, + 2.0f, 3.0f, 1.0f, 0.0f, 3.0f, 1.0f, 2.0f, 2.0f, + 1.0f, 2.0f, 2.0f, 1.0f, 1.0f, 1.0f, 6.0f, 1.0f, + 1.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 5.0f, 2.0f }); + + topology topology( + input_layout("input", input_mem->get_layout()), + data("weights", weights_mem), + data("bias", bias_mem), + data("scale", scale_mem), + data("zp", zp_mem), + fully_connected("fc_prim", input_info("input"), "weights", "bias", "scale", "zp", data_types::f16, padding(), 3, 2) + ); + + auto config = get_test_default_config(engine); + config.set_property(ov::intel_gpu::allow_new_shape_infer(true)); + config.set_property(ov::intel_gpu::optimize_data(true)); + + network::ptr network = get_network(engine, topology, config, get_test_stream_ptr(), is_caching_test); + network->set_input_data("input", input_mem); + + auto outputs = network->execute(); + ASSERT_EQ(outputs.size(), size_t(1)); + ASSERT_EQ(outputs.begin()->first, "fc_prim"); + + auto output_mem = outputs.begin()->second.get_memory(); + + cldnn::mem_lock output_ptr(output_mem, get_test_stream()); + + ov::PartialShape expected_shape{1, 1, 32}; + ASSERT_EQ(expected_shape, output_mem->get_layout().get_partial_shape()); + + std::vector expected_result = { 5.f, 12.f, -10.f, -48.f, 9.75f, -14.5f, 32.f, -19.f, + 54.5f, 64.f, -9.f, -37.5f, 12.f, -3.f, 6.5f, -7.5f, + 2.f, 14.5f, -4.5f, -38.f, -3.f, -30.5f, 18.5f, -8.f, + 39.f, 62.f, -20.f, -32.f, 6.25f, -8.f, -3.f, -5.f, }; + + for (size_t i = 0; i < output_ptr.size(); i++) { + ASSERT_EQ(expected_result[i], output_ptr[i]) << "i = " << i; + } + } + void test_compressed_scale_bias(bool is_caching_test) { auto& engine = get_test_engine(); @@ -1229,7 +1298,7 @@ class fully_connected_gpu_tests: public ::testing::Test { ov::PartialShape expected_shape{2, 8}; ASSERT_EQ(expected_shape, output_mem->get_layout().get_partial_shape()); - std::vector expected_result = { + std::vector expected_result = { ov::float16(18), ov::float16(84), ov::float16(-66), ov::float16(-116), ov::float16(19.5), ov::float16(-13.5), ov::float16(30), ov::float16(6), ov::float16(-18), ov::float16(-84), ov::float16(66), ov::float16(116), ov::float16(-19.5), ov::float16(13.5), ov::float16(-30), ov::float16(-6) }; @@ -2679,6 +2748,10 @@ TEST_F(fully_connected_gpu_tests, compressed_scale_bias) { this->test_compressed_scale_bias(false); } +TEST_F(fully_connected_gpu_tests, compressed_int8_scale_zp_bias) { + this->test_compressed_int8_scale_zp_bias(false); +} + TEST_F(fully_connected_gpu_tests, compressed_scale_bias_cached) { this->test_compressed_scale_bias(true); } diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/multiple_streams_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/multiple_streams_gpu_test.cpp index 7717fa2b925b64..2fb0a6518dd941 100644 --- a/src/plugins/intel_gpu/tests/unit/test_cases/multiple_streams_gpu_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/test_cases/multiple_streams_gpu_test.cpp @@ -21,8 +21,7 @@ using namespace ::tests; TEST(multistream_gpu, basic) { const int num_streams = 2; - auto task_config = ov::threading::IStreamsExecutor::Config(); - task_config._streams = num_streams; + auto task_config = ov::threading::IStreamsExecutor::Config{"gpu_test", num_streams}; auto task_executor = std::make_shared(task_config); auto& engine = get_test_engine(); diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/swiglu_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/swiglu_gpu_test.cpp new file mode 100644 index 00000000000000..c2ac561127046a --- /dev/null +++ b/src/plugins/intel_gpu/tests/unit/test_cases/swiglu_gpu_test.cpp @@ -0,0 +1,91 @@ +// Copyright (C) 2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "test_utils.h" + +#include +#include +#include +#include "swiglu_inst.h" + +using namespace cldnn; +using namespace ::tests; + +class swiglu_gpu_test : public ::testing::TestWithParam {}; + +template +void swiglu_ref(const memory::ptr input, memory::ptr output, int32_t split_length) { + auto input_layout = input->get_layout(); + auto output_layout = output->get_layout(); + + uint32_t batch_size = output_layout.batch(); + uint32_t feature_size = output_layout.feature(); + uint32_t y_size = output_layout.spatial(1); + uint32_t x_size = output_layout.spatial(0); + + cldnn::mem_lock src(input, get_test_stream()); + cldnn::mem_lock dst(output, get_test_stream()); + + T res; + for (uint32_t b = 0; b < batch_size; ++b) { + for (uint32_t f = 0; f < feature_size; ++f) { + for (uint32_t y = 0; y < y_size; ++y) { + for (uint32_t x = 0; x < x_size; ++x) { + auto tensor_src = tensor(batch(b), feature(f), spatial(x, y, 0, 0)); + auto tensor_dst = tensor(batch(b), feature(f), spatial(x, y, 0, 0)); + size_t src_offset = input_layout.get_linear_offset(tensor_src); + size_t dst_offset = output_layout.get_linear_offset(tensor_dst); + res = src[src_offset]; + res = (res / (static_cast(1) + (std::exp((-(static_cast(1) * res)))))); + res *= src[src_offset + static_cast(split_length)]; + dst[dst_offset] = res; + } + } + } + } +} + +TEST(swiglu_gpu_test, swiglu_test_bfyx_dyn) { + auto& engine = get_test_engine(); + + auto input_layout_dynamic = layout{ov::PartialShape{ov::Dimension::dynamic(), ov::Dimension::dynamic(), 6}, + data_types::f32, format::bfyx}; + auto input_mem = engine.allocate_memory({ov::PartialShape{2, 1, 6}, data_types::f32, format::bfyx}); + auto output_ref = engine.allocate_memory({ov::PartialShape{2, 1, 3}, data_types::f32, format::bfyx}); + + set_values(input_mem, { + 0.049011f, 0.000260f, -0.176636f, 0.016098f, 0.279297f, 0.036377f, + -0.127686f, 0.066650f, -0.394043f, -0.135620f, 0.040985f, -0.011589f + }); + + swiglu_ref(input_mem, output_ref, 3); + + topology topology; + topology.add(input_layout("input", input_layout_dynamic)); + topology.add(swiglu("swiglu", input_info("input"), -1, 3, tensor())); + + ExecutionConfig config = get_test_default_config(engine); + config.set_property(ov::intel_gpu::allow_new_shape_infer(true)); + + network network(engine, topology, config); + + network.set_input_data("input", input_mem); + + auto inst = network.get_primitive("swiglu"); + auto impl = inst->get_impl(); + ASSERT_TRUE(impl != nullptr); + ASSERT_TRUE(impl->is_dynamic()); + + auto outputs = network.execute(); + ASSERT_EQ(outputs.size(), size_t(1)); + ASSERT_EQ(outputs.begin()->first, "swiglu"); + + auto output = outputs.begin()->second.get_memory(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + cldnn::mem_lock output_ref_ptr(output_ref, get_test_stream()); + + for (unsigned int i = 0; i < output_ref->count(); ++i) { + EXPECT_NEAR(output_ptr[i], output_ref_ptr[i], 1e-3); + } +} diff --git a/src/plugins/intel_gpu/tests/unit/transformations/swiglu_fusion_test.cpp b/src/plugins/intel_gpu/tests/unit/transformations/swiglu_fusion_test.cpp new file mode 100644 index 00000000000000..6b87a791bdf1e3 --- /dev/null +++ b/src/plugins/intel_gpu/tests/unit/transformations/swiglu_fusion_test.cpp @@ -0,0 +1,97 @@ +// Copyright (C) 2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include +#include + +#include +#include +#include "common_test_utils/ov_test_utils.hpp" +#include + +#include + +#include "openvino/op/constant.hpp" +#include "openvino/op/multiply.hpp" +#include "openvino/op/parameter.hpp" +#include "openvino/op/swish.hpp" +#include "openvino/op/variadic_split.hpp" +#include "intel_gpu/op/swiglu.hpp" + +using namespace testing; +using namespace ov::intel_gpu; + +TEST_F(TransformationTestsF, SwiGLUFusionTest1) { + { + auto input = std::make_shared(ov::element::f16, ov::PartialShape{ 2, 1, 6 }); + auto axis_const = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {-1}); + auto split_lengths_const = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{2}, {3, -1}); + auto variadic_split = std::make_shared(input, axis_const, split_lengths_const); + auto swish = std::make_shared(variadic_split->output(0)); + auto mul = std::make_shared(swish, variadic_split->output(1)); + + model = std::make_shared(ov::NodeVector{mul}, ov::ParameterVector{input}); + manager.register_pass(); + } + { + int64_t axis = -1; + int64_t split_lenghts = 3; + auto input = std::make_shared(ov::element::f16, ov::PartialShape{ 2, 1, 6 });; + auto swiglu = std::make_shared(input, axis, split_lenghts, ov::element::f16); + + model_ref = std::make_shared(ov::NodeVector{swiglu}, ov::ParameterVector{input}); + } +} + +TEST_F(TransformationTestsF, SwiGLUFusionTest2) { + { + auto input = std::make_shared(ov::element::f16, ov::PartialShape{ -1, -1, 6 }); + auto axis_const = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {0}); + auto split_lengths_const = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{2}, {3, 3}); + auto variadic_split = std::make_shared(input, axis_const, split_lengths_const); + auto swish = std::make_shared(variadic_split->output(0)); + auto mul = std::make_shared(swish, variadic_split->output(1)); + + model = std::make_shared(ov::NodeVector{mul}, ov::ParameterVector{input}); + manager.register_pass(); + } +} + +TEST_F(TransformationTestsF, SwiGLUFusionTest3) { + { + auto input = std::make_shared(ov::element::f16, ov::PartialShape{ -1, -1, 6 }); + auto axis_const = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {-1}); + auto split_lengths_const = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{2}, {3, -1}); + auto variadic_split = std::make_shared(input, axis_const, split_lengths_const); + auto swish = std::make_shared(variadic_split->output(0)); + auto mul = std::make_shared(swish, variadic_split->output(1)); + + model = std::make_shared(ov::NodeVector{mul}, ov::ParameterVector{input}); + manager.register_pass(); + } + { + int64_t axis = -1; + int64_t split_lenghts = 3; + auto input = std::make_shared(ov::element::f16, ov::PartialShape{ -1, -1, 6 }); + auto swiglu = std::make_shared(input, axis, split_lenghts, ov::element::f16); + + model_ref = std::make_shared(ov::NodeVector{swiglu}, ov::ParameterVector{input}); + } +} + +TEST_F(TransformationTestsF, SwiGLUFusionTest4) { + { + auto input = std::make_shared(ov::element::f16, ov::PartialShape{ -1, -1, 6 }); + auto axis_const = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {-1}); + auto split_lengths_const = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{2}, {3, -1}); + auto variadic_split = std::make_shared(input, axis_const, split_lengths_const); + auto swish = std::make_shared(variadic_split->output(0)); + auto mul = std::make_shared(swish, variadic_split->output(0)); + + model = std::make_shared(ov::NodeVector{mul}, ov::ParameterVector{input}); + manager.register_pass(); + } +} diff --git a/src/plugins/intel_gpu/thirdparty/onednn_gpu b/src/plugins/intel_gpu/thirdparty/onednn_gpu index 41e05c66f91fa6..494af5f9921bda 160000 --- a/src/plugins/intel_gpu/thirdparty/onednn_gpu +++ b/src/plugins/intel_gpu/thirdparty/onednn_gpu @@ -1 +1 @@ -Subproject commit 41e05c66f91fa6fbbddedff0eb9b33913cf44fde +Subproject commit 494af5f9921bdae98f1a0e2955fa7d76ff386c4f diff --git a/src/plugins/proxy/src/plugin.cpp b/src/plugins/proxy/src/plugin.cpp index 180bb4d1dba26e..1cb9e7f3619c4d 100644 --- a/src/plugins/proxy/src/plugin.cpp +++ b/src/plugins/proxy/src/plugin.cpp @@ -9,12 +9,12 @@ #include #include "compiled_model.hpp" -#include "cpp_interfaces/interface/ie_internal_plugin_config.hpp" #include "openvino/core/any.hpp" #include "openvino/core/except.hpp" #include "openvino/proxy/properties.hpp" #include "openvino/runtime/device_id_parser.hpp" #include "openvino/runtime/iinfer_request.hpp" +#include "openvino/runtime/internal_properties.hpp" #include "openvino/runtime/iremote_context.hpp" #include "openvino/runtime/so_ptr.hpp" #include "openvino/util/common_util.hpp" diff --git a/src/plugins/proxy/tests/proxy_tests.cpp b/src/plugins/proxy/tests/proxy_tests.cpp index 0343e40ee240e2..8e7d8ea7df267b 100644 --- a/src/plugins/proxy/tests/proxy_tests.cpp +++ b/src/plugins/proxy/tests/proxy_tests.cpp @@ -8,7 +8,6 @@ #include #include "common_test_utils/file_utils.hpp" -#include "ie_plugin_config.hpp" #include "openvino/core/any.hpp" #include "openvino/core/except.hpp" #include "openvino/opsets/opset11.hpp" @@ -547,7 +546,7 @@ void ov::proxy::tests::ProxyTests::register_plugin_support_reshape(ov::Core& cor RO_property(ov::available_devices.name()), RO_property(ov::loaded_from_cache.name()), RO_property(ov::device::uuid.name()), - RO_property(METRIC_KEY(IMPORT_EXPORT_SUPPORT)), + RO_property(ov::device::capabilities.name()), RO_property(ov::optimal_batch_size.name()), RW_property(ov::hint::performance_mode.name()), RW_property(ov::hint::num_requests.name()), @@ -596,23 +595,9 @@ void ov::proxy::tests::ProxyTests::register_plugin_support_reshape(ov::Core& cor std::vector capabilities; capabilities.push_back(ov::device::capability::EXPORT_IMPORT); return decltype(ov::device::capabilities)::value_type(capabilities); - } else if (name == "SUPPORTED_CONFIG_KEYS") { // TODO: Remove this key - std::vector configs; - for (const auto& property : rwProperties) { - configs.emplace_back(property); - } - return configs; - } else if (METRIC_KEY(IMPORT_EXPORT_SUPPORT) == name) { - return true; } else if (ov::internal::caching_properties == name) { std::vector caching_properties = {ov::device::uuid}; return decltype(ov::internal::caching_properties)::value_type(caching_properties); - } else if (name == "SUPPORTED_METRICS") { // TODO: Remove this key - std::vector configs; - for (const auto& property : roProperties) { - configs.emplace_back(property); - } - return configs; } else if (name == ov::loaded_from_cache.name()) { return m_loaded_from_cache; } else if (name == ov::enable_profiling.name()) { @@ -680,7 +665,7 @@ void ov::proxy::tests::ProxyTests::register_plugin_support_subtract(ov::Core& co RO_property(ov::available_devices.name()), RO_property(ov::loaded_from_cache.name()), RO_property(ov::device::uuid.name()), - RO_property(METRIC_KEY(IMPORT_EXPORT_SUPPORT)), + RO_property(ov::device::capabilities.name()), }; // the whole config is RW before network is loaded. const static std::vector rwProperties{ @@ -722,23 +707,9 @@ void ov::proxy::tests::ProxyTests::register_plugin_support_subtract(ov::Core& co return m_loaded_from_cache; } else if (name == ov::enable_profiling.name()) { return decltype(ov::enable_profiling)::value_type{m_profiling}; - } else if (name == "SUPPORTED_CONFIG_KEYS") { // TODO: Remove this key - std::vector configs; - for (const auto& property : rwProperties) { - configs.emplace_back(property); - } - return configs; - } else if (METRIC_KEY(IMPORT_EXPORT_SUPPORT) == name) { - return true; } else if (ov::internal::caching_properties == name) { std::vector caching_properties = {ov::device::uuid}; return decltype(ov::internal::caching_properties)::value_type(caching_properties); - } else if (name == "SUPPORTED_METRICS") { // TODO: Remove this key - std::vector configs; - for (const auto& property : roProperties) { - configs.emplace_back(property); - } - return configs; } OPENVINO_THROW("Unsupported property: ", name); } @@ -787,7 +758,7 @@ void ov::proxy::tests::ProxyTests::register_plugin_without_devices(ov::Core& cor RO_property(ov::supported_properties.name()), RO_property(ov::available_devices.name()), RO_property(ov::loaded_from_cache.name()), - RO_property(METRIC_KEY(IMPORT_EXPORT_SUPPORT)), + RO_property(ov::device::capabilities.name()), }; // the whole config is RW before network is loaded. const static std::vector rwProperties{ @@ -817,20 +788,6 @@ void ov::proxy::tests::ProxyTests::register_plugin_without_devices(ov::Core& cor return m_loaded_from_cache; } else if (name == ov::enable_profiling.name()) { return decltype(ov::enable_profiling)::value_type{m_profiling}; - } else if (name == "SUPPORTED_CONFIG_KEYS") { // TODO: Remove this key - std::vector configs; - for (const auto& property : rwProperties) { - configs.emplace_back(property); - } - return configs; - } else if (METRIC_KEY(IMPORT_EXPORT_SUPPORT) == name) { - return true; - } else if (name == "SUPPORTED_METRICS") { // TODO: Remove this key - std::vector configs; - for (const auto& property : roProperties) { - configs.emplace_back(property); - } - return configs; } OPENVINO_THROW("Unsupported property: ", name); } diff --git a/src/plugins/template/backend/executable.hpp b/src/plugins/template/backend/executable.hpp index 2259cc5192a4c0..347c4493f04bc4 100644 --- a/src/plugins/template/backend/executable.hpp +++ b/src/plugins/template/backend/executable.hpp @@ -19,16 +19,16 @@ class Executable { Executable(); virtual ~Executable(); - /// \param outputs vector of runtime::Tensor used as outputs - /// \param inputs vector of runtime::Tensor used as inputs + /// \param outputs vector of Tensor used as outputs + /// \param inputs vector of Tensor used as inputs /// \param collect_performance Enable per operation performance statistic /// \returns true if iteration is successful, false otherwise virtual bool call(std::vector& outputs, const std::vector& inputs, bool collect_performance = false) = 0; - /// \param outputs vector of runtime::Tensor used as outputs - /// \param inputs vector of runtime::Tensor used as inputs + /// \param outputs vector of Tensor used as outputs + /// \param inputs vector of Tensor used as inputs /// \param context Evaluation context /// \param collect_performance Enable per operation performance statistic /// \returns true if iteration is successful, false otherwise @@ -41,14 +41,14 @@ class Executable { virtual void cancel() = 0; /// \brief Executes a single iteration of a Function. - /// \param outputs vector of runtime::Tensor used as outputs - /// \param inputs vector of runtime::Tensor used as inputs + /// \param outputs vector of Tensor used as outputs + /// \param inputs vector of Tensor used as inputs /// \returns true if iteration is successful, false otherwise bool call_with_validate(std::vector& outputs, const std::vector& inputs); /// \brief Validates a Function. - /// \param outputs vector of runtime::Tensor used as outputs - /// \param inputs vector of runtime::Tensor used as inputs + /// \param outputs vector of Tensor used as outputs + /// \param inputs vector of Tensor used as inputs void validate(const std::vector& outputs, const std::vector& inputs); /// \brief Query the input Parameters diff --git a/src/plugins/template/src/compiled_model.cpp b/src/plugins/template/src/compiled_model.cpp index 02fa9ec36e485a..4f79900fb2c950 100644 --- a/src/plugins/template/src/compiled_model.cpp +++ b/src/plugins/template/src/compiled_model.cpp @@ -147,7 +147,7 @@ ov::Any ov::template_plugin::CompiledModel::get_property(const std::string& name return decltype(ov::execution_devices)::value_type{get_plugin()->get_device_name() + "." + std::to_string(m_cfg.device_id)}; } else if (ov::optimal_number_of_infer_requests == name) { - unsigned int value = m_cfg.streams_executor_config._streams; + unsigned int value = m_cfg.streams; return decltype(ov::optimal_number_of_infer_requests)::value_type(value); } else if (ov::supported_properties == name) { auto ro_properties = default_ro_properties(); diff --git a/src/plugins/template/src/config.cpp b/src/plugins/template/src/config.cpp index 39e51ad262b465..f83690e6b9fe0c 100644 --- a/src/plugins/template/src/config.cpp +++ b/src/plugins/template/src/config.cpp @@ -14,9 +14,6 @@ Configuration::Configuration() {} Configuration::Configuration(const ov::AnyMap& config, const Configuration& defaultCfg, bool throwOnUnsupported) { *this = defaultCfg; - // If plugin needs to use ov::threading::StreamsExecutor it should be able to process its configuration - auto streamExecutorConfigKeys = - streams_executor_config.get_property(ov::supported_properties.name()).as>(); for (auto&& c : config) { const auto& key = c.first; const auto& value = c.second; @@ -25,9 +22,39 @@ Configuration::Configuration(const ov::AnyMap& config, const Configuration& defa disable_transformations = value.as(); } else if (ov::internal::exclusive_async_requests == key) { exclusive_async_requests = value.as(); - } else if (streamExecutorConfigKeys.end() != - std::find(std::begin(streamExecutorConfigKeys), std::end(streamExecutorConfigKeys), key)) { - streams_executor_config.set_property(key, value); + } else if (ov::num_streams.name() == key) { + ov::Any val = value.as(); + auto streams_value = val.as(); + if (streams_value.num >= 0) { + streams = streams_value.num; + } else if (streams_value == ov::streams::NUMA) { + streams = 1; + } else if (streams_value == ov::streams::AUTO) { + streams = ov::threading::IStreamsExecutor::Config::get_default_num_streams(); + } else { + OPENVINO_THROW("Wrong value for property key ", + key, + ". Expected non negative numbers (#streams) or ", + "ov::streams::NUMA|ov::streams::AUTO, Got: ", + value.as()); + } + } else if (ov::inference_num_threads.name() == key) { + int val; + try { + val = value.as(); + } catch (const std::exception&) { + OPENVINO_THROW("Wrong value for property key ", key, ". Expected only positive numbers (#threads)"); + } + if (val < 0) { + OPENVINO_THROW("Wrong value for property key ", key, ". Expected only positive numbers (#threads)"); + } + threads = val; + } else if (ov::internal::threads_per_stream.name() == key) { + try { + threads_per_stream = value.as(); + } catch (const std::exception&) { + OPENVINO_THROW("Wrong value ", value.as(), "for property key ", key); + } } else if (ov::device::id == key) { device_id = std::stoi(value.as()); OPENVINO_ASSERT(device_id <= 0, "Device ID ", device_id, " is not supported"); @@ -45,8 +72,6 @@ Configuration::Configuration(const ov::AnyMap& config, const Configuration& defa OPENVINO_THROW("Unsupported execution mode, should be ACCURACY or PERFORMANCE, but was: ", value.as()); } - } else if (ov::num_streams == key) { - streams_executor_config.set_property(key, value); } else if (ov::hint::num_requests == key) { auto tmp_val = value.as(); int tmp_i = std::stoi(tmp_val); @@ -65,12 +90,7 @@ Configuration::Configuration(const ov::AnyMap& config, const Configuration& defa } ov::Any Configuration::Get(const std::string& name) const { - auto streamExecutorConfigKeys = - streams_executor_config.get_property(ov::supported_properties.name()).as>(); - if ((streamExecutorConfigKeys.end() != - std::find(std::begin(streamExecutorConfigKeys), std::end(streamExecutorConfigKeys), name))) { - return streams_executor_config.get_property(name); - } else if (name == ov::device::id) { + if (name == ov::device::id) { return {std::to_string(device_id)}; } else if (name == ov::enable_profiling) { return {perf_count}; @@ -79,13 +99,11 @@ ov::Any Configuration::Get(const std::string& name) const { } else if (name == ov::template_plugin::disable_transformations) { return {disable_transformations}; } else if (name == ov::num_streams) { - return {std::to_string(streams_executor_config._streams)}; - } else if (name == ov::internal::cpu_bind_thread) { - return streams_executor_config.get_property(name); + return {std::to_string(streams)}; } else if (name == ov::inference_num_threads) { - return {std::to_string(streams_executor_config._threads)}; + return {std::to_string(threads)}; } else if (name == ov::internal::threads_per_stream) { - return {std::to_string(streams_executor_config._threadsPerStream)}; + return {std::to_string(threads_per_stream)}; } else if (name == ov::hint::performance_mode) { return performance_mode; } else if (name == ov::hint::inference_precision) { diff --git a/src/plugins/template/src/config.hpp b/src/plugins/template/src/config.hpp index 918e2b514f724a..ada22f8835d8bd 100644 --- a/src/plugins/template/src/config.hpp +++ b/src/plugins/template/src/config.hpp @@ -33,6 +33,9 @@ struct Configuration { int device_id = 0; bool perf_count = false; ov::threading::IStreamsExecutor::Config streams_executor_config; + int streams = 1; + int threads = 0; + int threads_per_stream = 0; ov::hint::PerformanceMode performance_mode = ov::hint::PerformanceMode::LATENCY; uint32_t num_requests = 1; bool disable_transformations = false; diff --git a/src/plugins/template/src/plugin.cpp b/src/plugins/template/src/plugin.cpp index a72549a81eaa15..ad98e81aec2c09 100644 --- a/src/plugins/template/src/plugin.cpp +++ b/src/plugins/template/src/plugin.cpp @@ -99,9 +99,14 @@ std::shared_ptr ov::template_plugin::Plugin::compile_model( OV_ITT_SCOPED_TASK(itt::domains::TemplatePlugin, "Plugin::compile_model"); auto fullConfig = Configuration{properties, m_cfg}; + fullConfig.streams_executor_config = ov::threading::IStreamsExecutor::Config{stream_executor_name, + fullConfig.streams, + fullConfig.threads_per_stream}; auto streamsExecutorConfig = ov::threading::IStreamsExecutor::Config::make_default_multi_threaded(fullConfig.streams_executor_config); - streamsExecutorConfig._name = stream_executor_name; + fullConfig.streams = streamsExecutorConfig.get_streams(); + fullConfig.threads = streamsExecutorConfig.get_threads(); + fullConfig.threads_per_stream = streamsExecutorConfig.get_threads_per_stream(); auto compiled_model = std::make_shared( model->clone(), shared_from_this(), @@ -138,6 +143,9 @@ std::shared_ptr ov::template_plugin::Plugin::import_model( } auto fullConfig = Configuration{_properties, m_cfg}; + fullConfig.streams_executor_config = ov::threading::IStreamsExecutor::Config{stream_executor_name, + fullConfig.streams, + fullConfig.threads_per_stream}; // read XML content std::string xmlString; std::uint64_t dataSize = 0; @@ -156,7 +164,9 @@ std::shared_ptr ov::template_plugin::Plugin::import_model( auto ov_model = get_core()->read_model(xmlString, weights); auto streamsExecutorConfig = ov::threading::IStreamsExecutor::Config::make_default_multi_threaded(fullConfig.streams_executor_config); - streamsExecutorConfig._name = stream_executor_name; + fullConfig.streams = streamsExecutorConfig.get_streams(); + fullConfig.threads = streamsExecutorConfig.get_threads(); + fullConfig.threads_per_stream = streamsExecutorConfig.get_threads_per_stream(); auto compiled_model = std::make_shared(ov_model, shared_from_this(), @@ -204,6 +214,7 @@ ov::SupportedOpsMap ov::template_plugin::Plugin::query_model(const std::shared_p #include "openvino/opsets/opset11_tbl.hpp" #include "openvino/opsets/opset12_tbl.hpp" #include "openvino/opsets/opset13_tbl.hpp" +#include "openvino/opsets/opset14_tbl.hpp" // clang-format on #undef _OPENVINO_OP_REG return op_super_set.contains_type(node->get_type_info()); diff --git a/src/plugins/template/tests/functional/core_config.cpp b/src/plugins/template/tests/functional/core_config.cpp index 2c54a0d17b2f8d..6c1c4e433b08e3 100644 --- a/src/plugins/template/tests/functional/core_config.cpp +++ b/src/plugins/template/tests/functional/core_config.cpp @@ -2,12 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "functional_test_utils/core_config.hpp" - #include "shared_test_classes/base/ov_subgraph.hpp" -void CoreConfiguration(LayerTestsUtils::LayerTestsCommon* test) {} - namespace ov { namespace test { diff --git a/src/plugins/template/tests/functional/op_reference/base_reference_test.cpp b/src/plugins/template/tests/functional/op_reference/base_reference_test.cpp index ed8621d0351a3e..845c5c0b15b1c8 100644 --- a/src/plugins/template/tests/functional/op_reference/base_reference_test.cpp +++ b/src/plugins/template/tests/functional/op_reference/base_reference_test.cpp @@ -92,126 +92,124 @@ void CommonReferenceTest::ValidateBlobs(const ov::Tensor& refBlob, const auto& element_type = refBlob.get_element_type(); switch (element_type) { case ov::element::bf16: - LayerTestsUtils::LayerTestsCommon::Compare(refBlob.data(), - outBlob.data(), - actual_comparision_size, - threshold, - abs_threshold); + ov::test::utils::compare_raw_data(refBlob.data(), + outBlob.data(), + actual_comparision_size, + threshold, + abs_threshold); break; case ov::element::f16: - LayerTestsUtils::LayerTestsCommon::Compare(refBlob.data(), - outBlob.data(), - actual_comparision_size, - threshold, - abs_threshold); + ov::test::utils::compare_raw_data(refBlob.data(), + outBlob.data(), + actual_comparision_size, + threshold, + abs_threshold); break; case ov::element::f8e4m3: - LayerTestsUtils::LayerTestsCommon::Compare( - refBlob.data(), - outBlob.data(), - actual_comparision_size, - threshold, - abs_threshold); + ov::test::utils::compare_raw_data(refBlob.data(), + outBlob.data(), + actual_comparision_size, + threshold, + abs_threshold); break; case ov::element::f8e5m2: - LayerTestsUtils::LayerTestsCommon::Compare( - refBlob.data(), - outBlob.data(), - actual_comparision_size, - threshold, - abs_threshold); + ov::test::utils::compare_raw_data(refBlob.data(), + outBlob.data(), + actual_comparision_size, + threshold, + abs_threshold); break; case ov::element::f32: - LayerTestsUtils::LayerTestsCommon::Compare(refBlob.data(), - outBlob.data(), - actual_comparision_size, - threshold, - abs_threshold); + ov::test::utils::compare_raw_data(refBlob.data(), + outBlob.data(), + actual_comparision_size, + threshold, + abs_threshold); break; case ov::element::f64: - LayerTestsUtils::LayerTestsCommon::Compare(refBlob.data(), - outBlob.data(), - actual_comparision_size, - threshold, - abs_threshold); + ov::test::utils::compare_raw_data(refBlob.data(), + outBlob.data(), + actual_comparision_size, + threshold, + abs_threshold); break; case ov::element::i8: - LayerTestsUtils::LayerTestsCommon::Compare(refBlob.data(), - outBlob.data(), - actual_comparision_size, - threshold, - abs_threshold); + ov::test::utils::compare_raw_data(refBlob.data(), + outBlob.data(), + actual_comparision_size, + threshold, + abs_threshold); break; case ov::element::i16: - LayerTestsUtils::LayerTestsCommon::Compare(refBlob.data(), - outBlob.data(), - actual_comparision_size, - threshold, - abs_threshold); + ov::test::utils::compare_raw_data(refBlob.data(), + outBlob.data(), + actual_comparision_size, + threshold, + abs_threshold); break; case ov::element::i32: - LayerTestsUtils::LayerTestsCommon::Compare(refBlob.data(), - outBlob.data(), - actual_comparision_size, - threshold, - abs_threshold); + ov::test::utils::compare_raw_data(refBlob.data(), + outBlob.data(), + actual_comparision_size, + threshold, + abs_threshold); break; case ov::element::i64: - LayerTestsUtils::LayerTestsCommon::Compare(refBlob.data(), - outBlob.data(), - actual_comparision_size, - threshold, - abs_threshold); + ov::test::utils::compare_raw_data(refBlob.data(), + outBlob.data(), + actual_comparision_size, + threshold, + abs_threshold); break; case ov::element::boolean: - LayerTestsUtils::LayerTestsCommon::Compare(refBlob.data(), - outBlob.data(), - actual_comparision_size, - threshold, - abs_threshold); + ov::test::utils::compare_raw_data(refBlob.data(), + outBlob.data(), + actual_comparision_size, + threshold, + abs_threshold); break; case ov::element::u8: - LayerTestsUtils::LayerTestsCommon::Compare(refBlob.data(), - outBlob.data(), - actual_comparision_size, - threshold, - abs_threshold); + ov::test::utils::compare_raw_data(refBlob.data(), + outBlob.data(), + actual_comparision_size, + threshold, + abs_threshold); break; case ov::element::u16: - LayerTestsUtils::LayerTestsCommon::Compare(refBlob.data(), - outBlob.data(), - actual_comparision_size, - threshold, - abs_threshold); + ov::test::utils::compare_raw_data(refBlob.data(), + outBlob.data(), + actual_comparision_size, + threshold, + abs_threshold); break; case ov::element::u32: - LayerTestsUtils::LayerTestsCommon::Compare(refBlob.data(), - outBlob.data(), - actual_comparision_size, - threshold, - abs_threshold); + ov::test::utils::compare_raw_data(refBlob.data(), + outBlob.data(), + actual_comparision_size, + threshold, + abs_threshold); break; case ov::element::u64: - LayerTestsUtils::LayerTestsCommon::Compare(refBlob.data(), - outBlob.data(), - actual_comparision_size, - threshold, - abs_threshold); + ov::test::utils::compare_raw_data(refBlob.data(), + outBlob.data(), + actual_comparision_size, + threshold, + abs_threshold); break; case ov::element::i4: case ov::element::u4: - LayerTestsUtils::LayerTestsCommon::Compare(static_cast(refBlob.data()), - static_cast(outBlob.data()), - actual_comparision_size / 2, - threshold, - abs_threshold); + ov::test::utils::compare_raw_data(static_cast(refBlob.data()), + static_cast(outBlob.data()), + actual_comparision_size / 2, + threshold, + abs_threshold); break; case ov::element::u1: - LayerTestsUtils::LayerTestsCommon::Compare(static_cast(refBlob.data()), - static_cast(outBlob.data()), - actual_comparision_size / 8, - threshold, - abs_threshold); + ov::test::utils::compare_raw_data(static_cast(refBlob.data()), + static_cast(outBlob.data()), + actual_comparision_size / 8, + threshold, + abs_threshold); break; default: FAIL() << "Comparator for " << element_type << " element type isn't supported"; diff --git a/src/plugins/template/tests/functional/op_reference/if.cpp b/src/plugins/template/tests/functional/op_reference/if.cpp index 5f51a03f02d427..fe05f18c27f50d 100644 --- a/src/plugins/template/tests/functional/op_reference/if.cpp +++ b/src/plugins/template/tests/functional/op_reference/if.cpp @@ -8,7 +8,6 @@ #include #include "base_reference_test.hpp" -#include "ie_core.hpp" #include "shared_test_classes/base/layer_test_utils.hpp" using namespace reference_tests; diff --git a/src/plugins/template/tests/functional/op_reference/interpolate.cpp b/src/plugins/template/tests/functional/op_reference/interpolate.cpp index 7eaed35bde1878..4805f4364c9401 100644 --- a/src/plugins/template/tests/functional/op_reference/interpolate.cpp +++ b/src/plugins/template/tests/functional/op_reference/interpolate.cpp @@ -50,8 +50,8 @@ struct InterpolateV1Params { Shape outShape; element::Type inType; element::Type outType; - runtime::Tensor inData; - runtime::Tensor outData; + ov::Tensor inData; + ov::Tensor outData; std::shared_ptr outShapeInput; op::v0::Interpolate::Attributes attrs; }; @@ -82,8 +82,8 @@ struct InterpolateV4Params { Shape outShape; element::Type inType; element::Type outType; - runtime::Tensor inData; - runtime::Tensor outData; + ov::Tensor inData; + ov::Tensor outData; std::vector outShapeInput; element::Type outShapeInputType; std::vector scales; diff --git a/src/plugins/template/tests/functional/op_reference/memory.cpp b/src/plugins/template/tests/functional/op_reference/memory.cpp index d2fad1ec59ad14..ffc1444c41a23c 100644 --- a/src/plugins/template/tests/functional/op_reference/memory.cpp +++ b/src/plugins/template/tests/functional/op_reference/memory.cpp @@ -36,8 +36,8 @@ struct ReadValueAssignParams { Shape m_output_shape; element::Type m_input_type; element::Type m_output_type; - runtime::Tensor m_input_data; - runtime::Tensor m_expected_data; + ov::Tensor m_input_data; + ov::Tensor m_expected_data; std::string m_variable_id; }; @@ -245,8 +245,8 @@ struct MemoryTestParams { ov::Shape m_output_shape; ov::element::Type m_input_type; ov::element::Type m_output_type; - ov::runtime::Tensor m_input_data; - ov::runtime::Tensor m_expected_data; + ov::Tensor m_input_data; + ov::Tensor m_expected_data; std::vector m_variable_id; size_t m_count_runs; size_t m_reset_on_run; diff --git a/src/plugins/template/tests/functional/op_reference/region_yolo.cpp b/src/plugins/template/tests/functional/op_reference/region_yolo.cpp index f1160722810f69..3e12ab8e4384ef 100644 --- a/src/plugins/template/tests/functional/op_reference/region_yolo.cpp +++ b/src/plugins/template/tests/functional/op_reference/region_yolo.cpp @@ -67,8 +67,8 @@ struct RegionYoloParams { ov::PartialShape inputShape; ov::element::Type inType; ov::element::Type outType; - ov::runtime::Tensor inputData; - ov::runtime::Tensor refData; + ov::Tensor inputData; + ov::Tensor refData; std::string testcaseName; }; diff --git a/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_executable_network/exec_network_base.cpp b/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_executable_network/exec_network_base.cpp index f6f96b5b20f8c3..cfb2bd7f1c30ca 100644 --- a/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_executable_network/exec_network_base.cpp +++ b/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_executable_network/exec_network_base.cpp @@ -3,7 +3,6 @@ // #include "behavior/compiled_model/compiled_model_base.hpp" -#include "ie_plugin_config.hpp" using namespace ov::test::behavior; namespace { diff --git a/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_executable_network/ov_exec_net_import_export.cpp b/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_executable_network/ov_exec_net_import_export.cpp index 388150d628600b..72f63a2344defe 100644 --- a/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_executable_network/ov_exec_net_import_export.cpp +++ b/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_executable_network/ov_exec_net_import_export.cpp @@ -3,7 +3,6 @@ // #include "behavior/compiled_model/import_export.hpp" #include "common_test_utils/test_constants.hpp" -#include "ie_plugin_config.hpp" using namespace ov::test::behavior; namespace { diff --git a/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_executable_network/properties.cpp b/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_executable_network/properties.cpp index 4f0d107387042c..4f5ba4f1baf4a2 100644 --- a/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_executable_network/properties.cpp +++ b/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_executable_network/properties.cpp @@ -4,7 +4,6 @@ #include "behavior/compiled_model/properties.hpp" -#include "ie_plugin_config.hpp" #include "openvino/runtime/properties.hpp" using namespace ov::test::behavior; diff --git a/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_infer_request/memory_states.cpp b/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_infer_request/memory_states.cpp new file mode 100644 index 00000000000000..6d8fd09d192786 --- /dev/null +++ b/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_infer_request/memory_states.cpp @@ -0,0 +1,20 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "behavior/ov_infer_request/memory_states.hpp" + +namespace { +using ov::test::behavior::memoryStateParams; +using ov::test::behavior::OVInferRequestVariableStateTest; + +std::vector memoryStateTestCases = {memoryStateParams(OVInferRequestVariableStateTest::get_network(), + {"c_1-3", "r_1-3"}, + ov::test::utils::DEVICE_TEMPLATE, + {})}; + +INSTANTIATE_TEST_SUITE_P(smoke_Template_BehaviorTests, + OVInferRequestVariableStateTest, + ::testing::ValuesIn(memoryStateTestCases), + OVInferRequestVariableStateTest::getTestCaseName); +} // namespace diff --git a/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_infer_request/properties_tests.cpp b/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_infer_request/properties_tests.cpp new file mode 100644 index 00000000000000..8aae5e01116c62 --- /dev/null +++ b/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_infer_request/properties_tests.cpp @@ -0,0 +1,21 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "behavior/ov_infer_request/properties_tests.hpp" + +#include + +namespace { +using ov::test::behavior::InferRequestPropertiesTest; + +const std::vector configs = {{}}; + +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, + InferRequestPropertiesTest, + ::testing::Combine(::testing::Values(1u), + ::testing::Values(ov::test::utils::DEVICE_TEMPLATE), + ::testing::ValuesIn(configs)), + InferRequestPropertiesTest::getTestCaseName); + +} // namespace diff --git a/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_plugin/hetero_synthetic.cpp b/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_plugin/hetero_synthetic.cpp new file mode 100644 index 00000000000000..090ce0e32f1917 --- /dev/null +++ b/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_plugin/hetero_synthetic.cpp @@ -0,0 +1,107 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "behavior/ov_plugin/hetero_synthetic.hpp" + +#include + +#include "common_test_utils/subgraph_builders/conv_pool_relu.hpp" +#include "common_test_utils/subgraph_builders/conv_pool_relu_non_zero.hpp" + +namespace { +using ov::test::behavior::OVHeteroSyntheticTest; +using ov::test::behavior::PluginParameter; + +// this tests load plugin by library name: this is not available during static linkage +#ifndef OPENVINO_STATIC_LIBRARY + +INSTANTIATE_TEST_SUITE_P(smoke_manyTargetInputs, + OVHeteroSyntheticTest, + ::testing::Combine(::testing::Values(std::vector{ + {"TEMPLATE0", "openvino_template_plugin"}, + {"TEMPLATE1", "openvino_template_plugin"}}), + ::testing::ValuesIn(OVHeteroSyntheticTest::withMajorNodesFunctions( + [] { + return ov::test::utils::make_conv_pool2_relu2(); + }, + {"Conv_1"}, + true))), + OVHeteroSyntheticTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_SingleMajorNode, + OVHeteroSyntheticTest, + ::testing::Combine(::testing::Values(std::vector{ + {"TEMPLATE0", "openvino_template_plugin"}, + {"TEMPLATE1", "openvino_template_plugin"}}), + ::testing::ValuesIn(OVHeteroSyntheticTest::_singleMajorNodeFunctions)), + OVHeteroSyntheticTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(nightly_RandomMajorNodes, + OVHeteroSyntheticTest, + ::testing::Combine(::testing::Values(std::vector{ + {"TEMPLATE0", "openvino_template_plugin"}, + {"TEMPLATE1", "openvino_template_plugin"}}), + ::testing::ValuesIn(OVHeteroSyntheticTest::_randomMajorNodeFunctions)), + OVHeteroSyntheticTest::getTestCaseName); + +static std::vector()>> dynamicBuilders = { + [] { + return ov::test::utils::make_conv_pool_relu_non_zero(); + }, +}; + +INSTANTIATE_TEST_SUITE_P( + smoke_NonZeroMajorNode_dynamic, + OVHeteroSyntheticTest, + ::testing::Combine(::testing::Values(std::vector{{"TEMPLATE0", "openvino_template_plugin"}, + {"TEMPLATE1", "openvino_template_plugin"}}), + ::testing::ValuesIn(OVHeteroSyntheticTest::withMajorNodesFunctions(dynamicBuilders.front(), + {"nonZero_1"}))), + OVHeteroSyntheticTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P( + smoke_NonZeroMajorNode_dynamic_batch, + OVHeteroSyntheticTest, + ::testing::Combine(::testing::Values(std::vector{{"TEMPLATE0", "openvino_template_plugin"}, + {"TEMPLATE1", "openvino_template_plugin"}}), + ::testing::ValuesIn(OVHeteroSyntheticTest::withMajorNodesFunctions(dynamicBuilders.front(), + {"nonZero_1"}, + true))), + OVHeteroSyntheticTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P( + smoke_SingleMajorNode_dynamic, + OVHeteroSyntheticTest, + ::testing::Combine(::testing::Values(std::vector{{"TEMPLATE0", "openvino_template_plugin"}, + {"TEMPLATE1", "openvino_template_plugin"}}), + ::testing::ValuesIn(OVHeteroSyntheticTest::singleMajorNodeFunctions(dynamicBuilders))), + OVHeteroSyntheticTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P( + nightly_RandomMajorNodes_dynamic, + OVHeteroSyntheticTest, + ::testing::Combine(::testing::Values(std::vector{{"TEMPLATE0", "openvino_template_plugin"}, + {"TEMPLATE1", "openvino_template_plugin"}}), + ::testing::ValuesIn(OVHeteroSyntheticTest::randomMajorNodeFunctions(dynamicBuilders))), + OVHeteroSyntheticTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P( + smoke_SingleMajorNode_dynamic_batch, + OVHeteroSyntheticTest, + ::testing::Combine(::testing::Values(std::vector{{"TEMPLATE0", "openvino_template_plugin"}, + {"TEMPLATE1", "openvino_template_plugin"}}), + ::testing::ValuesIn(OVHeteroSyntheticTest::singleMajorNodeFunctions(dynamicBuilders, true))), + OVHeteroSyntheticTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P( + nightly_RandomMajorNodes_dynamic_batch, + OVHeteroSyntheticTest, + ::testing::Combine(::testing::Values(std::vector{{"TEMPLATE0", "openvino_template_plugin"}, + {"TEMPLATE1", "openvino_template_plugin"}}), + ::testing::ValuesIn(OVHeteroSyntheticTest::randomMajorNodeFunctions(dynamicBuilders, true))), + OVHeteroSyntheticTest::getTestCaseName); + +#endif // !OPENVINO_STATIC_LIBRARY + +} // namespace diff --git a/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp b/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp index 43f2e9a61f8a98..f97448c7dea396 100644 --- a/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp +++ b/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp @@ -4,7 +4,6 @@ #include "behavior/ov_plugin/properties_tests.hpp" -#include "ie_plugin_config.hpp" #include "openvino/runtime/properties.hpp" using namespace ov::test::behavior; @@ -56,7 +55,7 @@ const std::vector multi_properties = { const std::vector auto_batch_properties = { {{ov::device::priorities.name(), ov::test::utils::DEVICE_TEMPLATE}}, - {{ov::device::priorities.name(), ov::test::utils::DEVICE_TEMPLATE}, {CONFIG_KEY(AUTO_BATCH_TIMEOUT), "1"}}, + {{ov::device::priorities.name(), ov::test::utils::DEVICE_TEMPLATE}, {ov::auto_batch_timeout.name(), "1"}}, }; INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, diff --git a/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_plugin/remote.cpp b/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_plugin/remote.cpp index af2f01a5fd3404..6417170c6f6bbd 100644 --- a/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_plugin/remote.cpp +++ b/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_plugin/remote.cpp @@ -5,7 +5,6 @@ #include "behavior/ov_plugin/remote.hpp" #include "common_test_utils/test_constants.hpp" -#include "ie_plugin_config.hpp" using namespace ov::test; diff --git a/src/plugins/template/tests/functional/shared_tests_instances/single_layer_tests/eltwise.cpp b/src/plugins/template/tests/functional/shared_tests_instances/single_layer_tests/eltwise.cpp index 8d034694905bd8..7689d706432d20 100644 --- a/src/plugins/template/tests/functional/shared_tests_instances/single_layer_tests/eltwise.cpp +++ b/src/plugins/template/tests/functional/shared_tests_instances/single_layer_tests/eltwise.cpp @@ -2,13 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/eltwise.hpp" +#include "single_op_tests/eltwise.hpp" #include #include "common_test_utils/test_constants.hpp" -using namespace ov::test::subgraph; +using namespace ov::test; namespace { std::vector> inShapesStatic = { @@ -113,7 +113,7 @@ std::vector eltwiseOpTypesSingleThread = { ov::test::utils::EltwiseTypes::POWER, }; -ov::AnyMap additional_config_single_thread = {{"CPU_THREADS_NUM", "1"}}; +ov::AnyMap additional_config_single_thread = {ov::inference_num_threads(1)}; const auto single_thread_params = ::testing::Combine(::testing::ValuesIn(ov::test::static_shapes_to_test_representation(inShapesSingleThread)), diff --git a/src/plugins/template/tests/functional/shared_tests_instances/single_layer_tests/softmax.cpp b/src/plugins/template/tests/functional/shared_tests_instances/single_layer_tests/softmax.cpp index 6b268c7f59cf04..18c1c2f3dfc7d1 100644 --- a/src/plugins/template/tests/functional/shared_tests_instances/single_layer_tests/softmax.cpp +++ b/src/plugins/template/tests/functional/shared_tests_instances/single_layer_tests/softmax.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/softmax.hpp" +#include "single_op_tests/softmax.hpp" #include diff --git a/src/plugins/template/tests/functional/skip_tests_config.cpp b/src/plugins/template/tests/functional/skip_tests_config.cpp index 288877da4c7bfa..0743b5837f2dab 100644 --- a/src/plugins/template/tests/functional/skip_tests_config.cpp +++ b/src/plugins/template/tests/functional/skip_tests_config.cpp @@ -121,9 +121,6 @@ std::vector disabledTestPatterns() { R"(.*eltwiseOpType=Mod_secondaryInputType=PARAMETER_opType=VECTOR_NetType=(f16|f32).*)", // Interpreter backend doesn't implement evaluate method for OP Multiply (by GroupNormalizationDecomposition) R"(.*ReferenceGroupNormalization.*_f64*)", - // Issue: 128924 - R"(.*OVClassModelTestP/OVClassModelTestP.ImportModelWithNullContextThrows.*)", - }; #ifdef _WIN32 diff --git a/src/plugins/template/tests/functional/subgraph_reference/base_reference_cnn_test.cpp b/src/plugins/template/tests/functional/subgraph_reference/base_reference_cnn_test.cpp deleted file mode 100644 index abdf47a4b8c3b0..00000000000000 --- a/src/plugins/template/tests/functional/subgraph_reference/base_reference_cnn_test.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// -#include "base_reference_cnn_test.hpp" - -#include - -#include "functional_test_utils/ov_plugin_cache.hpp" -#include "openvino/core/type/element_type.hpp" -#include "openvino/runtime/allocator.hpp" -#include "openvino/runtime/tensor.hpp" -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "transformations/utils/utils.hpp" - -using namespace ov; - -namespace reference_tests { - -ReferenceCNNTest::ReferenceCNNTest() : targetDevice("TEMPLATE") { - core = test::utils::PluginCache::get().core(targetDevice); - legacy_core = PluginCache::get().ie(targetDevice); -} - -void ReferenceCNNTest::Exec() { - LoadNetwork(); - LoadNetworkLegacy(); - - if (legacy_input_blobs.empty() && inputData.empty()) { - FillInputs(); - } - Infer(); - InferLegacy(); - - Validate(); -} - -void ReferenceCNNTest::LoadNetwork() { - executableNetwork = core->compile_model(function, targetDevice); -} - -void ReferenceCNNTest::LoadNetworkLegacy() { - auto inputInfo = legacy_network.getInputsInfo(); - auto outputInfo = legacy_network.getOutputsInfo(); - for (const auto& param : function->get_parameters()) { - inputInfo[param->get_friendly_name()]->setPrecision( - InferenceEngine::details::convertPrecision(param->get_element_type())); - } - for (const auto& result : function->get_results()) { - outputInfo[ov::op::util::create_ie_output_name(result->input_value(0))]->setPrecision( - InferenceEngine::details::convertPrecision(result->get_element_type())); - } - legacy_exec_network = legacy_core->LoadNetwork(legacy_network, targetDevice); -} - -void ReferenceCNNTest::FillInputs() { - const auto& params = function->get_parameters(); - std::default_random_engine random(0); // hard-coded seed to make test results predictable - std::uniform_int_distribution distrib(0, 255); - for (const auto& param : params) { - auto elem_count = shape_size(param->get_output_tensor(0).get_shape()); - InferenceEngine::TensorDesc d(InferenceEngine::Precision::FP32, - param->get_output_tensor(0).get_shape(), - InferenceEngine::Layout::NCHW); - auto blob = make_blob_with_precision(d); - blob->allocate(); - - auto mBlob = InferenceEngine::as(blob); - auto mBlobHolder = mBlob->wmap(); - auto buf = mBlobHolder.as(); - ASSERT_EQ(mBlob->size(), elem_count); - - ov::Tensor ov_blob; - ov_blob = ov::Tensor(param->get_element_type(), param->get_shape()); - auto ov_buf = static_cast(ov_blob.data()); - - for (size_t j = 0; j < elem_count; j++) { - auto v = distrib(random); - buf[j] = static_cast(v); - ov_buf[j] = static_cast(v); - } - legacy_input_blobs[param->get_friendly_name()] = blob; - inputData.push_back(ov_blob); - } -} - -void ReferenceCNNTest::Infer() { - inferRequest = executableNetwork.create_infer_request(); - const auto& functionParams = function->get_parameters(); - - for (size_t i = 0; i < functionParams.size(); ++i) { - const auto& param = functionParams[i]; - inferRequest.set_tensor(param->get_friendly_name(), inputData[i]); - } - inferRequest.infer(); -} - -void ReferenceCNNTest::InferLegacy() { - legacy_infer_request = legacy_exec_network.CreateInferRequest(); - legacy_infer_request.SetInput(legacy_input_blobs); - legacy_infer_request.Infer(); -} - -void ReferenceCNNTest::Validate() { - for (const auto& result : function->get_results()) { - auto name = ov::op::util::create_ie_output_name(result->input_value(0)); - outputs_ov20.emplace_back(inferRequest.get_tensor(name)); - auto outBlob = legacy_infer_request.GetBlob(name); - auto outMem = outBlob->buffer(); - void* outData = outMem.as(); - outputs_legacy.emplace_back(element::f32, result->get_shape(), outData); - } - for (size_t i = 0; i < outputs_legacy.size(); i++) { - CommonReferenceTest::ValidateBlobs(outputs_legacy[i], outputs_ov20[i], i, threshold, abs_threshold); - } -} - -} // namespace reference_tests diff --git a/src/plugins/template/tests/functional/subgraph_reference/base_reference_cnn_test.hpp b/src/plugins/template/tests/functional/subgraph_reference/base_reference_cnn_test.hpp deleted file mode 100644 index 4dcb27ee2c2dc4..00000000000000 --- a/src/plugins/template/tests/functional/subgraph_reference/base_reference_cnn_test.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "base_reference_test.hpp" -#include "inference_engine.hpp" - -namespace reference_tests { - -class ReferenceCNNTest { -public: - ReferenceCNNTest(); - - void Exec(); - - void LoadNetwork(); - void FillInputs(); // Both for legacy and for OV2.0 API - void Infer(); - - void LoadNetworkLegacy(); - void InferLegacy(); - - virtual void Validate(); - -protected: - const std::string targetDevice; - std::shared_ptr function; - InferenceEngine::CNNNetwork legacy_network; - - float threshold = 1e-5f; // Relative diff - float abs_threshold = -1.f; // Absolute diff (not used when negative) - - std::vector outputs_ov20; - std::vector outputs_legacy; - -protected: - // These will be generated by default, if user has not specified inputs manually - std::vector inputData; - InferenceEngine::BlobMap legacy_input_blobs; - -private: - std::shared_ptr core; - ov::CompiledModel executableNetwork; - ov::InferRequest inferRequest; - - std::shared_ptr legacy_core; - InferenceEngine::ExecutableNetwork legacy_exec_network; - InferenceEngine::InferRequest legacy_infer_request; -}; - -} // namespace reference_tests diff --git a/src/plugins/template/tests/functional/subgraph_reference/preprocess_opencv.cpp b/src/plugins/template/tests/functional/subgraph_reference/preprocess_opencv.cpp deleted file mode 100644 index d27122a1c01d38..00000000000000 --- a/src/plugins/template/tests/functional/subgraph_reference/preprocess_opencv.cpp +++ /dev/null @@ -1,418 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#ifdef OPENCV_TEMPLATE_TESTS - -# include -# include - -# include - -# include "base_reference_test.hpp" -# include "openvino/core/preprocess/pre_post_process.hpp" -# include "shared_test_classes/base/layer_test_utils.hpp" -# include "shared_test_classes/single_layer/convert_color_i420.hpp" -# include "shared_test_classes/single_layer/convert_color_nv12.hpp" - -using namespace ov; -using namespace ov::preprocess; -using namespace reference_tests; -namespace { - -class PreprocessOpenCVReferenceTest : public testing::Test, public CommonReferenceTest { -public: - void SetUp() override { - SKIP_IF_CURRENT_TEST_IS_DISABLED() - } -}; - -/// \brief Test class with counting deviated pixels -/// -/// OpenCV contains custom implementation for 8U and 16U (all calculations -/// are done in INTs instead of FLOATs), so deviation in 1 color step -/// between pixels is expected -class PreprocessOpenCVReferenceTest_8U : public PreprocessOpenCVReferenceTest { -public: - void Validate() override { - threshold = 1.f; - abs_threshold = 1.f; - // No pixels with deviation of more than 1 color step - CommonReferenceTest::Validate(); - // Less than 2% of deviations with 1 color step. 2% is experimental value - // For very precise (acceptable) float calculations - 1.4% deviation with G-API/OpenCV is observed - LayerTestsDefinitions::NV12TestUtils::ValidateColors(refOutData[0].data(), - actualOutData[0].data(), - refOutData[0].get_size(), - 0.02); - } -}; - -} // namespace - -static std::shared_ptr create_simple_function(element::Type type, const PartialShape& shape) { - auto data1 = std::make_shared(type, shape); - data1->set_friendly_name("input1"); - data1->get_output_tensor(0).set_names({"tensor_input1", "input1"}); - auto c = op::v0::Constant::create(type, {1}, {0}); - auto op = std::make_shared(data1, c); - op->set_friendly_name("Add0"); - auto res = std::make_shared(op); - res->set_friendly_name("Result1"); - res->get_output_tensor(0).set_names({"tensor_output1", "Result1"}); - return std::make_shared(ResultVector{res}, ParameterVector{data1}); -} - -TEST_F(PreprocessOpenCVReferenceTest, convert_rgb_gray_fp32) { - const size_t input_height = 50; - const size_t input_width = 50; - auto input_shape = Shape{1, input_height, input_width, 3}; - auto model_shape = Shape{1, input_height, input_width, 1}; - - auto input_img = std::vector(shape_size(input_shape)); - std::default_random_engine random(0); // hard-coded seed to make test results predictable - std::uniform_int_distribution distrib(-5, 300); - for (std::size_t i = 0; i < shape_size(input_shape); i++) - input_img[i] = static_cast(distrib(random)); - - function = create_simple_function(element::f32, model_shape); - - inputData.clear(); - - auto p = PrePostProcessor(function); - p.input().tensor().set_color_format(ColorFormat::RGB); - p.input().preprocess().convert_color(ColorFormat::GRAY); - function = p.build(); - - const auto& param = function->get_parameters()[0]; - inputData.emplace_back(param->get_element_type(), param->get_shape(), input_img.data()); - - // Calculate reference expected values from OpenCV - cv::Mat cvPic = cv::Mat(input_height, input_width, CV_32FC3, input_img.data()); - cv::Mat picGRAY; - cv::cvtColor(cvPic, picGRAY, CV_RGB2GRAY); - refOutData.emplace_back(param->get_element_type(), model_shape, picGRAY.data); - // Exec now - Exec(); -} - -TEST_F(PreprocessOpenCVReferenceTest, convert_bgr_gray_fp32) { - const size_t input_height = 50; - const size_t input_width = 50; - auto input_shape = Shape{1, input_height, input_width, 3}; - auto model_shape = Shape{1, input_height, input_width, 1}; - - auto input_img = std::vector(shape_size(input_shape)); - std::default_random_engine random(0); // hard-coded seed to make test results predictable - std::uniform_int_distribution distrib(-5, 300); - for (std::size_t i = 0; i < shape_size(input_shape); i++) - input_img[i] = static_cast(distrib(random)); - - function = create_simple_function(element::f32, model_shape); - - inputData.clear(); - - auto p = PrePostProcessor(function); - p.input().tensor().set_color_format(ColorFormat::BGR); - p.input().preprocess().convert_color(ColorFormat::GRAY); - function = p.build(); - - const auto& param = function->get_parameters()[0]; - inputData.emplace_back(param->get_element_type(), param->get_shape(), input_img.data()); - - // Calculate reference expected values from OpenCV - cv::Mat cvPic = cv::Mat(input_height, input_width, CV_32FC3, input_img.data()); - cv::Mat picGRAY; - cv::cvtColor(cvPic, picGRAY, CV_BGR2GRAY); - refOutData.emplace_back(param->get_element_type(), model_shape, picGRAY.data); - - // Exec now - Exec(); -} - -TEST_F(PreprocessOpenCVReferenceTest_8U, convert_rgb_gray_u8) { - const size_t input_height = 50; - const size_t input_width = 50; - auto input_shape = Shape{1, input_height, input_width, 3}; - auto model_shape = Shape{1, input_height, input_width, 1}; - - auto input_img = std::vector(shape_size(input_shape)); - std::default_random_engine random(0); // hard-coded seed to make test results predictable - std::uniform_int_distribution distrib(0, 255); - for (std::size_t i = 0; i < shape_size(input_shape); i++) - input_img[i] = static_cast(distrib(random)); - - function = create_simple_function(element::u8, model_shape); - - inputData.clear(); - - auto p = PrePostProcessor(function); - p.input().tensor().set_color_format(ColorFormat::RGB); - p.input().preprocess().convert_color(ColorFormat::GRAY); - function = p.build(); - - const auto& param = function->get_parameters()[0]; - inputData.emplace_back(param->get_element_type(), param->get_shape(), input_img.data()); - - // Calculate reference expected values from OpenCV - cv::Mat cvPic = cv::Mat(input_height, input_width, CV_8UC3, input_img.data()); - cv::Mat picGRAY; - cv::cvtColor(cvPic, picGRAY, CV_RGB2GRAY); - refOutData.emplace_back(param->get_element_type(), model_shape, picGRAY.data); - // Exec now - Exec(); -} - -TEST_F(PreprocessOpenCVReferenceTest_8U, convert_bgr_gray_u8) { - const size_t input_height = 50; - const size_t input_width = 50; - auto input_shape = Shape{1, input_height, input_width, 3}; - auto model_shape = Shape{1, input_height, input_width, 1}; - - auto input_img = std::vector(shape_size(input_shape)); - std::default_random_engine random(0); // hard-coded seed to make test results predictable - std::uniform_int_distribution distrib(0, 255); - for (std::size_t i = 0; i < shape_size(input_shape); i++) - input_img[i] = static_cast(distrib(random)); - - function = create_simple_function(element::u8, model_shape); - - inputData.clear(); - - auto p = PrePostProcessor(function); - p.input().tensor().set_color_format(ColorFormat::BGR); - p.input().preprocess().convert_color(ColorFormat::GRAY); - function = p.build(); - - const auto& param = function->get_parameters()[0]; - inputData.emplace_back(param->get_element_type(), param->get_shape(), input_img.data()); - - // Calculate reference expected values from OpenCV - cv::Mat cvPic = cv::Mat(input_height, input_width, CV_8UC3, input_img.data()); - cv::Mat picGRAY; - cv::cvtColor(cvPic, picGRAY, CV_BGR2GRAY); - refOutData.emplace_back(param->get_element_type(), model_shape, picGRAY.data); - - // Exec now - Exec(); -} - -TEST_F(PreprocessOpenCVReferenceTest_8U, convert_i420_full_color_range) { - size_t height = 64; // 64/2 = 32 values for R - size_t width = 64; // 64/2 = 32 values for G - int b_step = 5; - int b_dim = 255 / b_step + 1; - - // Test various possible r/g/b values within dimensions - auto ov20_input_yuv = LayerTestsDefinitions::I420TestUtils::color_test_image(height, width, b_step); - - auto full_height = height * b_dim; - auto func_shape = Shape{1, full_height, width, 3}; - function = create_simple_function(element::u8, func_shape); - - inputData.clear(); - - auto p = PrePostProcessor(function); - p.input().tensor().set_color_format(ColorFormat::I420_SINGLE_PLANE); - p.input().preprocess().convert_color(ColorFormat::BGR); - function = p.build(); - - const auto& param = function->get_parameters()[0]; - inputData.emplace_back(param->get_element_type(), param->get_shape(), ov20_input_yuv.data()); - - // Calculate reference expected values from OpenCV - cv::Mat picYV12 = - cv::Mat(static_cast(full_height) * 3 / 2, static_cast(width), CV_8UC1, ov20_input_yuv.data()); - cv::Mat picBGR; - cv::cvtColor(picYV12, picBGR, CV_YUV2BGR_I420); - refOutData.emplace_back(param->get_element_type(), func_shape, picBGR.data); - - // Exec now - Exec(); -} - -TEST_F(PreprocessOpenCVReferenceTest_8U, convert_nv12_full_color_range) { - size_t height = 64; // 64/2 = 32 values for R - size_t width = 64; // 64/2 = 32 values for G - int b_step = 5; - int b_dim = 255 / b_step + 1; - - // Test various possible r/g/b values within dimensions - auto ov20_input_yuv = LayerTestsDefinitions::NV12TestUtils::color_test_image(height, width, b_step); - - auto full_height = height * b_dim; - auto func_shape = Shape{1, full_height, width, 3}; - function = create_simple_function(element::u8, func_shape); - - inputData.clear(); - - auto p = PrePostProcessor(function); - p.input().tensor().set_color_format(ColorFormat::NV12_SINGLE_PLANE); - p.input().preprocess().convert_color(ColorFormat::BGR); - function = p.build(); - - const auto& param = function->get_parameters()[0]; - inputData.emplace_back(param->get_element_type(), param->get_shape(), ov20_input_yuv.data()); - - // Calculate reference expected values from OpenCV - cv::Mat picYV12 = - cv::Mat(static_cast(full_height) * 3 / 2, static_cast(width), CV_8UC1, ov20_input_yuv.data()); - cv::Mat picBGR; - cv::cvtColor(picYV12, picBGR, CV_YUV2BGR_NV12); - refOutData.emplace_back(param->get_element_type(), func_shape, picBGR.data); - - // Exec now - Exec(); -} - -TEST_F(PreprocessOpenCVReferenceTest_8U, convert_nv12_colored) { - auto input_yuv = std::vector{235, 81, 235, 81, 109, 184}; - auto func_shape = Shape{1, 2, 2, 3}; - function = create_simple_function(element::u8, func_shape); - - inputData.clear(); - - auto p = PrePostProcessor(function); - p.input().tensor().set_color_format(ColorFormat::NV12_SINGLE_PLANE); - p.input().preprocess().convert_color(ColorFormat::BGR); - function = p.build(); - - const auto& param = function->get_parameters()[0]; - inputData.emplace_back(param->get_element_type(), param->get_shape(), input_yuv.data()); - - // Calculate reference expected values from OpenCV - cv::Mat picYV12 = cv::Mat(3, 2, CV_8UC1, input_yuv.data()); - cv::Mat picBGR; - cv::cvtColor(picYV12, picBGR, CV_YUV2BGR_NV12); - refOutData.emplace_back(param->get_element_type(), func_shape, picBGR.data); - // Exec now - Exec(); -} - -TEST_F(PreprocessOpenCVReferenceTest, resize_u8_simple_linear) { - auto input_shape = Shape{1, 1, 2, 2}; - auto func_shape = Shape{1, 1, 1, 1}; - auto input_img = std::vector{5, 5, 5, 4}; - function = create_simple_function(element::u8, func_shape); - - inputData.clear(); - - auto p = PrePostProcessor(function); - p.input().tensor().set_spatial_static_shape(2, 2); - p.input().preprocess().resize(ResizeAlgorithm::RESIZE_LINEAR); - p.input().model().set_layout("NCHW"); - function = p.build(); - - const auto& param = function->get_parameters()[0]; - inputData.emplace_back(param->get_element_type(), param->get_shape(), input_img.data()); - - // Calculate reference expected values from OpenCV - cv::Mat cvPic = cv::Mat(2, 2, CV_8UC1, input_img.data()); - cv::Mat cvPicResized; - cv::resize(cvPic, cvPicResized, cv::Size(1, 1), cv::INTER_NEAREST); - refOutData.emplace_back(param->get_element_type(), func_shape, cvPicResized.data); - // Exec now - Exec(); -} - -TEST_F(PreprocessOpenCVReferenceTest_8U, resize_u8_large_picture_linear) { - const size_t input_height = 50; - const size_t input_width = 50; - const size_t func_height = 37; - const size_t func_width = 31; - auto input_shape = Shape{1, 1, input_height, input_width}; - auto func_shape = Shape{1, 1, func_height, func_width}; - auto input_img = std::vector(shape_size(input_shape)); - std::default_random_engine random(0); // hard-coded seed to make test results predictable - std::uniform_int_distribution distrib(0, 255); - for (std::size_t i = 0; i < shape_size(input_shape); i++) { - auto v = distrib(random); - input_img[i] = static_cast(v); - } - function = create_simple_function(element::u8, func_shape); - - inputData.clear(); - - auto p = PrePostProcessor(function); - p.input().tensor().set_spatial_static_shape(input_height, input_width); - p.input().preprocess().resize(ResizeAlgorithm::RESIZE_LINEAR); - p.input().model().set_layout("NCHW"); - function = p.build(); - - const auto& param = function->get_parameters()[0]; - inputData.emplace_back(param->get_element_type(), param->get_shape(), input_img.data()); - - // Calculate reference expected values from OpenCV - cv::Mat cvPic = cv::Mat(input_height, input_width, CV_8UC1, input_img.data()); - cv::Mat cvPicResized; - cv::resize(cvPic, cvPicResized, cv::Size(func_width, func_height), cv::INTER_LINEAR_EXACT); - refOutData.emplace_back(param->get_element_type(), func_shape, cvPicResized.data); - // Exec now - Exec(); -} - -TEST_F(PreprocessOpenCVReferenceTest, resize_f32_large_picture_linear) { - threshold = 0.01f; - abs_threshold = 0.01f; - const size_t input_height = 50; - const size_t input_width = 50; - const size_t func_height = 37; - const size_t func_width = 31; - auto input_shape = Shape{1, 1, input_height, input_width}; - auto func_shape = Shape{1, 1, func_height, func_width}; - auto input_img = std::vector(shape_size(input_shape)); - std::default_random_engine random(0); // hard-coded seed to make test results predictable - std::uniform_int_distribution distrib(0, 255); - for (std::size_t i = 0; i < shape_size(input_shape); i++) { - input_img[i] = static_cast(distrib(random)); - } - function = create_simple_function(element::f32, func_shape); - - inputData.clear(); - - auto p = PrePostProcessor(function); - p.input().tensor().set_spatial_static_shape(input_height, input_width); - p.input().preprocess().resize(ResizeAlgorithm::RESIZE_LINEAR); - p.input().model().set_layout("NCHW"); - function = p.build(); - - const auto& param = function->get_parameters()[0]; - inputData.emplace_back(param->get_element_type(), param->get_shape(), input_img.data()); - - // Calculate reference expected values from OpenCV - cv::Mat cvPic = cv::Mat(input_height, input_width, CV_32FC1, input_img.data()); - cv::Mat cvPicResized; - cv::resize(cvPic, cvPicResized, cv::Size(func_width, func_height), cv::INTER_LINEAR_EXACT); - refOutData.emplace_back(param->get_element_type(), func_shape, cvPicResized.data); - // Exec now - Exec(); -} - -TEST_F(PreprocessOpenCVReferenceTest, DISABLED_resize_f32_large_picture_cubic_small) { - const size_t input_height = 4; - const size_t input_width = 4; - const size_t func_height = 3; - const size_t func_width = 3; - auto input_shape = Shape{1, 1, input_height, input_width}; - auto func_shape = Shape{1, 1, func_height, func_width}; - auto element_type = element::f32; - auto input_img = std::vector{1.f, 2.f, 3.f, 4.f, 4.f, 3.f, 2.f, 1.f, 1.f, 2.f, 3.f, 4.f, 4.f, 3.f, 2.f, 1.f}; - function = create_simple_function(element_type, func_shape); - auto p = PrePostProcessor(function); - p.input().tensor().set_spatial_static_shape(input_height, input_width); - p.input().preprocess().resize(ResizeAlgorithm::RESIZE_CUBIC); - p.input().model().set_layout("NCHW"); - function = p.build(); - - inputData.emplace_back(element_type, input_shape, input_img.data()); - - // Calculate reference expected values from OpenCV - cv::Mat cvPic = cv::Mat(input_height, input_width, CV_32FC1, input_img.data()); - cv::Mat cvPicResized; - cv::resize(cvPic, cvPicResized, cv::Size(func_width, func_height), cv::INTER_CUBIC); - refOutData.emplace_back(element_type, func_shape, cvPicResized.data); - // Exec now - Exec(); -} - -#endif // OPENCV_TEMPLATE_TESTS diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/CMakeLists.txt b/src/tests/functional/plugin/conformance/subgraphs_dumper/CMakeLists.txt index 53af2c311509a3..5ae02b45468b2f 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/CMakeLists.txt +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/CMakeLists.txt @@ -7,6 +7,7 @@ set(TARGET_NAME ov_subgraphs_dumper) list(APPEND LIBRARIES gflags op_conformance_utils + openvino::core::dev ) # add subgraphs_dumpers tool diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/include/utils/node.hpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/include/utils/node.hpp index 6b9baa9e34a061..cc44b5a94d5201 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/include/utils/node.hpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/include/utils/node.hpp @@ -10,6 +10,7 @@ #include "openvino/openvino.hpp" #include "openvino/op/util/op_types.hpp" +#include "openvino/op/constant.hpp" namespace ov { namespace util { diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/utils/node.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/utils/node.cpp index 5139e3b62c2c56..29fad4668db272 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/utils/node.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/utils/node.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 #include "utils/node.hpp" +#include "validation_util.hpp" namespace ov { namespace util { @@ -116,9 +117,7 @@ std::shared_ptr clone_node(std::shared_ptr node, for (size_t i = 0; i < node->get_input_size(); ++i) { std::string input_name = node_name + "_" + std::to_string(i); // todo: replace deprecated code && remove this w/a for constant size - OPENVINO_SUPPRESS_DEPRECATED_START - const auto constant_input = ov::get_constant_from_source(node->input(i).get_source_output()); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto constant_input = ov::util::get_constant_from_source(node->input(i).get_source_output()); if (constant_input) { if (is_save_const || constant_input->get_byte_size() < 1024) { auto in_const = std::make_shared(constant_input->get_element_type(), diff --git a/src/tests/functional/plugin/conformance/test_runner/api_conformance_runner/src/core_config.cpp b/src/tests/functional/plugin/conformance/test_runner/api_conformance_runner/src/core_config.cpp index 4191dd7116e983..47939f62202dde 100644 --- a/src/tests/functional/plugin/conformance/test_runner/api_conformance_runner/src/core_config.cpp +++ b/src/tests/functional/plugin/conformance/test_runner/api_conformance_runner/src/core_config.cpp @@ -2,16 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "functional_test_utils/core_config.hpp" #include "common_test_utils/file_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" #include "openvino/util/file_util.hpp" #include "conformance.hpp" -// todo: remove as LayerTestBase will be removed -void CoreConfiguration(LayerTestsUtils::LayerTestsCommon* test) {} - namespace ov { namespace test { diff --git a/src/tests/functional/plugin/conformance/test_runner/api_conformance_runner/src/ov_executable_network/exec_network_base.cpp b/src/tests/functional/plugin/conformance/test_runner/api_conformance_runner/src/ov_executable_network/exec_network_base.cpp index b7abf26114f916..c3003fdc1c47c2 100644 --- a/src/tests/functional/plugin/conformance/test_runner/api_conformance_runner/src/ov_executable_network/exec_network_base.cpp +++ b/src/tests/functional/plugin/conformance/test_runner/api_conformance_runner/src/ov_executable_network/exec_network_base.cpp @@ -3,7 +3,6 @@ // #include "behavior/compiled_model/compiled_model_base.hpp" -#include "ie_plugin_config.hpp" #include "ov_api_conformance_helpers.hpp" diff --git a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/core_config.cpp b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/core_config.cpp index b572f190555828..47939f62202dde 100644 --- a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/core_config.cpp +++ b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/core_config.cpp @@ -2,16 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "functional_test_utils/core_config.hpp" #include "common_test_utils/file_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" #include "openvino/util/file_util.hpp" #include "conformance.hpp" -// todo: remove as LayerTestClass will be removed -void CoreConfiguration(LayerTestsUtils::LayerTestsCommon* test) {} - namespace ov { namespace test { diff --git a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cpp b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cpp index 0844d179ae79d7..9acf79ef199171 100644 --- a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cpp +++ b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cpp @@ -2074,6 +2074,7 @@ OpGenerator getOpGeneratorMap() { #include "openvino/opsets/opset11_tbl.hpp" #include "openvino/opsets/opset12_tbl.hpp" #include "openvino/opsets/opset13_tbl.hpp" +#include "openvino/opsets/opset14_tbl.hpp" #undef _OPENVINO_OP_REG }; return opGeneratorMap; diff --git a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/read_ir/read_ir.cpp b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/read_ir/read_ir.cpp index 5704638abe3094..10db7aebd9d195 100644 --- a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/read_ir/read_ir.cpp +++ b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/read_ir/read_ir.cpp @@ -312,7 +312,7 @@ std::vector ReadIRTest::calculate_refs() { size_t pos = 0; for (const auto& output : functionRefs->outputs()) { - auto out_tensor = ov::runtime::Tensor(output.get_element_type(), output.get_shape(), &ref_buffer[pos]); + auto out_tensor = ov::Tensor(output.get_element_type(), output.get_shape(), &ref_buffer[pos]); pos += out_tensor.get_byte_size(); } } diff --git a/src/tests/functional/plugin/shared/include/behavior/ov_infer_request/infer_request_dynamic.hpp b/src/tests/functional/plugin/shared/include/behavior/ov_infer_request/infer_request_dynamic.hpp index ea36010c8ba189..6c309643c99334 100644 --- a/src/tests/functional/plugin/shared/include/behavior/ov_infer_request/infer_request_dynamic.hpp +++ b/src/tests/functional/plugin/shared/include/behavior/ov_infer_request/infer_request_dynamic.hpp @@ -41,7 +41,7 @@ class OVInferRequestDynamicTests : public testing::WithParamInterface ie = utils::PluginCache::get().core(); std::shared_ptr function; diff --git a/src/tests/functional/plugin/shared/include/behavior/ov_infer_request/iteration_chaining.hpp b/src/tests/functional/plugin/shared/include/behavior/ov_infer_request/iteration_chaining.hpp index a9711fd97a7ea5..725899cd075c44 100644 --- a/src/tests/functional/plugin/shared/include/behavior/ov_infer_request/iteration_chaining.hpp +++ b/src/tests/functional/plugin/shared/include/behavior/ov_infer_request/iteration_chaining.hpp @@ -39,7 +39,7 @@ struct OVIterationChaining : public OVInferRequestTests { private: static std::shared_ptr getIterativeFunction(); - bool checkOutput(const ov::runtime::Tensor& in, const ov::runtime::Tensor& actual); + bool checkOutput(const ov::Tensor& in, const ov::Tensor& actual); }; } // namespace behavior diff --git a/src/tests/functional/plugin/shared/include/behavior/ov_plugin/core_threading.hpp b/src/tests/functional/plugin/shared/include/behavior/ov_plugin/core_threading.hpp index b7aebac307a351..5b7688b25ba75e 100644 --- a/src/tests/functional/plugin/shared/include/behavior/ov_plugin/core_threading.hpp +++ b/src/tests/functional/plugin/shared/include/behavior/ov_plugin/core_threading.hpp @@ -75,11 +75,13 @@ class CoreThreadingTestsWithCacheEnabled : public testing::WithParamInterface obj) { @@ -411,6 +413,7 @@ class CoreThreadingTestsWithIter : public testing::WithParamInterface(GetParam()); numThreads = std::get<1>(GetParam()); numIterations = std::get<2>(GetParam()); + APIBaseTest::SetUp(); } static std::string getTestCaseName(testing::TestParamInfo obj) { diff --git a/src/tests/functional/plugin/shared/include/behavior/ov_plugin/hetero_synthetic.hpp b/src/tests/functional/plugin/shared/include/behavior/ov_plugin/hetero_synthetic.hpp index 53eac08ca97ded..3d9141df798c09 100644 --- a/src/tests/functional/plugin/shared/include/behavior/ov_plugin/hetero_synthetic.hpp +++ b/src/tests/functional/plugin/shared/include/behavior/ov_plugin/hetero_synthetic.hpp @@ -55,6 +55,11 @@ class OVHeteroSyntheticTest : public testing::WithParamInterface randomMajorNodeFunctions( const std::vector()>>& builders, bool dynamic_batch = false, uint32_t seed = 0); + static std::vector withMajorNodesFunctions( + const std::function()>& builder, + const std::unordered_set& majorNodes, + bool dynamic_batch = false); + static std::vector _singleMajorNodeFunctions; static std::vector _randomMajorNodeFunctions; }; diff --git a/src/tests/functional/plugin/shared/include/behavior/ov_plugin/query_model.hpp b/src/tests/functional/plugin/shared/include/behavior/ov_plugin/query_model.hpp index 98473b6b9cad6c..ff0710e3edc9af 100644 --- a/src/tests/functional/plugin/shared/include/behavior/ov_plugin/query_model.hpp +++ b/src/tests/functional/plugin/shared/include/behavior/ov_plugin/query_model.hpp @@ -39,13 +39,6 @@ TEST_P(OVClassModelTestP, QueryModelWithKSO) { } } -TEST_P(OVClassModelTestP, ImportModelWithNullContextThrows) { - ov::Core ie = createCoreWithTemplate(); - ov::RemoteContext context; - std::istringstream stream("None"); - ASSERT_THROW(ie.import_model(stream, context, {}), ov::Exception); -} - TEST_P(OVClassQueryModelTest, QueryModelWithMatMul) { ov::Core ie = createCoreWithTemplate(); diff --git a/src/tests/functional/plugin/shared/include/execution_graph_tests/disable_lowering_precision.hpp b/src/tests/functional/plugin/shared/include/execution_graph_tests/disable_lowering_precision.hpp new file mode 100644 index 00000000000000..fa57366af0aecd --- /dev/null +++ b/src/tests/functional/plugin/shared/include/execution_graph_tests/disable_lowering_precision.hpp @@ -0,0 +1,39 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include +#include + +#include "shared_test_classes/base/layer_test_utils.hpp" +#include "ov_models/builders.hpp" + +namespace ExecutionGraphTests { + +using ExecGraphDisableLoweringPrecisionSpecificParams = std::tuple< + bool, //Disable lowering precision on device + std::string, //Target Device + ov::element::Type //Infer precision on target device +>; + +class ExecGraphDisableLoweringPrecision : public testing::WithParamInterface, + public ov::test::TestsCommon { +public: + static std::string getTestCaseName(testing::TestParamInfo obj); + +protected: + void SetUp() override; + void TearDown() override; + void create_model(); + void checkInferPrecision(); + bool disableLoweringPrecision; + std::string targetDevice; + ov::element::Type loweringPrecision; + std::shared_ptr funcPtr = nullptr; +}; + +} // namespace ExecutionGraphTests diff --git a/src/tests/functional/plugin/shared/include/low_precision_transformations/fuse_convert_transformation.hpp b/src/tests/functional/plugin/shared/include/low_precision_transformations/fuse_convert_transformation.hpp index e9480ca302253b..60017785053cc4 100644 --- a/src/tests/functional/plugin/shared/include/low_precision_transformations/fuse_convert_transformation.hpp +++ b/src/tests/functional/plugin/shared/include/low_precision_transformations/fuse_convert_transformation.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -11,8 +11,6 @@ #include "ov_lpt_models/common/fake_quantize_on_data.hpp" #include "ov_lpt_models/common/dequantization_operations.hpp" -using namespace ngraph; - namespace LayerTestsDefinitions { typedef std:: diff --git a/src/tests/functional/plugin/shared/include/low_precision_transformations/mvn_transformation.hpp b/src/tests/functional/plugin/shared/include/low_precision_transformations/mvn_transformation.hpp index fdb5677ddd601a..556c3012188922 100644 --- a/src/tests/functional/plugin/shared/include/low_precision_transformations/mvn_transformation.hpp +++ b/src/tests/functional/plugin/shared/include/low_precision_transformations/mvn_transformation.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -10,11 +10,9 @@ #include "shared_test_classes/base/low_precision_transformations/layer_transformation.hpp" #include "ov_lpt_models/common/fake_quantize_on_data.hpp" -using namespace ngraph; - namespace LayerTestsDefinitions { -typedef std::tuple MVNTransformationParams; +typedef std::tuple MVNTransformationParams; class MVNTransformation : public testing::WithParamInterface, diff --git a/src/tests/functional/plugin/shared/include/low_precision_transformations/reshape_transformation.hpp b/src/tests/functional/plugin/shared/include/low_precision_transformations/reshape_transformation.hpp index e46dd17f45c138..af82d694d41583 100644 --- a/src/tests/functional/plugin/shared/include/low_precision_transformations/reshape_transformation.hpp +++ b/src/tests/functional/plugin/shared/include/low_precision_transformations/reshape_transformation.hpp @@ -19,6 +19,7 @@ class ReshapeTransformationParam { ov::builder::subgraph::FakeQuantizeOnData fakeQuantize; std::string layerType; std::string expectedKernelType; + std::vector executionOrder; }; typedef std::tuple< diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/activation.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/activation.hpp deleted file mode 100644 index fab256e7766374..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/activation.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/activation.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(ActivationLayerTest, CompareWithRefs) { - Run(); -} - -TEST_P(ActivationParamLayerTest, CompareWithRefs) { - Run(); -} - -TEST_P(ActivationDynamicLayerTest, CompareWithRefs) { - Run(); -} - -TEST_P(ActivationLayerTest, QueryNetwork) { - QueryNetwork(); -} - -TEST_P(ActivationParamLayerTest, QueryNetwork) { - QueryNetwork(); -} - -TEST_P(ActivationDynamicLayerTest, QueryNetwork) { - QueryNetwork(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/adaptive_pooling.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/adaptive_pooling.hpp deleted file mode 100644 index 3caf98b7566cfd..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/adaptive_pooling.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/adaptive_pooling.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(AdaPoolLayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/batch_norm.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/batch_norm.hpp deleted file mode 100644 index a00d00b6a55e9b..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/batch_norm.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/batch_norm.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(BatchNormLayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/batch_to_space.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/batch_to_space.hpp deleted file mode 100644 index 8d9a51a07ed52e..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/batch_to_space.hpp +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/single_layer/batch_to_space.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(BatchToSpaceLayerTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/binary_convolution.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/binary_convolution.hpp deleted file mode 100644 index 6d76bf71a3ee66..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/binary_convolution.hpp +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/binary_convolution.hpp" - -namespace LayerTestsDefinitions { -TEST_P(BinaryConvolutionLayerTest, CompareWithRefs) { - Run(); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/broadcast.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/broadcast.hpp deleted file mode 100644 index 99093306807476..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/broadcast.hpp +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/broadcast.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(BroadcastLayerTest, CompareWithRefs) { - Run(); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/bucketize.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/bucketize.hpp deleted file mode 100644 index ec647ebc0b8076..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/bucketize.hpp +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/bucketize.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(BucketizeLayerTest, CompareWithRefs) { - Run(); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/clamp.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/clamp.hpp deleted file mode 100644 index 260e57f197731a..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/clamp.hpp +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/clamp.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(ClampLayerTest, CompareWithRefs) { - Run(); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/comparison.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/comparison.hpp deleted file mode 100644 index ef9e5cc4f0ced4..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/comparison.hpp +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -namespace LayerTestsDefinitions { - -TEST_P(ComparisonLayerTest, ComparisonTests) { - Run(); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/concat.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/concat.hpp deleted file mode 100644 index eb5d0385af59c0..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/concat.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/concat.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(ConcatLayerTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/constant.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/constant.hpp deleted file mode 100644 index a62bafd8611796..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/constant.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/constant.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(ConstantLayerTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/conversion.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/conversion.hpp deleted file mode 100644 index 924883d4ce5a26..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/conversion.hpp +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/conversion.hpp" - -namespace LayerTestsDefinitions { -TEST_P(ConversionLayerTest, CompareWithRefs) { - Run(); -}; -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/convert_color_i420.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/convert_color_i420.hpp deleted file mode 100644 index 14cbf9c7afd83d..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/convert_color_i420.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/convert_color_i420.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(ConvertColorI420LayerTest, CompareWithRefs) { - Run(); -} - -TEST_P(ConvertColorI420AccuracyTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/convert_color_nv12.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/convert_color_nv12.hpp deleted file mode 100644 index 5d876dd586eebe..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/convert_color_nv12.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/convert_color_nv12.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(ConvertColorNV12LayerTest, CompareWithRefs) { - Run(); -} - -TEST_P(ConvertColorNV12AccuracyTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/convolution.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/convolution.hpp deleted file mode 100644 index 8ca1b2e4f7e864..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/convolution.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/convolution.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(ConvolutionLayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/convolution_backprop.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/convolution_backprop.hpp deleted file mode 100644 index 2294c37ddd832d..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/convolution_backprop.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/convolution_backprop.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(ConvolutionBackpropLayerTest, CompareWithRefs) { - Run(); -} - -} diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/convolution_backprop_data.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/convolution_backprop_data.hpp deleted file mode 100644 index 6b478f796110d6..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/convolution_backprop_data.hpp +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -// DEPRECATED, can't be removed currently due to arm and kmb-plugin dependency (#55568) -#pragma once - -#include "shared_test_classes/single_layer/convolution_backprop_data.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(ConvolutionBackpropDataLayerTest, CompareWithRefs) { - Run(); -} - -} diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/ctc_greedy_decoder.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/ctc_greedy_decoder.hpp deleted file mode 100644 index 1ab7d86238bdbc..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/ctc_greedy_decoder.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/ctc_greedy_decoder.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(CTCGreedyDecoderLayerTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/ctc_greedy_decoder_seq_len.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/ctc_greedy_decoder_seq_len.hpp deleted file mode 100644 index 2ce811e192eda9..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/ctc_greedy_decoder_seq_len.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/ctc_greedy_decoder_seq_len.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(CTCGreedyDecoderSeqLenLayerTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/ctc_loss.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/ctc_loss.hpp deleted file mode 100644 index c54b3b7c42429b..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/ctc_loss.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/ctc_loss.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(CTCLossLayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/cum_sum.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/cum_sum.hpp deleted file mode 100644 index 462ba7668aa693..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/cum_sum.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/cum_sum.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(CumSumLayerTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/deformable_convolution.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/deformable_convolution.hpp deleted file mode 100644 index 0f6c7d8dce6c7f..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/deformable_convolution.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/deformable_convolution.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(DeformableConvolutionLayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/deformable_psroi_pooling.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/deformable_psroi_pooling.hpp deleted file mode 100644 index b5de0cd79147e9..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/deformable_psroi_pooling.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/deformable_psroi_pooling.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(DeformablePSROIPoolingLayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/depth_to_space.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/depth_to_space.hpp deleted file mode 100644 index 149ec97db2be40..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/depth_to_space.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/depth_to_space.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(DepthToSpaceLayerTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/detection_output.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/detection_output.hpp deleted file mode 100644 index 5b4ea932a9ae5c..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/detection_output.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/detection_output.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(DetectionOutputLayerTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/dft.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/dft.hpp deleted file mode 100644 index 5e5eeaf1e76268..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/dft.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/dft.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(DFTLayerTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/einsum.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/einsum.hpp deleted file mode 100644 index b314b540459637..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/einsum.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/einsum.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(EinsumLayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/eltwise.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/eltwise.hpp deleted file mode 100644 index 9aaafc52326c9c..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/eltwise.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -namespace ov { -namespace test { -namespace subgraph { - -TEST_P(EltwiseLayerTest, EltwiseTests) { - run(); -} - -} // namespace subgraph -} // namespace test -} // namespace ov diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/embedding_bag_offsets_sum.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/embedding_bag_offsets_sum.hpp deleted file mode 100644 index ca188d843fbd51..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/embedding_bag_offsets_sum.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/embedding_bag_offsets_sum.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(EmbeddingBagOffsetsSumLayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/embedding_bag_packed_sum.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/embedding_bag_packed_sum.hpp deleted file mode 100644 index d89e4d8d35bb0c..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/embedding_bag_packed_sum.hpp +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/embedding_bag_packed_sum.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(EmbeddingBagPackedSumLayerTest, CompareWithRefs) { - Run(); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/embedding_segments_sum.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/embedding_segments_sum.hpp deleted file mode 100644 index bc7a33d0b1145f..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/embedding_segments_sum.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/embedding_segments_sum.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(EmbeddingSegmentsSumLayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/experimental_detectron_detection_output.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/experimental_detectron_detection_output.hpp deleted file mode 100644 index 4b6e0c2fd20e2f..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/experimental_detectron_detection_output.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -namespace ov { -namespace test { -namespace subgraph { - -TEST_P(ExperimentalDetectronDetectionOutputLayerTest, ExperimentalDetectronDetectionOutputLayerTests) { - run(); -} - -} // namespace subgraph -} // namespace test -} // namespace ov diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/experimental_detectron_generate_proposals_single_image.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/experimental_detectron_generate_proposals_single_image.hpp deleted file mode 100644 index 644de35ce17ff5..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/experimental_detectron_generate_proposals_single_image.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -namespace ov { -namespace test { -namespace subgraph { - -TEST_P(ExperimentalDetectronGenerateProposalsSingleImageLayerTest, ExperimentalDetectronGenerateProposalsSingleImageLayerTests) { - run(); -} - -} // namespace subgraph -} // namespace test -} // namespace ov diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/experimental_detectron_prior_grid_generator.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/experimental_detectron_prior_grid_generator.hpp index 18a2ae23455534..c39c45e32a515c 100644 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/experimental_detectron_prior_grid_generator.hpp +++ b/src/tests/functional/plugin/shared/include/single_layer_tests/experimental_detectron_prior_grid_generator.hpp @@ -16,4 +16,4 @@ TEST_P(ExperimentalDetectronPriorGridGeneratorLayerTest, ExperimentalDetectronPr } // namespace subgraph } // namespace test -} // namespace ov +} // namespace ov \ No newline at end of file diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/experimental_detectron_roifeatureextractor.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/experimental_detectron_roifeatureextractor.hpp deleted file mode 100644 index 314c7b7e933369..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/experimental_detectron_roifeatureextractor.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -namespace ov { -namespace test { -namespace subgraph { - -TEST_P(ExperimentalDetectronROIFeatureExtractorLayerTest, ExperimentalDetectronROIFeatureExtractorTests) { - run(); -} - -} // namespace subgraph -} // namespace test -} // namespace ov diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/experimental_detectron_topkrois.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/experimental_detectron_topkrois.hpp deleted file mode 100644 index 4989f5fa545642..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/experimental_detectron_topkrois.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -namespace ov { -namespace test { -namespace subgraph { - -TEST_P(ExperimentalDetectronTopKROIsLayerTest, ExperimentalDetectronTopKROIsTests) { - run(); -} - -} // namespace subgraph -} // namespace test -} // namespace ov diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/extract_image_patches.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/extract_image_patches.hpp deleted file mode 100644 index 0ee4d9658582d1..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/extract_image_patches.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/extract_image_patches.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(ExtractImagePatchesTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/fake_quantize.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/fake_quantize.hpp deleted file mode 100644 index 70de29607d4326..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/fake_quantize.hpp +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/fake_quantize.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(FakeQuantizeLayerTest, CompareWithRefs) { - Run(); - SKIP_IF_CURRENT_TEST_IS_DISABLED(); - - if (BASE_SEED != USE_CLOCK_TIME && - BASE_SEED != USE_INCREMENTAL_SEED) { - return; - } - - size_t nIterations = 1; - for (; nIterations != 0; nIterations--) { - UpdateSeed(); - GenerateInputs(); - Infer(); - Validate(); - } -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/gather.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/gather.hpp deleted file mode 100644 index e909283ff31336..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/gather.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/gather.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(GatherLayerTest, CompareWithRefs) { - Run(); -}; - -TEST_P(Gather7LayerTest, CompareWithRefs) { - Run(); -}; - -TEST_P(Gather8LayerTest, CompareWithRefs) { - Run(); -}; - -TEST_P(Gather8IndiceScalarLayerTest, CompareWithRefs) { - Run(); -}; - -TEST_P(Gather8withIndicesDataLayerTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/gather_elements.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/gather_elements.hpp deleted file mode 100644 index e534d91c3db2b8..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/gather_elements.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/gather_elements.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(GatherElementsLayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/gather_nd.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/gather_nd.hpp deleted file mode 100644 index 696ff06165b1e8..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/gather_nd.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/gather_nd.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(GatherNDLayerTest, CompareWithRefs) { - Run(); -} - -TEST_P(GatherND8LayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/gather_tree.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/gather_tree.hpp deleted file mode 100644 index caeb462f822bd5..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/gather_tree.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/gather_tree.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(GatherTreeLayerTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/generate_proposals.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/generate_proposals.hpp deleted file mode 100644 index c1e4c78d94cb4f..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/generate_proposals.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -namespace ov { -namespace test { -namespace subgraph { - -TEST_P(GenerateProposalsLayerTest, GenerateProposalsLayerTests) { - run(); -} - -} // namespace subgraph -} // namespace test -} // namespace ov diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/grid_sample.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/grid_sample.hpp deleted file mode 100644 index a3fa38ac8d74c4..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/grid_sample.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/grid_sample.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(GridSampleLayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/grn.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/grn.hpp deleted file mode 100644 index 30d9350c5c23d5..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/grn.hpp +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/grn.hpp" - -namespace LayerTestsDefinitions { -TEST_P(GrnLayerTest, CompareWithRefs) { - Run(); -}; -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/group_convolution.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/group_convolution.hpp deleted file mode 100644 index a6b4a751ed5508..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/group_convolution.hpp +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/group_convolution.hpp" - -namespace LayerTestsDefinitions { -TEST_P(GroupConvolutionLayerTest, CompareWithRefs) { - Run(); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/group_convolution_backprop_data.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/group_convolution_backprop_data.hpp deleted file mode 100644 index 6ab5210c459e00..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/group_convolution_backprop_data.hpp +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/group_convolution_backprop_data.hpp" - -namespace LayerTestsDefinitions { - -// DEPRECATED, remove this old API when KMB (#58495) and ARM (#58496) plugins are migrated to new API -TEST_P(GroupConvBackpropDataLayerTest, CompareWithRefs) { - Run(); -} - -TEST_P(GroupConvBackpropLayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/gru_cell.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/gru_cell.hpp deleted file mode 100644 index 888ad3ad2ab75e..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/gru_cell.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/gru_cell.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(GRUCellTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/gru_sequence.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/gru_sequence.hpp deleted file mode 100644 index e1f0006f18bf2c..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/gru_sequence.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/gru_sequence.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(GRUSequenceTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/interpolate.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/interpolate.hpp deleted file mode 100644 index 38d0f270662ec9..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/interpolate.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/interpolate.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(InterpolateLayerTest, CompareWithRefs) { - Run(); -} - -using Interpolate11LayerTest = v11::InterpolateLayerTest; - -TEST_P(Interpolate11LayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/log_softmax.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/log_softmax.hpp deleted file mode 100644 index 8e587fedb918e4..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/log_softmax.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/log_softmax.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(LogSoftmaxLayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/logical.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/logical.hpp deleted file mode 100644 index 86c1700a4e488b..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/logical.hpp +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -namespace LayerTestsDefinitions { -TEST_P(LogicalLayerTest, LogicalTests) { - Run(); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/loop.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/loop.hpp deleted file mode 100644 index 7c87f19fbe7e18..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/loop.hpp +++ /dev/null @@ -1,232 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/loop.hpp" - -namespace LayerTestsDefinitions { - - -TEST_P(LoopTest, CompareWithRefs) { - SKIP_IF_CURRENT_TEST_IS_DISABLED() - Run(); -} - -TEST_P(StaticShapeLoopTest, CompareWithRefs) { - SKIP_IF_CURRENT_TEST_IS_DISABLED() - Run(); -} - -TEST_P(StaticShapeLoopTest, CompareWithPredefinedRefs) { - SKIP_IF_CURRENT_TEST_IS_DISABLED() - LoadNetwork(); - GenerateInputs(); - Infer(); - auto expectedOutputs = PredefinedRefs(); // use predefined refs instead of CalculateRefs function - const auto& actualOutputs = GetOutputs(); - - if (expectedOutputs.empty()) { - return; - } - - IE_ASSERT(actualOutputs.size() == expectedOutputs.size()) - << "nGraph interpreter has " << expectedOutputs.size() << " outputs, while IE " << actualOutputs.size(); - - Compare(expectedOutputs, actualOutputs); -} - -TEST_P(TrivialLoopTest, PassThroughBody) { - SKIP_IF_CURRENT_TEST_IS_DISABLED() - InferenceEngine::Precision iePrc; - InferenceEngine::SizeVector ieShape; - std::tie(iePrc, ieShape, targetDevice) = GetParam(); - - const auto prc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(iePrc); - const auto shape = ov::Shape{ieShape}; - const auto scalarShape = ov::Shape{}; - - auto start = std::make_shared(prc, shape); - auto count = std::make_shared(ov::element::i64, scalarShape, 5); - auto icond = std::make_shared(ov::element::boolean, scalarShape, true); - - // Loop body - auto b_data = std::make_shared(prc, shape); - auto b_cond = std::make_shared(ov::element::boolean, scalarShape); - - auto body = std::make_shared( - ov::OutputVector {b_cond, b_data}, // | passthrough body, no data changes - ov::ParameterVector {b_cond, b_data}); // | input -> output - - auto loop = std::make_shared(count, icond); - loop->set_function(body); - loop->set_special_body_ports({-1, 0}); - loop->set_invariant_input(b_cond, icond); - loop->set_invariant_input(b_data, start); - loop->get_iter_value(b_data, -1); - - function = std::make_shared( - ov::OutputVector {loop}, - ov::ParameterVector {start}); - - // Precalculated ref blobs - auto blob = make_blob_with_precision({iePrc, ieShape, InferenceEngine::TensorDesc::getLayoutByDims(ieShape)}); - blob->allocate(); - ov::test::utils::fill_data_with_broadcast(blob, 0, {10}); - - inputGens[""] = [&] (InferenceEngine::TensorDesc tdesc) { return blob; }; - outputGens[""] = [&] (InferenceEngine::TensorDesc tdesc) { return blob; }; - - Run(); -} - -TEST_P(TrivialLoopTest, UnusedInputBody) { - SKIP_IF_CURRENT_TEST_IS_DISABLED() - InferenceEngine::Precision iePrc; - InferenceEngine::SizeVector ieShape; - std::tie(iePrc, ieShape, targetDevice) = GetParam(); - - const auto prc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(iePrc); - const auto shape = ov::Shape{ieShape}; - const auto scalarShape = ov::Shape{}; - - auto start = std::make_shared(prc, shape); - auto count = std::make_shared(ov::element::i64, scalarShape, 5); - auto icond = std::make_shared(ov::element::boolean, scalarShape, true); - - // Loop body - auto b_data = std::make_shared(prc, shape); - auto b_cond = std::make_shared(ov::element::boolean, scalarShape, true); - auto b_iter = std::make_shared(ov::element::i64, scalarShape); - - auto body = std::make_shared( - ov::OutputVector {b_cond, b_data}, - ov::ParameterVector {b_data, b_iter}); - - auto loop = std::make_shared(count, icond); - loop->set_function(body); - loop->set_special_body_ports({1, 0}); - loop->set_invariant_input(b_data, start); - loop->get_iter_value(b_data, -1); - - function = std::make_shared( - ov::OutputVector {loop}, - ov::ParameterVector {start}); - - // Precalculated ref blobs - auto blob = make_blob_with_precision({iePrc, ieShape, InferenceEngine::TensorDesc::getLayoutByDims(ieShape)}); - blob->allocate(); - ov::test::utils::fill_data_with_broadcast(blob, 0, {10}); - - inputGens[""] = [&] (InferenceEngine::TensorDesc tdesc) { return blob; }; - outputGens[""] = [&] (InferenceEngine::TensorDesc tdesc) { return blob; }; - - Run(); -} - - - -TEST_P(TrivialLoopTest, AutoSlicingInput_CheckPredefinedValues) { - SKIP_IF_CURRENT_TEST_IS_DISABLED() - InferenceEngine::Precision iePrc; - InferenceEngine::SizeVector ieShape; - std::tie(iePrc, ieShape, targetDevice) = GetParam(); - const size_t batch_size = 5; - const size_t num_iteration = 3; - ieShape[0] = 1; - auto ieShape_to_slice = ieShape; - ieShape_to_slice[0] = batch_size; - CreateSlicedLoop(batch_size, num_iteration, iePrc, ieShape); - Run(); - // Precalculated ref blobs - auto blob = make_blob_with_precision({iePrc, ieShape_to_slice, InferenceEngine::TensorDesc::getLayoutByDims(ieShape_to_slice)}); - blob->allocate(); - std::vector seq_raw_data(batch_size); - std::iota(seq_raw_data.begin(), seq_raw_data.end(), 1); - ov::test::utils::fill_data_with_broadcast(blob, 0, seq_raw_data); - - auto blob_ref = make_blob_with_precision({iePrc, ieShape, InferenceEngine::TensorDesc::getLayoutByDims(ieShape)}); - blob_ref->allocate(); - ov::test::utils::fill_data_with_broadcast(blob_ref, 0, { num_iteration * (num_iteration + 1) / 2}); - - inputGens[""] = [&] (InferenceEngine::TensorDesc tdesc) { return blob; }; - outputGens[""] = [&] (InferenceEngine::TensorDesc tdesc) { return blob_ref; }; -} - -TEST_P(TrivialLoopTest, AutoSlicingInputWithDynCondition_CheckPredefinedValues) { - SKIP_IF_CURRENT_TEST_IS_DISABLED() - InferenceEngine::Precision iePrc; - InferenceEngine::SizeVector ieShape; - std::tie(iePrc, ieShape, targetDevice) = GetParam(); - - // auto slicing size : 5 - // trip count limit : 4 - // dyn exit after iter : 3 - // --------------------- - // should exit after 4 iterations - const size_t batch_size = 5; - const size_t trip_count = 5; - const size_t num_iteration = 3; - - ieShape[0] = 1; - auto ieShape_to_slice = ieShape; - ieShape_to_slice[0] = batch_size; - - CreateSlicedLoopDynCondition(batch_size, num_iteration, iePrc, ieShape, trip_count); - // Precalculated ref blobs - auto blob = make_blob_with_precision({iePrc, ieShape_to_slice, InferenceEngine::TensorDesc::getLayoutByDims(ieShape_to_slice)}); - blob->allocate(); - std::vector seq_raw_data(batch_size); - std::iota(seq_raw_data.begin(), seq_raw_data.end(), 1); - ov::test::utils::fill_data_with_broadcast(blob, 0, seq_raw_data); - - auto blob_ref = make_blob_with_precision({iePrc, ieShape, InferenceEngine::TensorDesc::getLayoutByDims(ieShape)}); - blob_ref->allocate(); - const size_t real_iter = num_iteration + 1; - ov::test::utils::fill_data_with_broadcast(blob_ref, 0, { real_iter * (real_iter + 1) / 2}); - - inputGens[""] = [&] (InferenceEngine::TensorDesc tdesc) { return blob; }; - outputGens[""] = [&] (InferenceEngine::TensorDesc tdesc) { return blob_ref; }; - - Run(); -} - -TEST_P(TrivialLoopTest, AutoSlicingInput_CheckReference) { - SKIP_IF_CURRENT_TEST_IS_DISABLED() - InferenceEngine::Precision iePrc; - InferenceEngine::SizeVector ieShape; - std::tie(iePrc, ieShape, targetDevice) = GetParam(); - const size_t batch_size = 5; - const size_t num_iteration = 3; - ieShape[0] = 1; - auto ieShape_to_slice = ieShape; - ieShape_to_slice[0] = batch_size; - CreateSlicedLoop(batch_size, num_iteration, iePrc, ieShape); - Run(); -} - -TEST_P(TrivialLoopTest, AutoSlicingInputWithDynCondition_CheckReference) { - SKIP_IF_CURRENT_TEST_IS_DISABLED() - InferenceEngine::Precision iePrc; - InferenceEngine::SizeVector ieShape; - std::tie(iePrc, ieShape, targetDevice) = GetParam(); - - // auto slicing size : 5 - // trip count limit : 4 - // dyn exit after iter : 3 - // --------------------- - // should exit after 4 iterations - const size_t batch_size = 5; - const size_t trip_count = 5; - const size_t num_iteration = 3; - - ieShape[0] = 1; - auto ieShape_to_slice = ieShape; - ieShape_to_slice[0] = batch_size; - - CreateSlicedLoopDynCondition(batch_size, num_iteration, iePrc, ieShape, trip_count); - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/low_precision.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/low_precision.hpp deleted file mode 100644 index f68deb3e73ebb6..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/low_precision.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/low_precision.hpp" - -namespace LowPrecisionTestDefinitions { - - TEST_P(LowPrecisionTest, CompareWithRefs) { - Run(); - } - -} // namespace LowPrecisionTestDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/lrn.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/lrn.hpp deleted file mode 100644 index f49c8f83f00755..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/lrn.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/lrn.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(LrnLayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/lstm_cell.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/lstm_cell.hpp deleted file mode 100644 index dd409653f5cbe0..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/lstm_cell.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/lstm_cell.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(LSTMCellTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/lstm_cell_basic.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/lstm_cell_basic.hpp deleted file mode 100644 index b39ef46ef8165f..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/lstm_cell_basic.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/lstm_cell_basic.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(LSTMCellBasicTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/lstm_sequence.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/lstm_sequence.hpp deleted file mode 100644 index 4a63aef30d47c1..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/lstm_sequence.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/lstm_sequence.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(LSTMSequenceTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/mat_mul.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/mat_mul.hpp deleted file mode 100644 index 310f30433410a3..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/mat_mul.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/mat_mul.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(MatMulTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/matrix_nms.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/matrix_nms.hpp deleted file mode 100644 index b10864baeb0df2..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/matrix_nms.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/matrix_nms.hpp" - -namespace ov { -namespace test { -namespace subgraph { - -TEST_P(MatrixNmsLayerTest, CompareWithRefs) { - run(); -}; - -} // namespace subgraph -} // namespace test -} // namespace ov diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/memory.h b/src/tests/functional/plugin/shared/include/single_layer_tests/memory.h deleted file mode 100644 index de5c01f78708fc..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/memory.h +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/memory.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(MemoryTest, CompareWithRefs) { - Run(); -}; - -TEST_P(MemoryTestV3, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/minimum_maximum.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/minimum_maximum.hpp deleted file mode 100644 index e04801e2b4315a..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/minimum_maximum.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/minimum_maximum.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(MaxMinLayerTest, CompareWithRefs){ - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/multiclass_nms.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/multiclass_nms.hpp deleted file mode 100644 index bb981de0355afc..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/multiclass_nms.hpp +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/multiclass_nms.hpp" - -namespace ov { -namespace test { -namespace subgraph { - -TEST_P(MulticlassNmsLayerTest, CompareWithRefs) { - run(); -}; - -TEST_P(MulticlassNmsLayerTest8, CompareWithRefs) { - run(); -}; - -} // namespace subgraph -} // namespace test -} // namespace ov diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/multinomial.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/multinomial.hpp deleted file mode 100644 index 1f1a04a2973dc3..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/multinomial.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// -#pragma once -#include "shared_test_classes/single_layer/multinomial.hpp" - -namespace ov { -namespace test { -namespace subgraph { - -TEST_P(MultinomialTest, CompareWithRefs) { - run(); -} - -TEST_P(MultinomialTest, CompareQueryModel) { - query_model(); -} - -} // namespace subgraph -} // namespace test -} // namespace ov diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/mvn.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/mvn.hpp deleted file mode 100644 index adbabbe5daacea..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/mvn.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/mvn.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(Mvn1LayerTest, CompareWithRefs) { - Run(); -}; - -TEST_P(Mvn6LayerTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/nms_rotated.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/nms_rotated.hpp deleted file mode 100644 index d02a115acaeb18..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/nms_rotated.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/nms_rotated.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(NmsRotatedLayerTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/non_max_suppression.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/non_max_suppression.hpp deleted file mode 100644 index 9e65aa030b7283..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/non_max_suppression.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/non_max_suppression.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(NmsLayerTest, CompareWithRefs) { - Run(); -}; - -TEST_P(Nms9LayerTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/nonzero.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/nonzero.hpp deleted file mode 100644 index 6cd8a15fc849f0..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/nonzero.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/nonzero.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(NonZeroLayerTest, CompareWithReference) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/normalize_l2.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/normalize_l2.hpp deleted file mode 100644 index 2f5ba8f540f2de..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/normalize_l2.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/normalize_l2.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(NormalizeL2LayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/one_hot.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/one_hot.hpp deleted file mode 100644 index fb41e10760e50a..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/one_hot.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/one_hot.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(OneHotLayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/pad.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/pad.hpp deleted file mode 100644 index 8bdf9a3d2c283c..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/pad.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/pad.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(PadLayerTest, CompareWithRefs) { - Run(); -} - -TEST_P(PadLayerTest12, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/pooling.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/pooling.hpp deleted file mode 100644 index a28f149673ecff..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/pooling.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/pooling.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(PoolingLayerTest, CompareWithRefs) { - Run(); -} - -TEST_P(GlobalPoolingLayerTest, CompareWithRefs) { - Run(); - - if (targetDevice == std::string{ov::test::utils::DEVICE_GPU}) { - PluginCache::get().reset(); - } -} - -TEST_P(MaxPoolingV8LayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/power.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/power.hpp deleted file mode 100644 index 65c40119408db6..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/power.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/power.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(PowerLayerTest, CompareWithRefs){ - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/prior_box.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/prior_box.hpp deleted file mode 100644 index 3a896e00c535fe..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/prior_box.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/prior_box.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(PriorBoxLayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/prior_box_clustered.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/prior_box_clustered.hpp deleted file mode 100644 index 1c218adea0dc06..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/prior_box_clustered.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/prior_box_clustered.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(PriorBoxClusteredLayerTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/proposal.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/proposal.hpp deleted file mode 100644 index 25cbf26bc4f9e3..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/proposal.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/proposal.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(ProposalLayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/psroi_pooling.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/psroi_pooling.hpp deleted file mode 100644 index 0c97a47860ccd5..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/psroi_pooling.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/psroi_pooling.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(PSROIPoolingLayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/random_uniform.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/random_uniform.hpp deleted file mode 100644 index 6198c19ed13359..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/random_uniform.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/random_uniform.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(RandomUniformLayerTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/range.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/range.hpp deleted file mode 100644 index ec3bd867346620..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/range.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/range.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(RangeNumpyLayerTest, CompareWithRefs) { - Run(); -} - -TEST_P(RangeLayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/rdft.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/rdft.hpp deleted file mode 100644 index c936ef55bc7dc4..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/rdft.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/rdft.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(RDFTLayerTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/reduce_ops.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/reduce_ops.hpp deleted file mode 100644 index d7f925e37f1622..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/reduce_ops.hpp +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/reduce_ops.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(ReduceOpsLayerTest, CompareWithRefs) { - Run(); -} - -TEST_P(ReduceOpsLayerWithSpecificInputTest, CompareWithRefs) { - Run(); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/region_yolo.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/region_yolo.hpp deleted file mode 100644 index ee559ca31265b9..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/region_yolo.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/region_yolo.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(RegionYoloLayerTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/reorg_yolo.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/reorg_yolo.hpp deleted file mode 100644 index 8ac3830e93cb97..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/reorg_yolo.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/reorg_yolo.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(ReorgYoloLayerTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/reshape.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/reshape.hpp deleted file mode 100644 index 8d92717a716877..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/reshape.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/reshape.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(ReshapeLayerTest, CompareWithRefsDynamicBath) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/result.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/result.hpp deleted file mode 100644 index 877fab2a9a3192..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/result.hpp +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include - -#include "shared_test_classes/single_layer/result.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(ResultLayerTest, CompareWithRefs) { - Run(); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/reverse.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/reverse.hpp deleted file mode 100644 index 15ff7048caf5d9..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/reverse.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/reverse.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(ReverseLayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/reverse_sequence.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/reverse_sequence.hpp deleted file mode 100644 index 8765bedfd34f2a..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/reverse_sequence.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/reverse_sequence.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(ReverseSequenceLayerTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/rnn_cell.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/rnn_cell.hpp deleted file mode 100644 index 75cb907d8f9d13..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/rnn_cell.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/rnn_cell.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(RNNCellTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/rnn_sequence.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/rnn_sequence.hpp deleted file mode 100644 index 50e98e9fae81fb..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/rnn_sequence.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/rnn_sequence.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(RNNSequenceTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/roi_align.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/roi_align.hpp deleted file mode 100644 index 465f3b72845dac..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/roi_align.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/roi_align.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(ROIAlignLayerTest, CompareWithRefs) { - Run(); -} - -TEST_P(ROIAlignV9LayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/roi_pooling.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/roi_pooling.hpp deleted file mode 100644 index 1979dfb6a9a8c5..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/roi_pooling.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/roi_pooling.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(ROIPoolingLayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/roll.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/roll.hpp deleted file mode 100644 index 965ff6f636794c..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/roll.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/roll.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(RollLayerTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/scatter_ND_update.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/scatter_ND_update.hpp deleted file mode 100644 index 01fc31d17fe6c8..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/scatter_ND_update.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/scatter_ND_update.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(ScatterNDUpdateLayerTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/scatter_elements_update.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/scatter_elements_update.hpp deleted file mode 100644 index bb3b3ad153d5fe..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/scatter_elements_update.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/scatter_elements_update.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(ScatterElementsUpdateLayerTest, CompareWithRefs) { - Run(); -}; - -TEST_P(ScatterElementsUpdate12LayerTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/scatter_update.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/scatter_update.hpp deleted file mode 100644 index 8c9cfa482a7994..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/scatter_update.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/scatter_update.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(ScatterUpdateLayerTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/select.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/select.hpp deleted file mode 100644 index 1ad9e07d9c617f..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/select.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/select.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(SelectLayerTest, CompareWithRefImpl) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/shape_of.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/shape_of.hpp deleted file mode 100644 index 758a93d9f51f0b..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/shape_of.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/shape_of.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(ShapeOfLayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/shuffle_channels.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/shuffle_channels.hpp deleted file mode 100644 index 7d7f6ab29c32e2..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/shuffle_channels.hpp +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/shuffle_channels.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(ShuffleChannelsLayerTest, CompareWithRefs) { - Run(); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/slice.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/slice.hpp deleted file mode 100644 index 41d553c12d8635..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/slice.hpp +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/slice.hpp" - -namespace LayerTestsDefinitions { -TEST_P(Slice8LayerTest, CompareWithRefs) { - run(); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/softmax.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/softmax.hpp index 25214ffcd0bdb8..5bb173a87d4be9 100644 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/softmax.hpp +++ b/src/tests/functional/plugin/shared/include/single_layer_tests/softmax.hpp @@ -4,28 +4,5 @@ #pragma once -#include "shared_test_classes/single_op/softmax.hpp" - -namespace ov { -namespace test { -namespace subgraph { - -TEST_P(SoftMaxLayerTest, CompareWithRefs) { - run(); -} - -TEST_P(SoftMaxLayerTest, CompareQueryModel) { - query_model(); -} - -TEST_P(SoftMax8LayerTest, CompareWithRefs) { - run(); -} - -TEST_P(SoftMax8LayerTest, CompareQueryModel) { - query_model(); -} - -} // namespace subgraph -} // namespace test -} // namespace ov +// TODO (vurusovs): for NPU compatibility. Remove after fix on NPU side +#include "single_op_tests/softmax.hpp" \ No newline at end of file diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/space_to_batch.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/space_to_batch.hpp deleted file mode 100644 index 3d7bf5fd8e9d1e..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/space_to_batch.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/space_to_batch.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(SpaceToBatchLayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/space_to_depth.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/space_to_depth.hpp deleted file mode 100644 index 5d5eb94b3e73c9..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/space_to_depth.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/space_to_depth.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(SpaceToDepthLayerTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/split.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/split.hpp deleted file mode 100644 index 06ef1c2d1b3c99..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/split.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/split.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(SplitLayerTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/squeeze_unsqueeze.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/squeeze_unsqueeze.hpp deleted file mode 100644 index 021f0d4c12b988..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/squeeze_unsqueeze.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/squeeze_unsqueeze.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(SqueezeUnsqueezeLayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/strided_slice.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/strided_slice.hpp deleted file mode 100644 index 10cc8ba8131a20..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/strided_slice.hpp +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/strided_slice.hpp" - -namespace LayerTestsDefinitions { -TEST_P(StridedSliceLayerTest, CompareWithRefs) { - Run(); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/tensor_iterator.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/tensor_iterator.hpp deleted file mode 100644 index c2187e2da69c94..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/tensor_iterator.hpp +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/tensor_iterator.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(TensorIteratorTest, CompareWithRefs) { - Run(); -}; -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/tile.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/tile.hpp deleted file mode 100644 index 6dbffae2d24e8c..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/tile.hpp +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/tile.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(TileLayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions - diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/topk.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/topk.hpp deleted file mode 100644 index 16d8dc09c19ed3..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/topk.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/topk.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(TopKLayerTest, CompareWithRefsDynamicBath) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/transpose.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/transpose.hpp deleted file mode 100644 index 0e44f8ca9dede8..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/transpose.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/transpose.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(TransposeLayerTest, CompareWithRefs) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/variadic_split.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/variadic_split.hpp deleted file mode 100644 index 557f3b65c62bd5..00000000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/variadic_split.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/single_layer/variadic_split.hpp" - -namespace LayerTestsDefinitions { - -TEST_P(VariadicSplitLayerTest, CompareWithRefs) { - Run(); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/group_normalization.hpp b/src/tests/functional/plugin/shared/include/single_op_tests/group_normalization.hpp similarity index 72% rename from src/tests/functional/plugin/shared/include/single_layer_tests/group_normalization.hpp rename to src/tests/functional/plugin/shared/include/single_op_tests/group_normalization.hpp index 8f080764adbced..a7887c22dafebe 100644 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/group_normalization.hpp +++ b/src/tests/functional/plugin/shared/include/single_op_tests/group_normalization.hpp @@ -2,11 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // #pragma once -#include "shared_test_classes/single_layer/group_normalization.hpp" +#include "shared_test_classes/single_op/group_normalization.hpp" namespace ov { namespace test { -namespace subgraph { TEST_P(GroupNormalizationTest, CompareWithRefs) { run(); @@ -16,6 +15,5 @@ TEST_P(GroupNormalizationTest, CompareQueryModel) { query_model(); } -} // namespace subgraph } // namespace test } // namespace ov diff --git a/src/tests/functional/plugin/shared/include/single_op_tests/softmax.hpp b/src/tests/functional/plugin/shared/include/single_op_tests/softmax.hpp new file mode 100644 index 00000000000000..25214ffcd0bdb8 --- /dev/null +++ b/src/tests/functional/plugin/shared/include/single_op_tests/softmax.hpp @@ -0,0 +1,31 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/single_op/softmax.hpp" + +namespace ov { +namespace test { +namespace subgraph { + +TEST_P(SoftMaxLayerTest, CompareWithRefs) { + run(); +} + +TEST_P(SoftMaxLayerTest, CompareQueryModel) { + query_model(); +} + +TEST_P(SoftMax8LayerTest, CompareWithRefs) { + run(); +} + +TEST_P(SoftMax8LayerTest, CompareQueryModel) { + query_model(); +} + +} // namespace subgraph +} // namespace test +} // namespace ov diff --git a/src/tests/functional/plugin/shared/include/single_op_tests/topk.hpp b/src/tests/functional/plugin/shared/include/single_op_tests/topk.hpp index 214286ec996802..9e061f454ebc26 100644 --- a/src/tests/functional/plugin/shared/include/single_op_tests/topk.hpp +++ b/src/tests/functional/plugin/shared/include/single_op_tests/topk.hpp @@ -11,5 +11,9 @@ namespace test { TEST_P(TopKLayerTest, Inference) { run(); } + +TEST_P(TopK11LayerTest, Inference) { + run(); +} } // namespace test } // namespace ov diff --git a/src/tests/functional/plugin/shared/src/behavior/compiled_model/import_export.cpp b/src/tests/functional/plugin/shared/src/behavior/compiled_model/import_export.cpp index 074100be73cc2b..72be0c6bcbb0b0 100644 --- a/src/tests/functional/plugin/shared/src/behavior/compiled_model/import_export.cpp +++ b/src/tests/functional/plugin/shared/src/behavior/compiled_model/import_export.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifcorer: Apache-2.0 // - +#include #include "behavior/compiled_model/import_export.hpp" #include "common_test_utils/ov_test_utils.hpp" @@ -298,6 +298,16 @@ TEST_P(OVClassCompiledModelImportExportTestP, smoke_ImportNetworkNoThrowWithDevi OV_ASSERT_NO_THROW(executableNetwork.create_infer_request()); } +TEST_P(OVClassCompiledModelImportExportTestP, smoke_ImportNetworkThrowWithDeviceName) { + SKIP_IF_CURRENT_TEST_IS_DISABLED(); + ov::Core ie = createCoreWithTemplate(); + std::stringstream wrongStm; + // Import model with wrong format throws exception + OV_EXPECT_THROW((ie.import_model(wrongStm, target_device)), + ov::Exception, + testing::HasSubstr("device xml header")); +} + // // GetRuntimeModel // diff --git a/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/batched_tensors.cpp b/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/batched_tensors.cpp index f252aa8792f327..45df311d407153 100644 --- a/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/batched_tensors.cpp +++ b/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/batched_tensors.cpp @@ -37,7 +37,7 @@ void OVInferRequestBatchedTests::SetUp() { void OVInferRequestBatchedTests::TearDown() { if (m_need_reset_core) { - ie->set_property({{CONFIG_KEY(CACHE_DIR), {}}}); + ie->set_property({ov::cache_dir()}); ie.reset(); PluginCache::get().reset(); ov::test::utils::removeFilesWithExt(m_cache_dir, "blob"); @@ -180,7 +180,7 @@ TEST_P(OVInferRequestBatchedTests, SetInputTensorsBase_Caching) { auto batch_shape = Shape{batch, 2, 2, 2}; auto one_shape_size = ov::shape_size(one_shape); auto model = OVInferRequestBatchedTests::create_n_inputs(1, element::f32, batch_shape, "N..."); - ie->set_property({{CONFIG_KEY(CACHE_DIR), m_cache_dir}}); + ie->set_property({ov::cache_dir(m_cache_dir)}); auto execNet_no_cache = ie->compile_model(model, target_device); auto execNet_cache = ie->compile_model(model, target_device); // Allocate 8 chunks, set 'user tensors' to 0, 2, 4, 6 chunks @@ -469,7 +469,7 @@ TEST_P(OVInferRequestBatchedTests, SetInputTensors_Cache_CheckDeepCopy) { std::vector buffer(ov::shape_size(batch_shape), 1); std::vector buffer_out(ov::shape_size(batch_shape), 1); auto model = OVInferRequestBatchedTests::create_n_inputs(2, element::f32, batch_shape, "NCHW"); - ie->set_property({{CONFIG_KEY(CACHE_DIR), m_cache_dir}}); + ie->set_property({ov::cache_dir(m_cache_dir)}); auto execNet_no_cache = ie->compile_model(model, target_device); auto execNet = ie->compile_model(model, target_device); ov::InferRequest req; diff --git a/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/infer_correctness.cpp b/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/infer_correctness.cpp index 0e3e84fa317989..dbde8b3f562a37 100644 --- a/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/infer_correctness.cpp +++ b/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/infer_correctness.cpp @@ -117,7 +117,7 @@ bool OVInferConsistencyTest::IsEqual(std::vector& a, } try { // if not equal will throw exception - LayerTestsUtils::LayerTestsCommon::Compare( + ov::test::utils::compare_raw_data( a[j].data(), b[j].data(), a[j].get_size(), 1e-2f); } catch (...) { isEqual = false; diff --git a/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/infer_request_dynamic.cpp b/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/infer_request_dynamic.cpp index 7390c0726747fb..8ea45c7e788116 100644 --- a/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/infer_request_dynamic.cpp +++ b/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/infer_request_dynamic.cpp @@ -44,7 +44,7 @@ void OVInferRequestDynamicTests::SetUp() { APIBaseTest::SetUp(); } -bool OVInferRequestDynamicTests::checkOutput(const ov::runtime::Tensor& in, const ov::runtime::Tensor& actual) { +bool OVInferRequestDynamicTests::checkOutput(const ov::Tensor& in, const ov::Tensor& actual) { bool result = true; auto net = ie->compile_model(function, ov::test::utils::DEVICE_TEMPLATE); ov::InferRequest req; @@ -96,7 +96,7 @@ TEST_P(OVInferRequestDynamicTests, InferDynamicNetwork) { ov::test::utils::InputGenerateData in_data; in_data.start_from = -50; in_data.range = 100; - ov::runtime::Tensor inTensor = ov::test::utils::create_and_fill_tensor(element::f32, shape, in_data); + ov::Tensor inTensor = ov::test::utils::create_and_fill_tensor(element::f32, shape, in_data); OV_ASSERT_NO_THROW(req = execNet.create_infer_request()); OV_ASSERT_NO_THROW(req.set_tensor("input_tensor", inTensor)); OV_ASSERT_NO_THROW(req.infer()); @@ -115,7 +115,7 @@ TEST_P(OVInferRequestDynamicTests, InferDynamicNetworkSetUnexpectedOutputTensorB auto execNet = ie->compile_model(function, target_device, configuration); // Create InferRequest ov::InferRequest req; - ov::runtime::Tensor tensor, otensor; + ov::Tensor tensor, otensor; const std::string outputname = function->outputs().back().get_any_name(); OV_ASSERT_NO_THROW(req = execNet.create_infer_request()); ov::test::utils::InputGenerateData in_data; @@ -144,7 +144,7 @@ TEST_P(OVInferRequestDynamicTests, InferDynamicNetworkSetOutputTensorPreAllocate auto execNet = ie->compile_model(function, target_device, configuration); // Create InferRequest ov::InferRequest req; - ov::runtime::Tensor tensor; + ov::Tensor tensor; const std::string outputname = function->outputs().back().get_any_name(); OV_ASSERT_NO_THROW(req = execNet.create_infer_request()); ov::test::utils::InputGenerateData in_data; @@ -153,7 +153,7 @@ TEST_P(OVInferRequestDynamicTests, InferDynamicNetworkSetOutputTensorPreAllocate tensor = ov::test::utils::create_and_fill_tensor(element::f32, refShape, in_data); OV_ASSERT_NO_THROW(req.set_tensor("input_tensor", tensor)); float ptr[5000]; - ov::runtime::Tensor otensor(element::f32, refOutShape, ptr); + ov::Tensor otensor(element::f32, refOutShape, ptr); OV_ASSERT_NO_THROW(req.set_tensor(outputname, otensor)); OV_ASSERT_NO_THROW(req.infer()); ASSERT_EQ(req.get_tensor(outputname).data(), ptr); @@ -172,7 +172,7 @@ TEST_P(OVInferRequestDynamicTests, InferDynamicNetworkSetOutputShapeBeforeInfer) auto execNet = ie->compile_model(function, target_device, configuration); // Create InferRequest ov::InferRequest req; - ov::runtime::Tensor tensor, otensor; + ov::Tensor tensor, otensor; const std::string outputname = function->outputs().back().get_any_name(); OV_ASSERT_NO_THROW(req = execNet.create_infer_request()); ov::test::utils::InputGenerateData in_data; @@ -199,7 +199,7 @@ TEST_P(OVInferRequestDynamicTests, InferDynamicNetworkGetOutputThenSetOutputTens auto execNet = ie->compile_model(function, target_device, configuration); // Create InferRequest ov::InferRequest req; - ov::runtime::Tensor tensor; + ov::Tensor tensor; const std::string outputname = function->outputs().back().get_any_name(); OV_ASSERT_NO_THROW(req = execNet.create_infer_request()); ov::test::utils::InputGenerateData in_data; @@ -213,7 +213,7 @@ TEST_P(OVInferRequestDynamicTests, InferDynamicNetworkGetOutputThenSetOutputTens ASSERT_TRUE(checkOutput(req.get_tensor("input_tensor"), req.get_tensor(outputname))); // then, set output tensor float ptr[5000]; - ov::runtime::Tensor otensor(element::f32, refOutShape, ptr); + ov::Tensor otensor(element::f32, refOutShape, ptr); OV_ASSERT_NO_THROW(req.set_tensor(outputname, otensor)); OV_ASSERT_NO_THROW(req.infer()); ASSERT_EQ(req.get_tensor(outputname).data(), ptr); diff --git a/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/io_tensor.cpp b/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/io_tensor.cpp index c716486a369951..e5820ae8d58c79 100644 --- a/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/io_tensor.cpp +++ b/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/io_tensor.cpp @@ -235,7 +235,7 @@ TEST_P(OVInferRequestIOTensorTest, InferStaticNetworkSetChangedInputTensorThrow) OV_ASSERT_NO_THROW(req = execNet.create_infer_request()); OV_ASSERT_NO_THROW(req.infer()); // Get input_tensor - ov::runtime::Tensor tensor; + ov::Tensor tensor; OV_ASSERT_NO_THROW(tensor = req.get_tensor(function->inputs().back().get_any_name())); // Set shape OV_ASSERT_NO_THROW(tensor.set_shape(shape2)); @@ -258,7 +258,7 @@ TEST_P(OVInferRequestIOTensorTest, InferStaticNetworkSetChangedOutputTensorThrow OV_ASSERT_NO_THROW(req = execNet.create_infer_request()); OV_ASSERT_NO_THROW(req.infer()); // Get output_tensor - ov::runtime::Tensor tensor; + ov::Tensor tensor; OV_ASSERT_NO_THROW(tensor = req.get_tensor(function->outputs().back().get_any_name());); // Set shape OV_ASSERT_NO_THROW(tensor.set_shape(shape2)); diff --git a/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/iteration_chaining.cpp b/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/iteration_chaining.cpp index 2e77ec5475e29f..1bb87fccfaf32d 100644 --- a/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/iteration_chaining.cpp +++ b/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/iteration_chaining.cpp @@ -78,7 +78,7 @@ void OVIterationChaining::TearDown() { OVInferRequestTests::TearDown(); } -bool OVIterationChaining::checkOutput(const ov::runtime::Tensor& in, const ov::runtime::Tensor& actual) { +bool OVIterationChaining::checkOutput(const ov::Tensor& in, const ov::Tensor& actual) { bool result = true; auto net = core->compile_model(function, ov::test::utils::DEVICE_TEMPLATE); ov::InferRequest req; diff --git a/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/wait.cpp b/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/wait.cpp index 5b1231df8e382d..47e583c9c8c3df 100644 --- a/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/wait.cpp +++ b/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/wait.cpp @@ -4,7 +4,6 @@ #include "behavior/ov_infer_request/wait.hpp" #include "openvino/runtime/exception.hpp" -#include "ie_plugin_config.hpp" namespace ov { namespace test { @@ -55,9 +54,9 @@ TEST_P(OVInferRequestWaitTests, canWaitWithotStartSsync) { TEST_P(OVInferRequestWaitTests, throwExceptionOnSetTensorAfterAsyncInfer) { auto&& config = configuration; - auto itConfig = config.find(CONFIG_KEY(CPU_THROUGHPUT_STREAMS)); + auto itConfig = config.find(ov::num_streams.name()); if (itConfig != config.end()) { - if (itConfig->second.as() != "CPU_THROUGHPUT_AUTO") { + if (itConfig->second.as() != ov::streams::AUTO) { if (std::stoi(itConfig->second.as()) == 0) { GTEST_SKIP() << "Not applicable with disabled streams"; } diff --git a/src/tests/functional/plugin/shared/src/behavior/ov_plugin/caching_tests.cpp b/src/tests/functional/plugin/shared/src/behavior/ov_plugin/caching_tests.cpp index 027309a0abdb95..1b682e7f964d8a 100644 --- a/src/tests/functional/plugin/shared/src/behavior/ov_plugin/caching_tests.cpp +++ b/src/tests/functional/plugin/shared/src/behavior/ov_plugin/caching_tests.cpp @@ -15,7 +15,6 @@ #include "functional_test_utils/summary/api_summary.hpp" #include "common_test_utils/subgraph_builders/conv_pool_relu.hpp" -#include "cpp_interfaces/interface/ie_internal_plugin_config.hpp" #include "openvino/core/node_vector.hpp" #include "openvino/op/parameter.hpp" #include "common_test_utils/subgraph_builders/split_conv_concat.hpp" diff --git a/src/tests/functional/plugin/shared/src/behavior/ov_plugin/hetero_synthetic.cpp b/src/tests/functional/plugin/shared/src/behavior/ov_plugin/hetero_synthetic.cpp index 125735eb476fd1..232146386fe254 100644 --- a/src/tests/functional/plugin/shared/src/behavior/ov_plugin/hetero_synthetic.cpp +++ b/src/tests/functional/plugin/shared/src/behavior/ov_plugin/hetero_synthetic.cpp @@ -184,6 +184,14 @@ std::vector OVHeteroSyntheticTest::randomMajorNodeFunctions( return results; } +std::vector OVHeteroSyntheticTest::withMajorNodesFunctions(const std::function()>& builder, + const std::unordered_set& majorNodes, + bool dynamic_batch) { + auto function = builder(); + std::vector result; + result.push_back(FunctionParameter{majorNodes, function, dynamic_batch, 0}); + return result; +} std::vector OVHeteroSyntheticTest::_singleMajorNodeFunctions = OVHeteroSyntheticTest::singleMajorNodeFunctions(builders); diff --git a/src/tests/functional/plugin/shared/src/behavior/ov_plugin/properties_tests.cpp b/src/tests/functional/plugin/shared/src/behavior/ov_plugin/properties_tests.cpp index 1f95c73dba5861..0329245b55caba 100644 --- a/src/tests/functional/plugin/shared/src/behavior/ov_plugin/properties_tests.cpp +++ b/src/tests/functional/plugin/shared/src/behavior/ov_plugin/properties_tests.cpp @@ -6,7 +6,6 @@ #include "behavior/ov_plugin/properties_tests.hpp" #include "openvino/runtime/properties.hpp" -#include "ie_plugin_config.hpp" #include "common_test_utils/subgraph_builders/split_concat.hpp" namespace ov { diff --git a/src/tests/functional/plugin/shared/src/execution_graph_tests/disable_lowering_precision.cpp b/src/tests/functional/plugin/shared/src/execution_graph_tests/disable_lowering_precision.cpp new file mode 100644 index 00000000000000..45ba0e98259c75 --- /dev/null +++ b/src/tests/functional/plugin/shared/src/execution_graph_tests/disable_lowering_precision.cpp @@ -0,0 +1,101 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include +#include +#include +#include +#include +#include + +#include "openvino/runtime/exec_model_info.hpp" +#include "openvino/core/model.hpp" +#include "common_test_utils/common_utils.hpp" +#include "shared_test_classes/base/layer_test_utils.hpp" +#include "functional_test_utils/ov_plugin_cache.hpp" +#include "functional_test_utils/skip_tests_config.hpp" +#include "execution_graph_tests/disable_lowering_precision.hpp" +#include "transformations/rt_info/disable_fp16_compression.hpp" + +namespace ExecutionGraphTests { + +std::string ExecGraphDisableLoweringPrecision::getTestCaseName(testing::TestParamInfo obj) { + std::ostringstream result; + bool disableLoweringPrecision; + std::string targetDevice; + ov::element::Type loweringPrecision; + + std::tie(disableLoweringPrecision, targetDevice, loweringPrecision) = obj.param; + result << "matmul_disable_lowingprecision=" << disableLoweringPrecision << "_"; + result << "device=" << targetDevice << "_"; + result << "loweringPrecision=" << loweringPrecision.to_string(); + return result.str(); +} + +void ExecGraphDisableLoweringPrecision::SetUp() { + std::tie(disableLoweringPrecision, targetDevice, loweringPrecision) = this->GetParam(); + create_model(); +} + +void ExecGraphDisableLoweringPrecision::TearDown() { +} + +/* test model: + --------- + |Input | + --------- + | + --------- + |matmul | + --------- + | + --------- + |Output | + --------- +*/ + +void ExecGraphDisableLoweringPrecision::create_model() { + auto A = std::make_shared(ov::element::f32, ov::PartialShape{4, 16}); + auto weiShape = ov::Shape{16, 16}; + auto weightConst = ov::op::v0::Constant::create(ov::element::i64, weiShape, std::vector(ov::shape_size(weiShape), 1)); + auto weightConvert = std::make_shared(weightConst, ov::element::f32); + auto matmul = std::make_shared(A, weightConvert); + matmul->set_friendly_name("Matmul0"); + if (disableLoweringPrecision) + ov::disable_fp16_compression(matmul); + funcPtr = std::make_shared(matmul->outputs(), ov::ParameterVector{A}, "testModel"); +} + +void ExecGraphDisableLoweringPrecision::checkInferPrecision() { + ov::CompiledModel compiledModel; + auto core = ov::test::utils::PluginCache::get().core(); + compiledModel = core->compile_model(funcPtr, targetDevice, + ov::hint::inference_precision(loweringPrecision)); + const auto runtime_model = compiledModel.get_runtime_model(); + ASSERT_NE(nullptr, runtime_model); + auto getExecValue = [](const ov::Node::RTMap& rtInfo, const std::string ¶mName) -> std::string { + auto it = rtInfo.find(paramName); + OPENVINO_ASSERT(rtInfo.end() != it); + return it->second.as(); + }; + std::string matmulPrecision; + for (const auto &node : runtime_model->get_ops()) { + const auto origName = getExecValue(node->get_rt_info(), ov::exec_model_info::ORIGINAL_NAMES); + if (origName.find("Matmul0") != std::string::npos) { + matmulPrecision = getExecValue(node->get_rt_info(), ov::exec_model_info::RUNTIME_PRECISION); + break; + } + } + ASSERT_TRUE(!matmulPrecision.empty()); + if (disableLoweringPrecision) + ASSERT_EQ(matmulPrecision, "f32"); + else + ASSERT_EQ(matmulPrecision, loweringPrecision.to_string()); + funcPtr.reset(); +} + +TEST_P(ExecGraphDisableLoweringPrecision, CheckRuntimePrecision) { + checkInferPrecision(); +} +} // namespace ExecutionGraphTests diff --git a/src/tests/functional/plugin/shared/src/low_precision_transformations/depth_to_space_transformation.cpp b/src/tests/functional/plugin/shared/src/low_precision_transformations/depth_to_space_transformation.cpp index 713bc7d8439867..31270f5180f684 100644 --- a/src/tests/functional/plugin/shared/src/low_precision_transformations/depth_to_space_transformation.cpp +++ b/src/tests/functional/plugin/shared/src/low_precision_transformations/depth_to_space_transformation.cpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // -#include #include #include #include diff --git a/src/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_transformation.cpp b/src/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_transformation.cpp index b4262c9b14001f..8151bc84410211 100644 --- a/src/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_transformation.cpp +++ b/src/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_transformation.cpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // -#include #include #include #include diff --git a/src/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_with_constant_transformation.cpp b/src/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_with_constant_transformation.cpp index 52fe187d7e5f86..7c1dd15d3657d1 100644 --- a/src/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_with_constant_transformation.cpp +++ b/src/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_with_constant_transformation.cpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // -#include #include #include #include diff --git a/src/tests/functional/plugin/shared/src/low_precision_transformations/reshape_transformation.cpp b/src/tests/functional/plugin/shared/src/low_precision_transformations/reshape_transformation.cpp index adc6d380cfcb45..50373c8dc2e4b2 100644 --- a/src/tests/functional/plugin/shared/src/low_precision_transformations/reshape_transformation.cpp +++ b/src/tests/functional/plugin/shared/src/low_precision_transformations/reshape_transformation.cpp @@ -51,6 +51,9 @@ void ReshapeTransformation::run() { LayerTransformation::run(); const auto params = std::get<3>(GetParam()); + + EXPECT_TRUE(check_execution_order(params.executionOrder)); + auto actualPrecision = get_runtime_precision_by_type(params.layerType); const auto expectedPrecision = params.expectedKernelType; if ((expectedPrecision == "FP32") && (actualPrecision == "FP16")) { diff --git a/src/tests/functional/plugin/shared/src/low_precision_transformations/squeeze_transformation.cpp b/src/tests/functional/plugin/shared/src/low_precision_transformations/squeeze_transformation.cpp index 7eaf42e6421504..1b5200db978d5a 100644 --- a/src/tests/functional/plugin/shared/src/low_precision_transformations/squeeze_transformation.cpp +++ b/src/tests/functional/plugin/shared/src/low_precision_transformations/squeeze_transformation.cpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // -#include #include #include #include diff --git a/src/tests/functional/plugin/shared/src/low_precision_transformations/unsqueeze_transformation.cpp b/src/tests/functional/plugin/shared/src/low_precision_transformations/unsqueeze_transformation.cpp index dd7575a4ff22a2..20a17137abad17 100644 --- a/src/tests/functional/plugin/shared/src/low_precision_transformations/unsqueeze_transformation.cpp +++ b/src/tests/functional/plugin/shared/src/low_precision_transformations/unsqueeze_transformation.cpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // -#include #include #include #include diff --git a/src/tests/functional/plugin/shared/src/onnx/quantized_models_tests.cpp b/src/tests/functional/plugin/shared/src/onnx/quantized_models_tests.cpp index bc4c02679070df..28b2c2b1843a06 100644 --- a/src/tests/functional/plugin/shared/src/onnx/quantized_models_tests.cpp +++ b/src/tests/functional/plugin/shared/src/onnx/quantized_models_tests.cpp @@ -2,10 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include "common_test_utils/file_utils.hpp" #include "onnx/quantized_models_tests.hpp" +#include + +#include "common_test_utils/file_utils.hpp" + namespace ONNXTestsDefinitions { std::string QuantizedModelsTests::getTestCaseName(const testing::TestParamInfo& obj) { @@ -20,8 +22,8 @@ void QuantizedModelsTests::SetUp() { } static std::string getModelFullPath(const char* path) { - return FileUtils::makePath( - FileUtils::makePath(ov::test::utils::getExecutableDirectory(), TEST_MODELS), path); + return ov::util::make_path(ov::util::make_path(ov::test::utils::getExecutableDirectory(), TEST_MODELS), + path); } void QuantizedModelsTests::run_model(const char* model, const LayerInputTypes& expected_layer_input_types, float thr) { diff --git a/src/tests/functional/plugin/shared/src/precomp.hpp b/src/tests/functional/plugin/shared/src/precomp.hpp index 593398719c235f..8e740185d89fe5 100644 --- a/src/tests/functional/plugin/shared/src/precomp.hpp +++ b/src/tests/functional/plugin/shared/src/precomp.hpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -31,3 +30,4 @@ #include #include "openvino/core/type/float16.hpp" +#include "openvino/openvino.hpp" diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/base/benchmark.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/base/benchmark.hpp index cd0e1375eda074..15d89175ea5382 100644 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/base/benchmark.hpp +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/base/benchmark.hpp @@ -63,139 +63,6 @@ class BenchmarkLayerTestReporter { pugi::xml_document report_xml_{}; }; -} // namespace test -} // namespace ov - -namespace LayerTestsDefinitions { - -template -class BenchmarkLayerTest : public BaseLayerTest { - static_assert(std::is_base_of::value, - "BaseLayerTest should inherit from LayerTestsUtils::LayerTestsCommon"); - -public: - static constexpr int kDefaultNumberOfAttempts = 100; - static constexpr double kMaxAllowedBenchmarkDifference = 0.05; - - void RunBenchmark(const std::initializer_list& nodeTypeNames, - const std::chrono::milliseconds warmupTime = std::chrono::milliseconds(2000), - const int numAttempts = kDefaultNumberOfAttempts) { - bench_node_type_names_ = nodeTypeNames; - warmup_time_ = warmupTime; - num_attempts_ = numAttempts; - this->configuration.insert({"PERF_COUNT", "YES"}); - this->Run(); - } - - void RunBenchmark(const std::string& nodeTypeName, - const std::chrono::milliseconds warmupTime = std::chrono::milliseconds(2000), - const int numAttempts = kDefaultNumberOfAttempts) { - if (!nodeTypeName.empty()) { - RunBenchmark({nodeTypeName}, warmupTime, numAttempts); - } else { - RunBenchmark({}, warmupTime, numAttempts); - } - } - - void Validate() override { - for (const auto& res : curr_bench_results_) { - const auto& node_type_name = res.first; - const auto curr_time = static_cast(res.second); - if (prev_bench_results_.count(node_type_name) > 0) { - const auto prev_time = static_cast(prev_bench_results_[node_type_name]); - const auto delta_time = static_cast(curr_time - prev_time); - if (delta_time/prev_time > kMaxAllowedBenchmarkDifference) { - std::cerr << "node_type_name: " << node_type_name << - ", for test case: " << BaseLayerTest::GetTestName() << - ", has exceeded the benchmark threshold: " << kMaxAllowedBenchmarkDifference << - ". Current: " << curr_time << " us, previous: " << prev_time << " us" << std::endl; - } - } - } - } - -protected: - void Infer() override { - this->inferRequest = this->executableNetwork.CreateInferRequest(); - this->ConfigureInferRequest(); - -#ifdef ENABLE_BENCHMARK_FILE_REPORT - reporter_ = std::unique_ptr( - new ::ov::test::BenchmarkLayerTestReporter{false}); -#else - reporter_ = std::unique_ptr( - new ::ov::test::BenchmarkLayerTestReporter{true}); -#endif - for (const auto& node_type_name : bench_node_type_names_) { - try { - const auto time = reporter_->get_time(node_type_name, BaseLayerTest::GetTestName()); - prev_bench_results_[node_type_name] = time; - } catch (...) { - } - } - - std::map results_us{}; - for (const auto& node_type_name : bench_node_type_names_) { - results_us[node_type_name] = {}; - } - - // Warmup - auto warm_current = std::chrono::steady_clock::now(); - const auto warm_end = warm_current + warmup_time_; - while (warm_current < warm_end) { - this->inferRequest.Infer(); - warm_current = std::chrono::steady_clock::now(); - } - - // Benchmark - for (size_t i = 0; i < num_attempts_; ++i) { - this->inferRequest.Infer(); - const auto& perf_results = this->inferRequest.GetPerformanceCounts(); - for (auto& res : results_us) { - const std::string node_type_name = res.first; - uint64_t& time = res.second; - auto found_profile = std::find_if(perf_results.begin(), perf_results.end(), - [&node_type_name](const InferenceEngine::InferenceEngineProfileInfo& profile) { - return profile.layer_type == node_type_name; - }); - if (found_profile == perf_results.end()) { - IE_THROW() << "Cannot find operator by node type: " << node_type_name; - } - time += found_profile->second.realTime_uSec; - } - } - - std::stringstream report{}; - uint64_t total_us = 0; - for (const auto& res : results_us) { - const std::string node_type_name = res.first; - uint64_t time = res.second; - time /= num_attempts_; - total_us += time; - report << std::fixed << std::setfill('0') << node_type_name << ": " << time << " us\n"; -#ifdef ENABLE_BENCHMARK_FILE_REPORT - curr_bench_results_[node_type_name] = time; - reporter_->report(node_type_name, BaseLayerTest::GetTestName(), time); -#endif - } - report << std::fixed << std::setfill('0') << "Total time: " << total_us << " us\n"; - std::cout << report.str(); - } - -private: - std::unique_ptr reporter_; - std::unordered_map prev_bench_results_; - std::unordered_map curr_bench_results_; - std::vector bench_node_type_names_; - std::chrono::milliseconds warmup_time_; - int num_attempts_; -}; - -} // namespace LayerTestsDefinitions - -namespace ov { -namespace test { - template class BenchmarkLayerTest : public BaseLayerTest { static_assert(std::is_base_of::value, diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/base/layer_test_utils.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/base/layer_test_utils.hpp index 2f42836f6e8f00..a23e1be0e84943 100644 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/base/layer_test_utils.hpp +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/base/layer_test_utils.hpp @@ -5,15 +5,12 @@ #pragma once #include -#include #include "common_test_utils/common_utils.hpp" #include "common_test_utils/ov_test_utils.hpp" #include "common_test_utils/test_common.hpp" -#include "functional_test_utils/blob_utils.hpp" +#include "common_test_utils/data_utils.hpp" #include "functional_test_utils/crash_handler.hpp" -#include "functional_test_utils/plugin_cache.hpp" -#include "functional_test_utils/precision_utils.hpp" #include "functional_test_utils/skip_tests_config.hpp" #include "functional_test_utils/summary/environment.hpp" #include "functional_test_utils/summary/op_summary.hpp" @@ -25,151 +22,9 @@ namespace LayerTestsUtils { using TargetDevice = std::string; -typedef std::tuple< - InferenceEngine::Precision, // Network Precision - InferenceEngine::SizeVector, // Input Shape - TargetDevice // Target Device -> basicParams; - -enum RefMode { - INTERPRETER, - CONSTANT_FOLDING, - IE -}; - -class LayerTestsCommon : public ov::test::TestsCommon { -public: - virtual InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo &inputInfo) const; - - virtual void Run(); - - virtual void Serialize(ov::pass::Serialize::Version ir_version = ov::pass::Serialize::Version::UNSPECIFIED); - - virtual void QueryNetwork(); - - static void Compare(const std::vector>> &expected, - const std::vector &actual, - float threshold, - float abs_threshold = -1.f); - - static void Compare(const std::pair> &expected, - const InferenceEngine::Blob::Ptr &actual, - float threshold, - float abs_threshold = -1.f); - - virtual void Compare(const std::vector>> &expectedOutputs, - const std::vector &actualOutputs); - - virtual void Compare(const std::pair> &expected, const InferenceEngine::Blob::Ptr &actual); - - virtual void Compare(const InferenceEngine::Blob::Ptr &expected, const InferenceEngine::Blob::Ptr &actual); - - virtual void Compare(const InferenceEngine::TensorDesc &actualDesc, const InferenceEngine::TensorDesc &expectedDesc); - - virtual void SetRefMode(RefMode mode); - - std::shared_ptr GetFunction(); - - std::map& GetConfiguration(); - - // get runtime precision by operation friendly name - std::string getRuntimePrecision(const std::string& layerName); - - // get runtime precision by operation type - std::string getRuntimePrecisionByType(const std::string& layerType); - - // get runtime precision by operation friendly name which can be fused - std::string getRuntimePrecisionByFusedName(const std::string& layerName); - - std::map getRuntimeInfo(); - -#ifndef NDEBUG - void showRuntimePrecisions(); -#endif - - template - static void Compare(const T_NGRAPH *expected, const T_IE *actual, std::size_t size, float threshold, float abs_threshold = -1.f) { - for (std::size_t i = 0; i < size; ++i) { - const T_NGRAPH &ref = expected[i]; - const auto &res = actual[i]; - const auto absoluteDifference = ov::test::utils::ie_abs(res - ref); - if (abs_threshold > 0.f && absoluteDifference > abs_threshold) { - IE_THROW() << "Absolute comparison of values expected: " << std::to_string(ref) << " and actual: " << std::to_string(res) - << " at index " << i << " with absolute threshold " << abs_threshold - << " failed"; - } - if (absoluteDifference <= threshold) { - continue; - } - double max; - if (sizeof(T_IE) < sizeof(T_NGRAPH)) { - max = static_cast(std::max(ov::test::utils::ie_abs(T_NGRAPH(res)), ov::test::utils::ie_abs(ref))); - } else { - max = static_cast(std::max(ov::test::utils::ie_abs(res), ov::test::utils::ie_abs(T_IE(ref)))); - } - double diff = static_cast(absoluteDifference) / max; - if (max == 0 || (diff > static_cast(threshold)) || - (std::isnan(static_cast(res)) ^ std::isnan(static_cast(ref)))) { - IE_THROW() << "Relative comparison of values expected: " << std::to_string(ref) << " and actual: " << std::to_string(res) - << " at index " << i << " with threshold " << threshold - << " failed"; - } - } - } - +class LayerTestsCommon { protected: LayerTestsCommon(); - - RefMode GetRefMode() { - return refMode; - } - - std::shared_ptr getCore() { - return core; - } - - virtual void ConfigureNetwork(); - - virtual void LoadNetwork(); - - virtual void ExpectLoadNetworkToThrow(const std::string& msg); - - virtual void GenerateInputs(); - - virtual void ConfigureInferRequest(); - - virtual void Infer(); - - TargetDevice targetDevice; - std::shared_ptr function; - std::shared_ptr functionRefs; - std::map configuration; - // Non default values of layouts/precisions will be set to CNNNetwork - InferenceEngine::Layout inLayout = InferenceEngine::Layout::ANY; - InferenceEngine::Layout outLayout = InferenceEngine::Layout::ANY; - InferenceEngine::Precision inPrc = InferenceEngine::Precision::UNSPECIFIED; - InferenceEngine::Precision outPrc = InferenceEngine::Precision::UNSPECIFIED; - InferenceEngine::ExecutableNetwork executableNetwork; - std::vector inputs; - float threshold; - float abs_threshold; - InferenceEngine::CNNNetwork cnnNetwork; - std::shared_ptr core; - - virtual void Validate(); - - virtual std::vector>> CalculateRefs(); - - /// default method to convert parameters for reference operation. Used before reference implementation execution - /// can be overridden by specific operation test - virtual void ConvertRefsParams(); - - virtual std::vector GetOutputs(); - - InferenceEngine::InferRequest inferRequest; - -private: - RefMode refMode = RefMode::INTERPRETER; }; } // namespace LayerTestsUtils diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/base/low_precision_transformations/layer_transformation.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/base/low_precision_transformations/layer_transformation.hpp index 20806c90f728c3..3e720a377bbc74 100644 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/base/low_precision_transformations/layer_transformation.hpp +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/base/low_precision_transformations/layer_transformation.hpp @@ -53,6 +53,10 @@ class LayerTransformation : virtual public ov::test::SubgraphBaseTest { // get runtime precision by operation friendly name which can be fused std::string get_runtime_precision_by_fused_name(const std::string& layerName); + // check operation sequence in an execution graph and orderedOpsTypes + // orderedOpsTypes can consist only necessary operations (fewer than exist in the execution graph) + bool check_execution_order(const std::vector& orderedOpsTypes); + std::map get_runtime_info(); void init_input_shapes(const ov::PartialShape& shape); diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/base/ov_subgraph.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/base/ov_subgraph.hpp index 1653f6ffd4298c..cedac0be53cc07 100644 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/base/ov_subgraph.hpp +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/base/ov_subgraph.hpp @@ -44,6 +44,7 @@ class SubgraphBaseTest : public ov::test::TestsCommon { void update_ref_model(); void match_parameters(); void init_input_shapes(const std::vector& shapes); + void set_callback_exception(std::function callback) { callback_exception = callback; } void TearDown() override { if (this->HasFailure() && !is_reported) { @@ -69,6 +70,8 @@ class SubgraphBaseTest : public ov::test::TestsCommon { std::map, std::shared_ptr> matched_parameters; precisions_map convert_precisions; + std::function callback_exception = nullptr; + constexpr static const double disable_threshold = std::numeric_limits::max(); double abs_threshold = disable_threshold, rel_threshold = disable_threshold; diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/base/utils/compare_results.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/base/utils/compare_results.hpp index 226d608bb687d2..985ba1e8bbc660 100644 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/base/utils/compare_results.hpp +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/base/utils/compare_results.hpp @@ -4,7 +4,6 @@ #pragma once -#include "ie_core.hpp" namespace ov { namespace test { @@ -13,8 +12,8 @@ namespace utils { using CompareMap = std::map &node, size_t port, - const ov::runtime::Tensor &expected, - const ov::runtime::Tensor &actual, + const ov::Tensor &expected, + const ov::Tensor &actual, double absThreshold, double relThreshold)>>; diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/base/utils/generate_inputs.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/base/utils/generate_inputs.hpp index df2a47513e17de..6e1af8f967a6b8 100644 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/base/utils/generate_inputs.hpp +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/base/utils/generate_inputs.hpp @@ -17,7 +17,7 @@ void reset_const_ranges(); std::vector color_test_image(size_t height, size_t width, int b_step, ov::preprocess::ColorFormat format); -using InputsMap = std::map& node, size_t port, const ov::element::Type& elemType, diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/activation.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/activation.hpp deleted file mode 100644 index d8fe3c676bc2ea..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/activation.hpp +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ie_core.hpp" -#include "ie_precision.hpp" - -#include "functional_test_utils/blob_utils.hpp" -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "common_test_utils/common_utils.hpp" - -#include "ov_models/utils/ov_helpers.hpp" -#include "ov_models/builders.hpp" - -namespace LayerTestsDefinitions { - -static std::map activationNames = { - {ngraph::helpers::ActivationTypes::Sigmoid, "Sigmoid"}, - {ngraph::helpers::ActivationTypes::Tanh, "Tanh"}, - {ngraph::helpers::ActivationTypes::Relu, "Relu"}, - {ngraph::helpers::ActivationTypes::LeakyRelu, "LeakyRelu"}, - {ngraph::helpers::ActivationTypes::Exp, "Exp"}, - {ngraph::helpers::ActivationTypes::Log, "Log"}, - {ngraph::helpers::ActivationTypes::Sign, "Sign"}, - {ngraph::helpers::ActivationTypes::Abs, "Abs"}, - {ngraph::helpers::ActivationTypes::Clamp, "Clamp"}, - {ngraph::helpers::ActivationTypes::Negative, "Negative"}, - {ngraph::helpers::ActivationTypes::Acos, "Acos"}, - {ngraph::helpers::ActivationTypes::Acosh, "Acosh"}, - {ngraph::helpers::ActivationTypes::Asin, "Asin"}, - {ngraph::helpers::ActivationTypes::Asinh, "Asinh"}, - {ngraph::helpers::ActivationTypes::Atan, "Atan"}, - {ngraph::helpers::ActivationTypes::Atanh, "Atanh"}, - {ngraph::helpers::ActivationTypes::Cos, "Cos"}, - {ngraph::helpers::ActivationTypes::Cosh, "Cosh"}, - {ngraph::helpers::ActivationTypes::Floor, "Floor"}, - {ngraph::helpers::ActivationTypes::Sin, "Sin"}, - {ngraph::helpers::ActivationTypes::Sinh, "Sinh"}, - {ngraph::helpers::ActivationTypes::Sqrt, "Sqrt"}, - {ngraph::helpers::ActivationTypes::Tan, "Tan"}, - {ngraph::helpers::ActivationTypes::Elu, "Elu"}, - {ngraph::helpers::ActivationTypes::Erf, "Erf"}, - {ngraph::helpers::ActivationTypes::HardSigmoid, "HardSigmoid"}, - {ngraph::helpers::ActivationTypes::Selu, "Selu"}, - {ngraph::helpers::ActivationTypes::Sigmoid, "Sigmoid"}, - {ngraph::helpers::ActivationTypes::Tanh, "Tanh"}, - {ngraph::helpers::ActivationTypes::Relu, "Relu"}, - {ngraph::helpers::ActivationTypes::LeakyRelu, "LeakyRelu"}, - {ngraph::helpers::ActivationTypes::Exp, "Exp"}, - {ngraph::helpers::ActivationTypes::Log, "Log"}, - {ngraph::helpers::ActivationTypes::Sign, "Sign"}, - {ngraph::helpers::ActivationTypes::Abs, "Abs"}, - {ngraph::helpers::ActivationTypes::Gelu, "Gelu"}, - {ngraph::helpers::ActivationTypes::Ceiling, "Ceiling"}, - {ngraph::helpers::ActivationTypes::PReLu, "PReLu"}, - {ngraph::helpers::ActivationTypes::Mish, "Mish"}, - {ngraph::helpers::ActivationTypes::HSwish, "HSwish"}, - {ngraph::helpers::ActivationTypes::SoftPlus, "SoftPlus"}, - {ngraph::helpers::ActivationTypes::Swish, "Swish"}, - {ngraph::helpers::ActivationTypes::HSigmoid, "HSigmoid"}, - {ngraph::helpers::ActivationTypes::RoundHalfToEven, "RoundHalfToEven"}, - {ngraph::helpers::ActivationTypes::RoundHalfAwayFromZero, "RoundHalfAwayFromZero"}, - {ngraph::helpers::ActivationTypes::GeluErf, "GeluErf"}, - {ngraph::helpers::ActivationTypes::GeluTanh, "GeluTanh"}, - {ngraph::helpers::ActivationTypes::SoftSign, "SoftSign"}, -}; - -typedef std::tuple< - std::pair>, // Activation type and constant value - InferenceEngine::Precision, - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - std::pair, std::vector>, - std::string> activationParams; - -class ActivationLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - ngraph::helpers::ActivationTypes activationType; - static std::string getTestCaseName(const testing::TestParamInfo &obj); - InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo &info) const override; - -protected: - void SetUp() override; -}; - -class ActivationParamLayerTest : public ActivationLayerTest { -protected: - void SetUp() override; - -private: - InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo &info) const override; - void generateActivationBlob(std::vector constantsValue); - ov::ParameterVector createActivationParams( - ov::element::Type ngPrc, std::vector inShape = {}); - -private: - std::vector constantsValue; -}; - -class ActivationDynamicLayerTest : public ActivationLayerTest { -public: - std::unordered_set static_dims; - void Run() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/adaptive_pooling.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/adaptive_pooling.hpp deleted file mode 100644 index 445094c03a1b7d..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/adaptive_pooling.hpp +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { -using adapoolParams = std::tuple< - std::vector, // feature map shape - std::vector, // pooled spatial shape - std::string, // pooling mode - InferenceEngine::Precision, // net precision - LayerTestsUtils::TargetDevice>; // device name - -class AdaPoolLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/batch_norm.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/batch_norm.hpp deleted file mode 100644 index b261641ab1ea79..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/batch_norm.hpp +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" - -namespace LayerTestsDefinitions { -typedef std::tuple< - double, // epsilon - InferenceEngine::Precision, // Net precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - InferenceEngine::SizeVector, // Input shapes - LayerTestsUtils::TargetDevice // Target device name -> BatchNormLayerTestParams; - -class BatchNormLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - - InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo &info) const override; - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/batch_to_space.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/batch_to_space.hpp deleted file mode 100644 index b8730d29ac6e77..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/batch_to_space.hpp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { - -using batchToSpaceParamsTuple = typename std::tuple< - std::vector, // block shape - std::vector, // crops begin - std::vector, // crops end - std::vector, // Input shapes - InferenceEngine::Precision, // Network precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - std::string>; // Device name>; - -class BatchToSpaceLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/binary_convolution.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/binary_convolution.hpp deleted file mode 100644 index b57cee5745ba25..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/binary_convolution.hpp +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { - -using binConvSpecificParams = std::tuple< - InferenceEngine::SizeVector, // Kernel size - InferenceEngine::SizeVector, // Strides - std::vector, // Pads begin - std::vector, // Pads end - InferenceEngine::SizeVector, // Dilations - size_t, // Num Output channels - ov::op::PadType, // Padding type - float>; // Padding value - -using binaryConvolutionTestParamsSet = std::tuple< - binConvSpecificParams, // - InferenceEngine::Precision, // Network precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - InferenceEngine::SizeVector, // Input shape - LayerTestsUtils::TargetDevice>; // Device name - -class BinaryConvolutionLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo &info) const override; - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/broadcast.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/broadcast.hpp deleted file mode 100644 index 38cf1bbe94ed2e..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/broadcast.hpp +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { - -using BroadcastParamsTuple = typename std::tuple< - InferenceEngine::SizeVector, // target shape - ngraph::AxisSet, // axes mapping - ov::op::BroadcastType, // broadcast mode - InferenceEngine::SizeVector, // Input shape - InferenceEngine::Precision, // Network precision - std::string>; // Device name - -class BroadcastLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/bucketize.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/bucketize.hpp deleted file mode 100644 index 169ce16bf892ed..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/bucketize.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include - -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { - -using bucketizeParamsTuple = std::tuple< - InferenceEngine::SizeVector, // Data shape - InferenceEngine::SizeVector, // Buckets shape - bool, // Right edge of interval - InferenceEngine::Precision, // Data input precision - InferenceEngine::Precision, // Buckets input precision - InferenceEngine::Precision, // Output precision - std::string>; // Device name - -class BucketizeLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo &info) const override; -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/clamp.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/clamp.hpp deleted file mode 100644 index 5e2c3a0ab8a64b..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/clamp.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include - -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { - -using clampParamsTuple = std::tuple< - InferenceEngine::SizeVector, // Input shape - std::pair, // Interval [min, max] - InferenceEngine::Precision, // Net precision - std::string>; // Device name - -class ClampLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/comparison.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/comparison.hpp deleted file mode 100644 index fb499a5c0396b5..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/comparison.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -#include -#include - -#include "common_test_utils/common_utils.hpp" -#include "common_test_utils/test_common.hpp" -#include "common_test_utils/test_constants.hpp" -#include "ie_core.hpp" - -namespace LayerTestsDefinitions { -namespace ComparisonParams { -using InputShapesTuple = std::pair, std::vector>; -} // ComparisonParams - -typedef std::tuple< - ComparisonParams::InputShapesTuple, // Input shapes tuple - InferenceEngine::Precision, // NG Inputs precision - ngraph::helpers::ComparisonTypes, // Comparison op type - ngraph::helpers::InputLayerType, // Second input type - InferenceEngine::Precision, // IE in precision - InferenceEngine::Precision, // IE out precision - std::string, // Device name - std::map // Additional network configuration -> ComparisonTestParams; - -class ComparisonLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { - ngraph::helpers::ComparisonTypes comparisonOpType; -protected: - void SetUp() override; - -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo &inputInfo) const override; -}; -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/concat.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/concat.hpp deleted file mode 100644 index d07d45909d1644..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/concat.hpp +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { - -using concatParamsTuple = typename std::tuple< - int, // Concat axis - std::vector>, // Input shapes - InferenceEngine::Precision, // Network precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - std::string>; // Device name - -// Multichannel -class ConcatLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/constant.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/constant.hpp deleted file mode 100644 index 8abc666eccb7e9..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/constant.hpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include - -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { - -using constantParamsTuple = typename std::tuple< - std::vector, // Constant data shape - InferenceEngine::Precision, // Constant data precision - std::vector, // Constant elements - std::string>; // Device name - -class ConstantLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/conversion.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/conversion.hpp deleted file mode 100644 index 476493c512d38b..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/conversion.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -#include -#include - -#include "common_test_utils/common_utils.hpp" -#include "common_test_utils/test_common.hpp" -#include "common_test_utils/test_constants.hpp" -#include "ie_core.hpp" - -namespace LayerTestsDefinitions { - -static std::map conversionNames = { - {ngraph::helpers::ConversionTypes::CONVERT, "Convert"}, - {ngraph::helpers::ConversionTypes::CONVERT_LIKE, "ConvertLike"}}; - -using ConversionParamsTuple = typename std::tuple>, // Input1 shapes - InferenceEngine::Precision, // Input1 precision - InferenceEngine::Precision, // Input2 precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - std::string>; // Device name - -class ConversionLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convert_color_i420.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convert_color_i420.hpp deleted file mode 100644 index 60cef22ee94e96..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convert_color_i420.hpp +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { - -using ConvertColorI420ParamsTuple = std::tuple< - ov::Shape, // Input Shape - ov::element::Type, // Element type - bool, // Conversion type - bool, // 1 or 3 planes - std::string>; // Device name - -class ConvertColorI420LayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; -}; - -//---------------------------------------- - -class ConvertColorI420AccuracyTest : public ConvertColorI420LayerTest { -protected: - void GenerateInputs() override; // Generate predefined image with R/G/B combinations - void Validate() override; // Regular validate + percentage of acceptable deviations - std::vector>> CalculateRefs() override; - - std::vector GetOutputs() override; -private: - std::vector expected_output; - InferenceEngine::Blob::Ptr actual_output; -}; - -namespace I420TestUtils { - -template -inline void ValidateColors(const T* expected, const T* actual, size_t size, float dev_threshold, float abs_threshold = 0.01f) { - size_t mismatches = 0; - for (size_t i = 0; i < size; i++) { - if (std::abs(static_cast(expected[i]) - static_cast(actual[i])) > abs_threshold) { - mismatches++; - } - } - ASSERT_LT(static_cast(mismatches) / size, dev_threshold) << mismatches << - " out of " << size << " color mismatches found which exceeds allowed threshold " << dev_threshold; -} - -inline std::vector color_test_image(size_t height, size_t width, int b_step) { - // Test all possible r/g/b values within dimensions - int b_dim = 255 / b_step + 1; - auto input_yuv = std::vector(height * b_dim * width * 3 / 2); - for (int b = 0; b <= 255; b += b_step) { - for (size_t y = 0; y < height / 2; y++) { - for (size_t x = 0; x < width / 2; x++) { - int r = static_cast(y) * 512 / static_cast(height); - int g = static_cast(x) * 512 / static_cast(width); - // Can't use random y/u/v for testing as this can lead to invalid R/G/B values - int y_val = ((66 * r + 129 * g + 25 * b + 128) / 256) + 16; - int u_val = ((-38 * r - 74 * g + 112 * b + 128) / 256) + 128; - int v_val = ((112 * r - 94 * g + 18 * b + 128) / 256) + 128; - - size_t b_offset = height * width * b / b_step * 3 / 2; - size_t u_index = b_offset + height * width + y * width / 2 + x; - size_t v_index = u_index + height * width / 4; - input_yuv[u_index] = u_val; - input_yuv[v_index] = v_val; - size_t y_index = b_offset + y * 2 * width + x * 2; - input_yuv[y_index] = y_val; - input_yuv[y_index + 1] = y_val; - input_yuv[y_index + width] = y_val; - input_yuv[y_index + width + 1] = y_val; - } - } - } - return input_yuv; -} - -} // namespace I420TestUtils -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convert_color_nv12.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convert_color_nv12.hpp deleted file mode 100644 index 2a691611443e9d..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convert_color_nv12.hpp +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { - -using ConvertColorNV12ParamsTuple = std::tuple< - ov::Shape, // Input Shape - ov::element::Type, // Element type - bool, // Conversion type - bool, // 1 or 2 planes - std::string>; // Device name - -class ConvertColorNV12LayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; -}; - -//---------------------------------------- - -class ConvertColorNV12AccuracyTest : public ConvertColorNV12LayerTest { -protected: - void GenerateInputs() override; // Generate predefined image with R/G/B combinations - void Validate() override; // Regular validate + percentage of acceptable deviations - std::vector>> CalculateRefs() override; - - std::vector GetOutputs() override; -private: - std::vector expected_output; - InferenceEngine::Blob::Ptr actual_output; -}; - -namespace NV12TestUtils { - -template -inline void ValidateColors(const T* expected, const T* actual, size_t size, float dev_threshold, float abs_threshold = 0.01f) { - size_t mismatches = 0; - for (size_t i = 0; i < size; i++) { - if (std::abs(static_cast(expected[i]) - static_cast(actual[i])) > abs_threshold) { - mismatches++; - } - } - ASSERT_LT(static_cast(mismatches) / size, dev_threshold) << mismatches << - " out of " << size << " color mismatches found which exceeds allowed threshold " << dev_threshold; -} - -inline std::vector color_test_image(size_t height, size_t width, int b_step) { - // Test all possible r/g/b values within dimensions - int b_dim = 255 / b_step + 1; - auto input_yuv = std::vector(height * b_dim * width * 3 / 2); - for (int b = 0; b <= 255; b += b_step) { - for (size_t y = 0; y < height / 2; y++) { - for (size_t x = 0; x < width / 2; x++) { - int r = static_cast(y) * 512 / static_cast(height); - int g = static_cast(x) * 512 / static_cast(width); - // Can't use random y/u/v for testing as this can lead to invalid R/G/B values - int y_val = ((66 * r + 129 * g + 25 * b + 128) / 256) + 16; - int u_val = ((-38 * r - 74 * g + 112 * b + 128) / 256) + 128; - int v_val = ((112 * r - 94 * g + 18 * b + 128) / 256) + 128; - - size_t b_offset = height * width * b / b_step * 3 / 2; - size_t uv_index = b_offset + height * width + y * width + x * 2; - input_yuv[uv_index] = u_val; - input_yuv[uv_index + 1] = v_val; - size_t y_index = b_offset + y * 2 * width + x * 2; - input_yuv[y_index] = y_val; - input_yuv[y_index + 1] = y_val; - input_yuv[y_index + width] = y_val; - input_yuv[y_index + width + 1] = y_val; - } - } - } - return input_yuv; -} - -} // namespace NV12TestUtils -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convolution.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convolution.hpp deleted file mode 100644 index 95b0a68c5914b3..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convolution.hpp +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { - -// ! [test_convolution:definition] -typedef std::tuple< - InferenceEngine::SizeVector, // Kernel size - InferenceEngine::SizeVector, // Strides - std::vector, // Pad begin - std::vector, // Pad end - InferenceEngine::SizeVector, // Dilation - size_t, // Num out channels - ov::op::PadType // Padding type -> convSpecificParams; -typedef std::tuple< - convSpecificParams, - InferenceEngine::Precision, // Net precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - InferenceEngine::SizeVector, // Input shapes - LayerTestsUtils::TargetDevice // Device name -> convLayerTestParamsSet; - -class ConvolutionLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; -// ! [test_convolution:definition] - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convolution_backprop.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convolution_backprop.hpp deleted file mode 100644 index 61503f7797b7b9..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convolution_backprop.hpp +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { - -typedef std::tuple< - InferenceEngine::SizeVector, // Kernel size - InferenceEngine::SizeVector, // Strides - std::vector, // Pad begin - std::vector, // Pad end - InferenceEngine::SizeVector, // Dilation - size_t, // Num out channels - ov::op::PadType, // Padding type - std::vector // Output padding -> convBackpropSpecificParams; -typedef std::tuple< - convBackpropSpecificParams, - InferenceEngine::Precision, // Net precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - InferenceEngine::SizeVector, // Input shapes - InferenceEngine::SizeVector, // Output shapes - LayerTestsUtils::TargetDevice // Device name -> convBackpropLayerTestParamsSet; - -class ConvolutionBackpropLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convolution_backprop_data.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convolution_backprop_data.hpp deleted file mode 100644 index 5b28cca7187b98..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convolution_backprop_data.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -// DEPRECATED, can't be removed currently due to arm and kmb-plugin dependency (#55568) - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { - -typedef std::tuple< - InferenceEngine::SizeVector, // Kernel size - InferenceEngine::SizeVector, // Strides - std::vector, // Pad begin - std::vector, // Pad end - InferenceEngine::SizeVector, // Dilation - size_t, // Num out channels - ov::op::PadType, // Padding type - std::vector // Output padding -> convBackpropDataSpecificParams; -typedef std::tuple< - convBackpropDataSpecificParams, - InferenceEngine::Precision, // Net precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - InferenceEngine::SizeVector, // Input shapes - InferenceEngine::SizeVector, // Output shapes - LayerTestsUtils::TargetDevice // Device name -> convBackpropDataLayerTestParamsSet; - -class ConvolutionBackpropDataLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/ctc_greedy_decoder.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/ctc_greedy_decoder.hpp deleted file mode 100644 index 8b5291934e0146..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/ctc_greedy_decoder.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { -typedef std::tuple< - InferenceEngine::Precision, - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - InferenceEngine::SizeVector, - bool, - std::string> ctcGreedyDecoderParams; - -class CTCGreedyDecoderLayerTest - : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/ctc_greedy_decoder_seq_len.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/ctc_greedy_decoder_seq_len.hpp deleted file mode 100644 index ba3d58d6e6b2a3..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/ctc_greedy_decoder_seq_len.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { -typedef std::tuple< - InferenceEngine::SizeVector, // Input shape - int, // Sequence lengths - InferenceEngine::Precision, // Probabilities precision - InferenceEngine::Precision, // Indices precision - int, // Blank index - bool, // Merge repeated - std::string // Device name - > ctcGreedyDecoderSeqLenParams; - -class CTCGreedyDecoderSeqLenLayerTest - : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/ctc_loss.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/ctc_loss.hpp deleted file mode 100644 index 53ba55889e3f6a..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/ctc_loss.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { - -typedef std::tuple< - std::vector, // Logits shapes - std::vector, // logits length - std::vector>, // labels - std::vector, // labels length - int, // blank index - bool, // preprocessCollapseRepeated - bool, // ctcMergeRepeated - bool // Unique -> CTCLossParamsSubset; - -typedef std::tuple< - CTCLossParamsSubset, - InferenceEngine::Precision, // Float point precision - InferenceEngine::Precision, // Integer precision - LayerTestsUtils::TargetDevice // Device name -> CTCLossParams; - -class CTCLossLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/cum_sum.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/cum_sum.hpp deleted file mode 100644 index 0b3746b5406543..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/cum_sum.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" - -namespace LayerTestsDefinitions { - -typedef std::tuple< - InferenceEngine::SizeVector, // Input shapes - InferenceEngine::Precision, // Input precision - int64_t, // Axis - bool, // Exclusive - bool, // Reverse - std::string> cumSumParams; // Device name - -class CumSumLayerTest : public testing::WithParamInterface, virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/deformable_convolution.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/deformable_convolution.hpp deleted file mode 100644 index c93764b6dde36c..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/deformable_convolution.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { - -typedef std::tuple< - InferenceEngine::SizeVector, // Deformable values size - InferenceEngine::SizeVector, // Kernel size - InferenceEngine::SizeVector, // Strides - std::vector, // Pad begin - std::vector, // Pad end - InferenceEngine::SizeVector, // Dilation - size_t, // Groups - size_t, // Deformable groups - size_t, // Num out channels - ov::op::PadType, // Padding type - bool, // Bilinear interpolation pad - bool // Modulation -> deformableConvSpecificParams; -typedef std::tuple< - deformableConvSpecificParams, - InferenceEngine::Precision, // Net precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - InferenceEngine::SizeVector, // Input shapes - LayerTestsUtils::TargetDevice // Device name -> deformableConvLayerTestParamsSet; - -class DeformableConvolutionLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo &info) const override; - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/deformable_psroi_pooling.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/deformable_psroi_pooling.hpp deleted file mode 100644 index 9ad896f62bfa86..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/deformable_psroi_pooling.hpp +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { - -using deformablePSROISpecificParams = std::tuple< - std::vector, // data input shape - std::vector, // rois input shape - std::vector, // trans input shape - int64_t, // output_dim - int64_t, // group_size - float, // spatial_scale - std::vector, // spatial_bins_x_y - float, // trans_std - int64_t>; // part_size - -using deformablePSROILayerTestParams = std::tuple< - deformablePSROISpecificParams, - InferenceEngine::Precision, // Net precision - LayerTestsUtils::TargetDevice>; // Device name - -class DeformablePSROIPoolingLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { - public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - void GenerateInputs() override; - - protected: - void SetUp() override; - - private: - float spatialScale_; - }; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/depth_to_space.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/depth_to_space.hpp deleted file mode 100644 index 26d972933f8851..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/depth_to_space.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" - -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { - -using depthToSpaceParamsTuple = typename std::tuple< - std::vector, // Input shape - InferenceEngine::Precision, // Input precision - ov::op::v0::DepthToSpace::DepthToSpaceMode, // Mode - std::size_t, // Block size - std::string>; // Device name> - -class DepthToSpaceLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/detection_output.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/detection_output.hpp deleted file mode 100644 index fe62ca78376ee2..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/detection_output.hpp +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { - -std::ostream& operator <<(std::ostream& os, const ov::op::v0::DetectionOutput::Attributes& inputShape); - -enum { - idxLocation, - idxConfidence, - idxPriors, - idxArmConfidence, - idxArmLocation, - numInputs -}; - -using DetectionOutputAttributes = std::tuple< - int, // numClasses - int, // backgroundLabelId - int, // topK - std::vector, // keepTopK - std::string, // codeType - float, // nmsThreshold - float, // confidenceThreshold - bool, // clip_afterNms - bool, // clip_beforeNms - bool // decreaseLabelId ->; - -using ParamsWhichSizeDepends = std::tuple< - bool, // varianceEncodedInTarget - bool, // shareLocation - bool, // normalized - size_t, // inputHeight - size_t, // inputWidth - InferenceEngine::SizeVector, // "Location" input - InferenceEngine::SizeVector, // "Confidence" input - InferenceEngine::SizeVector, // "Priors" input - InferenceEngine::SizeVector, // "ArmConfidence" input - InferenceEngine::SizeVector // "ArmLocation" input ->; - -using DetectionOutputParams = std::tuple< - DetectionOutputAttributes, - ParamsWhichSizeDepends, - size_t, // Number of batch - float, // objectnessScore - std::string // Device name ->; - -class DetectionOutputLayerTest : public testing::WithParamInterface, virtual public LayerTestsUtils::LayerTestsCommon { - public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - ov::op::v0::DetectionOutput::Attributes attrs; - std::vector inShapes; - void GenerateInputs() override; - void Compare(const std::vector>> &expectedOutputs, - const std::vector &actualOutputs) override; - protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/dft.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/dft.hpp deleted file mode 100644 index 1dee86fcad06fd..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/dft.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" - -namespace LayerTestsDefinitions { - -typedef std::tuple< - InferenceEngine::SizeVector, // Input shapes - InferenceEngine::Precision, // Input precision - std::vector, // Axes - std::vector, // Signal size - ngraph::helpers::DFTOpType, - std::string> DFTParams; // Device name - -class DFTLayerTest : public testing::WithParamInterface, virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/einsum.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/einsum.hpp deleted file mode 100644 index 6934f26861dd3c..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/einsum.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { - -typedef std::tuple< - std::string, // Equation - std::vector> // Input shapes -> EinsumEquationWithInput; - -typedef std::tuple< - InferenceEngine::Precision, // Input precision - EinsumEquationWithInput, // Equation with corresponding input shapes - std::string // Device name -> EinsumLayerTestParamsSet; - -class EinsumLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/eltwise.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/eltwise.hpp deleted file mode 100644 index 8a3aaa6755bc22..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/eltwise.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// -// NOTE: WILL BE REWORKED (31905) - -#pragma once - -#include "ov_models/utils/ov_helpers.hpp" -#include "common_test_utils/common_utils.hpp" -#include "shared_test_classes/base/ov_subgraph.hpp" - -namespace ov { -namespace test { -namespace subgraph { - -typedef std::tuple< - std::vector, // input shapes - ngraph::helpers::EltwiseTypes, // eltwise op type - ngraph::helpers::InputLayerType, // secondary input type - ov::test::utils::OpType, // op type - ElementType, // Net precision - ElementType, // In precision - ElementType, // Out precision - TargetDevice, // Device name - ov::AnyMap // Additional network configuration -> EltwiseTestParams; - -class EltwiseLayerTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest { -protected: - void SetUp() override; - -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -private: - void transformInputShapesAccordingEltwise(const ov::PartialShape& secondInputShape); -}; -} // namespace subgraph -} // namespace test -} // namespace ov diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/embedding_bag_offsets_sum.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/embedding_bag_offsets_sum.hpp deleted file mode 100644 index 60b1fb152b0a8d..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/embedding_bag_offsets_sum.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { - -typedef std::tuple< - std::vector, // emb_table_shape - std::vector, // indices - std::vector, // offsets - size_t, // default_index - bool, // with_weights - bool // with_def_index -> embeddingBagOffsetsSumParams; - -typedef std::tuple< - embeddingBagOffsetsSumParams, - InferenceEngine::Precision, // embedding table - InferenceEngine::Precision, // indices - LayerTestsUtils::TargetDevice> embeddingBagOffsetsSumLayerTestParamsSet; - -class EmbeddingBagOffsetsSumLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/embedding_bag_packed_sum.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/embedding_bag_packed_sum.hpp deleted file mode 100644 index aebd414f0326f5..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/embedding_bag_packed_sum.hpp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { - -typedef std::tuple< - std::vector, // emb_table_shape - std::vector>, // indices - bool // with_weights -> embeddingBagPackedSumParams; - -typedef std::tuple< - embeddingBagPackedSumParams, - InferenceEngine::Precision, // embedding table - InferenceEngine::Precision, // indices - LayerTestsUtils::TargetDevice> embeddingBagPackedSumLayerTestParamsSet; - - -class EmbeddingBagPackedSumLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/embedding_segments_sum.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/embedding_segments_sum.hpp deleted file mode 100644 index e683252eff7327..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/embedding_segments_sum.hpp +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { - -typedef std::tuple< - std::vector, // emb_table_shape - std::vector, // indices - std::vector, // segment_ids - size_t, // num_segments - size_t, // default_index - bool, // with_weights - bool // with_def_index -> embeddingSegmentsSumParams; - -typedef std::tuple< - embeddingSegmentsSumParams, - InferenceEngine::Precision, // embedding table - InferenceEngine::Precision, // indices - LayerTestsUtils::TargetDevice> embeddingSegmentsSumLayerTestParamsSet; - -class EmbeddingSegmentsSumLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/experimental_detectron_detection_output.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/experimental_detectron_detection_output.hpp deleted file mode 100644 index e62f86d9b3f05c..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/experimental_detectron_detection_output.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ov_models/utils/ov_helpers.hpp" -#include "common_test_utils/common_utils.hpp" -#include "shared_test_classes/base/ov_subgraph.hpp" - -namespace ov { -namespace test { -namespace subgraph { - -typedef std::tuple< - std::vector, // inputShapes - float, // score_threshold - float, // nms_threshol - float, // max_delta_log_wh - int64_t, // num_classes - int64_t, // post_nms_count - size_t, // max_detections_per_image - bool, // class_agnostic_box_regression - std::vector, // deltas_weights - ElementType, // Network precision - std::string // Device name -> ExperimentalDetectronDetectionOutputTestParams; - -class ExperimentalDetectronDetectionOutputLayerTest : - public testing::WithParamInterface, - virtual public SubgraphBaseTest { -protected: - void SetUp() override; - void generate_inputs(const std::vector& targetInputStaticShapes) override; - -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); -}; -} // namespace subgraph -} // namespace test -} // namespace ov diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/experimental_detectron_generate_proposals_single_image.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/experimental_detectron_generate_proposals_single_image.hpp deleted file mode 100644 index 5946ee093f705d..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/experimental_detectron_generate_proposals_single_image.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ov_models/utils/ov_helpers.hpp" -#include "common_test_utils/common_utils.hpp" -#include "shared_test_classes/base/ov_subgraph.hpp" - -namespace ov { -namespace test { -namespace subgraph { - -typedef std::tuple< - std::vector, // Input shapes - float, // min_size: minimum box width & height - float, // nms_threshold: specifies NMS threshold - int64_t, // post_nms_count: number of top-n proposals after NMS - int64_t, // pre_nms_count: number of top-n proposals after NMS - std::pair>, // input tensors - ElementType, // Network precision - std::string // Device name>; -> ExperimentalDetectronGenerateProposalsSingleImageTestParams; - -class ExperimentalDetectronGenerateProposalsSingleImageLayerTest : - public testing::WithParamInterface, - virtual public SubgraphBaseTest { -protected: - void SetUp() override; - void generate_inputs(const std::vector& targetInputStaticShapes) override; - -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); -}; -} // namespace subgraph -} // namespace test -} // namespace ov diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/experimental_detectron_prior_grid_generator.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/experimental_detectron_prior_grid_generator.hpp index 8ab367b39981e4..b61f888d387f12 100644 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/experimental_detectron_prior_grid_generator.hpp +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/experimental_detectron_prior_grid_generator.hpp @@ -35,4 +35,4 @@ class ExperimentalDetectronPriorGridGeneratorLayerTest : }; } // namespace subgraph } // namespace test -} // namespace ov +} // namespace ov \ No newline at end of file diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/experimental_detectron_roifeatureextractor.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/experimental_detectron_roifeatureextractor.hpp deleted file mode 100644 index 38f480a0a6ae45..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/experimental_detectron_roifeatureextractor.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ov_models/utils/ov_helpers.hpp" -#include "common_test_utils/common_utils.hpp" -#include "shared_test_classes/base/ov_subgraph.hpp" - -namespace ov { -namespace test { -namespace subgraph { - -using Attrs = ov::op::v6::ExperimentalDetectronROIFeatureExtractor::Attributes; -using ExperimentalROI = ov::op::v6::ExperimentalDetectronROIFeatureExtractor; - -typedef std::tuple< - std::vector, // Input shapes - int64_t, // Output size - int64_t, // Sampling ratio - std::vector, // Pyramid scales - bool, // Aligned - ElementType, // Network precision - std::string // Device name>; -> ExperimentalDetectronROIFeatureExtractorTestParams; - -class ExperimentalDetectronROIFeatureExtractorLayerTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest { -protected: - void SetUp() override; - -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); -}; -} // namespace subgraph -} // namespace test -} // namespace ov diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/experimental_detectron_topkrois.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/experimental_detectron_topkrois.hpp deleted file mode 100644 index 091c865a893bb6..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/experimental_detectron_topkrois.hpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "ov_models/utils/ov_helpers.hpp" -#include "common_test_utils/common_utils.hpp" -#include "shared_test_classes/base/ov_subgraph.hpp" - -namespace ov { -namespace test { -namespace subgraph { - -typedef std::tuple< - std::vector, // input shape - int64_t , // Max rois - ElementType, // Network precision - std::string // Device name -> ExperimentalDetectronTopKROIsTestParams; - -class ExperimentalDetectronTopKROIsLayerTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest { -protected: - void SetUp() override; - -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); -}; -} // namespace subgraph -} // namespace test -} // namespace ov diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/extract_image_patches.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/extract_image_patches.hpp deleted file mode 100644 index 8240652b6182fb..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/extract_image_patches.hpp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { - -using extractImagePatchesTuple = typename std::tuple< - std::vector, // input shape - std::vector, // kernel size - std::vector, // strides - std::vector, // rates - ov::op::PadType, // pad type - InferenceEngine::Precision, // Network precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - LayerTestsUtils::TargetDevice>; // Device name - -class ExtractImagePatchesTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/eye.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/eye.hpp deleted file mode 100644 index 6c3f83069faa91..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/eye.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// -#pragma once - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { - -using ElementType = ov::element::Type_t; -using TargetDevice = std::string; -using LocalElementType = ov::element_type_traits::value_type; - -using EyeLayerTestParams = std::tuple, // eye shape - std::vector, // output batch shape - std::vector, // eye params (rows, cols, diag_shift) - ElementType, // Net precision - TargetDevice>; // Device name - -class EyeLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(testing::TestParamInfo obj); - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/fake_quantize.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/fake_quantize.hpp deleted file mode 100644 index 66e5d3b0ef485f..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/fake_quantize.hpp +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -// seed selected using current cloc time -#define USE_CLOCK_TIME 1 -// seed started from default value, and incremented every time using big number like 9999 -#define USE_INCREMENTAL_SEED 2 - -/** - * redefine this seed to reproduce issue with given seed that can be read from gtest logs - */ -#define BASE_SEED 123 -#define NGRAPH_SEED 123 - -namespace LayerTestsDefinitions { - - -typedef std::tuple< - size_t, // fake quantize levels - std::vector, // fake quantize inputs shape - std::vector, // fake quantize (inputLow, inputHigh, outputLow, outputHigh) or empty for random - std::vector, // input generator data (low, high, resolution) or empty for default - ov::op::AutoBroadcastSpec // fake quantize broadcast mode -> fqSpecificParams; -typedef std::tuple< - fqSpecificParams, - InferenceEngine::Precision, // Net precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - InferenceEngine::SizeVector, // Input shapes - LayerTestsUtils::TargetDevice, // Device name - - std::pair> // Additional backend configuration and alis name to it -> fqLayerTestParamsSet; - -class FakeQuantizeLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo &info) const override; -protected: - void SetUp() override; - void UpdateSeed(); - - protected: - float inputDataMin = 0.0; - float inputDataMax = 10.0; - float inputDataResolution = 1.0; - int32_t seed = 1; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/gather.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/gather.hpp deleted file mode 100644 index c2f354f39200a6..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/gather.hpp +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { - -typedef std::tuple< - std::vector, // Indices - std::vector, // Indices shape - int, // Gather axis - std::vector, // Input shapes - InferenceEngine::Precision, // Network precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - std::string // Device name -> gatherParamsTuple; - -class GatherLayerTestBase : virtual public LayerTestsUtils::LayerTestsCommon { -public: - using ::testing::Test::SetUp; -protected: - void SetUp(const gatherParamsTuple& params); -}; - -class GatherLayerTest : public testing::WithParamInterface, public GatherLayerTestBase { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; -}; - - -typedef std::tuple< - std::vector, // Input shapes - std::vector, // Indices shape - std::tuple, // Gather axis and batch - InferenceEngine::Precision, // Network precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - std::string // Device name -> gather7ParamsTuple; - -class Gather7LayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -class Gather8LayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -class Gather8IndiceScalarLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -typedef std::tuple< - gather7ParamsTuple, - std::vector // indices data -> gather8withIndicesDataParamsTuple; - -class Gather8withIndicesDataLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/gather_elements.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/gather_elements.hpp deleted file mode 100644 index 8d5cc5467fa6b3..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/gather_elements.hpp +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { - -typedef std::tuple< - std::vector, // Data shapes - std::vector, // Indices shape - int, // Axis - InferenceEngine::Precision, // Data precision - InferenceEngine::Precision, // Indices precision - LayerTestsUtils::TargetDevice // Device name -> GatherElementsParams; - -class GatherElementsLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/gather_nd.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/gather_nd.hpp deleted file mode 100644 index 9e9705009578af..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/gather_nd.hpp +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { -using Config = std::map; - -typedef std::tuple< - std::vector, // Data shapes - std::vector, // Indices shape - int // batch dims -> GatherNDParamsSubset; - -typedef std::tuple< - GatherNDParamsSubset, - InferenceEngine::Precision, // Data precision - InferenceEngine::Precision, // Indices precision - LayerTestsUtils::TargetDevice, // Device name - Config // Plugin config -> GatherNDParams; - -class GatherNDLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; -}; - -class GatherND8LayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/gather_tree.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/gather_tree.hpp deleted file mode 100644 index 41925413e75d89..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/gather_tree.hpp +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { - -using GatherTreeParamsTuple = typename std::tuple< - std::vector, // Input tensors shape - ngraph::helpers::InputLayerType, // Secondary input type - InferenceEngine::Precision, // Network precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - std::string>; // Device name - -class GatherTreeLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo &info) const override; - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/generate_proposals.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/generate_proposals.hpp deleted file mode 100644 index d2c06541eff2b1..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/generate_proposals.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ov_models/utils/ov_helpers.hpp" -#include "common_test_utils/common_utils.hpp" -#include "shared_test_classes/base/ov_subgraph.hpp" - -namespace ov { -namespace test { -namespace subgraph { - -typedef std::tuple< - std::vector, // Input shapes - float, // min_size: minimum box width & height - float, // nms_threshold: specifies NMS threshold - int64_t, // post_nms_count: number of top-n proposals after NMS - int64_t, // pre_nms_count: number of top-n proposals after NMS - bool, // normalized: specifies whether box is normalized or not - std::pair>, // input tensors - ElementType, // Network precision - ElementType, // roi_num precision - std::string // Device name>; -> GenerateProposalsTestParams; - -class GenerateProposalsLayerTest : - public testing::WithParamInterface, - virtual public SubgraphBaseTest { -protected: - void SetUp() override; - void generate_inputs(const std::vector& targetInputStaticShapes) override; - void compare(const std::vector& expected, const std::vector& actual) override; - -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); -}; -} // namespace subgraph -} // namespace test -} // namespace ov diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/grid_sample.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/grid_sample.hpp deleted file mode 100644 index 19e06b49d5f443..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/grid_sample.hpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { - -using GridSampleParams = std::tuple; // Device name - -class GridSampleLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/grn.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/grn.hpp deleted file mode 100644 index 0e7cf8de26d7a2..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/grn.hpp +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "common_test_utils/common_utils.hpp" -#include "functional_test_utils/blob_utils.hpp" -#include "ie_core.hpp" -#include "ie_precision.hpp" - -#include "functional_test_utils/blob_utils.hpp" -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "common_test_utils/common_utils.hpp" - -#include "ov_models/utils/ov_helpers.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { -typedef std::tuple< - InferenceEngine::Precision, - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - InferenceEngine::SizeVector, - float, - std::string> grnParams; - -class GrnLayerTest - : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon{ -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - InferenceEngine::SizeVector inputShapes; - float bias; - - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/group_convolution.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/group_convolution.hpp deleted file mode 100644 index de90196085c575..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/group_convolution.hpp +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { -typedef std::tuple< - InferenceEngine::SizeVector, - InferenceEngine::SizeVector, - std::vector, - std::vector, - InferenceEngine::SizeVector, - size_t, - size_t, - ov::op::PadType> groupConvSpecificParams; -typedef std::tuple< - groupConvSpecificParams, - InferenceEngine::Precision, - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - InferenceEngine::SizeVector, - LayerTestsUtils::TargetDevice> groupConvLayerTestParamsSet; - -class GroupConvolutionLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/group_convolution_backprop_data.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/group_convolution_backprop_data.hpp deleted file mode 100644 index 03017430c08572..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/group_convolution_backprop_data.hpp +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { - -// DEPRECATED, remove this old API when KMB (#58495) and ARM (#58496) plugins are migrated to new API -using groupConvBackpropDataSpecificParams = std::tuple< - InferenceEngine::SizeVector, // kernels - InferenceEngine::SizeVector, // strides - std::vector, // pad begins - std::vector, // pad ends - InferenceEngine::SizeVector, // dilations - size_t, // num output channels - size_t, // num groups - ov::op::PadType>; // padding type -using groupConvBackpropDataLayerTestParamsSet = std::tuple< - groupConvBackpropDataSpecificParams, - InferenceEngine::Precision, // Network precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - InferenceEngine::SizeVector, // Input shape - LayerTestsUtils::TargetDevice>; // Device name - -class GroupConvBackpropDataLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -using groupConvBackpropSpecificParams = std::tuple< - InferenceEngine::SizeVector, // kernels - InferenceEngine::SizeVector, // strides - std::vector, // pad begins - std::vector, // pad ends - InferenceEngine::SizeVector, // dilations - size_t, // num output channels - size_t, // num groups - ov::op::PadType, // padding type - std::vector>; // output padding -using groupConvBackpropLayerTestParamsSet = std::tuple< - groupConvBackpropSpecificParams, - InferenceEngine::Precision, // Network precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - InferenceEngine::SizeVector, // Input shape - InferenceEngine::SizeVector, // Output shapes - LayerTestsUtils::TargetDevice>; // Device name - -class GroupConvBackpropLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(testing::TestParamInfo obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/gru_cell.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/gru_cell.hpp deleted file mode 100644 index ec6c7e61a462b5..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/gru_cell.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { - -using GRUCellParams = typename std::tuple< - bool, // using decompose to sub-ops transformation - size_t, // batch - size_t, // hidden size - size_t, // input size - std::vector, // activations - float, // clip - bool, // linear_before_reset - ngraph::helpers::InputLayerType, // W input type (Constant or Parameter) - ngraph::helpers::InputLayerType, // R input type (Constant or Parameter) - ngraph::helpers::InputLayerType, // B input type (Constant or Parameter) - InferenceEngine::Precision, // Network precision - std::string>; // Device name - -class GRUCellTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/gru_sequence.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/gru_sequence.hpp deleted file mode 100644 index 02a529a5a9bab4..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/gru_sequence.hpp +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" -#include "common_test_utils/test_enums.hpp" - -namespace LayerTestsDefinitions { - -using GRUSequenceParams = typename std::tuple< - ngraph::helpers::SequenceTestsMode, // pure Sequence or TensorIterator - size_t, // seq_lengths - size_t, // batch - size_t, // hidden size - // todo: fix. input size hardcoded to 10 due to limitation (10 args) of gtests Combine() func. - //size_t, // input size - std::vector, // activations - float, // clip - bool, // linear_before_reset - ov::op::RecurrentSequenceDirection, // direction - ngraph::helpers::InputLayerType, // WRB input type (Constant or Parameter) - InferenceEngine::Precision, // Network precision - std::string>; // Device name - -class GRUSequenceTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; - void GenerateInputs() override; - ngraph::helpers::SequenceTestsMode m_mode; - int64_t m_max_seq_len = 0; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/interpolate.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/interpolate.hpp deleted file mode 100644 index f2206ddf789ad0..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/interpolate.hpp +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" - -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { - -typedef std::tuple< - ov::op::util::InterpolateBase::InterpolateMode, // InterpolateMode - ov::op::util::InterpolateBase::ShapeCalcMode, // ShapeCalculationMode - ov::op::util::InterpolateBase::CoordinateTransformMode, // CoordinateTransformMode - ov::op::util::InterpolateBase::NearestMode, // NearestMode - bool, // AntiAlias - std::vector, // PadBegin - std::vector, // PadEnd - double, // Cube coef - std::vector, // Axes - std::vector // Scales -> InterpolateSpecificParams; - -typedef std::tuple< - InterpolateSpecificParams, - InferenceEngine::Precision, // Net precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - InferenceEngine::SizeVector, // Input shapes - InferenceEngine::SizeVector, // Target shapes - LayerTestsUtils::TargetDevice, // Device name - std::map // Additional network configuration -> InterpolateLayerTestParams; - -class InterpolateLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -namespace v11 { - -class InterpolateLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace v11 - -//Interpolate-1 test -typedef std::tuple< - InferenceEngine::Precision, // Net precision - InferenceEngine::Precision, // Input precision, output is the same - InferenceEngine::Layout, // Input layout, output is the same - InferenceEngine::SizeVector, // Input shapes - InferenceEngine::SizeVector, // Target shapes - std::string, // InterpolateMode - ngraph::AxisSet, // Axes - bool, // AntiAlias - std::vector, // Pads - LayerTestsUtils::TargetDevice // Device name -> Interpolate1LayerTestParams; - -class Interpolate1LayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(testing::TestParamInfo obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/is_inf.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/is_inf.hpp deleted file mode 100644 index 96971c3705c8be..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/is_inf.hpp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include - -#include "shared_test_classes/base/ov_subgraph.hpp" - -namespace ov { -namespace test { -namespace subgraph { - -using IsInfParams = std::tuple< - std::vector, // Data shape - bool, // Detect negative - bool, // Detect positive - ElementType, // Data precision - std::string, // Device name - std::map // Additional config - >; - -class IsInfLayerTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; - void generate_inputs(const std::vector& targetInputStaticShapes) override; -}; - -} // namespace subgraph -} // namespace test -} // namespace ov diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/log_softmax.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/log_softmax.hpp deleted file mode 100644 index 7218309e776dc2..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/log_softmax.hpp +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { - -using logSoftmaxLayerTestParams = std::tuple< - InferenceEngine::Precision, // netPrecision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - InferenceEngine::SizeVector, // inputShape - int64_t, // axis - std::string, // targetDevice - std::map // config ->; - -class LogSoftmaxLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/logical.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/logical.hpp deleted file mode 100644 index 81c80b8345c64f..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/logical.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -#include -#include - -#include "common_test_utils/common_utils.hpp" -#include "common_test_utils/test_common.hpp" -#include "common_test_utils/test_constants.hpp" -#include "ie_core.hpp" - -namespace LayerTestsDefinitions { -namespace LogicalParams { -using InputShapesTuple = std::pair, std::vector>; -} // LogicalParams - -typedef std::tuple< - LogicalParams::InputShapesTuple, // Input shapes tuple - ngraph::helpers::LogicalTypes, // Logical op type - ngraph::helpers::InputLayerType, // Second input type - InferenceEngine::Precision, // Net precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - std::string, // Device name - std::map // Additional network configuration -> LogicalTestParams; - -class LogicalLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -protected: - InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo &info) const override; - void SetupParams(); - void SetUp() override; - -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - static std::vector combineShapes(const std::map, std::vector>>& inputShapes); - -protected: - LogicalParams::InputShapesTuple inputShapes; - ngraph::helpers::LogicalTypes logicalOpType; - ngraph::helpers::InputLayerType secondInputType; - InferenceEngine::Precision netPrecision; - std::map additional_config; -}; -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/loop.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/loop.hpp deleted file mode 100644 index adbfd3e5c1a822..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/loop.hpp +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { -enum LOOP_IN_TYPE { - INVARIANT, - MERGED -}; - -using LoopParams = typename std::tuple< - bool, // ExecuteFirstIteration - bool, // BodyCondition is a constant? - bool, // BodyCondition value, if it is a Const - int64_t, // TripCount, -1 means infinity - std::vector, LOOP_IN_TYPE>>, // inputs - InferenceEngine::Precision, // Network precision - std::string>; // Device name - -class LoopTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; -}; - - -using StaticShapeLoopParams = typename std::tuple< - bool, - bool, - std::tuple< - bool, - int64_t, - int64_t, - int64_t - >, - int64_t, - InferenceEngine::SizeVector, - InferenceEngine::Precision, - std::string, - std::map - >; - -/** - * Test case with static SHAPE version of loop operation. - * Total iteration count is dynamic. - */ -class StaticShapeLoopTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo &info) const override; - std::vector>> PredefinedRefs(); - -private: - bool unrolling; // unroll Loop - bool static_iter_num; // trip count provided by constant node - bool static_continue_cond; // initial_cond provided by constant node - int64_t max_iter_num; // -1 means infinity loop (expected dynamic exit condition in body) - int64_t dynamic_exit; // -1 means always true - int64_t axis; // -1 means no auto concatenation - int64_t start_value; - InferenceEngine::SizeVector data_shape; - InferenceEngine::Precision data_prc; - - int64_t actual_n_iter(); - -protected: - void SetUp() override; -}; - - -class TrivialLoopTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -protected: - using RefBlobGenerator = std::function; - std::map inputGens, outputGens; - - void CreateSlicedLoop(size_t batch_size, size_t num_iteration, InferenceEngine::Precision iePrc, - InferenceEngine::SizeVector& ieShape); - void CreateSlicedLoopDynCondition(size_t batch_size, size_t num_iteration, InferenceEngine::Precision iePrc, - InferenceEngine::SizeVector& ieShape, size_t trip_count); - InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo &info) const override { - auto found = inputGens.find(info.name()); - if (found != inputGens.end()) { - return found->second(info.getTensorDesc()); - } - - found = inputGens.find(""); - if (found != inputGens.end()) { - return found->second(info.getTensorDesc()); - } - - return LayerTestsCommon::GenerateInput(info); - } - - std::vector>> CalculateRefs() override { - if (outputGens.empty()) - return LayerTestsCommon::CalculateRefs(); - - const auto results = function->get_results(); - const auto outs_info = cnnNetwork.getOutputsInfo(); - const auto num_out_blob = results.size(); - - std::vector>> res_collection(num_out_blob); - - for (size_t i = 0; i < num_out_blob; i++) { - // TODO: name of original NG result doesn't match with outs after conversion. - // Expected : auto name = results[i]->get_friendly_name(); - auto name = results[i]->get_input_node_ptr(0)->get_friendly_name(); - auto data = outs_info.at(name); - IE_ASSERT(data != nullptr); - - RefBlobGenerator generator; - auto found = outputGens.find(name); - if (found != outputGens.end()) { - generator = found->second; - } else { - found = outputGens.find(""); - if (found != outputGens.end()) { - generator = found->second; - } - } - - IE_ASSERT(generator != nullptr) << "Test output generator is not specified"; - auto blob = generator(data->getTensorDesc()); - auto blob_size = blob->byteSize(); - auto blob_ptr = blob->buffer().as(); - - auto &res = res_collection[i]; - res.second.resize(blob_size); - std::copy(blob_ptr, blob_ptr + blob_size, res.second.begin()); - } - return res_collection; - } -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/low_precision.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/low_precision.hpp deleted file mode 100644 index 990394bcab167b..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/low_precision.hpp +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LowPrecisionTestDefinitions { - -typedef std::tuple< - InferenceEngine::Precision, // Net precision - LayerTestsUtils::TargetDevice, // Device name - std::pair> // Configuration -> lowPrecisionTestParamsSet; - -class LowPrecisionTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; -// ! [test_low_precision:definition] - -} // namespace LowPrecisionTestDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/lrn.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/lrn.hpp deleted file mode 100644 index d4a3f69a707374..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/lrn.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { - -typedef std::tuple< - double, // Alpha - double, // Beta - double, // Bias - size_t, // Size - std::vector, // Reduction axes - InferenceEngine::Precision, // Network precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::SizeVector, // Input shapes - std::string // Device name -> lrnLayerTestParamsSet; - -class LrnLayerTest - : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/lstm_cell.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/lstm_cell.hpp deleted file mode 100644 index 1145c588794328..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/lstm_cell.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { - -using LSTMCellParams = typename std::tuple< - bool, // using decompose to sub-ops transformation - size_t, // batch - size_t, // hidden size - size_t, // input size - std::vector, // activations - float, // clip - ngraph::helpers::InputLayerType, // W input type (Constant or Parameter) - ngraph::helpers::InputLayerType, // R input type (Constant or Parameter) - ngraph::helpers::InputLayerType, // B input type (Constant or Parameter) - InferenceEngine::Precision, // Network precision - std::string>; // Device name - -class LSTMCellTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/lstm_cell_basic.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/lstm_cell_basic.hpp deleted file mode 100644 index 878da4062d3358..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/lstm_cell_basic.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { - -using LSTMCellBasicParams = typename std::tuple< - bool, // using decompose to sub-ops transformation - size_t, // batch - size_t, // hidden size - size_t, // input size - std::vector, // activations - float, // clip - InferenceEngine::Precision, // Network precision - std::string, // Device name - std::map>; // Config - -class LSTMCellBasicTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/lstm_sequence.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/lstm_sequence.hpp deleted file mode 100644 index 65ef47607874f5..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/lstm_sequence.hpp +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { - -using LSTMSequenceParams = typename std::tuple< - ngraph::helpers::SequenceTestsMode, // pure Sequence or TensorIterator - size_t, // seq_lengths - size_t, // batch - size_t, // hidden size - size_t, // input size - std::vector, // activations - float, // clip - ov::op::RecurrentSequenceDirection, // direction - ngraph::helpers::InputLayerType, // WRB input type (Constant or Parameter) - InferenceEngine::Precision, // Network precision - std::string>; // Device name - - -class LSTMSequenceTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); -protected: - void GenerateInputs() override; - void SetUp() override; - - ngraph::helpers::SequenceTestsMode m_mode; - int64_t m_max_seq_len = 0; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/mat_mul.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/mat_mul.hpp deleted file mode 100644 index 1b7f2a0898f710..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/mat_mul.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { -struct ShapeRelatedParams { - std::pair input1, input2; -}; - -typedef std::tuple< - ShapeRelatedParams, - InferenceEngine::Precision, // Network precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - ngraph::helpers::InputLayerType, // Secondary input type - LayerTestsUtils::TargetDevice, // Device name - std::map // Additional network configuration -> MatMulLayerTestParamsSet; - -class MatMulTest : public testing::WithParamInterface, virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - static std::vector combineShapes(const std::vector>& firstInputShapes, - const std::vector>& secondInputShapes, - bool transposeA, - bool transposeB); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/matrix_nms.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/matrix_nms.hpp deleted file mode 100644 index c00c76acaba6dc..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/matrix_nms.hpp +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include - -#include "ov_models/utils/ov_helpers.hpp" -#include "common_test_utils/common_utils.hpp" -#include "shared_test_classes/base/ov_subgraph.hpp" - -namespace ov { -namespace test { -namespace subgraph { - -using InputPrecisions = std::tuple; // iou_threshold, score_threshold, - -using TopKParams = std::tuple; // Maximum number of boxes to be selected per batch element - -using ThresholdParams = std::tuple; // filter out boxes with low confidence score after decaying - -using NmsParams = std::tuple, // Params using to create 1st and 2nd inputs - InputPrecisions, // Input precisions - ov::op::v8::MatrixNms::SortResultType, // Order of output elements - ov::element::Type, // Output type - TopKParams, // Maximum number of boxes topk params - ThresholdParams, // Thresholds: score_threshold, gaussian_sigma, post_threshold - int, // Background class id - bool, // If boxes are normalized - ov::op::v8::MatrixNms::DecayFunction, // Decay function - bool, // make output shape static - std::string>; // Device name - -class MatrixNmsLayerTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - void generate_inputs(const std::vector& targetInputStaticShapes) override; - void compare(const std::vector &expected, const std::vector &actual) override; - -protected: - void SetUp() override; - -private: - void GetOutputParams(size_t& numBatches, size_t& maxOutputBoxesPerBatch); - ov::op::v8::MatrixNms::Attributes m_attrs; - bool m_outStaticShape; -}; - -} // namespace subgraph -} // namespace test -} // namespace ov diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/memory.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/memory.hpp deleted file mode 100644 index 4d285d6505ea01..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/memory.hpp +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { - -using MemoryTestParams = std::tuple< - ngraph::helpers::MemoryTransformation, // Apply Memory transformation - int64_t, // iterationCount - InferenceEngine::SizeVector, // inputShape - InferenceEngine::Precision, // netPrecision - std::string // targetDevice ->; - -class MemoryTest : public testing::WithParamInterface, virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - void Run() override; - -protected: - std::vector>> CalculateRefs() override; - void SetUp() override; - void Infer() override; - virtual std::shared_ptr CreateReadValueOp( - const ov::Output& value, const std::shared_ptr& variable) const { - return std::make_shared(value, variable); - } - virtual std::shared_ptr CreateAssignOp( - const ov::Output& value, const std::shared_ptr& variable) const { - return std::make_shared(value, variable); - } - - virtual void CreateCommonFunc(); - - ov::element::Type ngPrc; - ov::Shape inputShape; - -private: - void CreateTIFunc(); - void ApplyLowLatency(); - - InferenceEngine::Precision netPrecision; - ov::EvaluationContext eval_context; - ngraph::helpers::MemoryTransformation transformation; - - int64_t iteration_count; -}; - -class MemoryTestV3 : public MemoryTest { -protected: - std::shared_ptr CreateReadValueOp( - const ov::Output& value, const std::shared_ptr& variable) const override { - return std::make_shared(value, variable->get_info().variable_id); - } - - std::shared_ptr CreateAssignOp( - const ov::Output& value, const std::shared_ptr& variable) const override { - return std::make_shared(value, variable->get_info().variable_id); - } -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/minimum_maximum.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/minimum_maximum.hpp deleted file mode 100644 index bee0cde0cdfea5..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/minimum_maximum.hpp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" -#include "common_test_utils/test_constants.hpp" - -namespace LayerTestsDefinitions { - -using MaxMinParamsTuple = typename std::tuple< - std::vector>, // Input shapes - ngraph::helpers::MinMaxOpType, // OperationType - InferenceEngine::Precision, // Network precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - ngraph::helpers::InputLayerType, // Secondary input type - std::string>; // Device name - -class MaxMinLayerTest: - public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon{ -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); -protected: - void SetUp() override; -}; -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/multiclass_nms.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/multiclass_nms.hpp deleted file mode 100644 index 3c8f9fb246b0f6..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/multiclass_nms.hpp +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include - -#include "ov_models/utils/ov_helpers.hpp" -#include "common_test_utils/common_utils.hpp" -#include "shared_test_classes/base/ov_subgraph.hpp" - -namespace ov { -namespace test { -namespace subgraph { - -using InputPrecisions = std::tuple; // iou_threshold, score_threshold, - // soft_nms_sigma precisions - -using InputfloatVar = std::tuple; // nmsEta - -using InputboolVar = std::tuple; // normalized - -using MulticlassNmsParams = std::tuple, // Params using to create inputs - InputPrecisions, // Input precisions - int32_t, // Max output boxes per class - InputfloatVar, // iouThreshold, scoreThreshold, nmsEta - int32_t, // background_class - int32_t, // keep_top_k - ov::element::Type, // Output type - ov::op::util::MulticlassNmsBase::SortResultType, // SortResultType - InputboolVar, // Sort result across batch, normalized - bool, // make output shape static - std::string>; - -class MulticlassNmsLayerTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - void generate_inputs(const std::vector& targetInputStaticShapes) override; - void compare(const std::vector &expected, const std::vector &actual) override; - -protected: - void SetUp() override; - virtual std::shared_ptr CreateNmsOp(const OutputVector& paramOuts) const { - std::shared_ptr nms; - if (paramOuts.size() > 2) { - nms = std::make_shared(paramOuts[0], paramOuts[1], paramOuts[2], m_attrs); - } else { - nms = std::make_shared(paramOuts[0], paramOuts[1], m_attrs); - } - return nms; - } - ov::op::util::MulticlassNmsBase::Attributes m_attrs; - -private: - void GetOutputParams(size_t& numBatches, size_t& maxOutputBoxesPerBatch); - bool m_outStaticShape; -}; - -class MulticlassNmsLayerTest8 : public MulticlassNmsLayerTest { -protected: - std::shared_ptr CreateNmsOp(const OutputVector& paramOuts) const override { - return std::make_shared(paramOuts[0], paramOuts[1], m_attrs); - } -}; -} // namespace subgraph -} // namespace test -} // namespace ov diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/multinomial.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/multinomial.hpp deleted file mode 100644 index af42c02638c773..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/multinomial.hpp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// -#pragma once -#include "ov_models/builders.hpp" -#include "common_test_utils/common_utils.hpp" -#include "shared_test_classes/base/ov_subgraph.hpp" - -namespace ov { -namespace test { -namespace subgraph { - -using MultinomialTestParams = std::tuple< - ElementType, // netPrecision - ElementType, // inPrecision - ElementType, // outPrecision - InputShape, // Dynamic shape + Target static shapes - std::int64_t, // Number of samples - element::Type_t, // Output type attribute - bool, // With replacement, - bool, // Log probs; - TargetDevice, // targetDevice - Config // config - >; - -class MultinomialTest : public testing::WithParamInterface, - virtual public ov::test::SubgraphBaseTest { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; -}; - -} // namespace subgraph -} // namespace test -} // namespace ov diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/mvn.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/mvn.hpp deleted file mode 100644 index 1cd6f8ae7ee2cb..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/mvn.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { - -typedef std::tuple< - InferenceEngine::SizeVector, // Input shapes - InferenceEngine::Precision, // Input precision - ngraph::AxisSet, // Reduction axes - bool, // Across channels - bool, // Normalize variance - double, // Epsilon - std::string // Device name - > mvn1Params; - -class Mvn1LayerTest : public testing::WithParamInterface, virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -typedef std::tuple< - InferenceEngine::SizeVector, // Input shapes - InferenceEngine::Precision, // Data precision - InferenceEngine::Precision, // Axes precision - std::vector, // Axes - bool, // Normalize variance - float, // Epsilon - std::string, // Epsilon mode - std::string // Device name - > mvn6Params; - -class Mvn6LayerTest : public testing::WithParamInterface, virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/nms_rotated.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/nms_rotated.hpp deleted file mode 100644 index 64e9ddc1535d5c..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/nms_rotated.hpp +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" - - -namespace LayerTestsDefinitions { - -using InputShapeParams = std::tuple; // Number of classes - -using InputPrecisions = - std::tuple; // iou_threshold, score_threshold, soft_nms_sigma precisions - -using NmsRotatedParams = std::tuple; // Device name - -class NmsRotatedLayerTest : public testing::WithParamInterface, virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - void GenerateInputs() override; - void Compare(const std::vector>>& expectedOutputs, - const std::vector& actualOutputs) override; - -protected: - void SetUp() override; - InputShapeParams inShapeParams; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/non_max_suppression.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/non_max_suppression.hpp deleted file mode 100644 index aeb31ea4ad0d58..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/non_max_suppression.hpp +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include - -#include "ov_models/builders.hpp" -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace testing { -namespace internal { - -template <> -inline void PrintTo(const ::ov::op::v5::NonMaxSuppression::BoxEncodingType& value, ::std::ostream* os) {} - -} // namespace internal -} // namespace testing - -namespace LayerTestsDefinitions { - -using InputShapeParams = std::tuple; // Number of classes - -using InputPrecisions = - std::tuple; // iou_threshold, score_threshold, soft_nms_sigma precisions - -using NmsParams = std::tuple; // Device name - -class NmsLayerTest : public testing::WithParamInterface, virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - void GenerateInputs() override; - void Compare(const std::vector>>& expectedOutputs, - const std::vector& actualOutputs) override; - -protected: - void SetUp() override; - InputShapeParams inShapeParams; - -private: - void CompareBBoxes(const std::vector>>& expectedOutputs, - const std::vector& actualOutputs); -}; - -class Nms9LayerTest : public NmsLayerTest { -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/nonzero.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/nonzero.hpp deleted file mode 100644 index e1eff18607cd60..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/nonzero.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/base/layer_test_utils.hpp" - -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -#include -#include -#include -#include - -namespace LayerTestsDefinitions { - -using ConfigMap = typename std::map; - -using NonZeroLayerTestParamsSet = typename std::tuple< - InferenceEngine::SizeVector, // Input shapes - InferenceEngine::Precision, // Input precision - LayerTestsUtils::TargetDevice, // Device name - ConfigMap>; // Additional network configuration - -class NonZeroLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/normalize_l2.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/normalize_l2.hpp deleted file mode 100644 index 3c46d1c5cf3522..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/normalize_l2.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" - -namespace LayerTestsDefinitions { - -using NormalizeL2LayerTestParams = std::tuple< - std::vector, // axes - float, // eps - ov::op::EpsMode, // eps_mode - InferenceEngine::SizeVector, // inputShape - InferenceEngine::Precision, // netPrecision - std::string // targetDevice ->; - -class NormalizeL2LayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; - InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo &info) const override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/one_hot.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/one_hot.hpp deleted file mode 100644 index f16ed98f9a43b9..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/one_hot.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -namespace LayerTestsDefinitions { -typedef std::tuple< - ov::element::Type, // depth type (any integer type) - int64_t, // depth value - ov::element::Type, // On & Off values type (any supported type) - float, // OnValue - float, // OffValue - int64_t, // axis - InferenceEngine::Precision, // Net precision - InferenceEngine::SizeVector, // Input shapes - LayerTestsUtils::TargetDevice // Target device name -> oneHotLayerTestParamsSet; - -class OneHotLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/pad.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/pad.hpp deleted file mode 100644 index 2fa4e951e47f52..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/pad.hpp +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" - -namespace LayerTestsDefinitions { -typedef std::tuple< - std::vector, // padsBegin - std::vector, // padsEnd - float, // argPadValue - ngraph::helpers::PadMode, // padMode - InferenceEngine::Precision, // Net precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::SizeVector, // Input shapes - LayerTestsUtils::TargetDevice // Target device name -> padLayerTestParamsSet; - -class PadLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; - virtual std::shared_ptr CreatePadOp(const ov::Output& data, - const std::vector& padsBegin, - const std::vector& padsEnd, - float argPadValue, - ngraph::helpers::PadMode padMode) const { - OPENVINO_SUPPRESS_DEPRECATED_START - const auto pad = ngraph::builder::makePad(data, padsBegin, padsEnd, argPadValue, padMode, false); - OPENVINO_SUPPRESS_DEPRECATED_END - return pad; - } -}; - -class PadLayerTest12 : public PadLayerTest { -protected: - std::shared_ptr CreatePadOp(const ov::Output& data, - const std::vector& padsBegin, - const std::vector& padsEnd, - float argPadValue, - ngraph::helpers::PadMode padMode) const override { - OPENVINO_SUPPRESS_DEPRECATED_START - const auto pad = ngraph::builder::makePad(data, padsBegin, padsEnd, argPadValue, padMode, true); - OPENVINO_SUPPRESS_DEPRECATED_END - return pad; - } -}; -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/pooling.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/pooling.hpp deleted file mode 100644 index 3cdc51ad43f9b4..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/pooling.hpp +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { - -typedef std::tuple< - ngraph::helpers::PoolingTypes, // Pooling type, max or avg - std::vector, // Kernel size - std::vector, // Stride - std::vector, // Pad begin - std::vector, // Pad end - ov::op::RoundingType, // Rounding type - ov::op::PadType, // Pad type - bool // Exclude pad -> poolSpecificParams; -typedef std::tuple< - poolSpecificParams, - InferenceEngine::Precision, // Net precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - std::vector, // Input shape - std::string // Device name -> poolLayerTestParamsSet; - -typedef std::tuple< - poolSpecificParams, - InferenceEngine::Precision, // Net precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - size_t, // Channel number - std::string // Device name -> globalPoolLayerTestParamsSet; - -typedef std::tuple< - std::vector, // Kernel size - std::vector, // Stride - std::vector, // Dilation - std::vector, // Pad begin - std::vector, // Pad end - ov::element::Type_t, // Index element type - int64_t, // Axis - ov::op::RoundingType, // Rounding type - ov::op::PadType // Pad type -> maxPoolV8SpecificParams; - -typedef std::tuple< - maxPoolV8SpecificParams, - InferenceEngine::Precision, // Net precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - std::vector, // Input shape - std::string // Device name -> maxPoolV8LayerTestParamsSet; - -class PoolingLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -class GlobalPoolingLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -class MaxPoolingV8LayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/power.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/power.hpp deleted file mode 100644 index 1a22a296c8c57e..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/power.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "common_test_utils/test_constants.hpp" - -namespace LayerTestsDefinitions { - - using PowerParamsTuple = typename std::tuple< - std::vector>, //input shapes - InferenceEngine::Precision, //Network precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - std::string, //Device name - std::vector>; //power - -class PowerLayerTest: - public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon{ -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); -protected: - void SetUp() override; -}; -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/prior_box.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/prior_box.hpp deleted file mode 100644 index 08761d7110d809..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/prior_box.hpp +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "common_test_utils/common_utils.hpp" -#include "functional_test_utils/blob_utils.hpp" -#include "ie_core.hpp" -#include "ie_precision.hpp" - -#include "functional_test_utils/blob_utils.hpp" -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "common_test_utils/common_utils.hpp" - -#include "ov_models/utils/ov_helpers.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { -using priorBoxSpecificParams = std::tuple< - std::vector, // min_size - std::vector, // max_size - std::vector, // aspect_ratio - std::vector, // density - std::vector, // fixed_ratio - std::vector, // fixed_size - bool, // clip - bool, // flip - float, // step - float, // offset - std::vector, // variance - bool, // scale_all_sizes - bool>; // min_max_aspect_ratios_order - -typedef std::tuple< - priorBoxSpecificParams, - InferenceEngine::Precision, // net precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - InferenceEngine::SizeVector, // input shape - InferenceEngine::SizeVector, // image shape - std::string> priorBoxLayerParams; - -class PriorBoxLayerTest - : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); -protected: - InferenceEngine::SizeVector inputShapes; - InferenceEngine::SizeVector imageShapes; - InferenceEngine::Precision netPrecision; - std::vector min_size; - std::vector max_size; - std::vector aspect_ratio; - std::vector density; - std::vector fixed_ratio; - std::vector fixed_size; - std::vector variance; - float step; - float offset; - bool clip; - bool flip; - bool scale_all_sizes; - bool min_max_aspect_ratios_order; - - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/prior_box_clustered.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/prior_box_clustered.hpp deleted file mode 100644 index 1f35f829f5d61a..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/prior_box_clustered.hpp +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "common_test_utils/common_utils.hpp" -#include "functional_test_utils/blob_utils.hpp" -#include "ie_core.hpp" -#include "ie_precision.hpp" - -#include "functional_test_utils/blob_utils.hpp" -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "common_test_utils/common_utils.hpp" - -#include "ov_models/utils/ov_helpers.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { - -typedef std::tuple< - std::vector, // widths - std::vector, // heights - bool, // clip - float, // step_width - float, // step_height - float, // step - float, // offset - std::vector> priorBoxClusteredSpecificParams; - -typedef std::tuple< - priorBoxClusteredSpecificParams, - InferenceEngine::Precision, // net precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - InferenceEngine::SizeVector, // input shape - InferenceEngine::SizeVector, // image shape - std::string> priorBoxClusteredLayerParams; - -class PriorBoxClusteredLayerTest - : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - InferenceEngine::SizeVector inputShapes; - InferenceEngine::SizeVector imageShapes; - InferenceEngine::Precision netPrecision; - std::vector widths; - std::vector heights; - std::vector variances; - float step_width; - float step_height; - float step; - float offset; - bool clip; - - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/proposal.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/proposal.hpp deleted file mode 100644 index 31223f0b26728e..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/proposal.hpp +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { - -namespace proposalTypes { - -typedef size_t base_size_type; -typedef size_t pre_nms_topn_type; -typedef size_t post_nms_topn_type; -typedef float nms_thresh_type; -typedef size_t min_size_type; -typedef std::vector ratio_type; -typedef std::vector scale_type; -typedef bool clip_before_nms_type; -typedef bool clip_after_nms_type; -typedef bool normalize_type; -typedef size_t feat_stride_type; -typedef float box_size_scale_type; -typedef float box_coordinate_scale_type; -typedef std::string framework_type; - -}; // namespace proposalTypes - -using namespace proposalTypes; - -typedef std::tuple< - base_size_type, - pre_nms_topn_type, - post_nms_topn_type, - nms_thresh_type, - min_size_type, - ratio_type, - scale_type, - clip_before_nms_type, - clip_after_nms_type, - framework_type> proposalSpecificParams; -typedef std::tuple< - proposalSpecificParams, - std::string> proposalLayerTestParamsSet; - -class ProposalLayerTest - : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - static std::string SerializeProposalSpecificParams(proposalSpecificParams& params); - InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo &info) const override; - void Compare(const std::vector>> &expectedOutputs, - const std::vector &actualOutputs) override; - template - void Compare(const T *expected, const T *actual, std::size_t size, - T threshold, const std::size_t output_index) { - for (std::size_t i = 0; i < size; ++i) { - const auto &ref = expected[i]; - const auto &res = actual[i]; - - // verify until first -1 appears in the 1st output. - if (output_index == 0 && - ov::test::utils::ie_abs(ref - static_cast(-1)) <= threshold) { - // output0 shape = {x, 5} - // output1 shape = {x} - // setting the new_size for output1 verification - num_selected_boxes = i / 5; - return; - } - - const auto absoluteDifference = ov::test::utils::ie_abs(res - ref); - if (absoluteDifference <= threshold) { - continue; - } - - const auto max = std::max(ov::test::utils::ie_abs(res), - ov::test::utils::ie_abs(ref)); - float diff = - static_cast(absoluteDifference) / static_cast(max); - ASSERT_TRUE(max != 0 && (diff <= static_cast(threshold))) - << "Relative comparison of values expected: " << ref - << " and actual: " << res << " at index " << i - << " with threshold " << threshold << " failed"; - } - } -protected: - void SetUp() override; - -private: - size_t num_selected_boxes; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/psroi_pooling.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/psroi_pooling.hpp deleted file mode 100644 index 14f35e754b1787..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/psroi_pooling.hpp +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { - -using psroiParams = std::tuple, // input shape - std::vector, // coords shape - size_t, // output_dim - size_t, // group_size - float, // Spatial scale - size_t, // spatial_bins_x - size_t, // spatial_bins_y - std::string, // mode - InferenceEngine::Precision, // Net precision - LayerTestsUtils::TargetDevice>; // Device name - -class PSROIPoolingLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { - public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - void GenerateInputs() override; - static void fillROITensor(float* buffer, int numROIs, int batchSize, - int height, int width, int groupSize, - float spatialScale, int spatialBinsX, int spatialBinsY, const std::string& mode); - - protected: - void SetUp() override; - - private: - size_t groupSize_; - float spatialScale_; - size_t spatialBinsX_; - size_t spatialBinsY_; - std::string mode_; - }; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/random_uniform.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/random_uniform.hpp deleted file mode 100644 index faa9430c80ab6f..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/random_uniform.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "constant.hpp" - -namespace LayerTestsDefinitions { - -struct RandomUniformTypeSpecificParams { - InferenceEngine::Precision precision; // Output data precision - double min_value; // min value constant, will be cast to the needed precision - double max_value; // max value constant, will be cast to the needed precision -}; - -using RandomUniformParamsTuple = typename std::tuple< - ov::Shape, // output shape - RandomUniformTypeSpecificParams, // parameters which depends on output type - int64_t, // global seed - int64_t, // operation seed - std::string>; // Device name - -class RandomUniformLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; - - void ConvertRefsParams() override; -}; - -} // namespace LayerTestsDefinitions - diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/range.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/range.hpp deleted file mode 100644 index b83fcee41fd1ec..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/range.hpp +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" - -namespace LayerTestsDefinitions { -typedef std::tuple< - float, // start - float, // stop - float, // step - InferenceEngine::Precision, // Net precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - std::string // Target device name -> RangeParams; - -class RangeLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { - float start, stop, step; -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - void Infer() override; - -protected: - void SetUp() override; -}; - -class RangeNumpyLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - void Infer() override; -protected: - void SetUp() override; -private: - float start, stop, step; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/rdft.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/rdft.hpp deleted file mode 100644 index aeaf504a117f95..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/rdft.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" - -namespace LayerTestsDefinitions { - -typedef std::tuple< - InferenceEngine::SizeVector, // Input shapes - InferenceEngine::Precision, // Input precision - std::vector, // Axes - std::vector, // Signal size - ngraph::helpers::DFTOpType, - std::string> RDFTParams; // Device name - -class RDFTLayerTest : public testing::WithParamInterface, virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/reduce_ops.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/reduce_ops.hpp deleted file mode 100644 index cb63bffe99a234..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/reduce_ops.hpp +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" - -namespace LayerTestsDefinitions { - -typedef std::tuple< - std::vector, // Axis to reduce order - ov::test::utils::OpType, // Scalar or vector type axis - bool, // Keep dims - ngraph::helpers::ReductionType, // Reduce operation type - InferenceEngine::Precision, // Net precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - std::vector, // Input shapes - std::string // Target device name -> reduceMeanParams; - -class ReduceOpsLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo &info) const override; - -protected: - void SetUp() override; -}; - -class ReduceOpsLayerWithSpecificInputTest : public ReduceOpsLayerTest { -protected: - InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo &info) const override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/region_yolo.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/region_yolo.hpp deleted file mode 100644 index 5a56fc002b2868..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/region_yolo.hpp +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { - -using regionYoloParamsTuple = std::tuple< - ov::Shape, // Input Shape - size_t, // classes - size_t, // coordinates - size_t, // num regions - bool, // do softmax - std::vector, // mask - int, // start axis - int, // end axis - InferenceEngine::Precision, // Network precision - std::string>; // Device name - -class RegionYoloLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/reorg_yolo.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/reorg_yolo.hpp deleted file mode 100644 index 2431ece8314db5..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/reorg_yolo.hpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { - -using ReorgYoloParamsTuple = typename std::tuple< - ov::Shape, // Input Shape - size_t, // stride - InferenceEngine::Precision, // Network precision - std::string>; // Device name - -class ReorgYoloLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/reshape.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/reshape.hpp deleted file mode 100644 index 814444bff712ed..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/reshape.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { - -typedef std::tuple, // Input shapes - std::vector, // OutForm Shapes - std::string, // Device name - std::map // Config - > - reshapeParams; -class ReshapeLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/result.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/result.hpp deleted file mode 100644 index 71cdbdae6dad38..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/result.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { - -using ConfigMap = typename std::map; - -using ResultTestParamSet = typename std::tuple< - InferenceEngine::SizeVector, // Input shapes - InferenceEngine::Precision, // Input precision - LayerTestsUtils::TargetDevice, // Device name - ConfigMap>; // Additional network configuration - -class ResultLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/reverse.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/reverse.hpp deleted file mode 100644 index 31521f05cd2a9e..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/reverse.hpp +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { -using reverseParams = std::tuple, // input shape - std::vector, // axes - std::string, // mode - InferenceEngine::Precision, // net precision - LayerTestsUtils::TargetDevice>; // device name - -class ReverseLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/reverse_sequence.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/reverse_sequence.hpp deleted file mode 100644 index 77049ac9c20c39..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/reverse_sequence.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { - -using ReverseSequenceParamsTuple = typename std::tuple< - int64_t, // Index of the batch dimension - int64_t, // Index of the sequence dimension - std::vector, // Input shapes - std::vector, // Shape of the input vector with sequence lengths to be reversed - ngraph::helpers::InputLayerType, // Secondary input type - InferenceEngine::Precision, // Network precision - std::string>; // Device name - -class ReverseSequenceLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/rnn_cell.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/rnn_cell.hpp deleted file mode 100644 index 9af0ac37ee2877..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/rnn_cell.hpp +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { - -using RNNCellParams = typename std::tuple< - bool, // using decompose to sub-ops transformation - size_t, // batch - size_t, // hidden size - size_t, // input size - std::vector, // activations - float, // clip - ngraph::helpers::InputLayerType, // W input type (Constant or Parameter) - ngraph::helpers::InputLayerType, // R input type (Constant or Parameter) - ngraph::helpers::InputLayerType, // B input type (Constant or Parameter) - InferenceEngine::Precision, // Network precision - std::string>; // Device name - -class RNNCellTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/rnn_sequence.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/rnn_sequence.hpp deleted file mode 100644 index 3292cdd015ffb3..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/rnn_sequence.hpp +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { - -using RNNSequenceParams = typename std::tuple< - ngraph::helpers::SequenceTestsMode, // pure Sequence or TensorIterator - size_t, // seq_lengths - size_t, // batch - size_t, // hidden size - size_t, // input size - std::vector, // activations - float, // clip - ov::op::RecurrentSequenceDirection, // direction - ngraph::helpers::InputLayerType, // WRB input type (Constant or Parameter) - InferenceEngine::Precision, // Network precision - std::string>; // Device name - -class RNNSequenceTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; - void GenerateInputs() override; - -private: - ngraph::helpers::SequenceTestsMode m_mode; - int64_t m_max_seq_len = 0; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/roi_align.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/roi_align.hpp deleted file mode 100644 index 5628ef23f0f87f..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/roi_align.hpp +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { - -using roialignParams = std::tuple, // feature map shape - std::vector, // proposal coords shape - int, // bin's row count - int, // bin's column count - float, // spatial scale - int, // pooling ratio - std::string, // pooling mode - InferenceEngine::Precision, // net precision - LayerTestsUtils::TargetDevice>; // device name - -class ROIAlignLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - static void fillCoordTensor(std::vector& coords, int height, int width, - float spatialScale, int pooledRatio, int pooledH, int pooledW); - static void fillIdxTensor(std::vector& idx, int batchSize); - -protected: - void SetUp() override; - -private: - int pooledH; - int pooledW; - float spatialScale; - int poolingRatio; - std::string poolingMode; -}; - -using roialignV9Params = std::tuple, // feature map shape - std::vector, // proposal coords shape - int, // bin's row count - int, // bin's column count - float, // spatial scale - int, // pooling ratio - std::string, // pooling mode - std::string, // roi aligned mode - InferenceEngine::Precision, // net precision - LayerTestsUtils::TargetDevice>; // device name - -class ROIAlignV9LayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; - -private: - int pooledH; - int pooledW; - float spatialScale; - int poolingRatio; - std::string poolingMode; - std::string roiAlignedMode; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/roi_pooling.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/roi_pooling.hpp deleted file mode 100644 index 9ca462fa1f9ad2..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/roi_pooling.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { - -using roiPoolingParamsTuple = std::tuple< - InferenceEngine::SizeVector, // Input shape - InferenceEngine::SizeVector, // Coords shape - std::vector, // Pooled shape {pooled_h, pooled_w} - float, // Spatial scale - ngraph::helpers::ROIPoolingTypes, // ROIPooling method - InferenceEngine::Precision, // Net precision - LayerTestsUtils::TargetDevice>; // Device name - -class ROIPoolingLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - void GenerateInputs() override; - -protected: - void SetUp() override; - -private: - ngraph::helpers::ROIPoolingTypes pool_method; - float spatial_scale; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/roll.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/roll.hpp deleted file mode 100644 index da3748424f9fd6..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/roll.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" - -namespace LayerTestsDefinitions { - -typedef std::tuple< - InferenceEngine::SizeVector, // Input shapes - InferenceEngine::Precision, // Input precision - std::vector, // Shift - std::vector, // Axes - std::string> rollParams; // Device name - -class RollLayerTest : public testing::WithParamInterface, virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/scatter_ND_update.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/scatter_ND_update.hpp deleted file mode 100644 index 7aeb0dafbb7817..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/scatter_ND_update.hpp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { -using sliceSelectInShape = std::tuple< - std::vector, // input shape - std::vector, // indices shape - std::vector, // indices value - std::vector>; // update shape - -using scatterNDUpdateParamsTuple = typename std::tuple< - sliceSelectInShape, // Input description - InferenceEngine::Precision, // Network precision - InferenceEngine::Precision, // indices precision - std::string>; // Device name - -class ScatterNDUpdateLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - static std::vector combineShapes( - const std::map, std::map, std::vector>>& inputShapes); - -protected: - void SetUp() override; -}; -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/scatter_elements_update.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/scatter_elements_update.hpp deleted file mode 100644 index 46c5b0d3c42d51..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/scatter_elements_update.hpp +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { -using axisShapeInShape = std::tuple< - std::vector, // input shape - std::vector, // update shape - int>; // axis - -using scatterElementsUpdateParamsTuple = typename std::tuple< - axisShapeInShape, // shape description - std::vector, // indices value - InferenceEngine::Precision, // Network precision - InferenceEngine::Precision, // indices precision - std::string>; // Device name - -using scatterElementsUpdate12ParamsTuple = typename std::tuple< - axisShapeInShape, // shape description - std::vector, // indices value - ov::op::v12::ScatterElementsUpdate::Reduction, // Reduce mode - bool, // Use init value - InferenceEngine::Precision, // Network precision - InferenceEngine::Precision, // indices precision - std::string>; // Device name - -class ScatterElementsUpdateLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - static std::vector combineShapes( - const std::map, std::map, std::vector>>& inputShapes); - -protected: - void SetUp() override; -}; - -class ScatterElementsUpdate12LayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); -protected: - void SetUp() override; -}; -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/scatter_update.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/scatter_update.hpp deleted file mode 100644 index fa5157ccee5b5a..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/scatter_update.hpp +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { -using axisUpdateShapeInShape = std::tuple< - std::vector, // input shape - std::vector, // indices shape - std::vector, // update shape - int64_t>; // axis - -using scatterUpdateParamsTuple = typename std::tuple< - axisUpdateShapeInShape, // shape description - std::vector, // indices value - InferenceEngine::Precision, // input precision - InferenceEngine::Precision, // indices precision - std::string>; // Device name - -class ScatterUpdateLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - static std::vector combineShapes( - const std::map, std::map, std::vector>>& inputShapes); - -protected: - void SetUp() override; -}; -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/select.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/select.hpp deleted file mode 100644 index 7426dc04a0ca03..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/select.hpp +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include - -#include "ov_models/builders.hpp" - -namespace LayerTestsDefinitions { - -typedef std::tuple< - std::vector>, // mask, then, else shapes - InferenceEngine::Precision, // then, else precision - ov::op::AutoBroadcastSpec, // broadcast - std::string> selectTestParams; // device name - -class SelectLayerTest : public testing::WithParamInterface, virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/shape_of.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/shape_of.hpp deleted file mode 100644 index 2bd8ed1d917644..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/shape_of.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { -typedef std::tuple< - InferenceEngine::Precision, // Network precision - std::vector, // Input shapes - std::string // Device name -> shapeOfParamsCommon; - -typedef std::tuple< - InferenceEngine::Precision, // Network precision - InferenceEngine::Precision, // Output precision - std::vector, // Input shapes - std::string // Device name -> shapeOfParams; - -class ShapeOfLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(testing::TestParamInfo obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/shuffle_channels.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/shuffle_channels.hpp deleted file mode 100644 index 566842c3a0c65a..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/shuffle_channels.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { - -typedef std::tuple< - int, // axis - int // group -> shuffleChannelsSpecificParams; - -typedef std::tuple< - shuffleChannelsSpecificParams, - InferenceEngine::Precision, // Net precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - InferenceEngine::SizeVector, // Input shapes - LayerTestsUtils::TargetDevice // Device name -> shuffleChannelsLayerTestParamsSet; - -class ShuffleChannelsLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/slice.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/slice.hpp deleted file mode 100644 index efed23ec5b6a24..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/slice.hpp +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "shared_test_classes/base/ov_subgraph.hpp" - -namespace LayerTestsDefinitions { - -struct Slice8SpecificParams { - std::vector shapes; - std::vector start; - std::vector stop; - std::vector step; - std::vector axes; -}; - -using Slice8Params = std::tuple< - Slice8SpecificParams, // Slice-8 specific parameters - ov::test::ElementType, // Net precision - ov::test::ElementType, // Input precision - ov::test::ElementType, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - std::string, // Device name - std::map // Additional network configuration ->; - -class Slice8LayerTest : public testing::WithParamInterface, - virtual public ov::test::SubgraphBaseTest { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; -}; -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/space_to_batch.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/space_to_batch.hpp deleted file mode 100644 index b3383f73c3d0f4..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/space_to_batch.hpp +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { - -using spaceToBatchParamsTuple = typename std::tuple< - std::vector, // block_shape - std::vector, // pads_begin - std::vector, // pads_end - std::vector, // Input shapes - InferenceEngine::Precision, // Network precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - std::string>; // Device name>; - -class SpaceToBatchLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; -}; -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/space_to_depth.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/space_to_depth.hpp deleted file mode 100644 index 361ff9fa41015c..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/space_to_depth.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" - -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { - -using spaceToDepthParamsTuple = typename std::tuple< - std::vector, // Input shape - InferenceEngine::Precision, // Input precision - ov::op::v0::SpaceToDepth::SpaceToDepthMode, // Mode - std::size_t, // Block size - std::string>; // Device name> - -class SpaceToDepthLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/split.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/split.hpp deleted file mode 100644 index ccb9a43b144758..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/split.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" - -namespace LayerTestsDefinitions { - -typedef std::tuple< - size_t, // Num splits - int64_t, // Axis - InferenceEngine::Precision, // Net precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - std::vector, // Input shapes - std::vector, // Used outputs indices - std::string // Target device name -> splitParams; - -class SplitLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/squeeze_unsqueeze.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/squeeze_unsqueeze.hpp deleted file mode 100644 index 995ca768b15b07..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/squeeze_unsqueeze.hpp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" - -namespace LayerTestsDefinitions { -using ShapeAxesTuple = std::pair, std::vector>; - -typedef std::tuple< - ShapeAxesTuple, // InputShape (required), Squeeze indexes (if empty treated as non-existent) - ngraph::helpers::SqueezeOpType, // OpType - InferenceEngine::Precision, // Net precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - std::string // Target device name -> squeezeParams; - -class SqueezeUnsqueezeLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/strided_slice.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/strided_slice.hpp deleted file mode 100644 index 3bc225c5ae6114..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/strided_slice.hpp +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsDefinitions { - -struct StridedSliceSpecificParams { - InferenceEngine::SizeVector inputShape; - std::vector begin; - std::vector end; - std::vector strides; - std::vector beginMask; - std::vector endMask; - std::vector newAxisMask; - std::vector shrinkAxisMask; - std::vector ellipsisAxisMask; -}; - -using StridedSliceParams = std::tuple< - StridedSliceSpecificParams, - InferenceEngine::Precision, // Net precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - std::string, // Device name - std::map // Additional network configuration ->; - -class StridedSliceLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; -}; -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/tensor_iterator.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/tensor_iterator.hpp deleted file mode 100644 index 15342892a43e1a..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/tensor_iterator.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { - -using TensorIteratorParams = typename std::tuple< - bool, // using unroll tensor iterator transformation - size_t, // seq_lengths - size_t, // batch - size_t, // hidden size - // todo: fix. input size hardcoded to 10 due to limitation (10 args) of gtests Combine() func. - //size_t, // input size - size_t, // sequence axis - float, // clip - ngraph::helpers::TensorIteratorBody, // body type - ov::op::RecurrentSequenceDirection, // direction - InferenceEngine::Precision, // Network precision - std::string>; // Device name - -class TensorIteratorTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/tile.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/tile.hpp deleted file mode 100644 index 1ce46e8bf30878..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/tile.hpp +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" - -namespace LayerTestsDefinitions { - -typedef std::vector TileSpecificParams; -typedef std::tuple< - TileSpecificParams, - InferenceEngine::Precision, // Net precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - InferenceEngine::SizeVector, // Input shapes - LayerTestsUtils::TargetDevice // Device name -> TileLayerTestParamsSet; - -class TileLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/topk.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/topk.hpp deleted file mode 100644 index 3759c0bef6d569..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/topk.hpp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" - -namespace LayerTestsDefinitions { -typedef std::tuple< - int64_t, // keepK - int64_t, // axis - ov::op::v3::TopK::Mode, // mode - ov::op::v3::TopK::SortType, // sort - InferenceEngine::Precision, // Net precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::SizeVector, // inputShape - std::string // Target device name -> TopKParams; - -class TopKLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo &info) const override; - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/transpose.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/transpose.hpp deleted file mode 100644 index b7547ac1aa8e47..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/transpose.hpp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" - -namespace LayerTestsDefinitions { - -typedef std::tuple< - std::vector, // Input order - InferenceEngine::Precision, // Net precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - std::vector, // Input shapes - std::string // Target device name -> transposeParams; - -class TransposeLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/variadic_split.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/variadic_split.hpp deleted file mode 100644 index b041d368e8f073..00000000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/variadic_split.hpp +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" - -namespace LayerTestsDefinitions { - -typedef std::tuple< - std::vector, // Num splits - int64_t, // Axis - InferenceEngine::Precision, // Net precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - std::vector, // Input shapes - std::string // Target device name -> VariadicSplitParams; - -class VariadicSplitLayerTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/group_normalization.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/group_normalization.hpp similarity index 98% rename from src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/group_normalization.hpp rename to src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/group_normalization.hpp index 1527c07a635977..f89e75b11f1d86 100644 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/group_normalization.hpp +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/group_normalization.hpp @@ -8,7 +8,6 @@ namespace ov { namespace test { -namespace subgraph { using GroupNormalizationTestParams = std::tuple, // Data shape - bool, // Detect negative - bool, // Detect positive - ov::element::Type, // Model type - std::string, // Device name - std::map // Additional config ->; +using IsInfParams = std::tuple, // Data shape + bool, // Detect negative + bool, // Detect positive + ov::element::Type, // Model type + std::string, // Device name + ov::AnyMap // Additional config + >; class IsInfLayerTest : public testing::WithParamInterface, virtual public SubgraphBaseTest { diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/topk.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/topk.hpp index 953a2cffe8661d..f3d2849ccc0615 100644 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/topk.hpp +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/topk.hpp @@ -21,11 +21,31 @@ typedef std::tuple< std::string // Target device name > TopKParams; +typedef std::tuple< + int64_t, // keepK + int64_t, // axis + ov::op::v1::TopK::Mode, // mode + ov::op::v1::TopK::SortType, // sort + ov::element::Type, // Model type + std::vector, // Input shape + bool, // Stable + std::string // Target device name +> TopK11Params; + class TopKLayerTest : public testing::WithParamInterface, virtual public ov::test::SubgraphBaseTest { public: static std::string getTestCaseName(const testing::TestParamInfo& obj); +protected: + void SetUp() override; +}; + +class TopK11LayerTest : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseTest { +public: + static std::string getTestCaseName(const testing::TestParamInfo& obj); + protected: void SetUp() override; }; diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/scaleshift.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/scaleshift.hpp index ac72c943319c2a..3c0a23c74d2bde 100644 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/scaleshift.hpp +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/scaleshift.hpp @@ -32,23 +32,3 @@ class ScaleShiftLayerTest: }; } // namespace test } // namespace ov - -// legacy impl for npu repo -namespace SubgraphTestsDefinitions { - -using ScaleShiftParamsTuple = typename std::tuple< - std::vector>, //input shapes - InferenceEngine::Precision, //Network precision - std::string, //Device name - std::vector, //scale - std::vector>; //shift - -class ScaleShiftLayerTest: - public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon{ -public: - static std::string getTestCaseName(const testing::TestParamInfo &obj); -protected: - void SetUp() override; -}; -} // namespace SubgraphTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/split_conv_concat.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/split_conv_concat.hpp index d74865a6bb0c6b..a08870dfb68006 100644 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/split_conv_concat.hpp +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/split_conv_concat.hpp @@ -30,16 +30,3 @@ class SplitConvConcat : public testing::WithParamInterface, - virtual public ov::test::SplitConvConcatBase { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - -} // namespace SubgraphTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/stateful_model.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/stateful_model.hpp index 70016ea8b6c840..807238dc6fa966 100644 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/stateful_model.hpp +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/stateful_model.hpp @@ -113,7 +113,7 @@ class StaticShapeStatefulModel : public StatefulModelTest { inputs.clear(); const auto& funcInputs = function->inputs(); const auto& funcInput = funcInputs.front(); - auto tensor = ov::runtime::Tensor{ov::element::f32, funcInput.get_shape()}; + auto tensor = ov::Tensor{ov::element::f32, funcInput.get_shape()}; auto inputData = tensor.data::value_type>(); inputData[0] = input_vals[i]; inputs.insert({funcInput.get_node_shared_ptr(), tensor}); @@ -222,7 +222,7 @@ class StaticShapeTwoStatesModel : public StatefulModelTest { inputs.clear(); const auto& funcInputs = function->inputs(); const auto& funcInput = funcInputs.front(); - auto tensor = ov::runtime::Tensor{testPrc, funcInput.get_shape()}; + auto tensor = ov::Tensor{testPrc, funcInput.get_shape()}; auto inputData = tensor.data::value_type>(); inputData[0] = input_vals[i]; inputs.insert({funcInput.get_node_shared_ptr(), tensor}); @@ -336,7 +336,7 @@ class DynamicShapeStatefulModel : public StatefulModelTest { auto states = inferRequest.query_state(); ASSERT_FALSE(states.empty()); - auto init_tensor = ov::runtime::Tensor{testPrc, ov::Shape{1, 1}}; + auto init_tensor = ov::Tensor{testPrc, ov::Shape{1, 1}}; auto init_data = init_tensor.data::value_type>(); init_data[0] = vec_state[0]; states.front().set_state(init_tensor); @@ -348,7 +348,7 @@ class DynamicShapeStatefulModel : public StatefulModelTest { auto &input_shape = shapes.front(); const auto& funcInputs = function->inputs(); const auto& funcInput = funcInputs.front(); - auto tensor = ov::runtime::Tensor{testPrc, input_shape}; + auto tensor = ov::Tensor{testPrc, input_shape}; auto input_data = tensor.data::value_type>(); for (size_t i = 0; i < input_shape.front(); ++i) { input_data[i] = input_vals[i]; @@ -507,7 +507,7 @@ class DynamicShapeStatefulModelStateAsInp : public StatefulModelTest { auto states = inferRequest.query_state(); ASSERT_FALSE(states.empty()); - auto init_tensor = ov::runtime::Tensor{testPrc, ov::Shape{1, 1}}; + auto init_tensor = ov::Tensor{testPrc, ov::Shape{1, 1}}; auto init_data = init_tensor.data::value_type>(); init_data[0] = vec_state[0]; states.front().set_state(init_tensor); @@ -519,7 +519,7 @@ class DynamicShapeStatefulModelStateAsInp : public StatefulModelTest { auto &input_shape = shapes.front(); const auto& funcInputs = function->inputs(); for (auto&& funcInput : funcInputs) { - auto tensor = ov::runtime::Tensor{testPrc, input_shape}; + auto tensor = ov::Tensor{testPrc, input_shape}; auto input_data = tensor.data::value_type>(); for (size_t i = 0; i < input_shape[1]; ++i) { input_data[i] = input_vals[i]; diff --git a/src/tests/functional/shared_test_classes/src/base/layer_test_utils.cpp b/src/tests/functional/shared_test_classes/src/base/layer_test_utils.cpp deleted file mode 100644 index 0ce03a96ac0fac..00000000000000 --- a/src/tests/functional/shared_test_classes/src/base/layer_test_utils.cpp +++ /dev/null @@ -1,700 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#ifdef _WIN32 -#include -#endif - -#include - -#include "common_test_utils/file_utils.hpp" -#include "functional_test_utils/core_config.hpp" -#include "ie_icore.hpp" -#include "openvino/opsets/opset.hpp" -#include "openvino/pass/serialize.hpp" -#include "openvino/runtime/device_id_parser.hpp" -#include "shared_test_classes/base/layer_test_utils.hpp" - -namespace LayerTestsUtils { - -namespace { -std::vector>> getConstData( - const std::shared_ptr& function) { - size_t numOutputs = function->get_output_size(); - std::vector>> outputs(numOutputs); - auto funcResults = function->get_results(); - for (size_t i = 0; i < numOutputs; i++) { - outputs[i].first = funcResults[i]->get_element_type(); - const auto& output = function->output(i).get_node_shared_ptr(); - OPENVINO_ASSERT(output->inputs().size() == 1); - auto parrentNode = output->input_value(0).get_node_shared_ptr(); - OPENVINO_ASSERT(ov::op::util::is_constant(parrentNode), - "Function was not fully folded to constant state!\n", - "Parent node of one of results is not constant and has type ", - parrentNode->get_type_name()); - - const auto data = std::dynamic_pointer_cast(parrentNode)->get_data_ptr(); - const auto dataSize = ov::shape_size(parrentNode->get_shape()) * parrentNode->get_element_type().size(); - outputs[i].second.resize(dataSize); - std::copy(data, data + dataSize, outputs[i].second.data()); - } - return outputs; -} -} // namespace - -LayerTestsCommon::LayerTestsCommon() : threshold(1e-2f), abs_threshold(-1.f) { - core = PluginCache::get().ie(targetDevice); -} - -void LayerTestsCommon::Run() { - bool isCurrentTestDisabled = ov::test::utils::current_test_is_disabled(); - - ov::test::utils::PassRate::Statuses status = isCurrentTestDisabled ? - ov::test::utils::PassRate::Statuses::SKIPPED : - ov::test::utils::PassRate::Statuses::CRASHED; - - auto &s = ov::test::utils::OpSummary::getInstance(); - s.setDeviceName(targetDevice); - s.updateOPsStats(function, status); - - if (isCurrentTestDisabled) - GTEST_SKIP() << "Disabled test due to configuration" << std::endl; - - if (functionRefs == nullptr) { - functionRefs = function->clone(); - functionRefs->set_friendly_name("refFunction"); - } - - // in case of crash jump will be made and work will be continued - auto crashHandler = std::unique_ptr(new ov::test::utils::CrashHandler()); - - // place to jump in case of a crash - int jmpRes = 0; -#ifdef _WIN32 - jmpRes = setjmp(ov::test::utils::env); -#else - jmpRes = sigsetjmp(ov::test::utils::env, 1); -#endif - if (jmpRes == ov::test::utils::JMP_STATUS::ok) { - crashHandler->StartTimer(); - try { - LoadNetwork(); - GenerateInputs(); - Infer(); - Validate(); - s.updateOPsStats(functionRefs, ov::test::utils::PassRate::Statuses::PASSED); - } - catch (const std::runtime_error &re) { - s.updateOPsStats(functionRefs, ov::test::utils::PassRate::Statuses::FAILED); - GTEST_FATAL_FAILURE_(re.what()); - } catch (const std::exception &ex) { - s.updateOPsStats(functionRefs, ov::test::utils::PassRate::Statuses::FAILED); - GTEST_FATAL_FAILURE_(ex.what()); - } catch (...) { - s.updateOPsStats(functionRefs, ov::test::utils::PassRate::Statuses::FAILED); - GTEST_FATAL_FAILURE_("Unknown failure occurred."); - } - } else if (jmpRes == ov::test::utils::JMP_STATUS::anyError) { - IE_THROW() << "Crash happens"; - } else if (jmpRes == ov::test::utils::JMP_STATUS::alarmErr) { - s.updateOPsStats(functionRefs, ov::test::utils::PassRate::Statuses::HANGED); - IE_THROW() << "Crash happens"; - } -} - -void LayerTestsCommon::Serialize(ov::pass::Serialize::Version ir_version) { - SKIP_IF_CURRENT_TEST_IS_DISABLED(); - - std::string output_name = ov::test::utils::generateTestFilePrefix(); - - std::string out_xml_path = output_name + ".xml"; - std::string out_bin_path = output_name + ".bin"; - - ov::pass::Manager manager; - manager.register_pass(out_xml_path, out_bin_path, ir_version); - manager.run_passes(function); - function->validate_nodes_and_infer_types(); - - auto result = getCore()->ReadNetwork(out_xml_path, out_bin_path); - - bool success; - std::string message; - std::tie(success, message) = - compare_functions(result.getFunction(), function, false, false, false, - true, // precision - true); // attributes - - EXPECT_TRUE(success) << message; - - ov::test::utils::removeIRFiles(out_xml_path, out_bin_path); -} - -void LayerTestsCommon::QueryNetwork() { - SKIP_IF_CURRENT_TEST_IS_DISABLED(); - - cnnNetwork = InferenceEngine::CNNNetwork(function); - - auto queryNetworkResult = PluginCache::get().ie()->QueryNetwork(cnnNetwork, targetDevice); - std::set expected; - for (auto&& node : function->get_ops()) { - expected.insert(node->get_friendly_name()); - } - - std::set actual; - for (auto&& res : queryNetworkResult.supportedLayersMap) { - // compare with originally used device name - ASSERT_EQ(ov::DeviceIDParser(res.second).get_device_name(), targetDevice); - - actual.insert(res.first); - } - ASSERT_EQ(expected, actual); -} - -InferenceEngine::Blob::Ptr LayerTestsCommon::GenerateInput(const InferenceEngine::InputInfo& info) const { - return FuncTestUtils::createAndFillBlob(info.getTensorDesc()); -} - -void LayerTestsCommon::Compare( - const std::vector>>& expectedOutputs, - const std::vector& actualOutputs, - float threshold, - float abs_threshold) { - for (std::size_t outputIndex = 0; outputIndex < expectedOutputs.size(); ++outputIndex) { - const auto &expected = expectedOutputs[outputIndex]; - const auto &actual = actualOutputs[outputIndex]; - Compare(expected, actual, threshold, abs_threshold); - } -} - -template -inline void callCompare(const std::pair>& expected, - const T_IE* actualBuffer, - size_t size, - float threshold, - float abs_threshold) { - auto expectedBuffer = expected.second.data(); - switch (expected.first) { - case ov::element::Type_t::boolean: - case ov::element::Type_t::u8: - LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), - actualBuffer, - size, - threshold, - abs_threshold); - break; - case ov::element::Type_t::i8: - LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), - actualBuffer, - size, - threshold, - abs_threshold); - break; - case ov::element::Type_t::u16: - LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), - actualBuffer, - size, - threshold, - abs_threshold); - break; - case ov::element::Type_t::i16: - LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), - actualBuffer, - size, - threshold, - abs_threshold); - break; - case ov::element::Type_t::u32: - LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), - actualBuffer, - size, - threshold, - abs_threshold); - break; - case ov::element::Type_t::i32: - LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), - actualBuffer, - size, - threshold, - abs_threshold); - break; - case ov::element::Type_t::u64: - LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), - actualBuffer, - size, - threshold, - abs_threshold); - break; - case ov::element::Type_t::i64: - LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), - actualBuffer, - size, - threshold, - abs_threshold); - break; - case ov::element::Type_t::bf16: - LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), - actualBuffer, - size, - threshold, - abs_threshold); - break; - case ov::element::Type_t::f16: - LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), - actualBuffer, - size, - threshold, - abs_threshold); - break; - case ov::element::Type_t::f32: - LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), - actualBuffer, - size, - threshold, - abs_threshold); - break; - case ov::element::Type_t::f64: - LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), - actualBuffer, - size, - threshold, - abs_threshold); - break; - case ov::element::Type_t::i4: { - auto expectedOut = - ngraph::helpers::convertOutputPrecision(expected.second, expected.first, ov::element::Type_t::i8, size); - LayerTestsCommon::Compare(reinterpret_cast(expectedOut.data()), - actualBuffer, - size, - threshold, - abs_threshold); - break; - } - case ov::element::Type_t::u4: { - auto expectedOut = - ngraph::helpers::convertOutputPrecision(expected.second, expected.first, ov::element::Type_t::u8, size); - LayerTestsCommon::Compare(reinterpret_cast(expectedOut.data()), - actualBuffer, - size, - threshold, - abs_threshold); - break; - } - case ov::element::Type_t::dynamic: - case ov::element::Type_t::undefined: - LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), - actualBuffer, - size, - threshold, - abs_threshold); - break; - default: - FAIL() << "Comparator for " << expected.first << " precision isn't supported"; - } - return; -} - -void LayerTestsCommon::Compare(const std::pair>& expected, - const InferenceEngine::Blob::Ptr& actual, - float threshold, - float abs_threshold) { - const auto &precision = actual->getTensorDesc().getPrecision(); - auto k = static_cast(expected.first.size()) / precision.size(); - // W/A for int4, uint4 - if (expected.first == ov::element::Type_t::u4 || expected.first == ov::element::Type_t::i4) { - k /= 2; - } else if (expected.first == ov::element::Type_t::undefined || expected.first == ov::element::Type_t::dynamic) { - k = 1; - } - ASSERT_EQ(expected.second.size(), actual->byteSize() * k); - - auto memory = InferenceEngine::as(actual); - IE_ASSERT(memory); - const auto lockedMemory = memory->wmap(); - const auto actualBuffer = lockedMemory.as(); - - const auto &size = actual->size(); - switch (precision) { - case InferenceEngine::Precision::BOOL: - case InferenceEngine::Precision::U8: - callCompare(expected, reinterpret_cast(actualBuffer), size, threshold, abs_threshold); - break; - case InferenceEngine::Precision::I8: - callCompare(expected, reinterpret_cast(actualBuffer), size, threshold, abs_threshold); - break; - case InferenceEngine::Precision::U16: - callCompare(expected, reinterpret_cast(actualBuffer), size, threshold, abs_threshold); - break; - case InferenceEngine::Precision::I16: - callCompare(expected, reinterpret_cast(actualBuffer), size, threshold, abs_threshold); - break; - case InferenceEngine::Precision::U32: - callCompare(expected, reinterpret_cast(actualBuffer), size, threshold, abs_threshold); - break; - case InferenceEngine::Precision::I32: - callCompare(expected, reinterpret_cast(actualBuffer), size, threshold, abs_threshold); - break; - case InferenceEngine::Precision::U64: - callCompare(expected, reinterpret_cast(actualBuffer), size, threshold, abs_threshold); - break; - case InferenceEngine::Precision::I64: - callCompare(expected, reinterpret_cast(actualBuffer), size, threshold, abs_threshold); - break; - case InferenceEngine::Precision::BF16: - callCompare(expected, - reinterpret_cast(actualBuffer), - size, - threshold, - abs_threshold); - break; - case InferenceEngine::Precision::FP16: - callCompare(expected, - reinterpret_cast(actualBuffer), - size, - threshold, - abs_threshold); - break; - case InferenceEngine::Precision::FP32: - callCompare(expected, reinterpret_cast(actualBuffer), size, threshold, abs_threshold); - break; - case InferenceEngine::Precision::FP64: - callCompare(expected, reinterpret_cast(actualBuffer), size, threshold, abs_threshold); - break; - default: - FAIL() << "Comparator for " << precision << " precision isn't supported"; - } -} - -void LayerTestsCommon::Compare(const std::pair>& expected, - const InferenceEngine::Blob::Ptr& actual) { - Compare(expected, actual, threshold); -} - -void LayerTestsCommon::Compare(const InferenceEngine::Blob::Ptr &expected, const InferenceEngine::Blob::Ptr &actual) { - auto get_raw_buffer = [](const InferenceEngine::Blob::Ptr &blob) { - auto memory = InferenceEngine::as(blob); - IE_ASSERT(memory); - const auto lockedMemory = memory->wmap(); - return lockedMemory.as(); - }; - const auto expectedBuffer = get_raw_buffer(expected); - const auto actualBuffer = get_raw_buffer(actual); - - const auto &precision = actual->getTensorDesc().getPrecision(); - const auto &size = actual->size(); - switch (precision) { - case InferenceEngine::Precision::FP32: - Compare(reinterpret_cast(expectedBuffer), reinterpret_cast(actualBuffer), - size, threshold); - break; - case InferenceEngine::Precision::I32: - Compare(reinterpret_cast(expectedBuffer), - reinterpret_cast(actualBuffer), size, 0); - break; - case InferenceEngine::Precision::I16: - Compare(reinterpret_cast(expectedBuffer), - reinterpret_cast(actualBuffer), size, 0); - break; - case InferenceEngine::Precision::U8: - Compare(reinterpret_cast(expectedBuffer), - reinterpret_cast(actualBuffer), size, 0); - break; - default: - FAIL() << "Comparator for " << precision << " precision isn't supported"; - } -} - -void LayerTestsCommon::Compare(const InferenceEngine::TensorDesc &actualDesc, const InferenceEngine::TensorDesc &expectedDesc) { - auto expectedDims = actualDesc.getDims(); - auto actualDims = expectedDesc.getDims(); - ASSERT_EQ(actualDims.size(), expectedDims.size()); - for (size_t j = 0; j < actualDims.size(); ++j) { - ASSERT_EQ(actualDims.at(j), expectedDims.at(j)); - } - ASSERT_EQ(actualDesc.getLayout(), expectedDesc.getLayout()); - ASSERT_EQ(actualDesc.getPrecision(), expectedDesc.getPrecision()); -} - -void LayerTestsCommon::ConfigureNetwork() { - for (const auto &in : cnnNetwork.getInputsInfo()) { - if (inLayout != InferenceEngine::Layout::ANY) { - in.second->setLayout(inLayout); - } - if (inPrc != InferenceEngine::Precision::UNSPECIFIED) { - in.second->setPrecision(inPrc); - } - } - - for (const auto &out : cnnNetwork.getOutputsInfo()) { - if (outLayout != InferenceEngine::Layout::ANY) { - out.second->setLayout(outLayout); - } - if (outPrc != InferenceEngine::Precision::UNSPECIFIED) { - out.second->setPrecision(outPrc); - } - } -} - -void LayerTestsCommon::LoadNetwork() { - cnnNetwork = InferenceEngine::CNNNetwork{function}; - CoreConfiguration(this); - ConfigureNetwork(); - executableNetwork = core->LoadNetwork(cnnNetwork, targetDevice, configuration); -} - -void LayerTestsCommon::ExpectLoadNetworkToThrow(const std::string& msg) { - std::string what; - try { - LoadNetwork(); - } catch (const std::exception& e) { - what.assign(e.what()); - } - EXPECT_STR_CONTAINS(what.c_str(), msg.c_str()); -} - -void LayerTestsCommon::GenerateInputs() { - inputs.clear(); - const auto& inputsInfo = executableNetwork.GetInputsInfo(); - const auto& functionParams = function->get_parameters(); - for (int i = 0; i < functionParams.size(); ++i) { - const auto& param = functionParams[i]; - const auto infoIt = inputsInfo.find(param->get_friendly_name()); - GTEST_ASSERT_NE(infoIt, inputsInfo.cend()); - InferenceEngine::InputInfo::CPtr info = infoIt->second; - InferenceEngine::Blob::Ptr blob = GenerateInput(*info); - inputs.push_back(blob); - } -} - -void LayerTestsCommon::ConfigureInferRequest() { - const auto& inputsInfo = executableNetwork.GetInputsInfo(); - const auto& functionParams = function->get_parameters(); - for (int i = 0; i < functionParams.size(); ++i) { - const auto& param = functionParams[i]; - const auto infoIt = inputsInfo.find(param->get_friendly_name()); - GTEST_ASSERT_NE(infoIt, inputsInfo.cend()); - - const auto& info = infoIt->second; - auto blob = inputs[i]; - inferRequest.SetBlob(info->name(), blob); - } -} - -void LayerTestsCommon::Infer() { - inferRequest = executableNetwork.CreateInferRequest(); - - ConfigureInferRequest(); - - inferRequest.Infer(); -} - -void LayerTestsCommon::ConvertRefsParams() { - ngraph::pass::ConvertPrecision().run_on_model(functionRefs); - ngraph::pass::ConvertPrecision().run_on_model(functionRefs); -} - -std::vector>> LayerTestsCommon::CalculateRefs() { - ConvertRefsParams(); - functionRefs->validate_nodes_and_infer_types(); - - auto referenceInputs = std::vector>(inputs.size()); - auto refInputsTypes = std::vector(inputs.size()); - for (std::size_t i = 0; i < inputs.size(); ++i) { - const auto &input = inputs[i]; - const auto inputSize = input->byteSize(); - - auto &referenceInput = referenceInputs[i]; - referenceInput.resize(inputSize); - - auto memory = InferenceEngine::as(input); - IE_ASSERT(memory); - const auto lockedMemory = memory->wmap(); - const auto buffer = lockedMemory.as(); - std::copy(buffer, buffer + inputSize, referenceInput.data()); - - refInputsTypes[i] = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(memory->getTensorDesc().getPrecision()); - } - - const auto &&outputsInfo = executableNetwork.GetOutputsInfo(); - std::vector convertType; - convertType.reserve(outputsInfo.size()); - for (const auto &output : outputsInfo) { - convertType.push_back( - FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc( - output.second->getTensorDesc().getPrecision())); - } - - std::vector>> expectedOutputs; - switch (refMode) { - case INTERPRETER: { - expectedOutputs = ngraph::helpers::interpreterFunction(functionRefs, referenceInputs, refInputsTypes); - break; - } - case CONSTANT_FOLDING: { - const auto &foldedFunc = ngraph::helpers::foldFunction(functionRefs, referenceInputs, refInputsTypes); - expectedOutputs = getConstData(foldedFunc); - break; - } - case IE: { - // reference inference on device with other options and nGraph function has to be implemented here - break; - } - } - - return expectedOutputs; -} - -std::vector LayerTestsCommon::GetOutputs() { - auto outputs = std::vector{}; - for (const auto &output : executableNetwork.GetOutputsInfo()) { - const auto &name = output.first; - outputs.push_back(inferRequest.GetBlob(name)); - } - return outputs; -} - -void LayerTestsCommon::Compare( - const std::vector>>& expectedOutputs, - const std::vector& actualOutputs) { - Compare(expectedOutputs, actualOutputs, threshold); -} - -void LayerTestsCommon::Validate() { - if (functionRefs == nullptr) { - functionRefs = function->clone(); - } - auto expectedOutputs = CalculateRefs(); - const auto &actualOutputs = GetOutputs(); - - if (expectedOutputs.empty()) { - return; - } - - IE_ASSERT(actualOutputs.size() == expectedOutputs.size()) - << "nGraph interpreter has " << expectedOutputs.size() << " outputs, while IE " << actualOutputs.size(); - - Compare(expectedOutputs, actualOutputs); -} - -std::string LayerTestsCommon::getRuntimePrecision(const std::string& layerName) { - const auto execGraph = executableNetwork.GetExecGraphInfo(); - const auto execFunction = execGraph.getFunction(); - - for (const auto& op : execFunction->get_ops()) { - const auto name = op->get_friendly_name(); - if (name == layerName) { - const auto& rtInfo = op->get_rt_info(); - const auto& it = rtInfo.find("runtimePrecision"); - IE_ASSERT(it != rtInfo.end()) << "Runtime precision is not found for node: " << name; - return it->second.as(); - } - } - - return ""; -} - -std::string LayerTestsCommon::getRuntimePrecisionByType(const std::string& layerType) { - const auto execGraph = executableNetwork.GetExecGraphInfo(); - const auto execFunction = execGraph.getFunction(); - - for (const auto& op : execFunction->get_ops()) { - const auto& rtInfo = op->get_rt_info(); - const auto& typeIt = rtInfo.find("layerType"); - - IE_ASSERT(typeIt != rtInfo.end()) << "Layer is not found for type: " << layerType; - - auto type = typeIt->second.as(); - if (type == layerType) { - const auto& it = rtInfo.find("runtimePrecision"); - IE_ASSERT(it != rtInfo.end()) << "Runtime precision is not found for node: " << type; - return it->second.as(); - } - } - - return ""; -} - -std::string LayerTestsCommon::getRuntimePrecisionByFusedName(const std::string& layerName) { - const auto execGraph = executableNetwork.GetExecGraphInfo(); - const auto execFunction = execGraph.getFunction(); - - const auto parse = [](const std::string& originalLayersNames) -> std::set { - std::set names; - - std::string tmp = originalLayersNames; - size_t beginPosition = 0ul; - size_t endPosition; - while ((endPosition = tmp.find(",", beginPosition)) != std::string::npos) { - names.insert(tmp.substr(beginPosition, endPosition - beginPosition)); - beginPosition = endPosition + 1; - } - - names.insert(tmp.substr(beginPosition, endPosition - beginPosition)); - return names; - }; - - for (const auto& op : execFunction->get_ops()) { - const auto& rtInfo = op->get_rt_info(); - - const auto& nameIt = rtInfo.find("originalLayersNames"); - IE_ASSERT(nameIt != rtInfo.end()) << "originalLayersNames is not found for node: " << layerName; - const auto fusedName = parse(nameIt->second.as()); - if (fusedName.find(layerName) == fusedName.end()) { - continue; - } - - const auto& it = rtInfo.find("runtimePrecision"); - IE_ASSERT(it != rtInfo.end()) << "runtimePrecision is not found for node: " << layerName; - const auto rtPrecisionPtr = it->second.as(); - return rtPrecisionPtr; - } - - return ""; -} - -std::map LayerTestsCommon::getRuntimeInfo() { - const auto execGraph = executableNetwork.GetExecGraphInfo(); - const auto function = execGraph.getFunction(); - std::map runtimeInfo; - for (const auto& op : function->get_ops()) { - runtimeInfo[op->get_friendly_name()] = op->get_rt_info(); - } - return runtimeInfo; -} - -#ifndef NDEBUG -void LayerTestsCommon::showRuntimePrecisions() { - const auto execGraph = executableNetwork.GetExecGraphInfo(); - const auto execFunction = execGraph.getFunction(); - - for (const auto& op : execFunction->get_ops()) { - const auto& rtInfo = op->get_rt_info(); - - const auto& nameIt = rtInfo.find("originalLayersNames"); - const auto name = nameIt->second.as(); - - const auto& typeIt = rtInfo.find("layerType"); - const auto type = typeIt->second.as(); - - const auto& it = rtInfo.find("runtimePrecision"); - const auto rtPrecisionPtr = it->second.as(); - - std::cout << type << "(" << name << "): " << rtPrecisionPtr << std::endl; - } -} -#endif - -void LayerTestsCommon::SetRefMode(RefMode mode) { - refMode = mode; -} - -std::shared_ptr LayerTestsCommon::GetFunction() { - return function; -} - -std::map &LayerTestsCommon::GetConfiguration() { - return configuration; -} - -} // namespace LayerTestsUtils diff --git a/src/tests/functional/shared_test_classes/src/base/low_precision_transformations/layer_transformation.cpp b/src/tests/functional/shared_test_classes/src/base/low_precision_transformations/layer_transformation.cpp index cacdd7df76badb..6ff1d2a6e23a2b 100644 --- a/src/tests/functional/shared_test_classes/src/base/low_precision_transformations/layer_transformation.cpp +++ b/src/tests/functional/shared_test_classes/src/base/low_precision_transformations/layer_transformation.cpp @@ -7,15 +7,10 @@ #include #include -#include -#include "cpp_interfaces/interface/ie_internal_plugin_config.hpp" #include "functional_test_utils/blob_utils.hpp" #include "ov_models/pass/convert_prc.hpp" -using namespace InferenceEngine; -using namespace ngraph; - namespace LayerTestsUtils { ov::pass::low_precision::LayerTransformation::Params LayerTransformationParamsNGraphFactory::createParamsU8I8AndI8() { return ov::pass::low_precision::LayerTransformation::Params(); @@ -36,7 +31,7 @@ ov::pass::low_precision::LayerTransformation::Params LayerTransformationParamsNG LayerTransformation::LayerTransformation() { rel_threshold = 1.1; abs_threshold = 1.0e-4; - configuration[PluginConfigInternalParams::KEY_LP_TRANSFORMS_MODE] = PluginConfigParams::YES; + configuration["LP_TRANSFORMS_MODE"] = true; } std::pair LayerTransformation::get_quantization_interval(ov::element::Type precision) { @@ -127,6 +122,39 @@ std::string LayerTransformation::get_runtime_precision_by_fused_name(const std:: return find_node_by_runtime_precision(compiledModel, is_node_f); } +bool LayerTransformation::check_execution_order(const std::vector& orderedOpsTypes) { + if (orderedOpsTypes.empty()) { + return true; + } + + size_t comparisonIndex = 0; + const std::shared_ptr& execFunction = compiledModel.get_runtime_model(); + for (const auto& op : execFunction->get_ordered_ops()) { + const auto& rtInfo = op->get_rt_info(); + const auto& typeIt = rtInfo.find("layerType"); + OPENVINO_ASSERT(typeIt != rtInfo.end(), "layerType is not found"); + + const auto layerType = typeIt->second.as(); + if (orderedOpsTypes[comparisonIndex] == layerType) { + // if comparisonIndex == 0 then start comparision + // if comparisonIndex != 0 then comparision has been started, check next operation type in sequence + comparisonIndex++; + + if (comparisonIndex >= orderedOpsTypes.size()) { + // all operation types in sequence were checked, comparision is ended + return true; + } + } else if (comparisonIndex != 0) { + // if comparision has been started and operation type is not equal then exit + return false; + } + } + + // actually we can be here only if operation sequence too long + // (execution graph doesn't have some operations from operations sequence) + return comparisonIndex == orderedOpsTypes.size(); +} + std::map LayerTransformation::get_runtime_info() { const ov::CompiledModel& execNet = compiledModel; const std::shared_ptr& function = execNet.get_runtime_model(); diff --git a/src/tests/functional/shared_test_classes/src/base/ov_subgraph.cpp b/src/tests/functional/shared_test_classes/src/base/ov_subgraph.cpp index 973836336f37cf..33b00c0a69e3af 100644 --- a/src/tests/functional/shared_test_classes/src/base/ov_subgraph.cpp +++ b/src/tests/functional/shared_test_classes/src/base/ov_subgraph.cpp @@ -79,8 +79,14 @@ void SubgraphBaseTest::run() { } status = ov::test::utils::PassRate::Statuses::PASSED; } catch (const std::exception& ex) { - status = ov::test::utils::PassRate::Statuses::FAILED; - errorMessage = ex.what(); + if (callback_exception != nullptr) { + // exception will be checked by callback. + callback_exception(ex); + return; + } else { + status = ov::test::utils::PassRate::Statuses::FAILED; + errorMessage = ex.what(); + } } catch (...) { status = ov::test::utils::PassRate::Statuses::FAILED; errorMessage = "Unknown failure occurred."; @@ -90,10 +96,10 @@ void SubgraphBaseTest::run() { GTEST_FATAL_FAILURE_(errorMessage.c_str()); } } else if (jmpRes == ov::test::utils::JMP_STATUS::anyError) { - IE_THROW() << "Crash happens"; + OPENVINO_THROW("Crash happens"); } else if (jmpRes == ov::test::utils::JMP_STATUS::alarmErr) { summary.updateOPsStats(function, ov::test::utils::PassRate::Statuses::HANGED, rel_influence_coef); - IE_THROW() << "Crash happens"; + OPENVINO_THROW("Crash happens"); } } @@ -164,7 +170,7 @@ void SubgraphBaseTest::query_model() { actual.insert(res.first); } if (expected != actual) { - IE_THROW() << "Expected and actual are different"; + OPENVINO_THROW("Expected and actual are different"); } status = ov::test::utils::PassRate::Statuses::PASSED; } catch (const std::exception& ex) { @@ -179,10 +185,10 @@ void SubgraphBaseTest::query_model() { GTEST_FATAL_FAILURE_(errorMessage.c_str()); } } else if (jmpRes == ov::test::utils::JMP_STATUS::anyError) { - IE_THROW() << "Crash happens"; + OPENVINO_THROW("Crash happens"); } else if (jmpRes == ov::test::utils::JMP_STATUS::alarmErr) { summary.updateOPsStats(function, ov::test::utils::PassRate::Statuses::HANGED, rel_influence_coef); - IE_THROW() << "Crash happens"; + OPENVINO_THROW("Crash happens"); } } @@ -241,10 +247,10 @@ void SubgraphBaseTest::import_export() { GTEST_FATAL_FAILURE_(errorMessage.c_str()); } } else if (jmpRes == ov::test::utils::JMP_STATUS::anyError) { - IE_THROW() << "Crash happens"; + OPENVINO_THROW("Crash happens"); } else if (jmpRes == ov::test::utils::JMP_STATUS::alarmErr) { summary.updateOPsStats(function, ov::test::utils::PassRate::Statuses::HANGED, rel_influence_coef); - IE_THROW() << "Crash happens"; + OPENVINO_THROW("Crash happens"); } } diff --git a/src/tests/functional/shared_test_classes/src/base/utils/generate_inputs.cpp b/src/tests/functional/shared_test_classes/src/base/utils/generate_inputs.cpp index 6a982171cc6bcd..7514ab753ab100 100644 --- a/src/tests/functional/shared_test_classes/src/base/utils/generate_inputs.cpp +++ b/src/tests/functional/shared_test_classes/src/base/utils/generate_inputs.cpp @@ -491,7 +491,6 @@ ov::Tensor generate(const std::shared_ptr& node, size_t port, const ov::element::Type& elemType, const ov::Shape& targetShape) { - InferenceEngine::Blob::Ptr blobPtr; switch (port) { case 0: { auto data_size = shape_size(targetShape); diff --git a/src/tests/functional/shared_test_classes/src/single_layer/activation.cpp b/src/tests/functional/shared_test_classes/src/single_layer/activation.cpp deleted file mode 100644 index 037978ae1c1cbc..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/activation.cpp +++ /dev/null @@ -1,253 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/activation.hpp" -#include "common_test_utils/node_builders/activation.hpp" - -namespace LayerTestsDefinitions { - -std::string ActivationLayerTest::getTestCaseName(const testing::TestParamInfo &obj) { - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - std::pair, std::vector> shapes; - std::string targetDevice; - std::pair> activationDecl; - std::tie(activationDecl, netPrecision, inPrc, outPrc, inLayout, outLayout, shapes, targetDevice) = obj.param; - - std::ostringstream result; - const char separator = '_'; - result << activationNames[activationDecl.first] << separator; - result << "IS=" << ov::test::utils::vec2str(shapes.first) << separator; - result << "AS=" << ov::test::utils::vec2str(shapes.second) << separator; - result << "ConstantsValue=" << ov::test::utils::vec2str(activationDecl.second) << separator; - result << "netPRC=" << netPrecision.name() << separator; - result << "inPRC=" << inPrc.name() << separator; - result << "outPRC=" << outPrc.name() << separator; - result << "inL=" << inLayout << separator; - result << "outL=" << outLayout << separator; - result << "trgDev=" << targetDevice; - return result.str(); -} - -void ActivationLayerTest::SetUp() { - InferenceEngine::Precision netPrecision; - std::pair, std::vector> shapes; - std::pair> activationDecl; - std::tie(activationDecl, netPrecision, inPrc, outPrc, inLayout, outLayout, shapes, targetDevice) = GetParam(); - - activationType = activationDecl.first; - auto constantsValue = activationDecl.second; - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params {std::make_shared(ngPrc, ov::Shape(shapes.first))}; - params[0]->set_friendly_name("Input"); - - if (activationType == ngraph::helpers::ActivationTypes::PReLu && constantsValue.empty()) { - const auto elemnts_count = ov::shape_size(shapes.second); - constantsValue.resize(elemnts_count); - std::iota(constantsValue.begin(), constantsValue.end(), -10); - } - - auto activation = ov::test::utils::make_activation(params[0], ngPrc, activationType, shapes.second, constantsValue); - - function = std::make_shared(ov::NodeVector{activation}, params); -} - -InferenceEngine::Blob::Ptr ActivationLayerTest::GenerateInput(const InferenceEngine::InputInfo &info) const { - bool inPrcSigned = function->get_parameters()[0]->get_element_type().is_signed(); - int32_t data_start_from; - uint32_t data_range; - int32_t resolution; - - switch (activationType) { - case ngraph::helpers::ActivationTypes::Log: { - data_start_from = 1; - data_range = 20; - resolution = 32768; - break; - } - case ngraph::helpers::ActivationTypes::Sqrt: { - data_start_from = 0; - data_range = 20; - resolution = 32768; - break; - } - case ngraph::helpers::ActivationTypes::Asin: { - data_start_from = -1; - data_range = 2; - resolution = 32768; - break; - } - case ngraph::helpers::ActivationTypes::Acos: { - data_start_from = -1; - data_range = 2; - resolution = 32768; - break; - } - case ngraph::helpers::ActivationTypes::Acosh: { - data_start_from = 1; - data_range = 200; - resolution = 32768; - break; - } - case ngraph::helpers::ActivationTypes::Atanh: { - data_start_from = -1; - data_range = 2; - resolution = 32768; - break; - } - case ngraph::helpers::ActivationTypes::Ceiling: { - data_start_from = -1000; - data_range = 2000; - resolution = 32768; - break; - } - case ngraph::helpers::ActivationTypes::RoundHalfToEven: { - data_start_from = -10; - data_range = 20; - resolution = 4; - break; - } - case ngraph::helpers::ActivationTypes::RoundHalfAwayFromZero: { - data_start_from = -10; - data_range = 20; - resolution = 4; - break; - } - case ngraph::helpers::ActivationTypes::Mish: { - data_start_from = -20; - data_range = 60; - resolution = 32768; - break; - } - case ngraph::helpers::ActivationTypes::SoftPlus: { - data_start_from = -100; - data_range = 200; - resolution = 32768; - break; - } - case ngraph::helpers::ActivationTypes::SoftSign: { - data_start_from = -100; - data_range = 200; - resolution = 32768; - break; - } - default: { - data_start_from = -10; - data_range = 20; - resolution = 32768; - break; - } - } - if (!inPrcSigned) { - data_range = 15; - data_start_from = 0; - } - - return FuncTestUtils::createAndFillBlob(info.getTensorDesc(), data_range, - data_start_from, - resolution); -} - -ov::ParameterVector ActivationParamLayerTest::createActivationParams(ov::element::Type ngPrc, std::vector inShape) { - switch (activationType) { - case ngraph::helpers::ActivationTypes::PReLu: { - ov::ParameterVector negativeSlopeParam {std::make_shared(ngPrc, ov::Shape(inShape))}; - negativeSlopeParam[0]->set_friendly_name("negativeSlope"); - return negativeSlopeParam; - } - case ngraph::helpers::ActivationTypes::LeakyRelu: { - ov::ParameterVector leakySlopeParam {std::make_shared(ngPrc, ov::Shape(inShape))}; - leakySlopeParam[0]->set_friendly_name("leakySlope"); - return leakySlopeParam; - } - case ngraph::helpers::ActivationTypes::HardSigmoid: { - ov::ParameterVector hardSigmoidParam {std::make_shared(ngPrc, ov::Shape(inShape)), - std::make_shared(ngPrc, ov::Shape(inShape))}; - hardSigmoidParam[0]->set_friendly_name("alpha"); - hardSigmoidParam[1]->set_friendly_name("beta"); - return hardSigmoidParam; - } - case ngraph::helpers::ActivationTypes::Selu: { - ov::ParameterVector seluParam {std::make_shared(ngPrc, ov::Shape(inShape)), - std::make_shared(ngPrc, ov::Shape(inShape))}; - seluParam[0]->set_friendly_name("alpha"); - seluParam[1]->set_friendly_name("lambda"); - return seluParam; - } - default: - IE_THROW() << "Unsupported activation type for Params test type"; - } -} - -InferenceEngine::Blob::Ptr ActivationParamLayerTest::GenerateInput(const InferenceEngine::InputInfo &info) const { - InferenceEngine::Blob::Ptr blobPtr; - const std::string& name = info.name(); - if (name == "negativeSlope") { - const auto elemnts_count = ov::shape_size(function->get_parameters()[1]->get_shape()); - std::vector param_data(elemnts_count); - std::iota(param_data.begin(), param_data.end(), -10); - blobPtr = FuncTestUtils::createAndFillBlobWithFloatArray(info.getTensorDesc(), ¶m_data[0], elemnts_count); - } else if (name == "leakySlope") { - const auto elemnts_count = ov::shape_size(function->get_parameters()[1]->get_shape()); - std::vector param_data(elemnts_count, constantsValue[0]); - blobPtr = FuncTestUtils::createAndFillBlobWithFloatArray(info.getTensorDesc(), ¶m_data[0], elemnts_count); - } else if (name == "alpha") { - blobPtr = FuncTestUtils::createAndFillBlobWithFloatArray(info.getTensorDesc(), &constantsValue[0], 1); - } else if (name == "beta" || name == "lambda") { - blobPtr = FuncTestUtils::createAndFillBlobWithFloatArray(info.getTensorDesc(), &constantsValue[1], 1); - } else { - blobPtr = FuncTestUtils::createAndFillBlob(info.getTensorDesc(), 20, -10, 1); - } - return blobPtr; -} - -void ActivationParamLayerTest::SetUp() { - InferenceEngine::Precision netPrecision; - std::pair, std::vector> shapes; - std::pair> activationDecl; - std::tie(activationDecl, netPrecision, inPrc, outPrc, inLayout, outLayout, shapes, targetDevice) = GetParam(); - - activationType = activationDecl.first; - constantsValue = activationDecl.second; - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params {std::make_shared(ngPrc, ov::Shape(shapes.first))}; - auto activationParams = createActivationParams(ngPrc, shapes.second); - - params[0]->set_friendly_name("Input"); - params.insert(params.end(), activationParams.begin(), activationParams.end()); - - auto activation = ov::test::utils::make_activation(params, ngPrc, activationType); - ov::ResultVector results{std::make_shared(activation)}; - function = std::make_shared(results, params); -} - -void ActivationDynamicLayerTest::Run() { - const auto& params = function->get_parameters(); - ov::PartialShape output_shape; - - // make each parameter dimension dynamic with range {1 .. prev_dim * 2} - for (const auto& parameter : params) { - auto& dynamic_pshape = parameter->get_partial_shape(); - OPENVINO_ASSERT(dynamic_pshape.rank().is_static(), - "tests are not prepared to work with dynamically ranked inputs"); - for (size_t i = 0; i < dynamic_pshape.rank().get_length(); ++i) { - if (static_dims.count(i)) - continue; - dynamic_pshape[i] = {1, dynamic_pshape[i].get_max_length() * 2}; - } - parameter->set_partial_shape(dynamic_pshape); - if (parameter->get_friendly_name() == "Input") - output_shape = dynamic_pshape; - } - function->validate_nodes_and_infer_types(); - - const auto& results = function->get_results(); - OPENVINO_ASSERT(results.size() == 1); - ASSERT_EQ(results[0]->get_output_partial_shape(0), output_shape); - // no inference and checks are done here -- just shape check because we miss CNNNetwork functionality - // to handle dynamic inputs-outputs and test functionality to generate blob of a certain shape -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/adaptive_pooling.cpp b/src/tests/functional/shared_test_classes/src/single_layer/adaptive_pooling.cpp deleted file mode 100644 index ce8656427aea4b..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/adaptive_pooling.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ov_models/builders.hpp" -#include "common_test_utils/node_builders/constant.hpp" -#include "shared_test_classes/single_layer/adaptive_pooling.hpp" - -using namespace InferenceEngine; -using namespace FuncTestUtils::PrecisionUtils; - -namespace LayerTestsDefinitions { - -std::string AdaPoolLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - std::vector inputShape; - std::vector pooledSpatialShape; - - std::string poolingMode; - InferenceEngine::Precision netPrecision; - std::string targetDevice; - std::tie(inputShape, pooledSpatialShape, poolingMode, netPrecision, targetDevice) = obj.param; - - std::ostringstream result; - - result << "in_shape=" << ov::test::utils::vec2str(inputShape) << "_"; - result << "pooled_spatial_shape=" << ov::test::utils::vec2str(pooledSpatialShape) << "_"; - result << "mode=" << poolingMode << "_"; - result << "prec=" << netPrecision.name() << "_"; - result << "dev=" << targetDevice; - return result.str(); -} - -void AdaPoolLayerTest::SetUp() { - std::vector inputShape; - std::vector pooledSpatialShape; - std::string poolingMode; - InferenceEngine::Precision netPrecision; - std::tie(inputShape, pooledSpatialShape, poolingMode, netPrecision, targetDevice) = this->GetParam(); - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - - ov::Shape pooledShape = {pooledSpatialShape.size() }; - auto pooledParam = ov::test::utils::deprecated::make_constant(ov::element::i32, pooledShape, pooledSpatialShape); - - // we cannot create abstract Op to use polymorphism - auto adapoolMax = std::make_shared(params[0], pooledParam, ov::element::i32); - auto adapoolAvg = std::make_shared(params[0], pooledParam); - - function = (poolingMode == "max" ? std::make_shared(adapoolMax->outputs(), params, "AdaPoolMax") : - std::make_shared(adapoolAvg->outputs(), params, "AdaPoolAvg")); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/batch_norm.cpp b/src/tests/functional/shared_test_classes/src/single_layer/batch_norm.cpp deleted file mode 100644 index 2f5e1ad8787010..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/batch_norm.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/batch_norm.hpp" - -#include "common_test_utils/node_builders/constant.hpp" - -namespace LayerTestsDefinitions { -std::string BatchNormLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - InferenceEngine::SizeVector inputShapes; - double epsilon; - std::string targetDevice; - std::tie(epsilon, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShapes, targetDevice) = obj.param; - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "epsilon=" << epsilon << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "trgDev=" << targetDevice; - return result.str(); -} - -InferenceEngine::Blob::Ptr BatchNormLayerTest::GenerateInput(const InferenceEngine::InputInfo &info) const { - return FuncTestUtils::createAndFillBlobConsistently(info.getTensorDesc(), 3, 0, 1); -} - -void BatchNormLayerTest::SetUp() { - InferenceEngine::Precision netPrecision; - InferenceEngine::SizeVector inputShapes; - double epsilon; - std::tie(epsilon, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShapes, targetDevice) = this->GetParam(); - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - - ov::ParameterVector params {std::make_shared(ngPrc, ov::Shape(inputShapes))}; - - size_t C = inputShapes.at(1); - bool random = true; - std::vector values(C); - auto gamma = ov::test::utils::deprecated::make_constant(ngPrc, ov::Shape{C}, values, random, 1.f, 0.f); - auto beta = ov::test::utils::deprecated::make_constant(ngPrc, ov::Shape{C}, values, random, 1.f, 0.f); - auto mean = ov::test::utils::deprecated::make_constant(ngPrc, ov::Shape{C}, values, random, 1.f, 0.f); - - // Fill the vector for variance with positive values - std::default_random_engine gen; - std::uniform_real_distribution dis(0.0, 10.0); - std::generate(values.begin(), values.end(), [&dis, &gen]() { - return dis(gen); - }); - auto variance = ov::test::utils::deprecated::make_constant(ngPrc, ov::Shape{C}, values, !random); - auto batchNorm = std::make_shared(params[0], gamma, beta, mean, variance, epsilon); - - ov::ResultVector results{std::make_shared(batchNorm)}; - function = std::make_shared(results, params, "BatchNormInference"); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/batch_to_space.cpp b/src/tests/functional/shared_test_classes/src/single_layer/batch_to_space.cpp deleted file mode 100644 index 3c18b64f4e976b..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/batch_to_space.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ov_models/builders.hpp" -#include "shared_test_classes/single_layer/batch_to_space.hpp" - -namespace LayerTestsDefinitions { - -std::string BatchToSpaceLayerTest::getTestCaseName(const testing::TestParamInfo &obj) { - std::vector inShapes; - std::vector blockShape, cropsBegin, cropsEnd; - InferenceEngine::Precision netPrc; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - std::string targetName; - std::tie(blockShape, cropsBegin, cropsEnd, inShapes, netPrc, inPrc, outPrc, inLayout, outLayout, targetName) = obj.param; - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inShapes) << "_"; - result << "netPRC=" << netPrc.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "BS=" << ov::test::utils::vec2str(blockShape) << "_"; - result << "CB=" << ov::test::utils::vec2str(cropsBegin) << "_"; - result << "CE=" << ov::test::utils::vec2str(cropsEnd) << "_"; - result << "trgDev=" << targetName << "_"; - return result.str(); -} - -void BatchToSpaceLayerTest::SetUp() { - std::vector inputShape; - std::vector blockShape, cropsBegin, cropsEnd; - InferenceEngine::Precision netPrecision; - std::tie(blockShape, cropsBegin, cropsEnd, inputShape, netPrecision, inPrc, outPrc, inLayout, outLayout, targetDevice) = this->GetParam(); - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - OPENVINO_SUPPRESS_DEPRECATED_START - auto b2s = ngraph::builder::makeBatchToSpace(params[0], ngPrc, blockShape, cropsBegin, cropsEnd); - OPENVINO_SUPPRESS_DEPRECATED_END - ov::ResultVector results{std::make_shared(b2s)}; - function = std::make_shared(results, params, "BatchToSpace"); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/binary_convolution.cpp b/src/tests/functional/shared_test_classes/src/single_layer/binary_convolution.cpp deleted file mode 100644 index 6c6e00ffddfd81..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/binary_convolution.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/binary_convolution.hpp" - -namespace LayerTestsDefinitions { - -std::string BinaryConvolutionLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - binConvSpecificParams binConvParams; - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - InferenceEngine::SizeVector inputShape; - std::string targetDevice; - - std::tie(binConvParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, targetDevice) = obj.param; - - ov::op::PadType padType; - InferenceEngine::SizeVector kernel, stride, dilation; - std::vector padBegin, padEnd; - size_t convOutChannels; - float padValue; - std::tie(kernel, stride, padBegin, padEnd, dilation, convOutChannels, padType, padValue) = binConvParams; - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShape) << "_"; - result << "KS=" << ov::test::utils::vec2str(kernel) << "_"; - result << "S=" << ov::test::utils::vec2str(stride) << "_"; - result << "PB=" << ov::test::utils::vec2str(padBegin) << "_"; - result << "PE=" << ov::test::utils::vec2str(padEnd) << "_"; - result << "D=" << ov::test::utils::vec2str(dilation) << "_"; - result << "O=" << convOutChannels << "_"; - result << "AP=" << padType << "_"; - result << "PV=" << padValue << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "trgDev=" << targetDevice; - return result.str(); -} - -InferenceEngine::Blob::Ptr BinaryConvolutionLayerTest::GenerateInput(const InferenceEngine::InputInfo &info) const { - InferenceEngine::Blob::Ptr blobPtr; - const std::string name = info.name(); - // there is no input generation for filters since CPU implementation uses Constant - // TODO: enable filters input generation as Parameter when supported (Issue 50148) - if (name == "a_data_batch") { - blobPtr = FuncTestUtils::createAndFillBlob(info.getTensorDesc(), 1, 0, 1, 7235346); - } - return blobPtr; -} - -void BinaryConvolutionLayerTest::SetUp() { - binConvSpecificParams binConvParams; - InferenceEngine::Precision netPrecision; - InferenceEngine::SizeVector inputShape; - - std::tie(binConvParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, targetDevice) = - this->GetParam(); - - ov::op::PadType padType; - InferenceEngine::SizeVector kernelSize, strides, dilations; - std::vector padsBegin, padsEnd; - size_t numOutChannels; - float padValue; - std::tie(kernelSize, strides, padsBegin, padsEnd, dilations, numOutChannels, padType, padValue) = binConvParams; - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - params[0]->set_friendly_name("a_data_batch"); - - // TODO: refactor build BinaryConvolution op to accept filters input as Parameter - auto binConv = ngraph::builder::makeBinaryConvolution(params[0], kernelSize, strides, padsBegin, padsEnd, dilations, padType, numOutChannels, - padValue); - ov::ResultVector results{std::make_shared(binConv)}; - function = std::make_shared(results, params, "BinaryConvolution"); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/broadcast.cpp b/src/tests/functional/shared_test_classes/src/single_layer/broadcast.cpp deleted file mode 100644 index 17dc2b6f389ff9..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/broadcast.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/broadcast.hpp" - -#include "ov_models/builders.hpp" - -namespace LayerTestsDefinitions { -std::string BroadcastLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::SizeVector targetShape; - ov::AxisSet axesMapping; - ov::op::BroadcastType mode; - InferenceEngine::SizeVector inputShape; - InferenceEngine::Precision networkPrecision; - std::string deviceName; - std::tie(targetShape, axesMapping, mode, inputShape, networkPrecision, deviceName) = obj.param; - - std::ostringstream result; - result << "targetShape=" << ov::test::utils::vec2str(targetShape) << "_"; - result << "axesMapping=" << ov::test::utils::set2str(axesMapping) << "_"; - result << "mode=" << mode << "_"; - result << "inShape=" << ov::test::utils::vec2str(inputShape) << "_"; - result << "inNPrec=" << networkPrecision << "_"; - result << "trgDev=" << deviceName; - return result.str(); -} - -void BroadcastLayerTest::SetUp() { - InferenceEngine::SizeVector targetShape; - ov::AxisSet axesMapping; - ov::op::BroadcastType mode; - InferenceEngine::SizeVector inputShape; - InferenceEngine::Precision networkPrecision; - std::tie(targetShape, axesMapping, mode, inputShape, networkPrecision, targetDevice) = this->GetParam(); - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(networkPrecision); - - auto target_shape_const = ov::op::v0::Constant::create(ov::element::i64, {targetShape.size()}, targetShape); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - - std::shared_ptr broadcast; - if (mode == ov::op::BroadcastType::NONE) { - auto axisSetConst = ov::op::v0::Constant::create(ov::element::i64, {axesMapping.size()}, axesMapping.to_vector()); - broadcast = std::make_shared(params[0], target_shape_const, axisSetConst, mode); - } else { // numpy/bidirectional modes - broadcast = std::make_shared(params[0], target_shape_const, mode); - } - ov::ResultVector results{std::make_shared(broadcast)}; - function = std::make_shared(results, params, "BroadcastInference"); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/bucketize.cpp b/src/tests/functional/shared_test_classes/src/single_layer/bucketize.cpp deleted file mode 100644 index 74b0e8ec2c824d..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/bucketize.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/bucketize.hpp" - -namespace LayerTestsDefinitions { - std::string BucketizeLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::SizeVector dataShape; - InferenceEngine::SizeVector bucketsShape; - bool with_right_bound; - InferenceEngine::Precision inDataPrc; - InferenceEngine::Precision inBucketsPrc; - InferenceEngine::Precision netPrc; - std::string targetDevice; - - std::tie(dataShape, bucketsShape, with_right_bound, inDataPrc, inBucketsPrc, netPrc, targetDevice) = obj.param; - - std::ostringstream result; - result << "DS=" << ov::test::utils::vec2str(dataShape) << "_"; - result << "BS=" << ov::test::utils::vec2str(bucketsShape) << "_"; - if (with_right_bound) - result << "rightIntervalEdge_"; - else - result << "leftIntervalEdge_"; - result << "inDataPrc=" << inDataPrc.name() << "_"; - result << "inBucketsPrc=" << inBucketsPrc.name() << "_"; - result << "netPrc=" << netPrc.name() << "_"; - result << "trgDev=" << targetDevice; - return result.str(); - } - - InferenceEngine::Blob::Ptr BucketizeLayerTest::GenerateInput(const InferenceEngine::InputInfo &info) const { - InferenceEngine::Blob::Ptr blobPtr; - const std::string name = info.name(); - if (name == "a_data") { - auto data_shape = info.getTensorDesc().getDims(); - auto data_size = std::accumulate(begin(data_shape), end(data_shape), 1, std::multiplies()); - blobPtr = FuncTestUtils::createAndFillBlob(info.getTensorDesc(), data_size * 5, 0, 10, 7235346); - } else if (name == "b_buckets") { - blobPtr = FuncTestUtils::createAndFillBlobUniqueSequence(info.getTensorDesc(), 0, 10, 8234231); - } - return blobPtr; - } - - void BucketizeLayerTest::SetUp() { - InferenceEngine::SizeVector dataShape; - InferenceEngine::SizeVector bucketsShape; - bool with_right_bound; - InferenceEngine::Precision inDataPrc; - InferenceEngine::Precision inBucketsPrc; - InferenceEngine::Precision netPrc; - - std::tie(dataShape, bucketsShape, with_right_bound, inDataPrc, inBucketsPrc, netPrc, targetDevice) = this->GetParam(); - - auto ngInDataPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inDataPrc); - auto ngInBucketsPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inBucketsPrc); - auto ngNetPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrc); - auto data = std::make_shared(ngInDataPrc, ov::Shape(dataShape)); - data->set_friendly_name("a_data"); - auto buckets = std::make_shared(ngInBucketsPrc, ov::Shape(bucketsShape)); - buckets->set_friendly_name("b_buckets"); - auto bucketize = std::make_shared(data, buckets, ngNetPrc, with_right_bound); - function = std::make_shared(std::make_shared(bucketize), ov::ParameterVector{data, buckets}, "Bucketize"); - } -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/clamp.cpp b/src/tests/functional/shared_test_classes/src/single_layer/clamp.cpp deleted file mode 100644 index 6088bef35b3bdf..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/clamp.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/clamp.hpp" - -namespace LayerTestsDefinitions { - -std::string ClampLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::SizeVector inShape; - std::pair interval; - InferenceEngine::Precision netPrc; - std::string targetDevice; - - std::tie(inShape, interval, netPrc, targetDevice) = obj.param; - - std::ostringstream result; - result << "inShape=" << ov::test::utils::vec2str(inShape) << "_"; - result << "min=" << interval.first << "_"; - result << "max=" << interval.second << "_"; - result << "netPrc=" << netPrc.name() << "_"; - result << "trgDev=" << targetDevice; - return result.str(); -} - -void ClampLayerTest::SetUp() { - InferenceEngine::SizeVector inShape; - std::pair interval; - InferenceEngine::Precision netPrc; - - std::tie(inShape, interval, netPrc, targetDevice) = this->GetParam(); - - auto ngNetPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrc); - auto input = std::make_shared(ngNetPrc, ov::Shape(inShape)); - auto clamp = std::make_shared(input, interval.first, interval.second); - function = std::make_shared(std::make_shared(clamp), ov::ParameterVector{input}); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/comparison.cpp b/src/tests/functional/shared_test_classes/src/single_layer/comparison.cpp deleted file mode 100644 index 97057a6b6e9f0b..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/comparison.cpp +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ov_models/builders.hpp" -#include "shared_test_classes/single_layer/comparison.hpp" - -using namespace LayerTestsDefinitions::ComparisonParams; -using namespace ngraph::helpers; - -namespace LayerTestsDefinitions { -std::string ComparisonLayerTest::getTestCaseName(const testing::TestParamInfo &obj) { - InputShapesTuple inputShapes; - InferenceEngine::Precision ngInputsPrecision; - ComparisonTypes comparisonOpType; - InputLayerType secondInputType; - InferenceEngine::Precision ieInPrecision; - InferenceEngine::Precision ieOutPrecision; - std::string targetName; - std::map additional_config; - std::tie(inputShapes, - ngInputsPrecision, - comparisonOpType, - secondInputType, - ieInPrecision, - ieOutPrecision, - targetName, - additional_config) = obj.param; - std::ostringstream results; - - results << "IS0=" << ov::test::utils::vec2str(inputShapes.first) << "_"; - results << "IS1=" << ov::test::utils::vec2str(inputShapes.second) << "_"; - results << "inputsPRC=" << ngInputsPrecision.name() << "_"; - results << "comparisonOpType=" << comparisonOpType << "_"; - results << "secondInputType=" << secondInputType << "_"; - if (ieInPrecision != InferenceEngine::Precision::UNSPECIFIED) { - results << "IEInPRC=" << ieInPrecision.name() << "_"; - } - if (ieOutPrecision != InferenceEngine::Precision::UNSPECIFIED) { - results << "IEOutPRC=" << ieOutPrecision.name() << "_"; - } - results << "targetDevice=" << targetName; - return results.str(); -} - -void ComparisonLayerTest::SetUp() { - InputShapesTuple inputShapes; - InferenceEngine::Precision ngInputsPrecision; - InputLayerType secondInputType; - InferenceEngine::Precision ieInPrecision; - InferenceEngine::Precision ieOutPrecision; - std::string targetName; - std::map additional_config; - std::tie(inputShapes, - ngInputsPrecision, - comparisonOpType, - secondInputType, - ieInPrecision, - ieOutPrecision, - targetDevice, - additional_config) = this->GetParam(); - - auto ngInputsPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(ngInputsPrecision); - configuration.insert(additional_config.begin(), additional_config.end()); - - inPrc = ieInPrecision; - outPrc = ieOutPrecision; - - ov::ParameterVector inputs {std::make_shared(ngInputsPrc, ov::Shape(inputShapes.first))}; - - OPENVINO_SUPPRESS_DEPRECATED_START - auto secondInput = ngraph::builder::makeInputLayer(ngInputsPrc, secondInputType, inputShapes.second); - OPENVINO_SUPPRESS_DEPRECATED_END - if (secondInputType == InputLayerType::PARAMETER) { - inputs.push_back(std::dynamic_pointer_cast(secondInput)); - } - - auto comparisonNode = ngraph::builder::makeComparison(inputs[0], secondInput, comparisonOpType); - function = std::make_shared(comparisonNode, inputs, "Comparison"); -} - -InferenceEngine::Blob::Ptr ComparisonLayerTest::GenerateInput(const InferenceEngine::InputInfo &inputInfo) const { - InferenceEngine::Blob::Ptr blob; - - if (comparisonOpType == ComparisonTypes::IS_FINITE || comparisonOpType == ComparisonTypes::IS_NAN) { - blob = make_blob_with_precision(inputInfo.getTensorDesc()); - blob->allocate(); - auto dataPtr = blob->buffer().as(); - auto dataPtrInt = blob->buffer().as(); - const auto range = blob->size(); - const float start = -static_cast(range) / 2.f; - testing::internal::Random random(1); - - for (size_t i = 0; i < range; i++) { - if (i % 7 == 0) { - dataPtr[i] = std::numeric_limits::infinity(); - } else if (i % 7 == 1) { - dataPtr[i] = -std::numeric_limits::infinity(); - } else if (i % 7 == 2) { - dataPtrInt[i] = 0x7F800000 + random.Generate(range); - } else if (i % 7 == 3) { - dataPtr[i] = std::numeric_limits::quiet_NaN(); - } else if (i % 7 == 5) { - dataPtr[i] = -std::numeric_limits::quiet_NaN(); - } else { - dataPtr[i] = start + static_cast(random.Generate(range)); - } - } - } else { - blob = LayerTestsUtils::LayerTestsCommon::GenerateInput(inputInfo); - } - - return blob; -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/concat.cpp b/src/tests/functional/shared_test_classes/src/single_layer/concat.cpp deleted file mode 100644 index ce237c8b0d7c67..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/concat.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/concat.hpp" - -namespace LayerTestsDefinitions { - -std::string ConcatLayerTest::getTestCaseName(const testing::TestParamInfo &obj) { - int axis; - std::vector> inputShapes; - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - std::string targetName; - std::tie(axis, inputShapes, netPrecision, inPrc, outPrc, inLayout, outLayout, targetName) = obj.param; - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "axis=" << axis << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "trgDev=" << targetName; - return result.str(); -} - -void ConcatLayerTest::SetUp() { - int axis; - std::vector> inputShape; - InferenceEngine::Precision netPrecision; - std::tie(axis, inputShape, netPrecision, inPrc, outPrc, inLayout, outLayout, targetDevice) = this->GetParam(); - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params; - ov::OutputVector paramsOuts; - for (auto&& shape : inputShape) { - auto param = std::make_shared(ngPrc, ov::Shape(shape)); - params.push_back(param); - paramsOuts.push_back(param); - } - auto concat = std::make_shared(paramsOuts, axis); - ov::ResultVector results{std::make_shared(concat)}; - function = std::make_shared(results, params, "concat"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/constant.cpp b/src/tests/functional/shared_test_classes/src/single_layer/constant.cpp deleted file mode 100644 index 984ce96bddf729..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/constant.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/constant.hpp" - -namespace LayerTestsDefinitions { -namespace { -template -std::vector getElements(const std::vector& v) { - const auto new_size = std::min(N, v.size()); - return {begin(v), std::next(begin(v), new_size)}; -} -} // namespace - -std::string ConstantLayerTest::getTestCaseName( - const testing::TestParamInfo& obj) { - std::vector data_shape; - InferenceEngine::Precision data_precision; - std::vector data_elements; - std::string targetName; - - std::tie(data_shape, data_precision, data_elements, targetName) = obj.param; - - std::ostringstream result; - result << "S=" << ov::test::utils::vec2str(data_shape) << "_"; - result << "dataPRC=" << data_precision.name() << "_"; - result << "dataValue=" << ov::test::utils::vec2str(getElements<5>(data_elements)) << "_"; - return result.str(); -} - -void ConstantLayerTest::SetUp() { - std::vector data_shape; - InferenceEngine::Precision data_precision; - std::vector data_elements; - - std::tie(data_shape, data_precision, data_elements, targetDevice) = this->GetParam(); - - const auto precision = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(data_precision); - auto constant = ov::op::v0::Constant::create(precision, data_shape, data_elements); - ov::ResultVector results{std::make_shared(constant)}; - - function = std::make_shared(results, ov::ParameterVector{}, "constant"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/conversion.cpp b/src/tests/functional/shared_test_classes/src/single_layer/conversion.cpp deleted file mode 100644 index d8fbdfeb1a58ec..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/conversion.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/conversion.hpp" - -#include "ov_models/builders.hpp" - -namespace LayerTestsDefinitions { - -std::string ConversionLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - ngraph::helpers::ConversionTypes conversionOpType; - InferenceEngine::Precision inputPrecision, targetPrecision; - InferenceEngine::Layout inLayout, outLayout; - std::string targetName; - std::vector> inputShape; - std::tie(conversionOpType, inputShape, inputPrecision, targetPrecision, inLayout, outLayout, targetName) = - obj.param; - std::ostringstream result; - result << "conversionOpType=" << conversionNames[conversionOpType] << "_"; - result << "IS=" << ov::test::utils::vec2str(inputShape) << "_"; - result << "inputPRC=" << inputPrecision.name() << "_"; - result << "targetPRC=" << targetPrecision.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "trgDev=" << targetName; - return result.str(); -} - -void ConversionLayerTest::SetUp() { - if (ov::test::utils::current_test_is_disabled()) { - GTEST_SKIP() << "Disabled test due to configuration" << std::endl; - } - ngraph::helpers::ConversionTypes conversionOpType; - InferenceEngine::Precision inputPrecision, targetPrecision; - std::vector> inputShape; - std::tie(conversionOpType, inputShape, inputPrecision, targetPrecision, inLayout, outLayout, targetDevice) = - GetParam(); - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inputPrecision); - auto targetPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(targetPrecision); - ov::ParameterVector params; - for (auto&& shape : inputShape) { - params.push_back(std::make_shared(ngPrc, ov::Shape(shape))); - } - std::shared_ptr conversion; - if (ov::test::utils::ConversionTypes::CONVERT == conversionOpType) { - conversion = std::make_shared(params.front(), targetPrc); - } else { - const auto like = std::make_shared(targetPrc, ov::Shape{1}); - conversion = std::make_shared(params.front(), like); - } - ov::ResultVector results{std::make_shared(conversion)}; - function = std::make_shared(results, params, "Conversion"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/convert_color_i420.cpp b/src/tests/functional/shared_test_classes/src/single_layer/convert_color_i420.cpp deleted file mode 100644 index a952493b9b4748..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/convert_color_i420.cpp +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/convert_color_i420.hpp" -#include "openvino/op/i420_to_rgb.hpp" -#include "openvino/op/i420_to_bgr.hpp" - -namespace LayerTestsDefinitions { - -std::string ConvertColorI420LayerTest::getTestCaseName(const testing::TestParamInfo &obj) { - ov::Shape inputShape; - ov::element::Type type; - bool conversion, singlePlane; - std::string targetName; - std::tie(inputShape, type, conversion, singlePlane, targetName) = obj.param; - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShape) << "_"; - result << "netPRC=" << type.c_type_string() << "_"; - result << "convRGB=" << conversion << "_"; - result << "singlePlane=" << singlePlane << "_"; - result << "targetDevice=" << targetName; - return result.str(); -} - -void ConvertColorI420LayerTest::SetUp() { - ov::Shape inputShape; - ov::element::Type ngPrc; - bool conversionToRGB, singlePlane; - abs_threshold = 1.0f; // I420 conversion can use various algorithms, thus some absolute deviation is allowed - threshold = 1.f; // Ignore relative comparison for I420 convert (allow 100% relative deviation) - std::tie(inputShape, ngPrc, conversionToRGB, singlePlane, targetDevice) = GetParam(); - if (singlePlane) { - inputShape[1] = inputShape[1] * 3 / 2; - auto param = std::make_shared(ngPrc, inputShape); - std::shared_ptr convert_color; - if (conversionToRGB) { - convert_color = std::make_shared(param); - } else { - convert_color = std::make_shared(param); - } - function = std::make_shared(std::make_shared(convert_color), - ov::ParameterVector{param}, "ConvertColorI420"); - } else { - auto uvShape = ov::Shape{inputShape[0], inputShape[1] / 2, inputShape[2] / 2, 1}; - auto param_y = std::make_shared(ngPrc, inputShape); - auto param_u = std::make_shared(ngPrc, uvShape); - auto param_v = std::make_shared(ngPrc, uvShape); - std::shared_ptr convert_color; - if (conversionToRGB) { - convert_color = std::make_shared(param_y, param_u, param_v); - } else { - convert_color = std::make_shared(param_y, param_u, param_v); - } - function = std::make_shared(std::make_shared(convert_color), - ov::ParameterVector{param_y, param_u, param_v}, - "ConvertColorI420"); - } -} - -// -------- Accuracy test (R/G/B combinations) -------- - -void ConvertColorI420AccuracyTest::GenerateInputs() { - inputs.clear(); - const auto& inputsInfo = executableNetwork.GetInputsInfo(); - const auto& functionParams = function->get_parameters(); - for (const auto& param : functionParams) { - const auto infoIt = inputsInfo.find(param->get_friendly_name()); - GTEST_ASSERT_NE(infoIt, inputsInfo.cend()); - InferenceEngine::InputInfo::CPtr info = infoIt->second; - InferenceEngine::Blob::Ptr blob = make_blob_with_precision(info->getTensorDesc()); - blob->allocate(); - size_t full_height = param->get_shape()[1]; - size_t full_width = param->get_shape()[2]; - int b_dim = static_cast(full_height * 2 / (3 * full_width)); - ASSERT_GT(b_dim, 1) << "Image height is invalid for I420 Accuracy test"; - ASSERT_EQ(255 % (b_dim - 1), 0) << "Image height is invalid for I420 Accuracy test"; - int b_step = 255 / (b_dim - 1); - auto input_image = I420TestUtils::color_test_image(full_width, full_width, b_step); - auto* rawBlobDataPtr = blob->buffer().as(); - for (size_t j = 0; j < input_image.size(); ++j) { - rawBlobDataPtr[j] = input_image[j]; - } - - inputs.push_back(blob); - } -} - -void ConvertColorI420AccuracyTest::Validate() { - ConvertColorI420LayerTest::Validate(); - - ASSERT_FALSE(expected_output.empty()); - ASSERT_TRUE(actual_output); - auto memory = InferenceEngine::as(actual_output); - const auto lockedMemory = memory->wmap(); - const auto* actualBuffer = lockedMemory.as(); - - // Allow less than 2% of deviations with 1 color step. 2% is experimental value - // For different calculation methods - 1.4% deviation is observed - I420TestUtils::ValidateColors(expected_output.data(), actualBuffer, expected_output.size(), 0.02); -} - -std::vector>> ConvertColorI420AccuracyTest::CalculateRefs() { - auto refs = ConvertColorI420LayerTest::CalculateRefs(); - if (!refs.empty()) { - auto out = refs[0].second; - expected_output.reserve(out.size()); - for (auto val : out) { - expected_output.push_back(val); - } - } - return refs; -} - -std::vector ConvertColorI420AccuracyTest::GetOutputs() { - auto outputs = ConvertColorI420LayerTest::GetOutputs(); - if (!outputs.empty()) { - actual_output = InferenceEngine::Blob::Ptr(outputs[0]); - } - return outputs; -} - - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/convert_color_nv12.cpp b/src/tests/functional/shared_test_classes/src/single_layer/convert_color_nv12.cpp deleted file mode 100644 index 4155d3777ec79f..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/convert_color_nv12.cpp +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/convert_color_nv12.hpp" -#include "openvino/op/nv12_to_rgb.hpp" -#include "openvino/op/nv12_to_bgr.hpp" - -namespace LayerTestsDefinitions { - -std::string ConvertColorNV12LayerTest::getTestCaseName(const testing::TestParamInfo &obj) { - ov::Shape inputShape; - ov::element::Type type; - bool conversion, singlePlane; - std::string targetName; - std::tie(inputShape, type, conversion, singlePlane, targetName) = obj.param; - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShape) << "_"; - result << "netPRC=" << type.c_type_string() << "_"; - result << "convRGB=" << conversion << "_"; - result << "singlePlane=" << singlePlane << "_"; - result << "targetDevice=" << targetName; - return result.str(); -} - -void ConvertColorNV12LayerTest::SetUp() { - ov::Shape inputShape; - ov::element::Type ngPrc; - bool conversionToRGB, singlePlane; - abs_threshold = 1.0f; // NV12 conversion can use various algorithms, thus some absolute deviation is allowed - threshold = 1.f; // Ignore relative comparison for NV12 convert (allow 100% relative deviation) - std::tie(inputShape, ngPrc, conversionToRGB, singlePlane, targetDevice) = GetParam(); - if (singlePlane) { - inputShape[1] = inputShape[1] * 3 / 2; - auto param = std::make_shared(ngPrc, inputShape); - std::shared_ptr convert_color; - if (conversionToRGB) { - convert_color = std::make_shared(param); - } else { - convert_color = std::make_shared(param); - } - function = std::make_shared(std::make_shared(convert_color), - ov::ParameterVector{param}, "ConvertColorNV12"); - } else { - auto uvShape = ov::Shape{inputShape[0], inputShape[1] / 2, inputShape[2] / 2, 2}; - auto param_y = std::make_shared(ngPrc, inputShape); - auto param_uv = std::make_shared(ngPrc, uvShape); - std::shared_ptr convert_color; - if (conversionToRGB) { - convert_color = std::make_shared(param_y, param_uv); - } else { - convert_color = std::make_shared(param_y, param_uv); - } - function = std::make_shared(std::make_shared(convert_color), - ov::ParameterVector{param_y, param_uv}, "ConvertColorNV12"); - } -} - -// -------- Accuracy test (R/G/B combinations) -------- - -void ConvertColorNV12AccuracyTest::GenerateInputs() { - inputs.clear(); - const auto& inputsInfo = executableNetwork.GetInputsInfo(); - const auto& functionParams = function->get_parameters(); - for (const auto& param : functionParams) { - const auto infoIt = inputsInfo.find(param->get_friendly_name()); - GTEST_ASSERT_NE(infoIt, inputsInfo.cend()); - InferenceEngine::InputInfo::CPtr info = infoIt->second; - InferenceEngine::Blob::Ptr blob = make_blob_with_precision(info->getTensorDesc()); - blob->allocate(); - size_t full_height = param->get_shape()[1]; - size_t full_width = param->get_shape()[2]; - int b_dim = static_cast(full_height * 2 / (3 * full_width)); - ASSERT_GT(b_dim, 1) << "Image height is invalid for NV12 Accuracy test"; - ASSERT_EQ(255 % (b_dim - 1), 0) << "Image height is invalid for NV12 Accuracy test"; - int b_step = 255 / (b_dim - 1); - auto input_image = NV12TestUtils::color_test_image(full_width, full_width, b_step); - auto* rawBlobDataPtr = blob->buffer().as(); - for (size_t j = 0; j < input_image.size(); ++j) { - rawBlobDataPtr[j] = input_image[j]; - } - - inputs.push_back(blob); - } -} - -void ConvertColorNV12AccuracyTest::Validate() { - ConvertColorNV12LayerTest::Validate(); - - ASSERT_FALSE(expected_output.empty()); - ASSERT_TRUE(actual_output); - auto memory = InferenceEngine::as(actual_output); - const auto lockedMemory = memory->wmap(); - const auto* actualBuffer = lockedMemory.as(); - - // Allow less than 2% of deviations with 1 color step. 2% is experimental value - // For different calculation methods - 1.4% deviation is observed - NV12TestUtils::ValidateColors(expected_output.data(), actualBuffer, expected_output.size(), 0.02); -} - -std::vector>> ConvertColorNV12AccuracyTest::CalculateRefs() { - auto refs = ConvertColorNV12LayerTest::CalculateRefs(); - if (!refs.empty()) { - auto out = refs[0].second; - expected_output.reserve(out.size()); - for (auto val : out) { - expected_output.push_back(val); - } - } - return refs; -} - -std::vector ConvertColorNV12AccuracyTest::GetOutputs() { - auto outputs = ConvertColorNV12LayerTest::GetOutputs(); - if (!outputs.empty()) { - actual_output = InferenceEngine::Blob::Ptr(outputs[0]); - } - return outputs; -} - - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/convolution.cpp b/src/tests/functional/shared_test_classes/src/single_layer/convolution.cpp deleted file mode 100644 index fe264058f3f7b3..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/convolution.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/convolution.hpp" - -namespace LayerTestsDefinitions { - -std::string ConvolutionLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - convSpecificParams convParams; - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - InferenceEngine::SizeVector inputShapes; - std::string targetDevice; - std::tie(convParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShapes, targetDevice) = - obj.param; - ov::op::PadType padType; - InferenceEngine::SizeVector kernel, stride, dilation; - std::vector padBegin, padEnd; - size_t convOutChannels; - std::tie(kernel, stride, padBegin, padEnd, dilation, convOutChannels, padType) = convParams; - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "K" << ov::test::utils::vec2str(kernel) << "_"; - result << "S" << ov::test::utils::vec2str(stride) << "_"; - result << "PB" << ov::test::utils::vec2str(padBegin) << "_"; - result << "PE" << ov::test::utils::vec2str(padEnd) << "_"; - result << "D=" << ov::test::utils::vec2str(dilation) << "_"; - result << "O=" << convOutChannels << "_"; - result << "AP=" << padType << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "trgDev=" << targetDevice; - return result.str(); -} - -void ConvolutionLayerTest::SetUp() { - convSpecificParams convParams; - std::vector inputShape; - auto netPrecision = InferenceEngine::Precision::UNSPECIFIED; - std::tie(convParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, targetDevice) = - this->GetParam(); - ov::op::PadType padType; - InferenceEngine::SizeVector kernel, stride, dilation; - std::vector padBegin, padEnd; - size_t convOutChannels; - std::tie(kernel, stride, padBegin, padEnd, dilation, convOutChannels, padType) = convParams; - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - std::vector filter_weights; - auto conv = std::dynamic_pointer_cast( - ngraph::builder::makeConvolution(params[0], ngPrc, kernel, stride, padBegin, - padEnd, dilation, padType, convOutChannels, false, filter_weights)); - ov::ResultVector results{std::make_shared(conv)}; - function = std::make_shared(results, params, "convolution"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/convolution_backprop.cpp b/src/tests/functional/shared_test_classes/src/single_layer/convolution_backprop.cpp deleted file mode 100644 index 8e0ec8fc3c0d4c..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/convolution_backprop.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/convolution_backprop.hpp" - -namespace LayerTestsDefinitions { - -std::string ConvolutionBackpropLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - convBackpropSpecificParams convBackpropDataParams; - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - InferenceEngine::SizeVector inputShapes; - InferenceEngine::SizeVector outputShapes; - std::string targetDevice; - std::tie(convBackpropDataParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShapes, outputShapes, targetDevice) = obj.param; - ov::op::PadType padType; - InferenceEngine::SizeVector kernel, stride, dilation; - std::vector padBegin, padEnd, outPadding; - size_t convOutChannels; - std::tie(kernel, stride, padBegin, padEnd, dilation, convOutChannels, padType, outPadding) = convBackpropDataParams; - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "OS=" << ov::test::utils::vec2str(outputShapes) << "_"; - result << "K" << ov::test::utils::vec2str(kernel) << "_"; - result << "S" << ov::test::utils::vec2str(stride) << "_"; - result << "PB" << ov::test::utils::vec2str(padBegin) << "_"; - result << "PE" << ov::test::utils::vec2str(padEnd) << "_"; - result << "D=" << ov::test::utils::vec2str(dilation) << "_"; - result << "OP=" << ov::test::utils::vec2str(outPadding) << "_"; - result << "O=" << convOutChannels << "_"; - result << "AP=" << padType << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "trgDev=" << targetDevice; - return result.str(); -} - -void ConvolutionBackpropLayerTest::SetUp() { - convBackpropSpecificParams convBackpropDataParams; - std::vector inputShape; - std::vector outputShape; - auto netPrecision = InferenceEngine::Precision::UNSPECIFIED; - std::tie(convBackpropDataParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, outputShape, targetDevice) = this->GetParam(); - ov::op::PadType padType; - InferenceEngine::SizeVector kernel, stride, dilation; - std::vector padBegin, padEnd, outPadding; - size_t convOutChannels; - std::tie(kernel, stride, padBegin, padEnd, dilation, convOutChannels, padType, outPadding) = convBackpropDataParams; - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - auto convBackpropData = std::dynamic_pointer_cast( - ngraph::builder::makeConvolutionBackpropData(params[0], ngPrc, kernel, stride, padBegin, - padEnd, dilation, padType, convOutChannels, false, outPadding)); - if (!outputShape.empty()) { - auto outShape = ov::op::v0::Constant::create(ov::element::i64, {outputShape.size()}, outputShape); - convBackpropData = std::dynamic_pointer_cast( - ngraph::builder::makeConvolutionBackpropData(params[0], outShape, ngPrc, kernel, stride, padBegin, - padEnd, dilation, padType, convOutChannels)); - } - ov::ResultVector results{std::make_shared(convBackpropData)}; - function = std::make_shared(results, params, "convolutionBackpropData"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/convolution_backprop_data.cpp b/src/tests/functional/shared_test_classes/src/single_layer/convolution_backprop_data.cpp deleted file mode 100644 index 94010e9a26e3c9..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/convolution_backprop_data.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -// DEPRECATED, can't be removed currently due to arm and kmb-plugin dependency (#55568) - -#include "shared_test_classes/single_layer/convolution_backprop_data.hpp" - -namespace LayerTestsDefinitions { - -std::string ConvolutionBackpropDataLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - convBackpropDataSpecificParams convBackpropDataParams; - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - InferenceEngine::SizeVector inputShapes; - InferenceEngine::SizeVector outputShapes; - std::string targetDevice; - std::tie(convBackpropDataParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShapes, outputShapes, targetDevice) = obj.param; - ov::op::PadType padType; - InferenceEngine::SizeVector kernel, stride, dilation; - std::vector padBegin, padEnd, outPadding; - size_t convOutChannels; - std::tie(kernel, stride, padBegin, padEnd, dilation, convOutChannels, padType, outPadding) = convBackpropDataParams; - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "OS=" << ov::test::utils::vec2str(outputShapes) << "_"; - result << "K" << ov::test::utils::vec2str(kernel) << "_"; - result << "S" << ov::test::utils::vec2str(stride) << "_"; - result << "PB" << ov::test::utils::vec2str(padBegin) << "_"; - result << "PE" << ov::test::utils::vec2str(padEnd) << "_"; - result << "D=" << ov::test::utils::vec2str(dilation) << "_"; - result << "OP=" << ov::test::utils::vec2str(outPadding) << "_"; - result << "O=" << convOutChannels << "_"; - result << "AP=" << padType << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "trgDev=" << targetDevice; - return result.str(); -} - -void ConvolutionBackpropDataLayerTest::SetUp() { - convBackpropDataSpecificParams convBackpropDataParams; - std::vector inputShape; - std::vector outputShape; - auto netPrecision = InferenceEngine::Precision::UNSPECIFIED; - std::tie(convBackpropDataParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, outputShape, targetDevice) = this->GetParam(); - ov::op::PadType padType; - InferenceEngine::SizeVector kernel, stride, dilation; - std::vector padBegin, padEnd, outPadding; - size_t convOutChannels; - std::tie(kernel, stride, padBegin, padEnd, dilation, convOutChannels, padType, outPadding) = convBackpropDataParams; - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - auto convBackpropData = std::dynamic_pointer_cast( - ngraph::builder::makeConvolutionBackpropData(params[0], ngPrc, kernel, stride, padBegin, - padEnd, dilation, padType, convOutChannels, false, outPadding)); - if (!outputShape.empty()) { - auto outShape = ov::op::v0::Constant::create(ov::element::i64, {outputShape.size()}, outputShape); - convBackpropData = std::dynamic_pointer_cast( - ngraph::builder::makeConvolutionBackpropData(params[0], outShape, ngPrc, kernel, stride, padBegin, - padEnd, dilation, padType, convOutChannels)); - } - ov::ResultVector results{std::make_shared(convBackpropData)}; - function = std::make_shared(results, params, "convolutionBackpropData"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/ctc_greedy_decoder.cpp b/src/tests/functional/shared_test_classes/src/single_layer/ctc_greedy_decoder.cpp deleted file mode 100644 index fc55ee41d018a8..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/ctc_greedy_decoder.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/ctc_greedy_decoder.hpp" -#include "ov_models/builders.hpp" - -namespace LayerTestsDefinitions { -std::string CTCGreedyDecoderLayerTest::getTestCaseName( - const testing::TestParamInfo& obj) { - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - InferenceEngine::SizeVector inputShapes; - std::string targetDevice; - bool mergeRepeated; - std::tie(netPrecision, - inPrc, outPrc, inLayout, outLayout, - inputShapes, - mergeRepeated, - targetDevice) = obj.param; - - std::ostringstream result; - const char separator = '_'; - - result << "IS=" << ov::test::utils::vec2str(inputShapes) << separator; - result << "netPRC=" << netPrecision.name() << separator; - result << "inPRC=" << inPrc.name() << separator; - result << "outPRC=" << outPrc.name() << separator; - result << "inL=" << inLayout << separator; - result << "outL=" << outLayout << separator; - result << "merge_repeated=" << std::boolalpha << mergeRepeated << separator; - result << "trgDev=" << targetDevice; - - return result.str(); -} - -void CTCGreedyDecoderLayerTest::SetUp() { - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - InferenceEngine::SizeVector inputShapes; - bool mergeRepeated; - std::tie(netPrecision, inPrc, outPrc, inLayout, outLayout, inputShapes, mergeRepeated, targetDevice) = GetParam(); - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector paramsIn {std::make_shared(ngPrc, ov::Shape(inputShapes))}; - - OPENVINO_SUPPRESS_DEPRECATED_START - auto ctcGreedyDecoder = std::dynamic_pointer_cast( - ngraph::builder::makeCTCGreedyDecoder(paramsIn[0], mergeRepeated)); - OPENVINO_SUPPRESS_DEPRECATED_END - - ov::ResultVector results{ std::make_shared(ctcGreedyDecoder) }; - function = std::make_shared(results, paramsIn, "CTCGreedyDecoder"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/ctc_greedy_decoder_seq_len.cpp b/src/tests/functional/shared_test_classes/src/single_layer/ctc_greedy_decoder_seq_len.cpp deleted file mode 100644 index 82168a7b820f7c..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/ctc_greedy_decoder_seq_len.cpp +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include -#include - -#include "shared_test_classes/single_layer/ctc_greedy_decoder_seq_len.hpp" -#include "ov_models/builders.hpp" -#include "common_test_utils/node_builders/constant.hpp" - -namespace LayerTestsDefinitions { -std::string CTCGreedyDecoderSeqLenLayerTest::getTestCaseName( - const testing::TestParamInfo& obj) { - InferenceEngine::SizeVector inputShape; - int sequenceLengths; - InferenceEngine::Precision dataPrecision, indicesPrecision; - int blankIndex; - bool mergeRepeated; - std::string targetDevice; - std::tie(inputShape, - sequenceLengths, - dataPrecision, - indicesPrecision, - blankIndex, - mergeRepeated, - targetDevice) = obj.param; - - std::ostringstream result; - - result << "IS=" << ov::test::utils::vec2str(inputShape) << '_'; - result << "seqLen=" << sequenceLengths << '_'; - result << "dataPRC=" << dataPrecision.name() << '_'; - result << "idxPRC=" << indicesPrecision.name() << '_'; - result << "BlankIdx=" << blankIndex << '_'; - result << "mergeRepeated=" << std::boolalpha << mergeRepeated << '_'; - result << "trgDev=" << targetDevice; - - return result.str(); -} - -void CTCGreedyDecoderSeqLenLayerTest::SetUp() { - InferenceEngine::SizeVector inputShape; - int sequenceLengths; - InferenceEngine::Precision dataPrecision, indicesPrecision; - int blankIndex; - bool mergeRepeated; - std::tie(inputShape, - sequenceLengths, - dataPrecision, - indicesPrecision, - blankIndex, - mergeRepeated, - targetDevice) = GetParam(); - - auto ngDataPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(dataPrecision); - auto ngIdxPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(indicesPrecision); - ov::ParameterVector paramsIn {std::make_shared(ngDataPrc, ov::Shape(inputShape))}; - - const auto sequenceLenNode = [&] { - const size_t B = inputShape[0]; - const size_t T = inputShape[1]; - - // Cap sequence length up to T - const int seqLen = std::min(T, sequenceLengths); - - std::mt19937 gen{42}; - std::uniform_int_distribution dist(1, seqLen); - - std::vector sequenceLenData(B); - for (int b = 0; b < B; b++) { - const int len = dist(gen); - sequenceLenData[b] = len; - } - - return ov::test::utils::deprecated::make_constant(ngIdxPrc, {B}, sequenceLenData); - }(); - - // Cap blank index up to C - 1 - int C = inputShape.at(2); - blankIndex = std::min(blankIndex, C - 1); - - OPENVINO_SUPPRESS_DEPRECATED_START - auto ctcGreedyDecoderSeqLen = std::dynamic_pointer_cast( - ngraph::builder::makeCTCGreedyDecoderSeqLen(paramsIn[0], sequenceLenNode, - blankIndex, mergeRepeated, ngIdxPrc)); - OPENVINO_SUPPRESS_DEPRECATED_END - - ov::ResultVector results; - for (int i = 0; i < ctcGreedyDecoderSeqLen->get_output_size(); i++) { - results.push_back(std::make_shared(ctcGreedyDecoderSeqLen->output(i))); - } - function = std::make_shared(results, paramsIn, "CTCGreedyDecoderSeqLen"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/ctc_loss.cpp b/src/tests/functional/shared_test_classes/src/single_layer/ctc_loss.cpp deleted file mode 100644 index 406991d7d8d61d..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/ctc_loss.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ov_models/builders.hpp" -#include "shared_test_classes/single_layer/ctc_loss.hpp" - -namespace LayerTestsDefinitions { - -std::string CTCLossLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::SizeVector logitsShapes; - InferenceEngine::Precision fpPrecision, intPrecision; - bool preprocessCollapseRepeated, ctcMergeRepeated, unique; - std::vector logitsLength, labelsLength; - std::vector> labels; - int blankIndex; - std::string targetDevice; - CTCLossParamsSubset ctcLossArgsSubset; - std::tie(ctcLossArgsSubset, fpPrecision, intPrecision, targetDevice) = obj.param; - std::tie(logitsShapes, logitsLength, labels, labelsLength, blankIndex, preprocessCollapseRepeated, - ctcMergeRepeated, unique) = ctcLossArgsSubset; - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(logitsShapes) << "_"; - result << "LL=" << ov::test::utils::vec2str(logitsLength) << "_"; - result << "A=" << ov::test::utils::vec2str(labels) << "_"; - result << "AL=" << ov::test::utils::vec2str(labelsLength) << "_"; - result << "BI=" << blankIndex << "_"; - result << "PCR=" << preprocessCollapseRepeated << "_"; - result << "CMR=" << ctcMergeRepeated << "_"; - result << "U=" << unique << "_"; - result << "PF=" << fpPrecision.name() << "_"; - result << "PI=" << intPrecision.name() << "_"; - result << "targetDevice=" << targetDevice; - return result.str(); -} - -void CTCLossLayerTest::SetUp() { - std::vector logitsShapes; - InferenceEngine::Precision fpPrecision, intPrecision; - bool preprocessCollapseRepeated, ctcMergeRepeated, unique; - std::vector logitsLength, labelsLength; - std::vector> labels; - int blankIndex; - CTCLossParamsSubset ctcLossArgsSubset; - std::tie(ctcLossArgsSubset, fpPrecision, intPrecision, targetDevice) = this->GetParam(); - std::tie(logitsShapes, logitsLength, labels, labelsLength, blankIndex, preprocessCollapseRepeated, - ctcMergeRepeated, unique) = ctcLossArgsSubset; - - auto ngFpPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(fpPrecision); - auto ngIntPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(intPrecision); - - ov::ParameterVector params {std::make_shared(ngFpPrc, ov::Shape(logitsShapes))}; - OPENVINO_SUPPRESS_DEPRECATED_START - auto ctcLoss = std::dynamic_pointer_cast( - ngraph::builder::makeCTCLoss(params[0], logitsLength, labels, labelsLength, blankIndex, - ngFpPrc, ngIntPrc, preprocessCollapseRepeated, ctcMergeRepeated, unique)); - OPENVINO_SUPPRESS_DEPRECATED_END - - ov::ResultVector results{std::make_shared(ctcLoss)}; - function = std::make_shared(results, params, "CTCLoss"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/cum_sum.cpp b/src/tests/functional/shared_test_classes/src/single_layer/cum_sum.cpp deleted file mode 100644 index dd834b5545d069..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/cum_sum.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/cum_sum.hpp" - -namespace LayerTestsDefinitions { - -std::string CumSumLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::SizeVector inputShapes; - InferenceEngine::Precision inputPrecision; - int64_t axis; - bool exclusive, reverse; - std::string targetDevice; - std::tie(inputShapes, inputPrecision, axis, exclusive, reverse, targetDevice) = obj.param; - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "Precision=" << inputPrecision.name() << "_"; - result << "Axis=" << axis << "_"; - result << "Exclusive=" << (exclusive ? "TRUE" : "FALSE") << "_"; - result << "Reverse=" << (reverse ? "TRUE" : "FALSE") << "_"; - result << "TargetDevice=" << targetDevice; - return result.str(); -} - -void CumSumLayerTest::SetUp() { - InferenceEngine::SizeVector inputShapes; - InferenceEngine::Precision inputPrecision; - bool exclusive, reverse; - int64_t axis; - std::tie(inputShapes, inputPrecision, axis, exclusive, reverse, targetDevice) = this->GetParam(); - const auto inType = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inputPrecision); - const auto paramData = std::make_shared(inType, ov::Shape(inputShapes)); - const auto axisNode = std::make_shared(ov::element::Type_t::i64, ov::Shape{}, std::vector{axis})->output(0); - const auto cumSum = std::make_shared(paramData, axisNode, exclusive, reverse); - - ov::ResultVector results{std::make_shared(cumSum)}; - function = std::make_shared(results, ov::ParameterVector{paramData}, "cumsum"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/deformable_convolution.cpp b/src/tests/functional/shared_test_classes/src/single_layer/deformable_convolution.cpp deleted file mode 100644 index bd215a2458f51d..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/deformable_convolution.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// -#include "shared_test_classes/single_layer/deformable_convolution.hpp" - -namespace LayerTestsDefinitions { -std::string DeformableConvolutionLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - deformableConvSpecificParams convParams; - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - InferenceEngine::SizeVector inputShapes; - std::string targetDevice; - std::tie(convParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShapes, targetDevice) = - obj.param; - ov::op::PadType padType; - InferenceEngine::SizeVector offsets, filter, stride, dilation; - std::vector padBegin, padEnd; - size_t groups, deformable_groups, convOutChannels; - bool with_bilinear_interpolation_pad, with_modulation; - std::tie(offsets, filter, stride, padBegin, padEnd, dilation, groups, deformable_groups, convOutChannels, padType, - with_bilinear_interpolation_pad, with_modulation) = convParams; - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "DV" << ov::test::utils::vec2str(offsets) << "_"; - result << "K" << ov::test::utils::vec2str(filter) << "_"; - result << "S" << ov::test::utils::vec2str(stride) << "_"; - result << "PB" << ov::test::utils::vec2str(padBegin) << "_"; - result << "PE" << ov::test::utils::vec2str(padEnd) << "_"; - result << "D=" << ov::test::utils::vec2str(dilation) << "_"; - result << "G=" << groups << "_"; - result << "DG=" << deformable_groups << "_"; - result << "O=" << convOutChannels << "_"; - result << "AP=" << padType << "_"; - result << "BI_PAD=" << with_bilinear_interpolation_pad << "_"; - result << "MODULATION=" << with_modulation << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "trgDev=" << targetDevice; - return result.str(); -} - -InferenceEngine::Blob::Ptr DeformableConvolutionLayerTest::GenerateInput(const InferenceEngine::InputInfo &info) const { - InferenceEngine::Blob::Ptr blobPtr; - const std::string& name = info.name(); - if (name == "a_data") { - blobPtr = LayerTestsUtils::LayerTestsCommon::GenerateInput(info); - } else if (name == "b_offset_vals") { - blobPtr = FuncTestUtils::createAndFillBlobFloat(info.getTensorDesc(), 2, 0, 10); - } else if (name == "c_filter_vals") { - blobPtr = LayerTestsUtils::LayerTestsCommon::GenerateInput(info); - } else if (name == "c_modulation_scalars") { - blobPtr = FuncTestUtils::createAndFillBlobFloat(info.getTensorDesc(), 1, 0, 20); - } - return blobPtr; -} -void DeformableConvolutionLayerTest::SetUp() { - deformableConvSpecificParams convParams; - std::vector inputShape; - InferenceEngine::Precision netPrecision; - std::tie(convParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, targetDevice) = - this->GetParam(); - ov::op::PadType padType; - InferenceEngine::SizeVector offsets, filter, stride, dilation; - std::vector padBegin, padEnd; - size_t groups, deformable_groups, convOutChannels; - bool with_bilinear_interpolation_pad, with_modulation; - std::tie(offsets, filter, stride, padBegin, padEnd, dilation, groups, deformable_groups, convOutChannels, padType, - with_bilinear_interpolation_pad, with_modulation) = convParams; - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params; - for (auto&& shape : {inputShape, offsets, filter}) { - params.push_back(std::make_shared(ngPrc, ov::Shape(shape))); - } - auto data = std::make_shared(ngPrc, ov::Shape(inputShape)); - data->set_friendly_name("a_data"); - auto offset_vals = std::make_shared(ngPrc, ov::Shape(offsets)); - offset_vals->set_friendly_name("b_offset_vals"); - auto filter_vals = std::make_shared(ngPrc, ov::Shape(filter)); - filter_vals->set_friendly_name("c_filter_vals"); - ov::ParameterVector parameters{data, offset_vals, filter_vals}; - std::shared_ptr deformable_conv; - if (with_modulation) { - auto modulation_shape = ov::Shape(offsets); - modulation_shape[1] = offsets[1] / 2; - auto modulation_scalars = std::make_shared(ngPrc, modulation_shape); - modulation_scalars->set_friendly_name("c_modulation_scalars"); - - deformable_conv = std::make_shared(data, offset_vals, filter_vals, modulation_scalars, stride, padBegin, - padEnd, dilation, padType, groups, deformable_groups, - with_bilinear_interpolation_pad); - parameters.push_back(modulation_scalars); - } else { - deformable_conv = std::make_shared(data, offset_vals, filter_vals, stride, padBegin, padEnd, dilation, - padType, groups, deformable_groups, with_bilinear_interpolation_pad); - } - - ov::ResultVector results{std::make_shared(deformable_conv)}; - function = std::make_shared(results, parameters, "deformable_convolution"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/deformable_psroi_pooling.cpp b/src/tests/functional/shared_test_classes/src/single_layer/deformable_psroi_pooling.cpp deleted file mode 100644 index 0557da19c55540..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/deformable_psroi_pooling.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/deformable_psroi_pooling.hpp" - - -namespace LayerTestsDefinitions { - - std::string DeformablePSROIPoolingLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - std::vector dataShape; - std::vector roisShape; - std::vector offsetsShape; - int64_t outputDim; - int64_t groupSize; - float spatialScale; - std::vector spatialBinsXY; - float trans_std; - int64_t part_size; - InferenceEngine::Precision netPrecision; - std::string targetDevice; - deformablePSROISpecificParams opParams; - - std::tie(opParams, netPrecision, targetDevice) = obj.param; - std::tie(dataShape, roisShape, offsetsShape, outputDim, groupSize, spatialScale, spatialBinsXY, - trans_std, part_size) = opParams; - - std::ostringstream result; - - result << "data_shape=" << ov::test::utils::vec2str(dataShape) << "_"; - result << "rois_shape=" << ov::test::utils::vec2str(roisShape) << "_"; - result << "offsets_shape=" << ov::test::utils::vec2str(offsetsShape) << "_"; - result << "out_dim=" << outputDim << "_"; - result << "group_size=" << groupSize << "_"; - result << "scale=" << spatialScale << "_"; - result << "bins_x=" << spatialBinsXY[0] << "_"; - result << "bins_y=" << spatialBinsXY[1] << "_"; - result << "trans_std=" << trans_std << "_"; - result << "part_size=" << part_size << "_"; - result << "prec=" << netPrecision.name() << "_"; - result << "dev=" << targetDevice; - return result.str(); - } - - void DeformablePSROIPoolingLayerTest::GenerateInputs() { - auto data_input_shape = cnnNetwork.getInputShapes().begin()->second; - const auto batch_distrib = data_input_shape[0] - 1; - const auto height = data_input_shape[2] / spatialScale_; - const auto width = data_input_shape[3] / spatialScale_; - - size_t it = 0; - for (const auto &input : cnnNetwork.getInputsInfo()) { - const auto &info = input.second; - InferenceEngine::Blob::Ptr blob; - - if (it == 0) { - blob = GenerateInput(*info); - } else if (it == 1) { - blob = make_blob_with_precision(info->getTensorDesc()); - blob->allocate(); - ov::test::utils::fill_data_roi(blob, batch_distrib, - height, width, 1.0f, true); - } else { - blob = make_blob_with_precision(info->getTensorDesc()); - blob->allocate(); - std::vector offset_data = ov::test::utils::generate_float_numbers(blob->size(), -0.9, 0.9); - ov::test::utils::fill_data_float_array(blob, &offset_data[0], blob->size()); - } - inputs.push_back(blob); - it++; - } - } - - void DeformablePSROIPoolingLayerTest::SetUp() { - std::vector dataShape; - std::vector roisShape; - std::vector offsetsShape; - int64_t outputDim; - int64_t groupSize; - std::string mode = "bilinear_deformable"; - std::vector spatialBinsXY; - float trans_std; - int64_t part_size; - InferenceEngine::Precision netPrecision; - deformablePSROISpecificParams opParams; - - std::tie(opParams, netPrecision, targetDevice) = this->GetParam(); - std::tie(dataShape, roisShape, offsetsShape, outputDim, groupSize, spatialScale_, spatialBinsXY, - trans_std, part_size) = opParams; - - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params; - ov::OutputVector inputs; - std::shared_ptr defomablePSROIPooling; - - if (offsetsShape.empty()) { // Test without optional third input (offsets) - params = ov::ParameterVector{std::make_shared(ngPrc, ov::Shape(dataShape)), - std::make_shared(ngPrc, ov::Shape(roisShape))}; - defomablePSROIPooling = std::make_shared(params[0], - params[1], - outputDim, - spatialScale_, - groupSize, - mode, - spatialBinsXY[0], - spatialBinsXY[1], - trans_std, - part_size); - } else { - params = ov::ParameterVector{std::make_shared(ngPrc, ov::Shape(dataShape)), - std::make_shared(ngPrc, ov::Shape(roisShape)), - std::make_shared(ngPrc, ov::Shape(offsetsShape))}; - defomablePSROIPooling = std::make_shared(params[0], - params[1], - params[2], - outputDim, - spatialScale_, - groupSize, - mode, - spatialBinsXY[0], - spatialBinsXY[1], - trans_std, - part_size); - } - - ov::ResultVector results{std::make_shared(defomablePSROIPooling)}; - function = std::make_shared(results, params, "deformable_psroi_pooling"); - } -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/depth_to_space.cpp b/src/tests/functional/shared_test_classes/src/single_layer/depth_to_space.cpp deleted file mode 100644 index 3861370f37ebf4..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/depth_to_space.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ov_models/builders.hpp" -#include "shared_test_classes/single_layer/depth_to_space.hpp" - -namespace LayerTestsDefinitions { - -static inline std::string DepthToSpaceModeToString(const ov::op::v0::DepthToSpace::DepthToSpaceMode& mode) { - static std::map names = { - {ov::op::v0::DepthToSpace::DepthToSpaceMode::BLOCKS_FIRST, "BLOCKS_FIRST"}, - {ov::op::v0::DepthToSpace::DepthToSpaceMode::DEPTH_FIRST, "DEPTH_FIRST"}, - }; - - auto i = names.find(mode); - if (i != names.end()) - return i->second; - else - throw std::runtime_error("Unsupported DepthToSpaceMode"); -} - -std::string DepthToSpaceLayerTest::getTestCaseName(const testing::TestParamInfo &obj) { - std::vector inShape; - ov::op::v0::DepthToSpace::DepthToSpaceMode mode; - std::size_t blockSize; - InferenceEngine::Precision inputPrecision; - std::string targetName; - std::tie(inShape, inputPrecision, mode, blockSize, targetName) = obj.param; - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inShape) << "_"; - result << "inPrc=" << inputPrecision.name() << "_"; - result << "M=" << DepthToSpaceModeToString(mode) << "_"; - result << "BS=" << blockSize << "_"; - result << "targetDevice=" << targetName << "_"; - return result.str(); -} - -void DepthToSpaceLayerTest::SetUp() { - std::vector inShape; - ov::op::v0::DepthToSpace::DepthToSpaceMode mode; - std::size_t blockSize; - InferenceEngine::Precision inputPrecision; - std::tie(inShape, inputPrecision, mode, blockSize, targetDevice) = this->GetParam(); - auto inPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inputPrecision); - ov::ParameterVector params {std::make_shared(inPrc, ov::Shape(inShape))}; - auto d2s = std::make_shared(params[0], mode, blockSize); - ov::ResultVector results{std::make_shared(d2s)}; - function = std::make_shared(results, params, "DepthToSpace"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/detection_output.cpp b/src/tests/functional/shared_test_classes/src/single_layer/detection_output.cpp deleted file mode 100644 index eb1e0e0320face..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/detection_output.cpp +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ov_models/builders.hpp" -#include "shared_test_classes/single_layer/detection_output.hpp" - -namespace LayerTestsDefinitions { - -std::ostream& operator <<(std::ostream& result, const ov::op::v0::DetectionOutput::Attributes& attrs) { - result << "Classes=" << attrs.num_classes << "_"; - result << "backgrId=" << attrs.background_label_id << "_"; - result << "topK=" << attrs.top_k << "_"; - result << "varEnc=" << attrs.variance_encoded_in_target << "_"; - result << "keepTopK=" << ov::test::utils::vec2str(attrs.keep_top_k) << "_"; - result << "codeType=" << attrs.code_type << "_"; - result << "shareLoc=" << attrs.share_location << "_"; - result << "nmsThr=" << attrs.nms_threshold << "_"; - result << "confThr=" << attrs.confidence_threshold << "_"; - result << "clipAfterNms=" << attrs.clip_after_nms << "_"; - result << "clipBeforeNms=" << attrs.clip_before_nms << "_"; - result << "decrId=" << attrs.decrease_label_id << "_"; - result << "norm=" << attrs.normalized << "_"; - result << "inH=" << attrs.input_height << "_"; - result << "inW=" << attrs.input_width << "_"; - result << "OS=" << attrs.objectness_score << "_"; - return result; -} - -std::string DetectionOutputLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - DetectionOutputAttributes commonAttrs; - ParamsWhichSizeDepends specificAttrs; - ov::op::v0::DetectionOutput::Attributes attrs; - size_t batch; - std::string targetDevice; - std::tie(commonAttrs, specificAttrs, batch, attrs.objectness_score, targetDevice) = obj.param; - - std::tie(attrs.num_classes, attrs.background_label_id, attrs.top_k, attrs.keep_top_k, attrs.code_type, attrs.nms_threshold, attrs.confidence_threshold, - attrs.clip_after_nms, attrs.clip_before_nms, attrs.decrease_label_id) = commonAttrs; - - const size_t numInputs = 5; - std::vector inShapes(numInputs); - std::tie(attrs.variance_encoded_in_target, attrs.share_location, attrs.normalized, attrs.input_height, attrs.input_width, - inShapes[idxLocation], inShapes[idxConfidence], inShapes[idxPriors], inShapes[idxArmConfidence], inShapes[idxArmLocation]) = specificAttrs; - - if (inShapes[idxArmConfidence].empty()) { - inShapes.resize(3); - } - - for (size_t i = 0; i < inShapes.size(); i++) { - inShapes[i][0] = batch; - } - - std::ostringstream result; - result << "IS = { "; - result << "LOC=" << ov::test::utils::vec2str(inShapes[0]) << "_"; - result << "CONF=" << ov::test::utils::vec2str(inShapes[1]) << "_"; - result << "PRIOR=" << ov::test::utils::vec2str(inShapes[2]); - std::string armConf, armLoc; - if (inShapes.size() > 3) { - armConf = "_ARM_CONF=" + ov::test::utils::vec2str(inShapes[3]) + "_"; - armLoc = "ARM_LOC=" + ov::test::utils::vec2str(inShapes[4]); - } - result << armConf; - result << armLoc << " }_"; - - result << attrs; - result << "TargetDevice=" << targetDevice; - return result.str(); -} - -void DetectionOutputLayerTest::GenerateInputs() { - size_t it = 0; - for (const auto &input : cnnNetwork.getInputsInfo()) { - const auto &info = input.second; - InferenceEngine::Blob::Ptr blob; - int32_t resolution = 1; - uint32_t range = 1; - if (it == 2) { - if (attrs.normalized) { - resolution = 100; - } else { - range = 10; - } - } else if (it == 1 || it == 3) { - resolution = 1000; - } else { - resolution = 10; - } - blob = make_blob_with_precision(info->getTensorDesc()); - blob->allocate(); - ov::test::utils::fill_data_random_float(blob, range, 0, resolution); - inputs.push_back(blob); - it++; - } -} - -void DetectionOutputLayerTest::Compare( - const std::vector>> &expectedOutputs, - const std::vector &actualOutputs) { - for (std::size_t outputIndex = 0; outputIndex < expectedOutputs.size(); ++outputIndex) { - const auto &expected = expectedOutputs[outputIndex].second; - const auto &actual = actualOutputs[outputIndex]; - - ASSERT_EQ(expected.size(), actual->byteSize()); - - size_t expSize = 0; - size_t actSize = 0; - - const auto &expectedBuffer = expected.data(); - auto memory = InferenceEngine::as(actual); - IE_ASSERT(memory); - const auto lockedMemory = memory->wmap(); - const auto actualBuffer = lockedMemory.as(); - - const float *expBuf = reinterpret_cast(expectedBuffer); - const float *actBuf = reinterpret_cast(actualBuffer); - for (size_t i = 0; i < actual->size(); i+=7) { - if (expBuf[i] == -1) - break; - expSize += 7; - } - for (size_t i = 0; i < actual->size(); i+=7) { - if (actBuf[i] == -1) - break; - actSize += 7; - } - ASSERT_EQ(expSize, actSize); - LayerTestsCommon::Compare(expBuf, actBuf, expSize, 1e-2f); - } -} - -void DetectionOutputLayerTest::SetUp() { - DetectionOutputAttributes commonAttrs; - ParamsWhichSizeDepends specificAttrs; - size_t batch; - std::tie(commonAttrs, specificAttrs, batch, attrs.objectness_score, targetDevice) = this->GetParam(); - - std::tie(attrs.num_classes, attrs.background_label_id, attrs.top_k, attrs.keep_top_k, attrs.code_type, attrs.nms_threshold, attrs.confidence_threshold, - attrs.clip_after_nms, attrs.clip_before_nms, attrs.decrease_label_id) = commonAttrs; - - inShapes.resize(numInputs); - std::tie(attrs.variance_encoded_in_target, attrs.share_location, attrs.normalized, attrs.input_height, attrs.input_width, - inShapes[idxLocation], inShapes[idxConfidence], inShapes[idxPriors], inShapes[idxArmConfidence], inShapes[idxArmLocation]) = specificAttrs; - - if (inShapes[idxArmConfidence].empty()) { - inShapes.resize(3); - } - - for (size_t i = 0; i < inShapes.size(); i++) { - inShapes[i][0] = batch; - } - - ov::ParameterVector params; - for (auto&& shape : inShapes) { - auto param = std::make_shared(ov::element::f32, ov::Shape(shape)); - params.push_back(param); - } - std::shared_ptr detOut; - if (params.size() == 3) - detOut = std::make_shared(params[0], params[1], params[2], attrs); - else if (params.size() == 5) - detOut = std::make_shared(params[0], params[1], params[2], params[3], params[4], attrs); - else - OPENVINO_THROW("DetectionOutput layer supports only 3 or 5 inputs"); - - ov::ResultVector results{std::make_shared(detOut)}; - function = std::make_shared(results, params, "DetectionOutput"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/dft.cpp b/src/tests/functional/shared_test_classes/src/single_layer/dft.cpp deleted file mode 100644 index 19cbf193edd39e..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/dft.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/dft.hpp" - -namespace LayerTestsDefinitions { - -std::string DFTLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::SizeVector inputShapes; - InferenceEngine::Precision inputPrecision; - std::vector axes; - std::vector signalSize; - ngraph::helpers::DFTOpType opType; - std::string targetDevice; - std::tie(inputShapes, inputPrecision, axes, signalSize, opType, targetDevice) = obj.param; - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "Precision=" << inputPrecision.name() << "_"; - result << "Axes=" << ov::test::utils::vec2str(axes) << "_"; - result << "SignalSize=" << ov::test::utils::vec2str(signalSize) << "_"; - result << "Inverse=" << (opType == ngraph::helpers::DFTOpType::INVERSE) << "_"; - result << "TargetDevice=" << targetDevice; - return result.str(); -} - -void DFTLayerTest::SetUp() { - InferenceEngine::SizeVector inputShapes; - InferenceEngine::Precision inputPrecision; - std::vector axes; - std::vector signalSize; - ngraph::helpers::DFTOpType opType; - std::tie(inputShapes, inputPrecision, axes, signalSize, opType, targetDevice) = this->GetParam(); - auto inType = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inputPrecision); - ov::ParameterVector paramVector; - auto paramData = std::make_shared(inType, ov::Shape(inputShapes)); - paramVector.push_back(paramData); - - auto dft = ngraph::builder::makeDFT(paramVector[0], axes, signalSize, opType); - - - ov::ResultVector results{std::make_shared(dft)}; - function = std::make_shared(results, paramVector, "DFT"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/einsum.cpp b/src/tests/functional/shared_test_classes/src/single_layer/einsum.cpp deleted file mode 100644 index cfec35565aa8b6..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/einsum.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/einsum.hpp" -#include "ov_models/builders.hpp" - -namespace LayerTestsDefinitions { - -std::string EinsumLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::Precision precision; - EinsumEquationWithInput equationWithInput; - std::string targetDevice; - std::tie(precision, equationWithInput, targetDevice) = obj.param; - std::string equation; - std::vector inputShapes; - std::tie(equation, inputShapes) = equationWithInput; - - std::ostringstream result; - result << "PRC=" << precision.name() << "_"; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "Eq=" << equation << "_"; - result << "trgDev=" << targetDevice; - return result.str(); -} - -void EinsumLayerTest::SetUp() { - InferenceEngine::Precision precision; - EinsumEquationWithInput equationWithInput; - std::tie(precision, equationWithInput, targetDevice) = this->GetParam(); - std::string equation; - std::vector inputShapes; - std::tie(equation, inputShapes) = equationWithInput; - - const auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(precision); - ov::ParameterVector params; - ov::OutputVector paramsOuts; - for (auto&& shape : inputShapes) { - auto param = std::make_shared(ngPrc, ov::Shape(shape)); - params.push_back(param); - paramsOuts.push_back(param); - } - - const auto einsum = std::make_shared(paramsOuts, equation); - const ov::ResultVector results{std::make_shared(einsum)}; - function = std::make_shared(results, params, "einsum"); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/eltwise.cpp b/src/tests/functional/shared_test_classes/src/single_layer/eltwise.cpp deleted file mode 100644 index de9bea835f46e1..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/eltwise.cpp +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ov_models/builders.hpp" -#include "common_test_utils/node_builders/constant.hpp" -#include -#include "shared_test_classes/single_layer/eltwise.hpp" -#include "common_test_utils/node_builders/eltwise.hpp" - -#include "functional_test_utils/plugin_cache.hpp" - -namespace ov { -namespace test { -namespace subgraph { - -std::string EltwiseLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - std::vector shapes; - ElementType netType, inType, outType; - ngraph::helpers::InputLayerType secondaryInputType; - ov::test::utils::OpType opType; - ngraph::helpers::EltwiseTypes eltwiseOpType; - std::string targetName; - ov::AnyMap additional_config; - std::tie(shapes, eltwiseOpType, secondaryInputType, opType, netType, inType, outType, targetName, additional_config) = obj.param; - std::ostringstream results; - - results << "IS=("; - for (const auto& shape : shapes) { - results << ov::test::utils::partialShape2str({shape.first}) << "_"; - } - results << ")_TS=("; - for (const auto& shape : shapes) { - for (const auto& item : shape.second) { - results << ov::test::utils::vec2str(item) << "_"; - } - } - results << ")_eltwiseOpType=" << eltwiseOpType << "_"; - results << "secondaryInputType=" << secondaryInputType << "_"; - results << "opType=" << opType << "_"; - results << "NetType=" << netType << "_"; - results << "InType=" << inType << "_"; - results << "OutType=" << outType << "_"; - results << "trgDev=" << targetName; - for (auto const& configItem : additional_config) { - results << "_configItem=" << configItem.first << "="; - configItem.second.print(results); - } - return results.str(); -} - -void EltwiseLayerTest::transformInputShapesAccordingEltwise(const ov::PartialShape& secondInputShape) { - // propagate shapes in case 1 shape is defined - if (inputDynamicShapes.size() == 1) { - inputDynamicShapes.push_back(inputDynamicShapes.front()); - for (auto& staticShape : targetStaticShapes) { - staticShape.push_back(staticShape.front()); - } - } - ASSERT_EQ(inputDynamicShapes.size(), 2) << "Incorrect inputs number!"; - if (!secondInputShape.is_static()) { - return; - } - if (secondInputShape.get_shape() == ov::Shape{1}) { - inputDynamicShapes[1] = secondInputShape; - for (auto& staticShape : targetStaticShapes) { - staticShape[1] = secondInputShape.get_shape(); - } - } -} - -void EltwiseLayerTest::SetUp() { - std::vector shapes; - ElementType netType; - ngraph::helpers::InputLayerType secondaryInputType; - ov::test::utils::OpType opType; - ngraph::helpers::EltwiseTypes eltwiseType; - Config additional_config; - std::tie(shapes, eltwiseType, secondaryInputType, opType, netType, inType, outType, targetDevice, configuration) = - this->GetParam(); - - init_input_shapes(shapes); - - ov::ParameterVector parameters{std::make_shared(netType, inputDynamicShapes.front())}; - - ov::PartialShape shape_input_secondary; - switch (opType) { - case ov::test::utils::OpType::SCALAR: { - shape_input_secondary = {1}; - break; - } - case ov::test::utils::OpType::VECTOR: - shape_input_secondary = inputDynamicShapes.back(); - break; - default: - FAIL() << "Unsupported Secondary operation type"; - } - // To propagate shape_input_secondary just in static case because all shapes are defined in dynamic scenarion - if (secondaryInputType == ngraph::helpers::InputLayerType::PARAMETER) { - transformInputShapesAccordingEltwise(shape_input_secondary); - } - - std::shared_ptr secondaryInput; - if (secondaryInputType == ngraph::helpers::InputLayerType::PARAMETER) { - auto param = std::make_shared(netType, shape_input_secondary); - secondaryInput = param; - parameters.push_back(param); - } else { - ov::Shape shape = inputDynamicShapes.back().get_max_shape(); - switch (eltwiseType) { - case ngraph::helpers::EltwiseTypes::DIVIDE: - case ngraph::helpers::EltwiseTypes::MOD: - case ngraph::helpers::EltwiseTypes::FLOOR_MOD: { - std::vector data = NGraphFunctions::Utils::generateVector(ov::shape_size(shape), 10, 2); - secondaryInput = ov::test::utils::deprecated::make_constant(netType, shape, data); - break; - } - case ngraph::helpers::EltwiseTypes::POWER: - secondaryInput = ov::test::utils::deprecated::make_constant(netType, shape, {}, true, 3); - break; - default: - secondaryInput = ov::test::utils::deprecated::make_constant(netType, shape, {}, true); - } - } - - parameters[0]->set_friendly_name("param0"); - secondaryInput->set_friendly_name("param1"); - - auto eltwise = ov::test::utils::make_eltwise(parameters[0], secondaryInput, eltwiseType); - function = std::make_shared(eltwise, parameters, "Eltwise"); -} - -} // namespace subgraph -} // namespace test -} // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/single_layer/embedding_bag_offsets_sum.cpp b/src/tests/functional/shared_test_classes/src/single_layer/embedding_bag_offsets_sum.cpp deleted file mode 100644 index b351df09dbc84b..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/embedding_bag_offsets_sum.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/embedding_bag_offsets_sum.hpp" -#include "ov_models/builders.hpp" - -namespace LayerTestsDefinitions { - -std::string EmbeddingBagOffsetsSumLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - embeddingBagOffsetsSumParams params; - InferenceEngine::Precision netPrecision, indPrecision; - std::string targetDevice; - std::tie(params, netPrecision, indPrecision, targetDevice) = obj.param; - std::vector embTableShape, indices, offsets; - size_t defaultIndex; - bool withWeights, withDefIndex; - std::tie(embTableShape, indices, offsets, defaultIndex, withWeights, withDefIndex) = params; - - std::ostringstream result; - result << "ETS=" << ov::test::utils::vec2str(embTableShape) << "_"; - result << "I" << ov::test::utils::vec2str(indices) << "_"; - result << "O" << ov::test::utils::vec2str(offsets) << "_"; - result << "DI" << defaultIndex << "_"; - result << "WW" << withWeights << "_"; - result << "WDI" << withDefIndex << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "indPRC=" << indPrecision.name() << "_"; - result << "targetDevice=" << targetDevice; - return result.str(); -} - -void EmbeddingBagOffsetsSumLayerTest::SetUp() { - embeddingBagOffsetsSumParams embParams; - auto netPrecision = InferenceEngine::Precision::UNSPECIFIED; - auto indPrecision = netPrecision; - std::tie(embParams, netPrecision, indPrecision, targetDevice) = this->GetParam(); - std::vector embTableShape, indices, offsets; - bool withWeights, withDefIndex; - size_t defaultIndex; - std::tie(embTableShape, indices, offsets, defaultIndex, withWeights, withDefIndex) = embParams; - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - auto ngIdxPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(indPrecision); - - auto emb_table_node = std::make_shared(ngPrc, ov::Shape(embTableShape)); - ov::ParameterVector params = {emb_table_node}; - - auto embBag = std::dynamic_pointer_cast( - ngraph::builder::makeEmbeddingBagOffsetsSum( - ngPrc, ngIdxPrc, emb_table_node, indices, offsets, defaultIndex, withWeights, withDefIndex)); - ov::ResultVector results{std::make_shared(embBag)}; - function = std::make_shared(results, params, "embeddingBagOffsetsSum"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/embedding_bag_packed_sum.cpp b/src/tests/functional/shared_test_classes/src/single_layer/embedding_bag_packed_sum.cpp deleted file mode 100644 index 8bd6d0ac1b5947..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/embedding_bag_packed_sum.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/embedding_bag_packed_sum.hpp" -#include "common_test_utils/node_builders/embedding_bag_packed_sum.hpp" - -namespace LayerTestsDefinitions { - -std::string EmbeddingBagPackedSumLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - embeddingBagPackedSumParams params; - InferenceEngine::Precision netPrecision, indPrecision; - std::string targetDevice; - std::tie(params, netPrecision, indPrecision, targetDevice) = obj.param; - std::vector embTableShape; - std::vector> indices; - bool withWeights; - std::tie(embTableShape, indices, withWeights) = params; - - std::ostringstream result; - result << "ETS=" << ov::test::utils::vec2str(embTableShape) << "_"; - result << "I" << ov::test::utils::vec2str(indices) << "_"; - result << "WW" << withWeights << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "indPRC=" << indPrecision.name() << "_"; - result << "targetDevice=" << targetDevice; - return result.str(); -} - -void EmbeddingBagPackedSumLayerTest::SetUp() { - embeddingBagPackedSumParams embParams; - auto netPrecision = InferenceEngine::Precision::UNSPECIFIED; - auto indPrecision = netPrecision; - std::tie(embParams, netPrecision, indPrecision, targetDevice) = this->GetParam(); - std::vector embTableShape; - std::vector> indices; - bool withWeights; - std::tie(embTableShape, indices, withWeights) = embParams; - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - auto ngIdxPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(indPrecision); - - auto emb_table_node = std::make_shared(ngPrc, ov::Shape(embTableShape)); - ov::ParameterVector params = {emb_table_node}; - - auto embBag = ov::test::utils::make_embedding_bag_packed_sum(ngPrc, ngIdxPrc, emb_table_node, indices, withWeights); - ov::ResultVector results{std::make_shared(embBag)}; - function = std::make_shared(results, params, "embeddingBagPackedSum"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/embedding_segments_sum.cpp b/src/tests/functional/shared_test_classes/src/single_layer/embedding_segments_sum.cpp deleted file mode 100644 index 808f37ff33be8e..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/embedding_segments_sum.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/embedding_segments_sum.hpp" -#include "ov_models/builders.hpp" - - -namespace LayerTestsDefinitions { - -std::string EmbeddingSegmentsSumLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - embeddingSegmentsSumParams params; - InferenceEngine::Precision netPrecision, indPrecision; - std::string targetDevice; - std::tie(params, netPrecision, indPrecision, targetDevice) = obj.param; - std::vector embTableShape, indices, segmentIds; - size_t numSegments, defaultIndex; - bool withWeights, withDefIndex; - std::tie(embTableShape, indices, segmentIds, numSegments, defaultIndex, withWeights, withDefIndex) = params; - - std::ostringstream result; - result << "ETS=" << ov::test::utils::vec2str(embTableShape) << "_"; - result << "I" << ov::test::utils::vec2str(indices) << "_"; - result << "SI" << ov::test::utils::vec2str(segmentIds) << "_"; - result << "NS" << numSegments << "_"; - result << "DI" << defaultIndex << "_"; - result << "WW" << withWeights << "_"; - result << "WDI" << withDefIndex << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "indPRC=" << indPrecision.name() << "_"; - result << "targetDevice=" << targetDevice; - return result.str(); -} - -void EmbeddingSegmentsSumLayerTest::SetUp() { - embeddingSegmentsSumParams embParams; - auto netPrecision = InferenceEngine::Precision::UNSPECIFIED; - auto indPrecision = netPrecision; - std::tie(embParams, netPrecision, indPrecision, targetDevice) = this->GetParam(); - std::vector embTableShape, indices, segmentIds; - bool withWeights, withDefIndex; - size_t numSegments, defaultIndex; - std::tie(embTableShape, indices, segmentIds, numSegments, defaultIndex, withWeights, withDefIndex) = embParams; - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - auto ngIdxPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(indPrecision); - - auto emb_table_node = std::make_shared(ngPrc, ov::Shape(embTableShape)); - ov::ParameterVector params = {emb_table_node}; - - auto embBag = std::dynamic_pointer_cast( - ngraph::builder::makeEmbeddingSegmentsSum( - ngPrc, ngIdxPrc, emb_table_node, indices, segmentIds, numSegments, defaultIndex, withWeights, withDefIndex)); - ov::ResultVector results{std::make_shared(embBag)}; - function = std::make_shared(results, params, "embeddingSegmentsSum"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/experimental_detectron_detection_output.cpp b/src/tests/functional/shared_test_classes/src/single_layer/experimental_detectron_detection_output.cpp deleted file mode 100644 index c17f1bfe0ae573..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/experimental_detectron_detection_output.cpp +++ /dev/null @@ -1,178 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/experimental_detectron_detection_output.hpp" -#include "ov_models/builders.hpp" -#include "common_test_utils/data_utils.hpp" -#include - -namespace ov { -namespace test { -namespace subgraph { - -namespace { - std::ostream& operator <<(std::ostream& ss, const ov::op::v6::ExperimentalDetectronDetectionOutput::Attributes& attributes) { - ss << "score_threshold=" << attributes.score_threshold << "_"; - ss << "nms_threshold=" << attributes.nms_threshold << "_"; - ss << "max_delta_log_wh=" << attributes.max_delta_log_wh << "_"; - ss << "num_classes=" << attributes.num_classes << "_"; - ss << "post_nms_count=" << attributes.post_nms_count << "_"; - ss << "max_detections_per_image=" << attributes.max_detections_per_image << "_"; - ss << "class_agnostic_box_regression=" << (attributes.class_agnostic_box_regression ? "true" : "false") << "_"; - ss << "deltas_weights=" << ov::test::utils::vec2str(attributes.deltas_weights); - return ss; -} -} // namespace - -std::string ExperimentalDetectronDetectionOutputLayerTest::getTestCaseName( - const testing::TestParamInfo& obj) { - std::vector inputShapes; - ov::op::v6::ExperimentalDetectronDetectionOutput::Attributes attributes; - ElementType netPrecision; - std::string targetName; - std::tie( - inputShapes, - attributes.score_threshold, - attributes.nms_threshold, - attributes.max_delta_log_wh, - attributes.num_classes, - attributes.post_nms_count, - attributes.max_detections_per_image, - attributes.class_agnostic_box_regression, - attributes.deltas_weights, - netPrecision, - targetName) = obj.param; - - std::ostringstream result; - - using ov::test::operator<<; - result << "input_rois=" << inputShapes[0] << "_"; - result << "input_deltas=" << inputShapes[1] << "_"; - result << "input_scores=" << inputShapes[2] << "_"; - result << "input_im_info=" << inputShapes[3] << "_"; - - using ov::test::subgraph::operator<<; - result << "attributes={" << attributes << "}_"; - result << "netPRC=" << netPrecision << "_"; - result << "trgDev=" << targetName; - return result.str(); -} - -void ExperimentalDetectronDetectionOutputLayerTest::SetUp() { - std::vector inputShapes; - ov::op::v6::ExperimentalDetectronDetectionOutput::Attributes attributes; - - ElementType netPrecision; - std::string targetName; - std::tie( - inputShapes, - attributes.score_threshold, - attributes.nms_threshold, - attributes.max_delta_log_wh, - attributes.num_classes, - attributes.post_nms_count, - attributes.max_detections_per_image, - attributes.class_agnostic_box_regression, - attributes.deltas_weights, - netPrecision, - targetName) = this->GetParam(); - - if (netPrecision == element::f16) - abs_threshold = 0.01; - - inType = outType = netPrecision; - targetDevice = targetName; - - init_input_shapes(inputShapes); - - ov::ParameterVector params; - for (auto&& shape : inputDynamicShapes) - params.push_back(std::make_shared(netPrecision, shape)); - - auto experimentalDetectron = std::make_shared( - params[0], // input_rois - params[1], // input_deltas - params[2], // input_scores - params[3], // input_im_info - attributes); - function = std::make_shared( - ov::OutputVector{experimentalDetectron->output(0), experimentalDetectron->output(1)}, - "ExperimentalDetectronDetectionOutput"); -} - -namespace { - -template -std::vector getValues(const std::vector& values) { - std::vector result(values.begin(), values.end()); - return result; -} - -template -std::vector generateInputTensors() { - const auto netPrecision = ov::element::from(); - std::vector inputTensors = { - // 16 x 4 = 64 - ov::test::utils::create_tensor( - netPrecision, - Shape{16, 4}, - getValues({ - 1.0f, 1.0f, 10.0f, 10.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, 4.0f, 1.0f, 8.0f, 5.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f - })), - // 16 x 8 - ov::test::utils::create_tensor( - netPrecision, - Shape{16, 8}, - getValues({ - 5.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, 1.0f, 4.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 8.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, - - 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f - })), - // 16 x 2 = 32 - ov::test::utils::create_tensor( - netPrecision, - Shape{16, 2}, - getValues({ - 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f - })), - // 1 x 3 = 3 - ov::test::utils::create_tensor(netPrecision, Shape{1, 3}, getValues({1.0f, 1.0f, 1.0f}))}; - - return inputTensors; -} -} // namespace - -void ExperimentalDetectronDetectionOutputLayerTest::generate_inputs( - const std::vector& targetInputStaticShapes) { - const auto netPrecision = std::get<9>(GetParam()); - - const std::vector inputTensors = - (netPrecision == element::f16) ? generateInputTensors() : generateInputTensors(); - - inputs.clear(); - const auto& funcInputs = function->inputs(); - for (auto i = 0ul; i < funcInputs.size(); ++i) { - if (targetInputStaticShapes[i] != inputTensors[i].get_shape()) { - OPENVINO_THROW("input shape is different from tensor shape"); - } - - inputs.insert({funcInputs[i].get_node_shared_ptr(), inputTensors[i]}); - } -} - -} // namespace subgraph -} // namespace test -} // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/single_layer/experimental_detectron_generate_proposals_single_image.cpp b/src/tests/functional/shared_test_classes/src/single_layer/experimental_detectron_generate_proposals_single_image.cpp deleted file mode 100644 index 04bde87024d440..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/experimental_detectron_generate_proposals_single_image.cpp +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/experimental_detectron_generate_proposals_single_image.hpp" -#include "ov_models/builders.hpp" -#include - -namespace ov { -namespace test { -namespace subgraph { - -namespace { -std::ostream& operator <<( - std::ostream& ss, - const ov::op::v6::ExperimentalDetectronGenerateProposalsSingleImage::Attributes& attributes) { - ss << "score_threshold=" << attributes.min_size << "_"; - ss << "nms_threshold=" << attributes.nms_threshold << "_"; - ss << "max_delta_log_wh=" << attributes.post_nms_count << "_"; - ss << "num_classes=" << attributes.pre_nms_count; - return ss; -} -} // namespace - -std::string ExperimentalDetectronGenerateProposalsSingleImageLayerTest::getTestCaseName( - const testing::TestParamInfo& obj) { - std::vector inputShapes; - ov::op::v6::ExperimentalDetectronGenerateProposalsSingleImage::Attributes attributes; - std::pair> inputTensors; - ElementType netPrecision; - std::string targetName; - std::tie( - inputShapes, - attributes.min_size, - attributes.nms_threshold, - attributes.post_nms_count, - attributes.pre_nms_count, - inputTensors, - netPrecision, - targetName) = obj.param; - - std::ostringstream result; - using ov::test::operator<<; - result << "im_info=" << inputShapes[0] << "_"; - result << "anchors=" << inputShapes[1] << "_"; - result << "deltas=" << inputShapes[2] << "_"; - result << "scores=" << inputShapes[3] << "_"; - - using ov::test::subgraph::operator<<; - result << "attributes={" << attributes << "}_"; - result << "inputTensors=" << inputTensors.first << "_"; - result << "netPRC=" << netPrecision << "_"; - result << "trgDev=" << targetName; - return result.str(); -} - -void ExperimentalDetectronGenerateProposalsSingleImageLayerTest::SetUp() { - std::vector inputShapes; - ov::op::v6::ExperimentalDetectronGenerateProposalsSingleImage::Attributes attributes; - std::pair> inputTensors; - ElementType netPrecision; - std::string targetName; - std::tie( - inputShapes, - attributes.min_size, - attributes.nms_threshold, - attributes.post_nms_count, - attributes.pre_nms_count, - inputTensors, - netPrecision, - targetName) = this->GetParam(); - - inType = outType = netPrecision; - targetDevice = targetName; - - init_input_shapes(inputShapes); - - ov::ParameterVector params; - for (auto&& shape : inputDynamicShapes) - params.push_back(std::make_shared(netPrecision, shape)); - - auto experimentalDetectron = std::make_shared( - params[0], // im_info - params[1], // anchors - params[2], // deltas - params[3], // scores - attributes); - function = std::make_shared( - ov::OutputVector{experimentalDetectron->output(0), experimentalDetectron->output(1)}, - "ExperimentalDetectronGenerateProposalsSingleImage"); -} - -void ExperimentalDetectronGenerateProposalsSingleImageLayerTest::generate_inputs(const std::vector& targetInputStaticShapes) { - auto inputTensors = std::get<5>(GetParam()); - - inputs.clear(); - const auto& funcInputs = function->inputs(); - for (auto i = 0ul; i < funcInputs.size(); ++i) { - if (targetInputStaticShapes[i] != inputTensors.second[i].get_shape()) { - OPENVINO_THROW("input shape is different from tensor shape"); - } - - inputs.insert({funcInputs[i].get_node_shared_ptr(), inputTensors.second[i]}); - } -} - -} // namespace subgraph -} // namespace test -} // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/single_layer/experimental_detectron_prior_grid_generator.cpp b/src/tests/functional/shared_test_classes/src/single_layer/experimental_detectron_prior_grid_generator.cpp index f3bf7d8bcf9edc..8e7ad1a168c5b0 100644 --- a/src/tests/functional/shared_test_classes/src/single_layer/experimental_detectron_prior_grid_generator.cpp +++ b/src/tests/functional/shared_test_classes/src/single_layer/experimental_detectron_prior_grid_generator.cpp @@ -74,7 +74,7 @@ void ExperimentalDetectronPriorGridGeneratorLayerTest::SetUp() { namespace { template -ov::runtime::Tensor generateTensorByShape(const Shape &shape) { +ov::Tensor generateTensorByShape(const Shape &shape) { return ov::test::utils::create_tensor( ov::element::from(), shape, @@ -98,7 +98,7 @@ void ExperimentalDetectronPriorGridGeneratorLayerTest::generate_inputs(const std inputs.insert({funcInputs[i].get_node_shared_ptr(), inputTensors.second[i]}); } for (auto j = i; j < funcInputs.size(); ++j) { - ov::runtime::Tensor inputTensor = (netPrecision == element::f16) + ov::Tensor inputTensor = (netPrecision == element::f16) ? generateTensorByShape(targetInputStaticShapes[j]) : generateTensorByShape( targetInputStaticShapes[j]); @@ -109,4 +109,4 @@ void ExperimentalDetectronPriorGridGeneratorLayerTest::generate_inputs(const std } // namespace subgraph } // namespace test -} // namespace ov +} // namespace ov \ No newline at end of file diff --git a/src/tests/functional/shared_test_classes/src/single_layer/experimental_detectron_roifeatureextractor.cpp b/src/tests/functional/shared_test_classes/src/single_layer/experimental_detectron_roifeatureextractor.cpp deleted file mode 100644 index 80847e7dd98879..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/experimental_detectron_roifeatureextractor.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ov_models/builders.hpp" -#include -#include "functional_test_utils/plugin_cache.hpp" -#include "shared_test_classes/single_layer/experimental_detectron_roifeatureextractor.hpp" - -namespace ov { -namespace test { -namespace subgraph { - -std::string ExperimentalDetectronROIFeatureExtractorLayerTest::getTestCaseName( - const testing::TestParamInfo& obj) { - std::vector inputShapes; - int64_t outputSize, samplingRatio; - std::vector pyramidScales; - bool aligned; - ElementType netPrecision; - std::string targetName; - std::tie(inputShapes, outputSize, samplingRatio, pyramidScales, aligned, netPrecision, targetName) = obj.param; - - std::ostringstream result; - if (inputShapes.front().first.size() != 0) { - result << "IS=("; - for (const auto &shape : inputShapes) { - result << ov::test::utils::partialShape2str({shape.first}) << "_"; - } - result.seekp(-1, result.cur); - result << ")_"; - } - result << "TS="; - for (const auto& shape : inputShapes) { - for (const auto& item : shape.second) { - result << ov::test::utils::vec2str(item) << "_"; - } - } - result << "outputSize=" << outputSize << "_"; - result << "samplingRatio=" << samplingRatio << "_"; - result << "pyramidScales=" << ov::test::utils::vec2str(pyramidScales) << "_"; - std::string alig = aligned ? "true" : "false"; - result << "aligned=" << alig << "_"; - result << "netPRC=" << netPrecision << "_"; - result << "trgDev=" << targetName; - return result.str(); -} - -void ExperimentalDetectronROIFeatureExtractorLayerTest::SetUp() { - std::vector inputShapes; - int64_t outputSize, samplingRatio; - std::vector pyramidScales; - bool aligned; - ElementType netPrecision; - std::string targetName; - std::tie(inputShapes, outputSize, samplingRatio, pyramidScales, aligned, netPrecision, targetName) = this->GetParam(); - - inType = outType = netPrecision; - targetDevice = targetName; - - init_input_shapes(inputShapes); - - Attrs attrs; - attrs.aligned = aligned; - attrs.output_size = outputSize; - attrs.sampling_ratio = samplingRatio; - attrs.pyramid_scales = pyramidScales; - - ov::ParameterVector params; - ov::OutputVector paramsOuts; - for (auto&& shape : inputDynamicShapes) { - auto param = std::make_shared(netPrecision, shape); - params.push_back(param); - paramsOuts.push_back(param); - } - auto experimentalDetectronROIFeatureExtractor = std::make_shared(paramsOuts, attrs); - function = std::make_shared(ov::OutputVector{experimentalDetectronROIFeatureExtractor->output(0), - experimentalDetectronROIFeatureExtractor->output(1)}, - "ExperimentalDetectronROIFeatureExtractor"); -} -} // namespace subgraph -} // namespace test -} // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/single_layer/experimental_detectron_topkrois.cpp b/src/tests/functional/shared_test_classes/src/single_layer/experimental_detectron_topkrois.cpp deleted file mode 100644 index c067bc4e3b1722..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/experimental_detectron_topkrois.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ov_models/builders.hpp" -#include -#include "shared_test_classes/single_layer/experimental_detectron_topkrois.hpp" - -namespace ov { -namespace test { -namespace subgraph { - -std::string ExperimentalDetectronTopKROIsLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - std::vector inputShapes; - int64_t maxRois; - ElementType netPrecision; - std::string targetName; - std::tie(inputShapes, maxRois, netPrecision, targetName) = obj.param; - - std::ostringstream result; - if (inputShapes.front().first.size() != 0) { - result << "IS=("; - for (const auto &shape : inputShapes) { - result << ov::test::utils::partialShape2str({shape.first}) << "_"; - } - result.seekp(-1, result.cur); - result << ")_"; - } - result << "TS="; - for (const auto& shape : inputShapes) { - for (const auto& item : shape.second) { - result << ov::test::utils::vec2str(item) << "_"; - } - } - result << "maxRois=" << maxRois << "_"; - result << "netPRC=" << netPrecision << "_"; - result << "trgDev=" << targetName; - return result.str(); -} - -void ExperimentalDetectronTopKROIsLayerTest::SetUp() { - std::vector inputShapes; - int64_t maxRois; - ElementType netPrecision; - std::string targetName; - std::tie(inputShapes, maxRois, netPrecision, targetName) = this->GetParam(); - - inType = outType = netPrecision; - targetDevice = targetName; - - init_input_shapes(inputShapes); - - ov::ParameterVector params; - for (auto&& shape : inputDynamicShapes) - params.push_back(std::make_shared(netPrecision, shape)); - - auto experimentalDetectronTopKROIs = std::make_shared(params[0], params[1], maxRois); - function = std::make_shared(ov::OutputVector {experimentalDetectronTopKROIs->output(0)}, "ExperimentalDetectronTopKROIs"); -} -} // namespace subgraph -} // namespace test -} // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/single_layer/extract_image_patches.cpp b/src/tests/functional/shared_test_classes/src/single_layer/extract_image_patches.cpp deleted file mode 100644 index 4ffcca538ab46d..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/extract_image_patches.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/extract_image_patches.hpp" -#include "ov_models/builders.hpp" - - -namespace LayerTestsDefinitions { - -std::string ExtractImagePatchesTest::getTestCaseName(const testing::TestParamInfo &obj) { - std::vector inputShape, kernel, strides, rates; - ov::op::PadType pad_type; - InferenceEngine::Precision netPrc; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout; - std::string targetName; - std::tie(inputShape, kernel, strides, rates, pad_type, netPrc, inPrc, outPrc, inLayout, targetName) = obj.param; - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShape) << "_"; - result << "netPRC=" << netPrc.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "K=" << ov::test::utils::vec2str(kernel) << "_"; - result << "S=" << ov::test::utils::vec2str(strides) << "_"; - result << "R=" << ov::test::utils::vec2str(rates) << "_"; - result << "P=" << pad_type << "_"; - result << "trgDev=" << targetName; - return result.str(); -} - -void ExtractImagePatchesTest::SetUp() { - std::vector inputShape, kernel, strides, rates; - ov::op::PadType pad_type; - InferenceEngine::Precision netPrecision; - std::tie(inputShape, kernel, strides, rates, pad_type, netPrecision, inPrc, outPrc, inLayout, targetDevice) = this->GetParam(); - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - - auto inputNode = std::make_shared(ngPrc, ov::Shape(inputShape)); - ov::ParameterVector params = {inputNode}; - - auto extImgPatches = std::make_shared( - inputNode, ov::Shape(kernel), ngraph::Strides(strides), ov::Shape(rates), pad_type); - ov::ResultVector results{std::make_shared(extImgPatches)}; - function = std::make_shared(results, params, "ExtractImagePatches"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/eye.cpp b/src/tests/functional/shared_test_classes/src/single_layer/eye.cpp deleted file mode 100644 index cf5a13baa14f3d..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/eye.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (C) 2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// -#include -#include -#include - -#include "ov_models/builders.hpp" -#include "shared_test_classes/single_layer/eye.hpp" - -namespace LayerTestsDefinitions { - -std::string EyeLayerTest::getTestCaseName(testing::TestParamInfo obj) { - EyeLayerTestParams params = obj.param; - - std::string td; - std::vector input_shapes; - ElementType net_precision; - std::vector out_batch_shape; - std::vector eye_par; - std::tie(input_shapes, out_batch_shape, eye_par, net_precision, td) = params; - std::ostringstream result; - result << "EyeTest_"; - result << "IS=("; - for (const auto& shape : input_shapes) { - result << ov::test::utils::partialShape2str({shape}) << "_"; - } - result << ")"; - result << "rowNum=" << eye_par[0] << "_"; - result << "colNum=" << eye_par[1] << "_"; - result << "diagShift=" << eye_par[2] << "_"; - result << "batchShape=" << ov::test::utils::vec2str(out_batch_shape) << "_"; - result << net_precision << "_"; - result << std::to_string(obj.index); - return result.str(); -} - -void EyeLayerTest::SetUp() { - std::vector input_shapes; - LocalElementType row_num, col_num; - LocalElementType shift; - std::vector out_batch_shape; - ElementType net_precision; - EyeLayerTestParams basicParamsSet = this->GetParam(); - - std::vector eye_par; - std::tie(input_shapes, out_batch_shape, eye_par, net_precision, targetDevice) = basicParamsSet; - row_num = eye_par[0]; - col_num = eye_par[1]; - shift = eye_par[2]; - - std::shared_ptr eye_operation; - - auto rows_const = std::make_shared(ov::element::i32, input_shapes[0], &row_num); - rows_const->set_friendly_name("rows"); - auto cols_const = std::make_shared(ov::element::i32, input_shapes[1], &col_num); - cols_const->set_friendly_name("cols"); - auto diag_const = std::make_shared(ov::element::i32, input_shapes[2], &shift); - diag_const->set_friendly_name("diagInd"); - - if (!out_batch_shape.empty() && out_batch_shape[0] != 0) { - auto batch_shape_par = std::make_shared(ov::element::i32, - ov::Shape{out_batch_shape.size()}, - out_batch_shape.data()); - batch_shape_par->set_friendly_name("batchShape"); - eye_operation = - std::make_shared(rows_const, cols_const, diag_const, batch_shape_par, net_precision); - } else { - eye_operation = std::make_shared(rows_const, cols_const, diag_const, net_precision); - } - // Without this call the eye operation will be calculated by CPU and substituted by Constant operator - ov::pass::disable_constant_folding(eye_operation); - ov::ResultVector results{std::make_shared(eye_operation)}; - function = std::make_shared(results, ov::ParameterVector{}, "eye"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/fake_quantize.cpp b/src/tests/functional/shared_test_classes/src/single_layer/fake_quantize.cpp deleted file mode 100644 index 1ede979e6b242f..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/fake_quantize.cpp +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/fake_quantize.hpp" - -#include "common_test_utils/node_builders/fake_quantize.hpp" - -namespace LayerTestsDefinitions { - - -std::string FakeQuantizeLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - fqSpecificParams fqParams; - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - InferenceEngine::SizeVector inputShapes; - std::string targetDevice; - std::pair> config; - std::tie(fqParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShapes, targetDevice, config) = obj.param; - size_t levels; - std::vector constShape; - std::vector fqDirectArgs; - std::vector inputArg; - ov::op::AutoBroadcastSpec broadcast; - std::tie(levels, constShape, fqDirectArgs, inputArg, broadcast) = fqParams; - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "CS=" << ov::test::utils::vec2str(constShape) << "_"; - result << "LEVELS=" << levels << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "trgDev=" << targetDevice; - if (!config.first.empty()) { - result << "_targetConfig=" << config.first; - } - if (!fqDirectArgs.empty()) { - result << "_fqArgs=" << fqDirectArgs[0] << "_" << fqDirectArgs[1] << "_" << fqDirectArgs[2] << "_" << fqDirectArgs[3]; - } - if (inputArg.size() == 3) { - result << "_inputArg=" << inputArg[0] << "_" << inputArg[1] << "_" << inputArg[2]; - } - result << "_" << broadcast.m_type; - return result.str(); -} - -void FakeQuantizeLayerTest::SetUp() { - fqSpecificParams fqParams; - std::vector inputShape; - std::pair> config; - auto netPrecision = InferenceEngine::Precision::UNSPECIFIED; - std::tie(fqParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, targetDevice, config) = this->GetParam(); - InferenceEngine::SizeVector kernel, stride, dilation; - size_t levels; - std::vector constShape; - std::vector fqDirectArg; - std::vector inputArg; - ov::op::AutoBroadcastSpec broadcast; - std::tie(levels, constShape, fqDirectArg, inputArg, broadcast) = fqParams; - if (inputArg.size() == 3) { - inputDataMin = inputArg[0]; - inputDataMax = inputArg[1]; - inputDataResolution = inputArg[2]; - } - if (fqDirectArg.size() != 0) { - threshold = (fqDirectArg[3] - fqDirectArg[2]) / levels; - } - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - - UpdateSeed(); - - std::shared_ptr fakeQNode; - if (fqDirectArg.empty()) { - int32_t ngraphSeed = seed; - if (NGRAPH_SEED != USE_CLOCK_TIME) { - ngraphSeed = NGRAPH_SEED; - } - std::cout << "\033[0;32m" << "[ ] " << "\033[0;0m" - << "ngraphSeed = " << ngraphSeed << std::endl; - fakeQNode = ov::test::utils::make_fake_quantize(params[0], ngPrc, levels, constShape, ngraphSeed); - } else { - fakeQNode = ov::test::utils::make_fake_quantize( - params[0], - ngPrc, - levels, - constShape, - {fqDirectArg[0]}, - {fqDirectArg[1]}, - {fqDirectArg[2]}, - {fqDirectArg[3]}); - } - auto fq = std::dynamic_pointer_cast(fakeQNode); - - ov::ResultVector results{std::make_shared(fq)}; - function = std::make_shared(results, params, "fakeQuantize"); - configuration = config.second; -} - -InferenceEngine::Blob::Ptr FakeQuantizeLayerTest::GenerateInput(const InferenceEngine::InputInfo &info) const { - return FuncTestUtils::createAndFillBlob(info.getTensorDesc(), inputDataMax - inputDataMin, inputDataMin, 1 / inputDataResolution, - seed); -} - -void FakeQuantizeLayerTest::UpdateSeed() { - if (BASE_SEED == USE_CLOCK_TIME) { - seed = std::chrono::system_clock::now().time_since_epoch().count(); - } else if (BASE_SEED == USE_INCREMENTAL_SEED) { - seed += 9999; - } else { - seed = BASE_SEED; - } - std::cout << "\033[0;32m" << "[ ] " << "\033[0;0m" - << "seed = " << seed << std::endl; -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/gather.cpp b/src/tests/functional/shared_test_classes/src/single_layer/gather.cpp deleted file mode 100644 index 25d9dfcfcd4249..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/gather.cpp +++ /dev/null @@ -1,230 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/gather.hpp" - -#include "common_test_utils/node_builders/constant.hpp" - -namespace LayerTestsDefinitions { - -void GatherLayerTestBase::SetUp(const gatherParamsTuple& params) { - int axis; - std::vector indices; - std::vector indicesShape; - std::vector inputShape; - InferenceEngine::Precision netPrecision; - std::tie(indices, indicesShape, axis, inputShape, netPrecision, inPrc, outPrc, inLayout, outLayout, targetDevice) = params; - ASSERT_EQ(ov::shape_size(indicesShape), indices.size()) << "Indices vector size and provided indices shape doesn't fit each other"; - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector functionParams {std::make_shared(ngPrc, ov::Shape(inputShape))}; - auto indicesNode = ov::op::v0::Constant::create(ov::element::i64, ov::Shape(indicesShape), indices); - auto axisNode = ov::op::v0::Constant::create(ov::element::i64, ov::Shape({}), {axis}); - auto gather = std::make_shared(functionParams[0], indicesNode, axisNode); - ov::ResultVector results{std::make_shared(gather)}; - function = std::make_shared(results, functionParams, "gather"); -} - -std::string GatherLayerTest::getTestCaseName(const testing::TestParamInfo &obj) { - int axis; - std::vector indices; - std::vector indicesShape, inputShape; - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - std::string targetName; - std::tie(indices, indicesShape, axis, inputShape, netPrecision, inPrc, outPrc, inLayout, outLayout, targetName) = obj.param; - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShape) << "_"; - result << "axis=" << axis << "_"; - result << "indices=" << ov::test::utils::vec2str(indices) << "_"; - result << "indicesShape=" << ov::test::utils::vec2str(indicesShape) << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "trgDev=" << targetName << "_"; - return result.str(); -} - -void GatherLayerTest::SetUp() { - GatherLayerTestBase::SetUp(GetParam()); -} - -std::string Gather7LayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - std::tuple axis_batchIdx; - std::vector indices; - std::vector indicesShape, inputShape; - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - std::string targetName; - std::tie(inputShape, indicesShape, axis_batchIdx, netPrecision, inPrc, outPrc, inLayout, outLayout, targetName) = obj.param; - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShape) << "_"; - result << "axis=" << std::get<0>(axis_batchIdx) << "_"; - result << "batchIdx=" << std::get<1>(axis_batchIdx) << "_"; - result << "indicesShape=" << ov::test::utils::vec2str(indicesShape) << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "trgDev=" << targetName << "_"; - return result.str(); -} - -void Gather7LayerTest::SetUp() { - std::tuple axis_batchIdx; - std::vector indicesShape; - std::vector inputShape; - InferenceEngine::Precision netPrecision; - std::tie(inputShape, indicesShape, axis_batchIdx, netPrecision, inPrc, outPrc, inLayout, outLayout, targetDevice) = GetParam(); - int axis = std::get<0>(axis_batchIdx); - int batchIdx = std::get<1>(axis_batchIdx); - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector functionParams {std::make_shared(ngPrc, ov::Shape(inputShape))}; - auto indicesNode = ov::test::utils::deprecated::make_constant(ov::element::i64, indicesShape, {}, true, - inputShape[axis < 0 ? axis + inputShape.size() : axis] - 1, 0); - auto axisNode = ov::op::v0::Constant::create(ov::element::i64, ov::Shape({}), { axis }); - auto gather = std::make_shared(functionParams[0], indicesNode, axisNode, batchIdx); - ov::ResultVector results{ std::make_shared(gather) }; - function = std::make_shared(results, functionParams, "gather"); -} - -std::string Gather8LayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - std::tuple axis_batchIdx; - std::vector indices; - std::vector indicesShape, inputShape; - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - std::string targetName; - std::tie(inputShape, indicesShape, axis_batchIdx, netPrecision, inPrc, outPrc, inLayout, outLayout, targetName) = obj.param; - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShape) << "_"; - result << "indicesShape=" << ov::test::utils::vec2str(indicesShape) << "_"; - result << "axis=" << std::get<0>(axis_batchIdx) << "_"; - result << "batchIdx=" << std::get<1>(axis_batchIdx) << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "trgDev=" << targetName << "_"; - return result.str(); -} - -void Gather8LayerTest::SetUp() { - std::tuple axis_batchIdx; - std::vector indicesShape; - std::vector inputShape; - InferenceEngine::Precision netPrecision; - std::tie(inputShape, indicesShape, axis_batchIdx, netPrecision, inPrc, outPrc, inLayout, outLayout, targetDevice) = GetParam(); - int axis = std::get<0>(axis_batchIdx); - int batchIdx = std::get<1>(axis_batchIdx); - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector functionParams {std::make_shared(ngPrc, ov::Shape(inputShape))}; - auto indicesNode = ov::test::utils::deprecated::make_constant(ov::element::i64, indicesShape, {}, true, - inputShape[axis < 0 ? axis + inputShape.size() : axis] - 1, - -static_cast(inputShape[axis < 0 ? axis + inputShape.size() : axis])); - auto axisNode = ov::op::v0::Constant::create(ov::element::i64, ov::Shape({}), { axis }); - auto gather = std::make_shared(functionParams[0], indicesNode, axisNode, batchIdx); - ov::ResultVector results{ std::make_shared(gather) }; - function = std::make_shared(results, functionParams, "gather"); -} - -std::string Gather8IndiceScalarLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - std::tuple axis_batchIdx; - std::vector indices; - std::vector indicesShape, inputShape; - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - std::string targetName; - std::tie(inputShape, indicesShape, axis_batchIdx, netPrecision, inPrc, outPrc, inLayout, outLayout, targetName) = obj.param; - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShape) << "_"; - result << "indicesShape=" << ov::test::utils::vec2str(indicesShape) << "_"; - result << "axis=" << std::get<0>(axis_batchIdx) << "_"; - result << "batchIdx=" << std::get<1>(axis_batchIdx) << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "trgDev=" << targetName << "_"; - return result.str(); -} - -void Gather8IndiceScalarLayerTest::SetUp() { - std::tuple axis_batchIdx; - std::vector indicesShape; - std::vector inputShape; - InferenceEngine::Precision netPrecision; - std::tie(inputShape, indicesShape, axis_batchIdx, netPrecision, inPrc, outPrc, inLayout, outLayout, targetDevice) = GetParam(); - int axis = std::get<0>(axis_batchIdx); - int batchIdx = std::get<1>(axis_batchIdx); - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector functionParams {std::make_shared(ngPrc, ov::Shape(inputShape))}; - auto indicesNode = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {inputShape[axis] - 1})->output(0); - - auto axisNode = ov::op::v0::Constant::create(ov::element::i64, ov::Shape({}), { axis }); - auto gather = std::make_shared(functionParams[0], indicesNode, axisNode, batchIdx); - ov::ResultVector results{ std::make_shared(gather) }; - function = std::make_shared(results, functionParams, "gather"); -} - -std::string Gather8withIndicesDataLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - gather7ParamsTuple basicParams; - std::vector indicesData; - std::tie(basicParams, indicesData) = obj.param; - - std::tuple axis_batchIdx; - std::vector indices; - std::vector indicesShape, inputShape; - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - std::string targetName; - std::tie(inputShape, indicesShape, axis_batchIdx, netPrecision, inPrc, outPrc, inLayout, outLayout, targetName) = basicParams; - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShape) << "_"; - result << "indicesShape=" << ov::test::utils::vec2str(indicesShape) << "_"; - result << "axis=" << std::get<0>(axis_batchIdx) << "_"; - result << "batchIdx=" << std::get<1>(axis_batchIdx) << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "trgDev=" << targetName << "_"; - - result << "indicesData=" << ov::test::utils::vec2str(indicesData) << "_"; - - return result.str(); -} - -void Gather8withIndicesDataLayerTest::SetUp() { - gather7ParamsTuple basicParams; - std::vector indicesData; - std::tie(basicParams, indicesData) = GetParam(); - - std::tuple axis_batchIdx; - std::vector indicesShape; - std::vector inputShape; - InferenceEngine::Precision netPrecision; - std::tie(inputShape, indicesShape, axis_batchIdx, netPrecision, inPrc, outPrc, inLayout, outLayout, targetDevice) = basicParams; - int axis = std::get<0>(axis_batchIdx); - int batchIdx = std::get<1>(axis_batchIdx); - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector functionParams {std::make_shared(ngPrc, ov::Shape(inputShape))}; - auto indicesNode = ov::test::utils::deprecated::make_constant(ov::element::i64, indicesShape, indicesData); - auto axisNode = ov::op::v0::Constant::create(ov::element::i64, ov::Shape({}), { axis }); - auto gather = std::make_shared(functionParams[0], indicesNode, axisNode, batchIdx); - ov::ResultVector results{ std::make_shared(gather) }; - function = std::make_shared(results, functionParams, "gather"); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/gather_elements.cpp b/src/tests/functional/shared_test_classes/src/single_layer/gather_elements.cpp deleted file mode 100644 index ab3be417769f8e..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/gather_elements.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include -#include -#include - -#include "ov_models/builders.hpp" -#include "shared_test_classes/single_layer/gather_elements.hpp" -#include "common_test_utils/ov_tensor_utils.hpp" - -namespace LayerTestsDefinitions { - -std::string GatherElementsLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::SizeVector dataShape, indicesShape; - InferenceEngine::Precision dPrecision, iPrecision; - int axis; - std::string device; - std::tie(dataShape, indicesShape, axis, dPrecision, iPrecision, device) = obj.param; - - std::ostringstream result; - result << "DS=" << ov::test::utils::vec2str(dataShape) << "_"; - result << "IS=" << ov::test::utils::vec2str(indicesShape) << "_"; - result << "Ax=" << axis << "_"; - result << "DP=" << dPrecision.name() << "_"; - result << "IP=" << iPrecision.name() << "_"; - result << "device=" << device; - - return result.str(); -} - -void GatherElementsLayerTest::SetUp() { - InferenceEngine::SizeVector dataShape, indicesShape; - InferenceEngine::Precision dPrecision, iPrecision; - int axis; - std::tie(dataShape, indicesShape, axis, dPrecision, iPrecision, targetDevice) = this->GetParam(); - outPrc = dPrecision; - - auto ngDPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(dPrecision); - auto ngIPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(iPrecision); - - ov::ParameterVector params {std::make_shared(ngDPrc, ov::Shape(dataShape))}; - - int posAxis = axis; - if (posAxis < 0) - posAxis += dataShape.size(); - const auto axisDim = dataShape[posAxis]; - - ov::test::utils::InputGenerateData in_data; - in_data.start_from = 0; - in_data.range = axisDim - 1; - auto indicesValues = ov::test::utils::create_and_fill_tensor(ov::element::i32, indicesShape, in_data); - auto indicesNode = std::make_shared(indicesValues); - - auto gather = std::make_shared(params[0], indicesNode, axis); - - ov::ResultVector results{std::make_shared(gather)}; - function = std::make_shared(results, params, "gatherEl"); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/gather_nd.cpp b/src/tests/functional/shared_test_classes/src/single_layer/gather_nd.cpp deleted file mode 100644 index 29a63fc6787005..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/gather_nd.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/gather_nd.hpp" - -namespace LayerTestsDefinitions { - -std::string GatherNDLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::SizeVector dataShape, indicesShape; - InferenceEngine::Precision dPrecision, iPrecision; - int batchDims; - std::string device; - Config config; - GatherNDParamsSubset gatherArgsSubset; - std::tie(gatherArgsSubset, dPrecision, iPrecision, device, config) = obj.param; - std::tie(dataShape, indicesShape, batchDims) = gatherArgsSubset; - - std::ostringstream result; - result << "DS=" << ov::test::utils::vec2str(dataShape) << "_"; - result << "IS=" << ov::test::utils::vec2str(indicesShape) << "_"; - result << "BD=" << batchDims << "_"; - result << "DP=" << dPrecision.name() << "_"; - result << "IP=" << iPrecision.name() << "_"; - result << "device=" << device; - if (!config.empty()) { - result << "_config="; - for (const auto& cfg : config) { - result << "{" << cfg.first << ": " << cfg.second << "}"; - } - } - - return result.str(); -} - -void GatherNDLayerTest::SetUp() { - InferenceEngine::SizeVector dataShape, indicesShape; - InferenceEngine::Precision dPrecision, iPrecision; - int batchDims; - GatherNDParamsSubset gatherArgsSubset; - std::tie(gatherArgsSubset, dPrecision, iPrecision, targetDevice, configuration) = this->GetParam(); - std::tie(dataShape, indicesShape, batchDims) = gatherArgsSubset; - - auto ngDPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(dPrecision); - auto ngIPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(iPrecision); - - ov::ParameterVector params {std::make_shared(ngDPrc, ov::Shape(dataShape))}; - auto dataNode = params[0]; - auto gather = std::dynamic_pointer_cast( - ngraph::builder::makeGatherND(dataNode, indicesShape, ngIPrc, batchDims)); - ov::ResultVector results{std::make_shared(gather)}; - function = std::make_shared(results, params, "gatherND"); -} - - -std::string GatherND8LayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - return GatherNDLayerTest::getTestCaseName(obj); -} - -void GatherND8LayerTest::SetUp() { - InferenceEngine::SizeVector dataShape, indicesShape; - InferenceEngine::Precision dPrecision, iPrecision; - int batchDims; - GatherNDParamsSubset gatherArgsSubset; - std::tie(gatherArgsSubset, dPrecision, iPrecision, targetDevice, configuration) = this->GetParam(); - std::tie(dataShape, indicesShape, batchDims) = gatherArgsSubset; - - auto ngDPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(dPrecision); - auto ngIPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(iPrecision); - - ov::ParameterVector params {std::make_shared(ngDPrc, ov::Shape(dataShape))}; - auto dataNode = params[0]; - auto gather = std::dynamic_pointer_cast( - ngraph::builder::makeGatherND8(dataNode, indicesShape, ngIPrc, batchDims)); - ov::ResultVector results{ std::make_shared(gather) }; - function = std::make_shared(results, params, "gatherND"); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/gather_tree.cpp b/src/tests/functional/shared_test_classes/src/single_layer/gather_tree.cpp deleted file mode 100644 index d19b8d1fd29733..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/gather_tree.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/gather_tree.hpp" - -#include "common_test_utils/node_builders/constant.hpp" - -namespace LayerTestsDefinitions { -std::string GatherTreeLayerTest::getTestCaseName(const testing::TestParamInfo &obj) { - std::vector inputShape; - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - ngraph::helpers::InputLayerType secondaryInputType; - std::string targetName; - - std::tie(inputShape, secondaryInputType, netPrecision, inPrc, outPrc, inLayout, outLayout, targetName) = obj.param; - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShape) << "_"; - result << "secondaryInputType=" << secondaryInputType << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "trgDev=" << targetName; - return result.str(); -} - -void GatherTreeLayerTest::SetUp() { - std::vector inputShape; - InferenceEngine::Precision netPrecision; - ngraph::helpers::InputLayerType secondaryInputType; - - std::tie(inputShape, secondaryInputType, netPrecision, inPrc, outPrc, inLayout, outLayout, targetDevice) = GetParam(); - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - - std::shared_ptr inp2; - std::shared_ptr inp3; - std::shared_ptr inp4; - - ov::ParameterVector paramsIn {std::make_shared(ngPrc, ov::Shape(inputShape))}; - if (ngraph::helpers::InputLayerType::PARAMETER == secondaryInputType) { - ov::ParameterVector paramsSecond{std::make_shared(ngPrc, ov::Shape(inputShape)), - std::make_shared(ngPrc, ov::Shape{inputShape.at(1)}), - std::make_shared(ngPrc, ov::Shape())}; - paramsIn.insert(paramsIn.end(), paramsSecond.begin(), paramsSecond.end()); - - inp2 = paramsIn.at(1); - inp3 = paramsIn.at(2); - inp4 = paramsIn.at(3); - } else if (ngraph::helpers::InputLayerType::CONSTANT == secondaryInputType) { - auto maxBeamIndex = inputShape.at(2) - 1; - - inp2 = ov::test::utils::deprecated::make_constant(ngPrc, inputShape, {}, true, maxBeamIndex); - inp3 = ov::test::utils::deprecated::make_constant(ngPrc, {inputShape.at(1)}, {}, true, maxBeamIndex); - inp4 = ov::test::utils::deprecated::make_constant(ngPrc, {}, {}, true, maxBeamIndex); - } else { - throw std::runtime_error("Unsupported inputType"); - } - - auto operationResult = std::make_shared(paramsIn.front(), inp2, inp3, inp4); - - ov::ResultVector results{std::make_shared(operationResult)}; - function = std::make_shared(results, paramsIn, "GatherTree"); -} - -InferenceEngine::Blob::Ptr GatherTreeLayerTest::GenerateInput(const InferenceEngine::InputInfo &info) const { - auto& shape = function->get_parameters()[0]->get_output_shape(0); - auto& vecDims = info.getTensorDesc().getDims(); - - auto maxBeamIndx = shape.at(2) - 1; - - if (vecDims.size() == 1 || vecDims.size() == 0) { //max_seq_len vector || end_token - return FuncTestUtils::createAndFillBlob(info.getTensorDesc(), maxBeamIndx, maxBeamIndx / 2); - } - - return FuncTestUtils::createAndFillBlob(info.getTensorDesc(), maxBeamIndx); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/generate_proposals.cpp b/src/tests/functional/shared_test_classes/src/single_layer/generate_proposals.cpp deleted file mode 100644 index 9b1c7fafa3a4fa..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/generate_proposals.cpp +++ /dev/null @@ -1,186 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/generate_proposals.hpp" -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "common_test_utils/ov_tensor_utils.hpp" - -namespace ov { -namespace test { -namespace subgraph { - -namespace { -std::ostream& operator <<( - std::ostream& ss, - const ov::op::v9::GenerateProposals::Attributes& attributes) { - ss << "score_threshold=" << attributes.min_size << "_"; - ss << "nms_threshold=" << attributes.nms_threshold << "_"; - ss << "post_nms_count=" << attributes.post_nms_count << "_"; - ss << "pre_nms_count=" << attributes.pre_nms_count; - ss << "normalized=" << attributes.normalized; - ss << "nms_eta=" << attributes.nms_eta; - return ss; -} -} // namespace - -std::string GenerateProposalsLayerTest::getTestCaseName( - const testing::TestParamInfo& obj) { - std::vector inputShapes; - ov::op::v9::GenerateProposals::Attributes attributes; - std::pair> inputTensors; - ElementType netPrecision; - ElementType roiNumPrecision; - std::string targetName; - std::tie( - inputShapes, - attributes.min_size, - attributes.nms_threshold, - attributes.post_nms_count, - attributes.pre_nms_count, - attributes.normalized, - inputTensors, - netPrecision, - roiNumPrecision, - targetName) = obj.param; - - std::ostringstream result; - using ov::test::operator<<; - result << "im_info=" << inputShapes[0] << "_"; - result << "anchors=" << inputShapes[1] << "_"; - result << "deltas=" << inputShapes[2] << "_"; - result << "scores=" << inputShapes[3] << "_"; - - using ov::test::subgraph::operator<<; - result << "attributes={" << attributes << "}_"; - result << "inputTensors=" << inputTensors.first << "_"; - result << "netPRC=" << netPrecision << "_"; - result << "roiNumPRC=" << roiNumPrecision << "_"; - result << "trgDev=" << targetName; - return result.str(); -} - -void GenerateProposalsLayerTest::SetUp() { - std::vector inputShapes; - ov::op::v9::GenerateProposals::Attributes attributes; - std::pair> inputTensors; - ElementType netPrecision; - ElementType roiNumPrecision; - std::string targetName; - std::tie( - inputShapes, - attributes.min_size, - attributes.nms_threshold, - attributes.post_nms_count, - attributes.pre_nms_count, - attributes.normalized, - inputTensors, - netPrecision, - roiNumPrecision, - targetName) = this->GetParam(); - - inType = outType = netPrecision; - targetDevice = targetName; - if (targetDevice == ov::test::utils::DEVICE_GPU) { - if (netPrecision == element::Type_t::f16) { - abs_threshold = 0.2; - } else { - abs_threshold = 0.00009; - } - } - - init_input_shapes(inputShapes); - - ov::ParameterVector params; - for (auto&& shape : inputDynamicShapes) - params.push_back(std::make_shared(netPrecision, shape)); - - auto generateProposals = std::make_shared( - params[0], // im_info - params[1], // anchors - params[2], // deltas - params[3], // scores - attributes, - roiNumPrecision); - function = std::make_shared( - ov::OutputVector{generateProposals->output(0), - generateProposals->output(1), - generateProposals->output(2)}, - "GenerateProposals"); -} - -void GenerateProposalsLayerTest::generate_inputs(const std::vector& targetInputStaticShapes) { - auto inputTensors = std::get<6>(GetParam()); - - inputs.clear(); - const auto& funcInputs = function->inputs(); - for (auto i = 0ul; i < funcInputs.size(); ++i) { - if (targetInputStaticShapes[i] != inputTensors.second[i].get_shape()) { - OPENVINO_THROW("input shape is different from tensor shape"); - } - - inputs.insert({funcInputs[i].get_node_shared_ptr(), inputTensors.second[i]}); - } -} - -void GenerateProposalsLayerTest::compare(const std::vector& expected, - const std::vector& actual) { - if (targetDevice != ov::test::utils::DEVICE_GPU) { - SubgraphBaseTest::compare(expected, actual); - return; - } - - const auto outputsNum = expected.size(); - ASSERT_EQ(outputsNum, 3); - ASSERT_EQ(outputsNum, actual.size()); - ASSERT_EQ(outputsNum, function->get_results().size()); - - // actual outputs 0 (rois) and 1 (roi_scores) may be padded with zeros - for (size_t i = 0; i < 2; ++i) { - const auto expectedNumRois = expected[i].get_shape()[0]; - const auto actualNumRois = actual[i].get_shape()[0]; - ASSERT_LE(expectedNumRois, actualNumRois); - - const auto actualBuffer = static_cast(actual[i].data()); - const auto expectedBuffer = static_cast(expected[i].data()); - const auto outputSize = i == 0 ? 4 : 1; - - if (outType == element::Type_t::f32) { - LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), - reinterpret_cast(actualBuffer), - expectedNumRois * outputSize, - rel_threshold, - abs_threshold); - } else { - LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), - reinterpret_cast(actualBuffer), - expectedNumRois * outputSize, - rel_threshold, - abs_threshold); - } - - if (expectedNumRois < actualNumRois) { - if (outType == element::Type_t::f32) { - const auto fBuffer = static_cast(actual[i].data()); - for (size_t j = expectedNumRois * outputSize; j < actualNumRois * outputSize; ++j) { - ASSERT_TRUE(fBuffer[j] == 0.0f) - << "Expected 0.0, actual: " << fBuffer[j] << " at index: " << j << ", output: " << i; - } - } else { - const float16 zero{0}; - const auto fBuffer = static_cast(actual[i].data()); - for (size_t j = expectedNumRois * outputSize; j < actualNumRois * outputSize; ++j) { - ASSERT_TRUE(fBuffer[j] == zero) - << "Expected 0.0, actual: " << fBuffer[j] << " at index: " << j << ", output: " << i; - } - } - } - } - - // output 2 - rois_num - ov::test::utils::compare(expected[2], actual[2], abs_threshold, rel_threshold); -} -} // namespace subgraph -} // namespace test -} // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/single_layer/grid_sample.cpp b/src/tests/functional/shared_test_classes/src/single_layer/grid_sample.cpp deleted file mode 100644 index baf9b7255dfaa5..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/grid_sample.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/grid_sample.hpp" - -namespace LayerTestsDefinitions { - -std::string GridSampleLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::SizeVector dataShape; - InferenceEngine::SizeVector gridShape; - decltype(ov::op::v9::GridSample::Attributes::align_corners) alignCorners; - decltype(ov::op::v9::GridSample::Attributes::mode) mode; - decltype(ov::op::v9::GridSample::Attributes::padding_mode) paddingMode; - InferenceEngine::Precision inDataPrc; - InferenceEngine::Precision inGridPrc; - std::string targetDevice; - - std::tie(dataShape, gridShape, alignCorners, mode, paddingMode, inDataPrc, inGridPrc, targetDevice) = obj.param; - - std::ostringstream result; - result << "DS=" << ov::test::utils::vec2str(dataShape) << "_"; - result << "GS=" << ov::test::utils::vec2str(gridShape) << "_"; - result << "AlignCorners=" << alignCorners << "_"; - result << "Mode=" << ov::as_string(mode) << "_"; - result << "PaddingMode=" << ov::as_string(paddingMode) << "_"; - result << "inDataPrc=" << inDataPrc.name() << "_"; - result << "inGridPrc=" << inGridPrc.name() << "_"; - result << "trgDev=" << targetDevice; - return result.str(); -} - -void GridSampleLayerTest::SetUp() { - InferenceEngine::SizeVector dataShape; - InferenceEngine::SizeVector gridShape; - decltype(ov::op::v9::GridSample::Attributes::align_corners) alignCorners; - decltype(ov::op::v9::GridSample::Attributes::mode) mode; - decltype(ov::op::v9::GridSample::Attributes::padding_mode) paddingMode; - InferenceEngine::Precision inDataPrc; - InferenceEngine::Precision inGridPrc; - - std::tie(dataShape, gridShape, alignCorners, mode, paddingMode, inDataPrc, inGridPrc, targetDevice) = - this->GetParam(); - - auto ngInDataPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inDataPrc); - auto ngInGridPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inGridPrc); - auto data = std::make_shared(ngInDataPrc, ov::Shape(dataShape)); - auto grid = std::make_shared(ngInGridPrc, ov::Shape(gridShape)); - auto gridSample = std::make_shared( - data, - grid, - ov::op::v9::GridSample::Attributes(alignCorners, mode, paddingMode)); - function = std::make_shared(std::make_shared(gridSample), - ov::ParameterVector{data, grid}, - "GridSample"); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/grn.cpp b/src/tests/functional/shared_test_classes/src/single_layer/grn.cpp deleted file mode 100644 index 32e880b4d5438f..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/grn.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/grn.hpp" - -namespace LayerTestsDefinitions { -std::string GrnLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - InferenceEngine::SizeVector inputShapes; - std::string targetDevice; - float bias; - std::tie(netPrecision, - inPrc, outPrc, inLayout, outLayout, - inputShapes, - bias, - targetDevice) = obj.param; - - std::ostringstream result; - const char separator = '_'; - - result << "IS=" << ov::test::utils::vec2str(inputShapes) << separator; - result << "netPRC=" << netPrecision.name() << separator; - result << "inPRC=" << inPrc.name() << separator; - result << "outPRC=" << outPrc.name() << separator; - result << "inL=" << inLayout << separator; - result << "outL=" << outLayout << separator; - result << "bias=" << bias << separator; - result << "trgDev=" << targetDevice; - return result.str(); -} - -void GrnLayerTest::SetUp() { - InferenceEngine::Precision netPrecision; - std::tie(netPrecision, inPrc, outPrc, inLayout, outLayout, inputShapes, bias, targetDevice) = GetParam(); - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector paramsIn {std::make_shared(ngPrc, ov::Shape(inputShapes))}; - auto grn = std::make_shared(paramsIn[0], bias); - ov::ResultVector results{ std::make_shared(grn) }; - function = std::make_shared(results, paramsIn, "Grn"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/group_convolution.cpp b/src/tests/functional/shared_test_classes/src/single_layer/group_convolution.cpp deleted file mode 100644 index 34a1145899e2bb..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/group_convolution.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/group_convolution.hpp" - -namespace LayerTestsDefinitions { - -std::string GroupConvolutionLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - groupConvSpecificParams groupConvParams; - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - InferenceEngine::SizeVector inputShapes; - std::string targetDevice; - std::tie(groupConvParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShapes, targetDevice) = obj.param; - ov::op::PadType padType; - InferenceEngine::SizeVector kernel, stride, dilation; - std::vector padBegin, padEnd; - size_t convOutChannels, numGroups; - std::tie(kernel, stride, padBegin, padEnd, dilation, convOutChannels, numGroups, padType) = groupConvParams; - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "K" << ov::test::utils::vec2str(kernel) << "_"; - result << "S" << ov::test::utils::vec2str(stride) << "_"; - result << "PB" << ov::test::utils::vec2str(padBegin) << "_"; - result << "PE" << ov::test::utils::vec2str(padEnd) << "_"; - result << "D=" << ov::test::utils::vec2str(dilation) << "_"; - result << "O=" << convOutChannels << "_"; - result << "G=" << numGroups << "_"; - result << "AP=" << padType << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "trgDev=" << targetDevice; - return result.str(); -} - -void GroupConvolutionLayerTest::SetUp() { - groupConvSpecificParams groupConvParams; - std::vector inputShape; - auto netPrecision = InferenceEngine::Precision::UNSPECIFIED; - std::tie(groupConvParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, targetDevice) = this->GetParam(); - ov::op::PadType padType; - InferenceEngine::SizeVector kernel, stride, dilation; - std::vector padBegin, padEnd; - size_t convOutChannels, numGroups; - std::tie(kernel, stride, padBegin, padEnd, dilation, convOutChannels, numGroups, padType) = groupConvParams; - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - auto groupConv = std::dynamic_pointer_cast( - ngraph::builder::makeGroupConvolution(params[0], ngPrc, kernel, stride, padBegin, - padEnd, dilation, padType, convOutChannels, numGroups)); - ov::ResultVector results{std::make_shared(groupConv)}; - function = std::make_shared(results, params, "groupConvolution"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/group_convolution_backprop_data.cpp b/src/tests/functional/shared_test_classes/src/single_layer/group_convolution_backprop_data.cpp deleted file mode 100644 index f62796ea09773b..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/group_convolution_backprop_data.cpp +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/group_convolution_backprop_data.hpp" - -namespace LayerTestsDefinitions { - -// DEPRECATED, remove this old API when KMB (#58495) and ARM (#58496) plugins are migrated to new API - -std::string GroupConvBackpropDataLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - groupConvBackpropDataSpecificParams groupConvBackpropDataParams; - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - InferenceEngine::SizeVector inputShapes; - std::string targetDevice; - std::tie(groupConvBackpropDataParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShapes, targetDevice) = obj.param; - ov::op::PadType padType; - InferenceEngine::SizeVector kernel, stride, dilation; - std::vector padBegin, padEnd; - size_t convOutChannels, numGroups; - std::tie(kernel, stride, padBegin, padEnd, dilation, convOutChannels, numGroups, padType) = groupConvBackpropDataParams; - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "K" << ov::test::utils::vec2str(kernel) << "_"; - result << "S" << ov::test::utils::vec2str(stride) << "_"; - result << "PB" << ov::test::utils::vec2str(padBegin) << "_"; - result << "PE" << ov::test::utils::vec2str(padEnd) << "_"; - result << "D=" << ov::test::utils::vec2str(dilation) << "_"; - result << "O=" << convOutChannels << "_"; - result << "G=" << numGroups << "_"; - result << "AP=" << padType << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "trgDev=" << targetDevice; - return result.str(); -} - -void GroupConvBackpropDataLayerTest::SetUp() { - groupConvBackpropDataSpecificParams groupConvBackpropDataParams; - std::vector inputShape; - auto netPrecision = InferenceEngine::Precision::UNSPECIFIED; - std::tie(groupConvBackpropDataParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, targetDevice) = this->GetParam(); - ov::op::PadType padType; - InferenceEngine::SizeVector kernel, stride, dilation; - std::vector padBegin, padEnd; - size_t convOutChannels, numGroups; - std::tie(kernel, stride, padBegin, padEnd, dilation, convOutChannels, numGroups, padType) = groupConvBackpropDataParams; - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - auto groupConvBackpropData = std::dynamic_pointer_cast( - ngraph::builder::makeGroupConvolutionBackpropData(params[0], ngPrc, kernel, stride, padBegin, - padEnd, dilation, padType, convOutChannels, numGroups)); - ov::ResultVector results{std::make_shared(groupConvBackpropData)}; - function = std::make_shared(results, params, "GroupConvolutionBackpropData"); -} - -std::string GroupConvBackpropLayerTest::getTestCaseName(testing::TestParamInfo obj) { - groupConvBackpropSpecificParams groupConvBackpropDataParams; - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - InferenceEngine::SizeVector inputShapes, outputShapes; - std::string targetDevice; - std::tie(groupConvBackpropDataParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShapes, outputShapes, targetDevice) = obj.param; - ov::op::PadType padType; - InferenceEngine::SizeVector kernel, stride, dilation; - std::vector padBegin, padEnd, outPadding; - size_t convOutChannels, numGroups; - std::tie(kernel, stride, padBegin, padEnd, dilation, convOutChannels, numGroups, padType, outPadding) = groupConvBackpropDataParams; - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "OS=" << ov::test::utils::vec2str(outputShapes) << "_"; - result << "K" << ov::test::utils::vec2str(kernel) << "_"; - result << "S" << ov::test::utils::vec2str(stride) << "_"; - result << "PB" << ov::test::utils::vec2str(padBegin) << "_"; - result << "PE" << ov::test::utils::vec2str(padEnd) << "_"; - result << "D=" << ov::test::utils::vec2str(dilation) << "_"; - result << "OP=" << ov::test::utils::vec2str(outPadding) << "_"; - result << "O=" << convOutChannels << "_"; - result << "G=" << numGroups << "_"; - result << "AP=" << padType << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "trgDev=" << targetDevice; - return result.str(); -} - -void GroupConvBackpropLayerTest::SetUp() { - groupConvBackpropSpecificParams groupConvBackpropDataParams; - std::vector inputShape, outputShape; - auto netPrecision = InferenceEngine::Precision::UNSPECIFIED; - std::tie(groupConvBackpropDataParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, outputShape, targetDevice) = this->GetParam(); - ov::op::PadType padType; - InferenceEngine::SizeVector kernel, stride, dilation; - std::vector padBegin, padEnd, outPadding; - size_t convOutChannels, numGroups; - std::tie(kernel, stride, padBegin, padEnd, dilation, convOutChannels, numGroups, padType, outPadding) = groupConvBackpropDataParams; - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - std::shared_ptr groupConvBackpropData; - if (!outputShape.empty()) { - auto outShape = ov::op::v0::Constant::create(ov::element::i64, {outputShape.size()}, outputShape); - groupConvBackpropData = std::dynamic_pointer_cast( - ngraph::builder::makeGroupConvolutionBackpropData(params[0], outShape, ngPrc, kernel, stride, padBegin, - padEnd, dilation, padType, convOutChannels, numGroups, false, outPadding)); - } else { - groupConvBackpropData = std::dynamic_pointer_cast( - ngraph::builder::makeGroupConvolutionBackpropData(params[0], ngPrc, kernel, stride, padBegin, - padEnd, dilation, padType, convOutChannels, numGroups, false, outPadding)); - } - ov::ResultVector results{std::make_shared(groupConvBackpropData)}; - function = std::make_shared(results, params, "GroupConvolutionBackpropData"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/gru_cell.cpp b/src/tests/functional/shared_test_classes/src/single_layer/gru_cell.cpp deleted file mode 100644 index 22984892495c17..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/gru_cell.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include "shared_test_classes/single_layer/gru_cell.hpp" -#include "common_test_utils/node_builders/constant.hpp" - -namespace LayerTestsDefinitions { - -using ngraph::helpers::InputLayerType; - -std::string GRUCellTest::getTestCaseName(const testing::TestParamInfo &obj) { - bool should_decompose; - size_t batch; - size_t hidden_size; - size_t input_size; - std::vector activations; - std::vector activations_alpha; - std::vector activations_beta; - float clip; - bool linear_before_reset; - std::vector> inputShapes; - InputLayerType WType; - InputLayerType RType; - InputLayerType BType; - InferenceEngine::Precision netPrecision; - std::string targetDevice; - std::tie(should_decompose, batch, hidden_size, input_size, activations, clip, - linear_before_reset, WType, RType, BType, netPrecision, targetDevice) = obj.param; - inputShapes = { - {{batch, input_size}, {batch, hidden_size}, {3 * hidden_size, input_size}, - {3 * hidden_size, hidden_size}, {(linear_before_reset? 4 : 3) * hidden_size}}, - }; - std::ostringstream result; - result << "decomposition" << should_decompose << "_"; - result << "batch=" << batch << "_"; - result << "hidden_size=" << hidden_size << "_"; - result << "input_size=" << input_size << "_"; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "activations=" << ov::test::utils::vec2str(activations) << "_"; - result << "clip=" << clip << "_"; - result << "linear_before_reset=" << linear_before_reset << "_"; - result << "WType=" << WType << "_"; - result << "RType=" << RType << "_"; - result << "BType=" << BType << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "targetDevice=" << targetDevice << "_"; - return result.str(); -} - -void GRUCellTest::SetUp() { - bool should_decompose; - size_t batch; - size_t hidden_size; - size_t input_size; - std::vector activations; - std::vector activations_alpha; - std::vector activations_beta; - float clip; - bool linear_before_reset; - InputLayerType WType; - InputLayerType RType; - InputLayerType BType; - InferenceEngine::Precision netPrecision; - std::tie(should_decompose, batch, hidden_size, input_size, activations, clip, linear_before_reset, - WType, RType, BType, netPrecision, targetDevice) = this->GetParam(); - - std::vector> inputShapes = { - {{batch, input_size}, {batch, hidden_size}, {3 * hidden_size, input_size}, - {3 * hidden_size, hidden_size}, {(linear_before_reset? 4 : 3) * hidden_size}}, - }; - std::vector WRB = {inputShapes[2], inputShapes[3], inputShapes[4]}; - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShapes[0])), - std::make_shared(ngPrc, ov::Shape(inputShapes[1]))}; - - std::shared_ptr W; - if (WType == InputLayerType::PARAMETER) { - const auto param = std::make_shared(ngPrc, WRB[0]); - W = param; - params.push_back(param); - } else { - W = ov::test::utils::deprecated::make_constant(ngPrc, WRB[0], {}, true); - } - - std::shared_ptr R; - if (RType == InputLayerType::PARAMETER) { - const auto param = std::make_shared(ngPrc, WRB[1]); - R = param; - params.push_back(param); - } else { - R = ov::test::utils::deprecated::make_constant(ngPrc, WRB[1], {}, true); - } - - std::shared_ptr B; - if (BType == InputLayerType::PARAMETER) { - const auto param = std::make_shared(ngPrc, WRB[2]); - B = param; - params.push_back(param); - } else { - B = ov::test::utils::deprecated::make_constant(ngPrc, WRB[2], {}, true); - } - - auto gru_cell = std::make_shared(params[0], params[1], W, R, B, hidden_size, activations, - activations_alpha, activations_beta, clip, - linear_before_reset); - ov::ResultVector results{std::make_shared(gru_cell->output(0))}; - function = std::make_shared(results, params, "gru_cell"); - if (should_decompose) { - ov::pass::Manager m; - m.register_pass(); - m.run_passes(function); - } -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/gru_sequence.cpp b/src/tests/functional/shared_test_classes/src/single_layer/gru_sequence.cpp deleted file mode 100644 index 42360e1ec06465..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/gru_sequence.cpp +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/gru_sequence.hpp" -#include "transformations/op_conversions/bidirectional_sequences_decomposition.hpp" -#include "transformations/op_conversions/convert_sequences_to_tensor_iterator.hpp" -#include "common_test_utils/ov_tensor_utils.hpp" -#include "common_test_utils/test_enums.hpp" -#include "common_test_utils/node_builders/constant.hpp" - -namespace LayerTestsDefinitions { - - using ngraph::helpers::InputLayerType; - - std::string GRUSequenceTest::getTestCaseName(const testing::TestParamInfo &obj) { - ngraph::helpers::SequenceTestsMode mode; - size_t seq_lengths; - size_t batch; - size_t hidden_size; - size_t input_size = 10; - std::vector activations; - std::vector activations_alpha; - std::vector activations_beta; - float clip; - bool linear_before_reset; - ov::op::RecurrentSequenceDirection direction; - InputLayerType WRBType; - InferenceEngine::Precision netPrecision; - std::string targetDevice; - std::tie(mode, seq_lengths, batch, hidden_size, activations, clip, linear_before_reset, direction, WRBType, - netPrecision, targetDevice) = obj.param; - std::vector> inputShapes = { - {{batch, input_size}, {batch, hidden_size}, {batch, hidden_size}, {3 * hidden_size, input_size}, - {3 * hidden_size, hidden_size}, {(linear_before_reset ? 4 : 3) * hidden_size}}, - }; - std::ostringstream result; - result << "mode=" << mode << "_"; - result << "seq_lengths=" << seq_lengths << "_"; - result << "batch=" << batch << "_"; - result << "hidden_size=" << hidden_size << "_"; - result << "input_size=" << input_size << "_"; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "activations=" << ov::test::utils::vec2str(activations) << "_"; - result << "direction=" << direction << "_"; - result << "clip=" << clip << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "targetDevice=" << targetDevice << "_"; - return result.str(); - } - - void GRUSequenceTest::SetUp() { - using namespace ngraph::helpers; - size_t seq_lengths; - size_t batch; - size_t hidden_size; - size_t input_size = 10; - std::vector activations; - std::vector activations_alpha; - std::vector activations_beta; - float clip; - bool linear_before_reset; - ov::op::RecurrentSequenceDirection direction; - InputLayerType WRBType; - InferenceEngine::Precision netPrecision; - std::tie(m_mode, seq_lengths, batch, hidden_size, activations, clip, linear_before_reset, direction, WRBType, - netPrecision, targetDevice) = this->GetParam(); - size_t num_directions = direction == ov::op::RecurrentSequenceDirection::BIDIRECTIONAL ? 2 : 1; - std::vector inputShapes = { - {{batch, seq_lengths, input_size}, {batch, num_directions, hidden_size}, {batch}, - {num_directions, 3 * hidden_size, input_size}, {num_directions, 3 * hidden_size, hidden_size}, - {num_directions, (linear_before_reset ? 4 : 3) * hidden_size}}, - }; - m_max_seq_len = seq_lengths; - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShapes[0])), - std::make_shared(ngPrc, ov::Shape(inputShapes[1]))}; - - const auto& W_shape = inputShapes[3]; - const auto& R_shape = inputShapes[4]; - const auto& B_shape = inputShapes[5]; - - std::shared_ptr seq_lengths_node; - if (m_mode == SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_PARAM || - m_mode == SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_PARAM || - m_mode == SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM) { - auto param = std::make_shared(ov::element::i64, ov::Shape(inputShapes[2])); - param->set_friendly_name("seq_lengths"); - params.push_back(param); - seq_lengths_node = param; - } else if (m_mode == ngraph::helpers::SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_CONST || - m_mode == ngraph::helpers::SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_CONST) { - seq_lengths_node = ov::test::utils::deprecated::make_constant(ov::element::i64, inputShapes[2], {}, true, - static_cast(seq_lengths), 0.f); - } else { - std::vector lengths(batch, seq_lengths); - seq_lengths_node = ov::test::utils::deprecated::make_constant(ov::element::i64, inputShapes[2], lengths, false); - } - - std::shared_ptr W, R, B; - if (WRBType == InputLayerType::PARAMETER) { - const auto W_param = std::make_shared(ngPrc, W_shape); - const auto R_param = std::make_shared(ngPrc, R_shape); - const auto B_param = std::make_shared(ngPrc, B_shape); - W = W_param; - R = R_param; - B = B_param; - params.push_back(W_param); - params.push_back(R_param); - params.push_back(B_param); - } else { - W = ov::test::utils::deprecated::make_constant(ngPrc, W_shape, {}, true); - R = ov::test::utils::deprecated::make_constant(ngPrc, R_shape, {}, true); - B = ov::test::utils::deprecated::make_constant(ngPrc, B_shape, {}, true); - } - - auto gru_sequence = std::make_shared(params[0], params[1], seq_lengths_node, W, R, B, hidden_size, direction, - activations, activations_alpha, activations_beta, clip, linear_before_reset); - ov::ResultVector results{std::make_shared(gru_sequence->output(0)), - std::make_shared(gru_sequence->output(1))}; - function = std::make_shared(results, params, "gru_sequence"); - bool is_pure_sequence = (m_mode == SequenceTestsMode::PURE_SEQ || - m_mode == SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM || - m_mode == SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_CONST); - if (!is_pure_sequence) { - ov::pass::Manager manager; - if (direction == ov::op::RecurrentSequenceDirection::BIDIRECTIONAL) - manager.register_pass(); - manager.register_pass(); - manager.run_passes(function); - bool ti_found = is_tensor_iterator_exist(function); - EXPECT_EQ(ti_found, true); - } else { - bool ti_found = is_tensor_iterator_exist(function); - EXPECT_EQ(ti_found, false); - } - } - - void GRUSequenceTest::GenerateInputs() { - inputs.clear(); - for (const auto &input : executableNetwork.GetInputsInfo()) { - const auto &info = input.second; - auto blob = GenerateInput(*info); - if (input.first == "seq_lengths") { - blob = FuncTestUtils::createAndFillBlob(info->getTensorDesc(), m_max_seq_len, 0); - } - inputs.push_back(blob); - } - } -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/interpolate.cpp b/src/tests/functional/shared_test_classes/src/single_layer/interpolate.cpp deleted file mode 100644 index 9a15d64c3038e1..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/interpolate.cpp +++ /dev/null @@ -1,270 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include "shared_test_classes/single_layer/interpolate.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -using ngraph::helpers::operator<<; - -namespace LayerTestsDefinitions { - -std::string InterpolateLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InterpolateSpecificParams interpolateParams; - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - InferenceEngine::SizeVector inputShapes, targetShapes; - std::string targetDevice; - std::map additional_config; - std::tie(interpolateParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShapes, targetShapes, targetDevice, additional_config) = obj.param; - std::vector padBegin, padEnd; - std::vector axes; - std::vector scales; - bool antialias; - ov::op::v4::Interpolate::InterpolateMode mode; - ov::op::v4::Interpolate::ShapeCalcMode shapeCalcMode; - ov::op::v4::Interpolate::CoordinateTransformMode coordinateTransformMode; - ov::op::v4::Interpolate::NearestMode nearestMode; - double cubeCoef; - std::tie(mode, shapeCalcMode, coordinateTransformMode, nearestMode, antialias, padBegin, padEnd, cubeCoef, axes, scales) = interpolateParams; - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "TS=" << ov::test::utils::vec2str(targetShapes) << "_"; - result << "InterpolateMode=" << mode << "_"; - result << "ShapeCalcMode=" << shapeCalcMode << "_"; - result << "CoordinateTransformMode=" << coordinateTransformMode << "_"; - result << "NearestMode=" << nearestMode << "_"; - result << "CubeCoef=" << cubeCoef << "_"; - result << "Antialias=" << antialias << "_"; - result << "PB=" << ov::test::utils::vec2str(padBegin) << "_"; - result << "PE=" << ov::test::utils::vec2str(padEnd) << "_"; - result << "Axes=" << ov::test::utils::vec2str(axes) << "_"; - result << "Scales=" << ov::test::utils::vec2str(scales) << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "trgDev=" << targetDevice; - return result.str(); -} - -void InterpolateLayerTest::SetUp() { - InterpolateSpecificParams interpolateParams; - std::vector inputShape, targetShape; - auto netPrecision = InferenceEngine::Precision::UNSPECIFIED; - std::map additional_config; - std::tie(interpolateParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, targetShape, targetDevice, additional_config) = this->GetParam(); - std::vector padBegin, padEnd; - std::vector axes; - std::vector scales; - bool antialias; - ov::op::v4::Interpolate::InterpolateMode mode; - ov::op::v4::Interpolate::ShapeCalcMode shapeCalcMode; - ov::op::v4::Interpolate::CoordinateTransformMode coordinateTransformMode; - ov::op::v4::Interpolate::NearestMode nearestMode; - - configuration.insert(additional_config.begin(), additional_config.end()); - - double cubeCoef; - std::tie(mode, shapeCalcMode, coordinateTransformMode, nearestMode, antialias, padBegin, padEnd, cubeCoef, axes, scales) = interpolateParams; - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - - auto sizesConst = ov::op::v0::Constant(ov::element::Type_t::i64, {targetShape.size()}, targetShape); - auto sizesInput = std::make_shared(sizesConst); - - auto scales_const = ov::op::v0::Constant(ov::element::Type_t::f32, {scales.size()}, scales); - auto scalesInput = std::make_shared(scales_const); - - ov::op::v4::Interpolate::InterpolateAttrs interpolateAttributes{mode, shapeCalcMode, padBegin, - padEnd, coordinateTransformMode, nearestMode, antialias, cubeCoef}; - - std::shared_ptr interpolate; - if (axes.empty()) { - interpolate = std::make_shared(params[0], - sizesInput, - scalesInput, - interpolateAttributes); - } else { - auto axesConst = ov::op::v0::Constant(ov::element::Type_t::i64, {axes.size()}, axes); - auto axesInput = std::make_shared(axesConst); - - interpolate = std::make_shared(params[0], - sizesInput, - scalesInput, - axesInput, - interpolateAttributes); - } - const ov::ResultVector results{std::make_shared(interpolate)}; - function = std::make_shared(results, params, "interpolate"); -} - -//Interpolate-1 - -std::string Interpolate1LayerTest::getTestCaseName(testing::TestParamInfo obj) { - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision dataPrecision; - InferenceEngine::Layout dataLayout; - InferenceEngine::SizeVector inputShapes, targetShapes; - std::string mode; - ngraph::AxisSet axes; - bool antialias; - std::vector pads; - std::string targetDevice; - std::tie(netPrecision, dataPrecision, dataLayout, inputShapes, targetShapes, - mode, axes, antialias, pads, targetDevice) = obj.param; - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "TS=" << ov::test::utils::vec2str(targetShapes) << "_"; - result << "InterpolateMode=" << mode << "_"; - result << "Antialias=" << antialias << "_"; - result << "PB=" << ov::test::utils::vec2str(pads) << "_"; - result << "PE=" << ov::test::utils::vec2str(pads) << "_"; - result << "Axes=" << ov::test::utils::vec2str(axes.to_vector()) << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "PRC=" << dataPrecision.name() << "_"; - result << "Layout=" << dataLayout << "_"; - result << "trgDev=" << targetDevice; - return result.str(); -} - -void Interpolate1LayerTest::SetUp() { - std::vector inputShape, targetShape; - auto netPrecision = InferenceEngine::Precision::UNSPECIFIED; - InferenceEngine::Precision dataPrecision; - InferenceEngine::Layout dataLayout; - std::string mode; - ngraph::AxisSet axes; - bool antialias; - std::vector pads; - std::tie(netPrecision, dataPrecision, dataLayout, inputShape, targetShape, - mode, axes, antialias, pads, targetDevice) = this->GetParam(); - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - - auto sizesConst = ov::op::v0::Constant(ov::element::Type_t::i64, {targetShape.size()}, targetShape); - auto sizesInput = std::make_shared(sizesConst); - - bool align_corners = true; - - ov::op::v0::Interpolate::Attributes interpolateAttributes; - interpolateAttributes.axes = axes; - interpolateAttributes.mode = mode; - interpolateAttributes.align_corners = align_corners; - interpolateAttributes.antialias = antialias; - interpolateAttributes.pads_begin = pads; - interpolateAttributes.pads_end = pads; - - auto interpolate = std::make_shared(params[0], sizesInput, interpolateAttributes); - - const ov::ResultVector results{std::make_shared(interpolate)}; - function = std::make_shared(results, params, "interpolate"); -} - -namespace v11 { - -std::string InterpolateLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InterpolateSpecificParams interpolateParams; - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - InferenceEngine::SizeVector inputShapes, targetShapes; - std::string targetDevice; - std::map additional_config; - std::tie(interpolateParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShapes, targetShapes, targetDevice, additional_config) = obj.param; - std::vector padBegin, padEnd; - std::vector axes; - std::vector scales; - bool antialias; - ov::op::util::InterpolateBase::InterpolateMode mode; - ov::op::util::InterpolateBase::ShapeCalcMode shapeCalcMode; - ov::op::util::InterpolateBase::CoordinateTransformMode coordinateTransformMode; - ov::op::util::InterpolateBase::NearestMode nearestMode; - double cubeCoef; - std::tie(mode, shapeCalcMode, coordinateTransformMode, nearestMode, antialias, padBegin, padEnd, cubeCoef, axes, scales) = interpolateParams; - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "TS=" << ov::test::utils::vec2str(targetShapes) << "_"; - result << "InterpolateMode=" << mode << "_"; - result << "ShapeCalcMode=" << shapeCalcMode << "_"; - result << "CoordinateTransformMode=" << coordinateTransformMode << "_"; - result << "NearestMode=" << nearestMode << "_"; - result << "CubeCoef=" << cubeCoef << "_"; - result << "Antialias=" << antialias << "_"; - result << "PB=" << ov::test::utils::vec2str(padBegin) << "_"; - result << "PE=" << ov::test::utils::vec2str(padEnd) << "_"; - result << "Axes=" << ov::test::utils::vec2str(axes) << "_"; - result << "Scales=" << ov::test::utils::vec2str(scales) << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "trgDev=" << targetDevice; - return result.str(); -} - -static std::shared_ptr makeScalesOrSizesInput(ov::op::util::InterpolateBase::ShapeCalcMode shapeCalcMode, - const std::vector& sizes, - const std::vector& scales) { - if (shapeCalcMode == ov::op::util::InterpolateBase::ShapeCalcMode::SIZES) - return std::make_shared(ov::element::Type_t::i64, ov::Shape{sizes.size()}, sizes); - else - return std::make_shared(ov::element::Type_t::f32, ov::Shape{scales.size()}, scales); -} - -void InterpolateLayerTest::SetUp() { - InterpolateSpecificParams interpolateParams; - std::vector inputShape, targetShape; - auto netPrecision = InferenceEngine::Precision::UNSPECIFIED; - std::map additional_config; - std::tie(interpolateParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, targetShape, targetDevice, additional_config) = this->GetParam(); - std::vector padBegin, padEnd; - std::vector axes; - std::vector scales; - bool antialias; - ov::op::util::InterpolateBase::InterpolateMode mode; - ov::op::util::InterpolateBase::ShapeCalcMode shapeCalcMode; - ov::op::util::InterpolateBase::CoordinateTransformMode coordinateTransformMode; - ov::op::util::InterpolateBase::NearestMode nearestMode; - - configuration.insert(additional_config.begin(), additional_config.end()); - - double cubeCoef; - std::tie(mode, shapeCalcMode, coordinateTransformMode, nearestMode, antialias, padBegin, padEnd, cubeCoef, axes, scales) = interpolateParams; - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - - auto scalesOrSizesInput = makeScalesOrSizesInput(shapeCalcMode, targetShape, scales); - - ov::op::util::InterpolateBase::InterpolateAttrs interpolateAttributes{mode, shapeCalcMode, padBegin, - padEnd, coordinateTransformMode, nearestMode, antialias, cubeCoef}; - - std::shared_ptr interpolate{}; - if (axes.empty()) { - interpolate = std::make_shared(params[0], - scalesOrSizesInput, - interpolateAttributes); - } else { - auto axesInput = std::make_shared(ov::element::Type_t::i64, ov::Shape{axes.size()}, axes); - - interpolate = std::make_shared(params[0], - scalesOrSizesInput, - axesInput, - interpolateAttributes); - } - const ov::ResultVector results{std::make_shared(interpolate)}; - function = std::make_shared(results, params, "interpolate"); -} - -} // namespace v11 - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/is_inf.cpp b/src/tests/functional/shared_test_classes/src/single_layer/is_inf.cpp deleted file mode 100644 index 2e1e6e35e6ca20..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/is_inf.cpp +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/is_inf.hpp" -#include "ov_models/builders.hpp" -#include "common_test_utils/ov_tensor_utils.hpp" -#include "ie_plugin_config.hpp" - -using namespace ov::test::subgraph; - -std::string IsInfLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - std::vector inputShapes; - ElementType dataPrc; - bool detectNegative, detectPositive; - std::string targetName; - std::map additionalConfig; - std::tie(inputShapes, detectNegative, detectPositive, dataPrc, targetName, additionalConfig) = obj.param; - std::ostringstream result; - - result << "IS=("; - for (size_t i = 0lu; i < inputShapes.size(); i++) { - result << ov::test::utils::partialShape2str({inputShapes[i].first}) << (i < inputShapes.size() - 1lu ? "_" : ""); - } - result << ")_TS="; - for (size_t i = 0lu; i < inputShapes.front().second.size(); i++) { - result << "{"; - for (size_t j = 0lu; j < inputShapes.size(); j++) { - result << ov::test::utils::vec2str(inputShapes[j].second[i]) << (j < inputShapes.size() - 1lu ? "_" : ""); - } - result << "}_"; - } - result << ")_detectNegative=" << (detectNegative ? "True" : "False") << "_"; - result << "detectPositive=" << (detectPositive ? "True" : "False") << "_"; - result << "dataPrc=" << dataPrc << "_"; - result << "trgDev=" << targetName; - - if (!additionalConfig.empty()) { - result << "_PluginConf"; - for (auto &item : additionalConfig) { - if (item.second == InferenceEngine::PluginConfigParams::YES) - result << "_" << item.first << "=" << item.second; - } - } - - return result.str(); -} - -void IsInfLayerTest::SetUp() { - std::vector shapes; - ElementType dataPrc; - bool detectNegative, detectPositive; - std::string targetName; - std::map additionalConfig; - std::tie(shapes, detectNegative, detectPositive, dataPrc, targetDevice, additionalConfig) = this->GetParam(); - - init_input_shapes(shapes); - configuration.insert(additionalConfig.begin(), additionalConfig.end()); - - ov::ParameterVector parameters; - for (auto&& shape : inputDynamicShapes) { - parameters.push_back(std::make_shared(dataPrc, shape)); - } - parameters[0]->set_friendly_name("Data"); - - ov::op::v10::IsInf::Attributes attributes {detectNegative, detectPositive}; - auto isInf = std::make_shared(parameters[0], attributes); - ov::ResultVector results; - for (int i = 0; i < isInf->get_output_size(); i++) { - results.push_back(std::make_shared(isInf->output(i))); - } - - function = std::make_shared(results, parameters, "IsInf"); -} - -namespace { - -template -void fill_tensor(ov::Tensor& tensor, int32_t range, T startFrom) { - auto pointer = tensor.data(); - testing::internal::Random random(1); - for (size_t i = 0; i < range; i++) { - if (i % 7 == 0) { - pointer[i] = std::numeric_limits::infinity(); - } else if (i % 7 == 1) { - pointer[i] = std::numeric_limits::quiet_NaN(); - } else if (i % 7 == 3) { - pointer[i] = -std::numeric_limits::infinity(); - } else if (i % 7 == 5) { - pointer[i] = -std::numeric_limits::quiet_NaN(); - } else { - pointer[i] = startFrom + static_cast(random.Generate(range)); - } - } -} - -} // namespace - -void IsInfLayerTest::generate_inputs(const std::vector& targetInputStaticShapes) { - inputs.clear(); - const auto& funcInputs = function->inputs(); - const auto& input = funcInputs[0]; - - int32_t range = std::accumulate(targetInputStaticShapes[0].begin(), targetInputStaticShapes[0].end(), 1, std::multiplies()); - float startFrom = -static_cast(range) / 2.f; - auto tensor = ov::Tensor{ input.get_element_type(), targetInputStaticShapes[0]}; - - if (input.get_element_type() == ov::element::f16) { - fill_tensor(tensor, range, startFrom); - } else { - fill_tensor(tensor, range, startFrom); - } - - inputs.insert({input.get_node_shared_ptr(), tensor}); -} diff --git a/src/tests/functional/shared_test_classes/src/single_layer/log_softmax.cpp b/src/tests/functional/shared_test_classes/src/single_layer/log_softmax.cpp deleted file mode 100644 index fbb74f9baa323b..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/log_softmax.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/log_softmax.hpp" - -namespace LayerTestsDefinitions { - -std::string LogSoftmaxLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - InferenceEngine::SizeVector inputShape; - int64_t axis; - std::string targetDevice; - std::map config; - std::tie(netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, axis, targetDevice, config) = obj.param; - - std::ostringstream result; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "IS=" << ov::test::utils::vec2str(inputShape) << "_"; - result << "axis=" << axis << "_"; - result << "trgDev=" << targetDevice; - - return result.str(); -} - -void LogSoftmaxLayerTest::SetUp() { - InferenceEngine::SizeVector inputShape; - InferenceEngine::Precision netPrecision; - int64_t axis; - - std::tie(netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, axis, targetDevice, configuration) = GetParam(); - outLayout = inLayout; - - const auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - - const ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - - const auto logSoftmax = std::make_shared(params.at(0), axis); - - const ov::ResultVector results {std::make_shared(logSoftmax)}; - - function = std::make_shared(results, params, "logSoftmax"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/logical.cpp b/src/tests/functional/shared_test_classes/src/single_layer/logical.cpp deleted file mode 100644 index db3760f067599d..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/logical.cpp +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ov_models/builders.hpp" -#include "shared_test_classes/single_layer/logical.hpp" - -using namespace LayerTestsDefinitions::LogicalParams; - -namespace LayerTestsDefinitions { -std::string LogicalLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InputShapesTuple inputShapes; - ngraph::helpers::LogicalTypes comparisonOpType; - ngraph::helpers::InputLayerType secondInputType; - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - std::string targetName; - std::map additional_config; - std::tie(inputShapes, comparisonOpType, secondInputType, netPrecision, inPrc, outPrc, inLayout, outLayout, targetName, additional_config) - = obj.param; - std::ostringstream results; - - results << "IS0=" << ov::test::utils::vec2str(inputShapes.first) << "_"; - results << "IS1=" << ov::test::utils::vec2str(inputShapes.second) << "_"; - results << "comparisonOpType=" << comparisonOpType << "_"; - results << "secondInputType=" << secondInputType << "_"; - results << "netPRC=" << netPrecision.name() << "_"; - results << "inPRC=" << inPrc.name() << "_"; - results << "outPRC=" << outPrc.name() << "_"; - results << "inL=" << inLayout << "_"; - results << "outL=" << outLayout << "_"; - results << "trgDev=" << targetName; - return results.str(); -} - -std::vector LogicalLayerTest::combineShapes(const std::map, std::vector>>& inputShapes) { - std::vector resVec; - for (auto& inputShape : inputShapes) { - for (auto& item : inputShape.second) { - resVec.push_back({inputShape.first, item}); - } - - if (inputShape.second.empty()) { - resVec.push_back({inputShape.first, {}}); - } - } - return resVec; -} - -InferenceEngine::Blob::Ptr LogicalLayerTest::GenerateInput(const InferenceEngine::InputInfo &info) const { - return FuncTestUtils::createAndFillBlob(info.getTensorDesc(), 2, 0); -} - -void LogicalLayerTest::SetupParams() { - std::tie(inputShapes, logicalOpType, secondInputType, netPrecision, - inPrc, outPrc, inLayout, outLayout, targetDevice, additional_config) = - this->GetParam(); - - configuration.insert(additional_config.begin(), additional_config.end()); -} - -void LogicalLayerTest::SetUp() { - SetupParams(); - - auto ngInputsPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inPrc); - ov::ParameterVector inputs {std::make_shared(ngInputsPrc, ov::Shape(inputShapes.first))}; - - std::shared_ptr logicalNode; - if (logicalOpType != ngraph::helpers::LogicalTypes::LOGICAL_NOT) { - OPENVINO_SUPPRESS_DEPRECATED_START - auto secondInput = ngraph::builder::makeInputLayer(ngInputsPrc, secondInputType, inputShapes.second); - OPENVINO_SUPPRESS_DEPRECATED_END - if (secondInputType == ngraph::helpers::InputLayerType::PARAMETER) { - inputs.push_back(std::dynamic_pointer_cast(secondInput)); - } - logicalNode = ngraph::builder::makeLogical(inputs[0], secondInput, logicalOpType); - } else { - logicalNode = ngraph::builder::makeLogical(inputs[0], ov::Output(), logicalOpType); - } - - function = std::make_shared(logicalNode, inputs, "Logical"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/loop.cpp b/src/tests/functional/shared_test_classes/src/single_layer/loop.cpp deleted file mode 100644 index 21aaa59b82b942..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/loop.cpp +++ /dev/null @@ -1,399 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/loop.hpp" -#include - -namespace LayerTestsDefinitions { - - std::string LoopTest::getTestCaseName(const testing::TestParamInfo &obj) { - bool execute_first_iteration; - bool is_body_condition_const; - bool body_condition; // works only if is_body_condition_const == - int64_t trip_count; - std::vector, LOOP_IN_TYPE>> inputs; - InferenceEngine::Precision netPrecision; - std::string targetDevice; - std::tie(execute_first_iteration, is_body_condition_const, body_condition, trip_count, inputs, netPrecision, - targetDevice) = obj.param; - - std::vector> inputs_separate; - std::vector types_separate; - for (auto &el : inputs) { - inputs_separate.push_back(el.first); - types_separate.push_back(el.second); - } - std::ostringstream result; - result << "execute_first_iteration" << execute_first_iteration << "_"; - result << "is_body_condition_const=" << is_body_condition_const << "_"; - result << "body_condition=" << body_condition << "_"; - result << "trip_count=" << trip_count << "_"; - result << "IS=" << ov::test::utils::vec2str(inputs_separate) << "_"; - result << "types=" << ov::test::utils::vec2str(types_separate) << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "targetDevice=" << targetDevice << "_"; - auto res_str = result.str(); - std::replace(res_str.begin(), res_str.end(), '-', '_'); - return res_str; - } - - void LoopTest::SetUp() { - SKIP_IF_CURRENT_TEST_IS_DISABLED() - bool execute_first_iteration; - bool is_body_condition_const; - bool body_condition; // works only if is_body_condition_const == - int64_t trip_count; - std::vector, LOOP_IN_TYPE>> inputs; - InferenceEngine::Precision netPrecision; - std::tie(execute_first_iteration, is_body_condition_const, body_condition, trip_count, inputs, netPrecision, - targetDevice) = this->GetParam(); - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - - // That which we iterate over - std::vector> inputs_separate; - std::vector types_separate; - for (auto &el : inputs) { - inputs_separate.push_back(el.first); - types_separate.push_back(el.second); - } - // Example: - /* auto X = std::make_shared(ov::element::f32, ov::Shape{32, 1, 10}); - auto Y = std::make_shared(ov::element::f32, ov::Shape{32, 1, 10}); - auto M = std::make_shared(ov::element::f32, ov::Shape{32, 1, 10});*/ - ov::ParameterVector params; - for (auto&& shape : inputs_separate) { - params.push_back(std::make_shared(ngPrc, ov::Shape(shape))); - } - - // Set up the cell body, a function from (Xi, Yi) -> (Zo) - // Body parameters - const std::vector body_params_shapes(inputs_separate.size(), ov::PartialShape::dynamic()); - auto current_iteration = std::make_shared(ov::element::i64, ov::Shape{1}); - - //Example: -/* auto Xi = std::make_shared(ov::element::f32, ov::PartialShape::dynamic()); - auto Yi = std::make_shared(ov::element::f32, ov::PartialShape::dynamic()); - auto M_body = std::make_shared(ov::element::f32, ov::PartialShape::dynamic());*/ - - ov::ParameterVector body_params; - for (const auto &pshape : body_params_shapes) { - auto paramNode = std::make_shared(ngPrc, pshape); - body_params.push_back(paramNode); - } - - std::shared_ptr body_condition_const; - if (is_body_condition_const) { - if (body_condition) { - body_condition_const = std::make_shared( - ov::element::boolean, ov::Shape{1}, true); - } else { - body_condition_const = std::make_shared( - ov::element::boolean, ov::Shape{1}, false); - } - } - - auto trip_count_const = - std::make_shared(ov::element::i64, ov::Shape{1}, trip_count); - - std::shared_ptr exec_condition; - if (execute_first_iteration) { - exec_condition = std::make_shared( - ov::element::boolean, ov::Shape{1}, true); - } else { - exec_condition = std::make_shared( - ov::element::boolean, ov::Shape{1}, false); - } - - // Body - std::shared_ptr Zo = body_params[0]; - for (int i = 1; i < body_params.size(); ++i) { - Zo = std::make_shared(body_params[i], Zo); - } - - // body_params.insert(body_params.begin(), current_iteration); - auto body = std::make_shared(ov::OutputVector{body_condition_const, Zo}, - body_params); - - auto loop = std::make_shared(trip_count_const, exec_condition); - loop->set_function(body); - loop->set_special_body_ports(ov::op::v5::Loop::SpecialBodyPorts{-1, 0}); - - for (int i = 0; i < body_params.size(); ++i) { - if (types_separate[i] == LOOP_IN_TYPE::INVARIANT) { - loop->set_invariant_input(body_params[i], params[i]); - } else if (types_separate[i] == LOOP_IN_TYPE::MERGED) { - // todo: support several merged inputs - // now supported only one in this sample - loop->set_merged_input(body_params[i], params[i], Zo); - } - } - - // Output 0 is last Zo - auto out0 = loop->get_iter_value(body_condition_const, -1); - auto out1 = loop->get_iter_value(Zo, -1); - // Output 1 is concat of Zos - // start=0, stride=1, part_size=1, end=-1, axis=1 - auto out2 = loop->get_concatenated_slices(Zo, 0, 1, 1, -1, 1); - - auto result0 = std::make_shared(out0); - auto result1 = std::make_shared(out1); - auto result2 = std::make_shared(out2); - function = std::make_shared(ov::ResultVector{result0, result1, result2}, params, "loop"); - } - - std::string StaticShapeLoopTest::getTestCaseName(const testing::TestParamInfo &obj) { - bool unrolling; - bool static_iter_num; - bool static_continue_cond; - int64_t max_iter_num; - int64_t dynamic_exit; - int64_t axis; - int64_t start_value; - InferenceEngine::SizeVector data_shape; - InferenceEngine::Precision data_prc; - std::string targetDevice; - auto args_papck = std::tie(static_iter_num, max_iter_num, dynamic_exit, axis); - std::map configuration; - std::tie( - unrolling, - static_continue_cond, - args_papck, - start_value, - data_shape, - data_prc, - targetDevice, - configuration) = obj.param; - - std::ostringstream result; - result << "unrolling=" << std::to_string(unrolling) << "_"; - result << "static_iter_num=" << std::to_string(static_iter_num) << "_"; - result << "static_continue_cond=" << std::to_string(static_continue_cond) << "_"; - result << "max_iter_num=" << std::to_string(max_iter_num) << "_"; - result << "dynamic_exit=" << std::to_string(dynamic_exit) << "_"; - result << "axis=" << std::to_string(axis) << "_"; - result << "start_value=" << std::to_string(start_value) << "_"; - result << "max_iter_num=" << std::to_string(max_iter_num) << "_"; - result << "IS=" << ov::test::utils::vec2str(data_shape) << "_"; - result << "netPRC=" << std::to_string(data_prc) << "_"; - result << "targetDevice=" << targetDevice << "_"; - - auto res_str = result.str(); - std::replace(res_str.begin(), res_str.end(), '-', '_'); - return res_str; - } - - void StaticShapeLoopTest::SetUp() { - SKIP_IF_CURRENT_TEST_IS_DISABLED() - auto args_papck = std::tie(static_iter_num, max_iter_num, dynamic_exit, axis); - std::tie( - unrolling, - static_continue_cond, - args_papck, - start_value, - data_shape, - data_prc, - targetDevice, - configuration) = GetParam(); - - const auto prc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(data_prc); - const auto ngShape = ov::Shape{data_shape}; - const auto scalarShape = ov::Shape{}; - - ov::ParameterVector params{}; - auto cond_input_create = [¶ms] (ov::element::Type prc, const ov::Shape &shape, int value = 0, bool is_static = false) - -> std::shared_ptr { - if (is_static) - return std::make_shared(prc, shape, value); - - auto input = std::make_shared(prc, shape); - params.push_back(input); - return input; - }; - - auto start = cond_input_create(prc, ngShape); - auto count = cond_input_create(ov::element::i64, scalarShape, max_iter_num, static_iter_num); - auto skip = cond_input_create(ov::element::boolean, scalarShape, true, static_continue_cond); - - // - // count skip start count skip start - // / / - // ___*___*____ __________*___*____ | idx | data | out | - // | idx in | | ex_val idx in | | 0 | 7 | 7 | - // | | / | | | / | / | | 1 | 7 | 8 | - // | add | | less add | | 2 | 8 | 10 | - // | | true | | | | | | 3 | 10 | 13 | - // | | | | | | | | ~~~~~ * * * ~~~~~ - // | out cnd | | cnd out | - // |___*____*___| |____*_____*________| - // Full loop Dynamic exit loop - // n_iter = count n_iter = ex_val - // - auto b_indx = std::make_shared(ov::element::i64, ov::Shape{}); - auto b_data = std::make_shared(prc, ngShape); - auto b_indx_cast = std::make_shared(b_indx, prc); - auto b_add = std::make_shared(b_data, b_indx_cast); - - std::shared_ptr b_cond; - if (dynamic_exit == -1) { - b_cond = std::make_shared(ov::element::boolean, ov::Shape{}, true); - } else { - auto b_exit_value = std::make_shared(ov::element::i64, scalarShape, dynamic_exit); - b_cond = std::make_shared(b_indx, b_exit_value); - } - - auto body = std::make_shared( - ov::OutputVector {b_cond, b_add}, // TODO: check with reverse - ov::ParameterVector {b_indx, b_data}); // TODO: check with reverse - - auto loop = std::make_shared(count, skip); - loop->set_function(body); - loop->set_special_body_ports({0, 0}); - loop->set_merged_input(b_data, start, b_add); - if (axis == -1) - loop->get_iter_value(b_add, -1); - else - loop->get_concatenated_slices(b_add, 0, 1, 1, -1, axis); - - function = std::make_shared( - ov::OutputVector {loop}, - params); - if (unrolling) { - ov::pass::Manager manager; - manager.register_pass(); - manager.run_passes(function); - } - } - - InferenceEngine::Blob::Ptr StaticShapeLoopTest::GenerateInput(const InferenceEngine::InputInfo &info) const { - auto tdesc = info.getTensorDesc(); - auto blob = make_blob_with_precision(tdesc); - blob->allocate(); - - if (tdesc.getLayout() == InferenceEngine::SCALAR) { - auto scalar_1d = ov::test::utils::make_reshape_view(blob, {1}); - ov::test::utils::fill_data_with_broadcast(scalar_1d, 0, {static_cast(max_iter_num)}); - } else { - ov::test::utils::fill_data_with_broadcast(blob, 0, {static_cast(start_value)}); - } - - return blob; - } - - int64_t StaticShapeLoopTest::actual_n_iter() { - constexpr auto INF_N_ITER = std::numeric_limits::max(); - IE_ASSERT(dynamic_exit != -1 || max_iter_num != -1); - - // dynamic_exit + 1 - because loop body looks like do-while loop with post condition check. - return std::min(dynamic_exit == -1 ? INF_N_ITER : dynamic_exit + 1, - max_iter_num == -1 ? INF_N_ITER : max_iter_num); - } - - // Predefined ref output - std::vector>> StaticShapeLoopTest::PredefinedRefs() { - bool auto_concat_out = (axis != -1); - const auto n_iter = actual_n_iter(); - - auto ref_shape = data_shape; - if (auto_concat_out) - ref_shape[axis] *= n_iter; - - using namespace ov::test::utils; - InferenceEngine::TensorDesc tdesc {data_prc, ref_shape, InferenceEngine::TensorDesc::getLayoutByDims(ref_shape)}; - std::pair> res; - res.first = function->get_result()->get_element_type(); - res.second = std::vector(byte_size(tdesc)); - auto out = make_blob_with_precision(tdesc, res.second.data()); - - std::vector vals(n_iter); - float val = start_value; - for (int i = 0; i < n_iter; i++) { - val += i; - vals[i] = val; - } - - if (auto_concat_out) - fill_data_with_broadcast(out, axis, vals); - else - fill_data_with_broadcast(out, 0, {val}); // broadcast scalar data - - return {res}; - } - - void TrivialLoopTest::CreateSlicedLoop(size_t batch_size, size_t num_iteration, InferenceEngine::Precision iePrc, - InferenceEngine::SizeVector& ieShape) { - const auto prc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(iePrc); - const auto scalarShape = ov::Shape{}; - - auto shape = ov::Shape{ieShape}; - auto to_slice_shape = ov::Shape{ieShape}; - to_slice_shape[0] = batch_size; - - auto to_slice = std::make_shared(prc, to_slice_shape); - auto start = std::make_shared(prc, shape, 0); - auto count = std::make_shared(ov::element::i64, scalarShape, num_iteration); - auto icond = std::make_shared(ov::element::boolean, scalarShape, true); - - // Loop body - auto b_data = std::make_shared(prc, shape); - auto b_recu = std::make_shared(prc, shape); - auto b_add = std::make_shared(b_data, b_recu); - auto b_cond = std::make_shared(ov::element::boolean, scalarShape, true); - - auto body = std::make_shared( - ov::OutputVector {b_cond, b_add}, - ov::ParameterVector {b_data, b_recu}); - - auto loop = std::make_shared(count, icond); - loop->set_function(body); - loop->set_special_body_ports({-1, 0}); - loop->set_sliced_input(b_data, to_slice, 0, 1, 1, -1, 0); - loop->set_merged_input(b_recu, start, b_add); - loop->get_iter_value(b_add, -1); - - function = std::make_shared( - ov::OutputVector {loop}, - ov::ParameterVector {to_slice}); - } - - void TrivialLoopTest::CreateSlicedLoopDynCondition(size_t batch_size, size_t num_iteration, InferenceEngine::Precision iePrc, - InferenceEngine::SizeVector& ieShape, size_t trip_count) { - auto shape = ov::Shape{ieShape}; - auto to_slice_shape = ov::Shape{ieShape}; - to_slice_shape[0] = batch_size; - - const auto prc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(iePrc); - const auto scalarShape = ov::Shape{}; - - auto to_slice = std::make_shared(prc, to_slice_shape); - auto start = std::make_shared(prc, shape, 0); - auto exit_on = std::make_shared(ov::element::i64, scalarShape, num_iteration); - auto count = std::make_shared(ov::element::i64, scalarShape, trip_count); - auto icond = std::make_shared(ov::element::boolean, scalarShape, true); - - // Loop body - auto b_data = std::make_shared(prc, shape); - auto b_recu = std::make_shared(prc, shape); - auto b_add = std::make_shared(b_data, b_recu); - auto b_iter = std::make_shared(ov::element::i64, scalarShape); - auto b_exit_on = std::make_shared(ov::element::i64, scalarShape); - auto b_cond = std::make_shared(b_iter, b_exit_on); - - auto body = std::make_shared( - ov::OutputVector {b_cond, b_add}, - ov::ParameterVector {b_data, b_recu, b_iter, b_exit_on}); - - auto loop = std::make_shared(count, icond); - loop->set_function(body); - loop->set_special_body_ports({2, 0}); - loop->set_sliced_input(b_data, to_slice, 0, 1, 1, -1, 0); - loop->set_invariant_input(b_exit_on, exit_on); - loop->set_merged_input(b_recu, start, b_add); - loop->get_iter_value(b_add, -1); - - function = std::make_shared( - ov::OutputVector {loop}, - ov::ParameterVector {to_slice}); - } -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/low_precision.cpp b/src/tests/functional/shared_test_classes/src/single_layer/low_precision.cpp deleted file mode 100644 index 046c985744ddd1..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/low_precision.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (C) 2019-2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/low_precision.hpp" -#include "ov_models/builders.hpp" -#include "common_test_utils/node_builders/constant.hpp" - -namespace LowPrecisionTestDefinitions { - -std::string LowPrecisionTest::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::Precision netPrecision; - std::string targetDevice; - std::pair> config; - std::tie(netPrecision, targetDevice, config) = obj.param; - - std::ostringstream result; - result << "netPRC=" << netPrecision.name() << "_"; - result << "trgDev=" << targetDevice; - if (!config.first.empty()) { - result << "_targetConfig=" << config.first; - } - return result.str(); -} - -void LowPrecisionTest::SetUp() { - InferenceEngine::Precision netPrecision; - std::pair> config; - std::tie(netPrecision, targetDevice, config) = this->GetParam(); - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - auto inputShape = ov::Shape{ 1, 16 }; - auto weights1Shape = ov::Shape{ 16, 16 }; - auto weights2Shape = ov::Shape{ 128, 32 }; - - // fully connected 1 - auto input = std::make_shared(ngPrc, inputShape); - std::vector weights1Data(ov::shape_size(weights1Shape), 0.0f); - - for (size_t i = 0; i < 16; i++) { - weights1Data[i * 17] = 10.0f + i; - } - - auto weights1 = ov::test::utils::deprecated::make_constant(ngPrc, weights1Shape, weights1Data); - auto fc1 = std::make_shared(input, weights1); - fc1->set_friendly_name("FullyConnected_1"); - - // bias 1 - std::vector bias1Data(ov::shape_size(inputShape), 0.0f); - auto bias1 = ov::test::utils::deprecated::make_constant(ngPrc, inputShape, bias1Data); - auto add1 = std::make_shared(fc1, bias1); - add1->set_friendly_name("Add_1"); -#if 0 - // ReLU 1 - auto relu1 = std::make_shared(add1); - relu1->set_friendly_name("Relu_1"); - - //// fully connected 2 - std::vector weights2Data(ov::shape_size(weights2Shape), 0.0f); - std::fill(weights2Data.begin(), weights2Data.end(), 0.0001f); - auto weights2 = ov::test::utils::deprecated::make_constant(ngPrc, weights2Shape, weights2Data); - auto fc2 = std::make_shared(relu1, weights2); - fc2->set_friendly_name("FullyConnected_2"); - - //// bias 2 - std::vector bias2Data(ov::shape_size(weights2Shape), 0.0f); - auto bias2 = ov::test::utils::deprecated::make_constant(ngPrc, weights2Shape, bias2Data); - auto add2 = std::make_shared(fc2, bias2); - add2->set_friendly_name("Add_2"); - - //// ReLU 2 - auto relu2 = std::make_shared(add2); - relu2->set_friendly_name("Relu_2"); -#endif - configuration = config.second; - function = std::make_shared(ov::ResultVector{std::make_shared(add1)}, - ov::ParameterVector{input}, - "LowPrecisionTest"); -} - -} // namespace LowPrecisionTestDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/lrn.cpp b/src/tests/functional/shared_test_classes/src/single_layer/lrn.cpp deleted file mode 100644 index f11ab7c420ef62..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/lrn.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/lrn.hpp" - -namespace LayerTestsDefinitions { - -std::string LrnLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - double alpha, beta, bias; - size_t size; - std::vector axes; - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - std::vector inputShapes; - std::string targetDevice; - std::tie(alpha, beta, bias, size, axes, netPrecision, inPrc, outPrc, inputShapes, targetDevice) = obj.param; - - std::ostringstream result; - const char separator = '_'; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << separator; - result << "Alpha=" << alpha << separator; - result << "Beta=" << beta << separator; - result << "Bias=" << bias << separator; - result << "Size=" << size << separator; - result << "Axes=" << ov::test::utils::vec2str(axes) << separator; - result << "netPRC=" << netPrecision.name() << separator; - result << "inPRC=" << inPrc.name() << separator; - result << "outPRC=" << outPrc.name() << separator; - result << "trgDev=" << targetDevice; - - return result.str(); -} - -void LrnLayerTest::SetUp() { - std::vector inputShapes; - auto netPrecision = InferenceEngine::Precision::UNSPECIFIED; - double alpha, beta, bias; - size_t size; - std::vector axes; - std::tie(alpha, beta, bias, size, axes, netPrecision, inPrc, outPrc, inputShapes, targetDevice) = GetParam(); - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params {std::make_shared(ngPrc, ov::Shape(inputShapes))}; - - auto axes_node = std::make_shared(ov::element::i64, ov::Shape{axes.size()}, axes.data()); - auto lrn = std::make_shared(params[0], axes_node, alpha, beta, bias, size); - ov::ResultVector results {std::make_shared(lrn)}; - function = std::make_shared(results, params, "lrn"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/lstm_cell.cpp b/src/tests/functional/shared_test_classes/src/single_layer/lstm_cell.cpp deleted file mode 100644 index e1ef6c5bc75ef0..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/lstm_cell.cpp +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "transformations/op_conversions/lstm_cell_decomposition.hpp" -#include "shared_test_classes/single_layer/lstm_cell.hpp" -#include "common_test_utils/node_builders/constant.hpp" - -namespace LayerTestsDefinitions { - -using ngraph::helpers::InputLayerType; - -std::string LSTMCellTest::getTestCaseName(const testing::TestParamInfo &obj) { - bool should_decompose; - size_t batch; - size_t hidden_size; - size_t input_size; - std::vector activations; - std::vector activations_alpha; - std::vector activations_beta; - float clip; - InputLayerType WType; - InputLayerType RType; - InputLayerType BType; - InferenceEngine::Precision netPrecision; - std::string targetDevice; - std::tie(should_decompose, batch, hidden_size, input_size, activations, clip, WType, RType, BType, - netPrecision, targetDevice) = obj.param; - std::vector> inputShapes = { - {{batch, input_size}, {batch, hidden_size}, {batch, hidden_size}, {4 * hidden_size, input_size}, - {4 * hidden_size, hidden_size}, {4 * hidden_size}}, - }; - std::ostringstream result; - result << "decomposition" << should_decompose << "_"; - result << "batch=" << batch << "_"; - result << "hidden_size=" << hidden_size << "_"; - result << "input_size=" << input_size << "_"; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "activations=" << ov::test::utils::vec2str(activations) << "_"; - result << "clip=" << clip << "_"; - result << "WType=" << WType << "_"; - result << "RType=" << RType << "_"; - result << "BType=" << BType << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "targetDevice=" << targetDevice << "_"; - return result.str(); -} - -void LSTMCellTest::SetUp() { - bool should_decompose; - size_t batch; - size_t hidden_size; - size_t input_size; - std::vector activations; - std::vector activations_alpha; - std::vector activations_beta; - float clip; - InputLayerType WType; - InputLayerType RType; - InputLayerType BType; - InferenceEngine::Precision netPrecision; - std::tie(should_decompose, batch, hidden_size, input_size, activations, clip, WType, RType, BType, - netPrecision, targetDevice) = this->GetParam(); - std::vector> inputShapes = { - {{batch, input_size}, {batch, hidden_size}, {batch, hidden_size}, {4 * hidden_size, input_size}, - {4 * hidden_size, hidden_size}, {4 * hidden_size}}, - }; - std::vector WRB = {inputShapes[3], inputShapes[4], inputShapes[5]}; - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShapes[0])), - std::make_shared(ngPrc, ov::Shape(inputShapes[1])), - std::make_shared(ngPrc, ov::Shape(inputShapes[2]))}; - - std::shared_ptr W; - if (WType == InputLayerType::PARAMETER) { - const auto param = std::make_shared(ngPrc, WRB[0]); - W = param; - params.push_back(param); - } else { - W = ov::test::utils::deprecated::make_constant(ngPrc, WRB[0], {}, true); - } - - std::shared_ptr R; - if (RType == InputLayerType::PARAMETER) { - const auto param = std::make_shared(ngPrc, WRB[1]); - R = param; - params.push_back(param); - } else { - R = ov::test::utils::deprecated::make_constant(ngPrc, WRB[1], {}, true); - } - - std::shared_ptr B; - if (BType == InputLayerType::PARAMETER) { - const auto param = std::make_shared(ngPrc, WRB[2]); - B = param; - params.push_back(param); - } else { - B = ov::test::utils::deprecated::make_constant(ngPrc, WRB[2], {}, true); - } - - auto lstm_cell = std::make_shared(params[0], params[1], params[2], W, R, B, hidden_size, activations, - activations_alpha, activations_beta, clip); - ov::ResultVector results{std::make_shared(lstm_cell->output(0)), - std::make_shared(lstm_cell->output(1))}; - function = std::make_shared(results, params, "lstm_cell"); - if (should_decompose) { - ov::pass::Manager m; - m.register_pass(); - m.run_passes(function); - } -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/lstm_cell_basic.cpp b/src/tests/functional/shared_test_classes/src/single_layer/lstm_cell_basic.cpp deleted file mode 100644 index 786880fd7bf960..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/lstm_cell_basic.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (C) 2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "transformations/op_conversions/lstm_cell_decomposition.hpp" -#include "shared_test_classes/single_layer/lstm_cell_basic.hpp" - -namespace LayerTestsDefinitions { - -std::string LSTMCellBasicTest::getTestCaseName(const testing::TestParamInfo &obj) { - bool should_decompose; - size_t batch; - size_t hidden_size; - size_t input_size; - std::vector activations; - std::vector activations_alpha; - std::vector activations_beta; - float clip; - InferenceEngine::Precision netPrecision; - std::string targetDevice; - std::map additionalConfig; - std::tie(should_decompose, batch, hidden_size, input_size, activations, clip, netPrecision, - targetDevice, additionalConfig) = obj.param; - std::vector> inputShapes = { - {{batch, input_size}, {batch, hidden_size}, {batch, hidden_size}, {4 * hidden_size, input_size}, - {4 * hidden_size, hidden_size}, {4 * hidden_size}}, - }; - std::ostringstream result; - result << "decomposition" << should_decompose << "_"; - result << "batch=" << batch << "_"; - result << "hidden_size=" << hidden_size << "_"; - result << "input_size=" << input_size << "_"; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "activations=" << ov::test::utils::vec2str(activations) << "_"; - result << "clip=" << clip << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "targetDevice=" << targetDevice << "_"; - for (const auto& configEntry : additionalConfig) { - result << configEntry.first << ", " << configEntry.second << ";"; - } - return result.str(); -} - -void LSTMCellBasicTest::SetUp() { - bool should_decompose; - size_t batch; - size_t hidden_size; - size_t input_size; - std::vector activations; - std::vector activations_alpha; - std::vector activations_beta; - float clip; - InferenceEngine::Precision netPrecision; - std::map additionalConfig; - std::tie(should_decompose, batch, hidden_size, input_size, activations, clip, netPrecision, - targetDevice, additionalConfig) = this->GetParam(); - - configuration.insert(additionalConfig.begin(), additionalConfig.end()); - std::vector> inputShapes = { - {{batch, input_size}, {batch, hidden_size}, {batch, hidden_size}, {4 * hidden_size, input_size}, - {4 * hidden_size, hidden_size}, {4 * hidden_size}}, - }; - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShapes[0])), - std::make_shared(ngPrc, ov::Shape(inputShapes[1])), - std::make_shared(ngPrc, ov::Shape(inputShapes[2]))}; - ov::OutputVector paramsOuts; - for (auto&& param : params) - paramsOuts.push_back(param); - - std::vector WRB = {inputShapes[3], inputShapes[4], inputShapes[5]}; - auto lstm_cell = ngraph::builder::makeLSTM(paramsOuts, WRB, hidden_size, activations, {}, {}, clip); - ov::ResultVector results{std::make_shared(lstm_cell->output(0)), - std::make_shared(lstm_cell->output(1))}; - function = std::make_shared(results, params, "lstm_cell"); - if (should_decompose) { - ov::pass::Manager m; - m.register_pass(); - m.run_passes(function); - } -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/lstm_sequence.cpp b/src/tests/functional/shared_test_classes/src/single_layer/lstm_sequence.cpp deleted file mode 100644 index 2757b90df0cf3f..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/lstm_sequence.cpp +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/lstm_sequence.hpp" -#include "transformations/op_conversions/bidirectional_sequences_decomposition.hpp" -#include "transformations/op_conversions/convert_sequences_to_tensor_iterator.hpp" -#include "common_test_utils/node_builders/constant.hpp" - -namespace LayerTestsDefinitions { - - using ngraph::helpers::InputLayerType; - - std::string LSTMSequenceTest::getTestCaseName(const testing::TestParamInfo &obj) { - ngraph::helpers::SequenceTestsMode mode; - size_t seq_lengths; - size_t batch; - size_t hidden_size; - size_t input_size; - std::vector activations; - std::vector activations_alpha; - std::vector activations_beta; - float clip; - ov::op::RecurrentSequenceDirection direction; - InputLayerType WRBType; - InferenceEngine::Precision netPrecision; - std::string targetDevice; - std::tie(mode, seq_lengths, batch, hidden_size, input_size, activations, clip, direction, - WRBType, netPrecision, targetDevice) = obj.param; - std::vector> inputShapes = { - {{batch, input_size}, {batch, hidden_size}, {batch, hidden_size}, {4 * hidden_size, input_size}, - {4 * hidden_size, hidden_size}, {4 * hidden_size}}, - }; - std::ostringstream result; - result << "mode=" << mode << "_"; - result << "seq_lengths=" << seq_lengths << "_"; - result << "batch=" << batch << "_"; - result << "hidden_size=" << hidden_size << "_"; - result << "input_size=" << input_size << "_"; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "activations=" << ov::test::utils::vec2str(activations) << "_"; - result << "direction=" << direction << "_"; - result << "clip=" << clip << "_"; - result << "WRBType=" << WRBType << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "targetDevice=" << targetDevice << "_"; - return result.str(); - } - - void LSTMSequenceTest::SetUp() { - using namespace ngraph::helpers; - using namespace ngraph::builder; - size_t seq_lengths; - - size_t batch; - size_t hidden_size; - size_t input_size; - std::vector activations; - std::vector activations_alpha; - std::vector activations_beta; - float clip; - ov::op::RecurrentSequenceDirection direction; - InputLayerType WRBType; - InferenceEngine::Precision netPrecision; - std::tie(m_mode, seq_lengths, batch, hidden_size, input_size, activations, clip, direction, - WRBType, netPrecision, targetDevice) = this->GetParam(); - size_t num_directions = direction == ov::op::RecurrentSequenceDirection::BIDIRECTIONAL ? 2 : 1; - m_max_seq_len = seq_lengths; - std::vector inputShapes = { - {{batch, seq_lengths, input_size}, {batch, num_directions, hidden_size}, {batch, num_directions, hidden_size}, - {batch}, {num_directions, 4 * hidden_size, input_size}, {num_directions, 4 * hidden_size, hidden_size}, {num_directions, 4 * hidden_size}}, - }; - - const auto& W_shape = inputShapes[4]; - const auto& R_shape = inputShapes[5]; - const auto& B_shape = inputShapes[6]; - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, inputShapes[0]), - std::make_shared(ngPrc, inputShapes[1]), - std::make_shared(ngPrc, inputShapes[2])}; - - std::shared_ptr seq_lengths_node; - if (m_mode == SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_PARAM || - m_mode == SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_PARAM || - m_mode == SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM) { - auto param = std::make_shared(ov::element::i64, inputShapes[3]); - seq_lengths_node = param; - seq_lengths_node->set_friendly_name("seq_lengths"); - params.push_back(param); - } else if (m_mode == ngraph::helpers::SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_CONST || - m_mode == ngraph::helpers::SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_CONST) { - seq_lengths_node = ov::test::utils::deprecated::make_constant(ov::element::i64, inputShapes[3], {}, true, - static_cast(seq_lengths), 0.f); - } else { - std::vector lengths(inputShapes[3][0], seq_lengths); - seq_lengths_node = ov::test::utils::deprecated::make_constant(ov::element::i64, inputShapes[3], lengths, false); - } - - std::shared_ptr W, R, B; - if (WRBType == InputLayerType::PARAMETER) { - const auto W_param = std::make_shared(ngPrc, W_shape); - const auto R_param = std::make_shared(ngPrc, R_shape); - const auto B_param = std::make_shared(ngPrc, B_shape); - W = W_param; - R = R_param; - B = B_param; - params.push_back(W_param); - params.push_back(R_param); - params.push_back(B_param); - } else { - W = ov::test::utils::deprecated::make_constant(ngPrc, W_shape, {}, true); - R = ov::test::utils::deprecated::make_constant(ngPrc, R_shape, {}, true); - B = ov::test::utils::deprecated::make_constant(ngPrc, B_shape, {}, true); - } - - auto lstm_sequence = std::make_shared(params[0], params[1], params[2], seq_lengths_node, W, R, B, hidden_size, direction, - std::vector{}, std::vector{}, activations, clip); - ov::ResultVector results{std::make_shared(lstm_sequence->output(0)), - std::make_shared(lstm_sequence->output(1)), - std::make_shared(lstm_sequence->output(2))}; - function = std::make_shared(results, params, "lstm_sequence"); - bool is_pure_sequence = (m_mode == SequenceTestsMode::PURE_SEQ || - m_mode == SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM || - m_mode == SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_CONST); - if (!is_pure_sequence) { - ov::pass::Manager manager; - if (direction == ov::op::RecurrentSequenceDirection::BIDIRECTIONAL) - manager.register_pass(); - manager.register_pass(); - manager.run_passes(function); - bool ti_found = is_tensor_iterator_exist(function); - EXPECT_EQ(ti_found, true); - } else { - bool ti_found = is_tensor_iterator_exist(function); - EXPECT_EQ(ti_found, false); - } - } - - void LSTMSequenceTest::GenerateInputs() { - for (const auto &input : executableNetwork.GetInputsInfo()) { - const auto &info = input.second; - auto blob = GenerateInput(*info); - if (input.first == "seq_lengths") { - blob = FuncTestUtils::createAndFillBlob(info->getTensorDesc(), m_max_seq_len, 0); - } - - inputs.push_back(blob); - } - } -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/mat_mul.cpp b/src/tests/functional/shared_test_classes/src/single_layer/mat_mul.cpp deleted file mode 100644 index ccc86749ca4852..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/mat_mul.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ov_models/builders.hpp" -#include "shared_test_classes/single_layer/mat_mul.hpp" - -namespace LayerTestsDefinitions { - -std::vector MatMulTest::combineShapes(const std::vector>& firstInputShapes, - const std::vector>& secondInputShapes, - bool transposeA, - bool transposeB) { - std::vector resVec; - for (const auto& firstInputShape : firstInputShapes) { - for (const auto& secondInputShape : secondInputShapes) { - resVec.push_back(ShapeRelatedParams{ {firstInputShape, transposeA}, {secondInputShape, transposeB } }); - } - } - return resVec; -} - -std::string MatMulTest::getTestCaseName(const testing::TestParamInfo &obj) { - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout; - ShapeRelatedParams shapeRelatedParams; - ngraph::helpers::InputLayerType secondaryInputType; - std::string targetDevice; - std::map additionalConfig; - std::tie(shapeRelatedParams, netPrecision, inPrc, outPrc, inLayout, secondaryInputType, targetDevice, additionalConfig) = - obj.param; - - std::ostringstream result; - result << "IS0=" << ov::test::utils::vec2str(shapeRelatedParams.input1.first) << "_"; - result << "IS1=" << ov::test::utils::vec2str(shapeRelatedParams.input2.first) << "_"; - result << "transpose_a=" << shapeRelatedParams.input1.second << "_"; - result << "transpose_b=" << shapeRelatedParams.input2.second << "_"; - result << "secondaryInputType=" << secondaryInputType << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "trgDev=" << targetDevice; - result << "config=("; - for (const auto& configEntry : additionalConfig) { - result << configEntry.first << ", " << configEntry.second << ";"; - } - result << ")"; - return result.str(); -} - -void MatMulTest::SetUp() { - ShapeRelatedParams shapeRelatedParams; - ngraph::helpers::InputLayerType secondaryInputType; - auto netPrecision = InferenceEngine::Precision::UNSPECIFIED; - std::map additionalConfig; - std::tie(shapeRelatedParams, netPrecision, inPrc, outPrc, inLayout, secondaryInputType, targetDevice, additionalConfig) = - this->GetParam(); - - configuration.insert(additionalConfig.begin(), additionalConfig.end()); - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params {std::make_shared(ngPrc, ov::Shape(shapeRelatedParams.input1.first))}; - - OPENVINO_SUPPRESS_DEPRECATED_START - auto secondaryInput = ngraph::builder::makeInputLayer(ngPrc, secondaryInputType, shapeRelatedParams.input2.first); - OPENVINO_SUPPRESS_DEPRECATED_END - if (secondaryInputType == ngraph::helpers::InputLayerType::PARAMETER) { - params.push_back(std::dynamic_pointer_cast(secondaryInput)); - } - auto MatMul = std::make_shared(params[0], secondaryInput, shapeRelatedParams.input1.second, shapeRelatedParams.input2.second); - ov::ResultVector results{std::make_shared(MatMul)}; - function = std::make_shared(results, params, "MatMul"); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/matrix_nms.cpp b/src/tests/functional/shared_test_classes/src/single_layer/matrix_nms.cpp deleted file mode 100644 index cc9621e27cd5fe..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/matrix_nms.cpp +++ /dev/null @@ -1,329 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ov_models/builders.hpp" -#include -#include "shared_test_classes/single_layer/matrix_nms.hpp" -#include "shared_test_classes/base/layer_test_utils.hpp" - -#include "functional_test_utils/plugin_cache.hpp" - -namespace ov { -namespace test { -namespace subgraph { - -using namespace ngraph; -using namespace InferenceEngine; -using ngraph::helpers::operator<<; - -std::string MatrixNmsLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - std::vector shapes; - InputPrecisions inPrecisions; - op::v8::MatrixNms::SortResultType sortResultType; - element::Type outType; - int backgroudClass; - op::v8::MatrixNms::DecayFunction decayFunction; - TopKParams topKParams; - ThresholdParams thresholdParams; - bool normalized; - bool outStaticShape; - std::string targetDevice; - std::tie(shapes, inPrecisions, sortResultType, outType, topKParams, thresholdParams, - backgroudClass, normalized, decayFunction, outStaticShape, targetDevice) = obj.param; - - ElementType paramsPrec, maxBoxPrec, thrPrec; - std::tie(paramsPrec, maxBoxPrec, thrPrec) = inPrecisions; - - int nmsTopK, keepTopK; - std::tie(nmsTopK, keepTopK) = topKParams; - - float score_threshold, gaussian_sigma, post_threshold; - std::tie(score_threshold, gaussian_sigma, post_threshold) = thresholdParams; - - std::ostringstream result; - result << "IS=("; - for (const auto& shape : shapes) { - result << ov::test::utils::partialShape2str({shape.first}) << "_"; - } - result << ")_TS=("; - for (const auto& shape : shapes) { - for (const auto& item : shape.second) { - result << ov::test::utils::vec2str(item) << "_"; - } - } - - result << ")_paramsPrec=" << paramsPrec << "_maxBoxPrec=" << maxBoxPrec << "_thrPrec=" << thrPrec << "_"; - result << "sortResultType=" << sortResultType << "_normalized=" << normalized << "_"; - result << "outType=" << outType << "_nmsTopK=" << nmsTopK << "_keepTopK=" << keepTopK << "_"; - result << "backgroudClass=" << backgroudClass << "_decayFunction=" << decayFunction << "_"; - result << "score_threshold=" << score_threshold << "_gaussian_sigma=" << gaussian_sigma << "_"; - result << "post_threshold=" << post_threshold << "_outStaticShape=" << outStaticShape <<"_TargetDevice=" << targetDevice; - return result.str(); -} - -void MatrixNmsLayerTest::generate_inputs(const std::vector& targetInputStaticShapes) { - inputs.clear(); - - const auto& funcInputs = function->inputs(); - for (int i = 0; i < funcInputs.size(); ++i) { - const auto& funcInput = funcInputs[i]; - ov::Tensor tensor; - - if (i == 1) { - tensor = ov::Tensor(funcInput.get_element_type(), targetInputStaticShapes[i]); - - const size_t range = 1; - const size_t startFrom = 0; - const size_t k = 1000; - const int seed = 1; - std::default_random_engine random(seed); - std::uniform_int_distribution distribution(k * startFrom, k * (startFrom + range)); - - auto *dataPtr = tensor.data(); - for (size_t i = 0; i < tensor.get_size(); i++) { - auto value = static_cast(distribution(random)); - dataPtr[i] = value / static_cast(k); - } - } else { - tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i]); - } - - inputs.insert({funcInput.get_node_shared_ptr(), tensor}); - } -} - -void MatrixNmsLayerTest::GetOutputParams(size_t& numBatches, size_t& maxOutputBoxesPerBatch) { - size_t it = 0; - size_t numBoxes = 0, numClasses = 0; - const auto& funcInputs = function->inputs(); - for (int i = 0; i < funcInputs.size(); ++i) { - const auto& funcInput = funcInputs[i]; - const auto& dims = inputs[funcInput.get_node_shared_ptr()].get_shape(); - - if (it == 1) { - numClasses = dims[1]; - } else { - numBatches = dims[0]; - numBoxes = dims[1]; - } - it++; - } - - ASSERT_TRUE(numBatches > 0 && numBoxes > 0 && numClasses > 0) - << "Expected numBatches, numBoxes, numClasses > 0, got:" << numBatches << ", " << numBoxes << ", " << numClasses; - - auto realClasses = numClasses; - if (m_attrs.background_class >= 0 && m_attrs.background_class < numClasses) { - realClasses = realClasses - 1; - } - - size_t maxOutputBoxesPerClass = 0; - if (m_attrs.nms_top_k >= 0) - maxOutputBoxesPerClass = std::min(numBoxes, static_cast(m_attrs.nms_top_k)); - else - maxOutputBoxesPerClass = numBoxes; - - maxOutputBoxesPerBatch = maxOutputBoxesPerClass * realClasses; - if (m_attrs.keep_top_k >= 0) - maxOutputBoxesPerBatch = - std::min(maxOutputBoxesPerBatch, static_cast(m_attrs.keep_top_k)); -} - -void MatrixNmsLayerTest::compare(const std::vector &expectedOutputs, - const std::vector &actualOutputs) { - auto batchIndex = -1; - size_t numBatches(0), maxOutputBoxesPerBatch(0); - GetOutputParams(numBatches, maxOutputBoxesPerBatch); - std::vector numPerBatch(numBatches); - for (int outputIndex = static_cast(expectedOutputs.size()) - 1; outputIndex >= 0 ; outputIndex--) { - const auto& actual = actualOutputs[outputIndex]; - const auto _dims = actual.get_shape(); - if (_dims.size() == 1 && _dims[0] == numBatches) { - batchIndex = outputIndex; - if (actual.get_element_type() == ov::element::i32) { - auto buffer = actual.data(); - std::copy_n(buffer, numBatches, numPerBatch.begin()); - } else { - auto buffer = actual.data(); - std::copy_n(buffer, numBatches, numPerBatch.begin()); - } - } - } - - for (int outputIndex = static_cast(expectedOutputs.size()) - 1; outputIndex >= 0 ; outputIndex--) { - const auto& expected = expectedOutputs[outputIndex]; - const auto& actual = actualOutputs[outputIndex]; - const auto actualBuffer = static_cast(actual.data()); - const auto expectedBuffer = static_cast(expected.data()); - - //Compare Selected Outputs & Selected Indices - if (outputIndex != batchIndex) { - if (outputIndex == 2) { - if (expected.get_size() != actual.get_size()) - throw std::runtime_error("Expected and actual size 3rd output have different size"); - } - - const auto& precision = actual.get_element_type(); - auto expected_offset = 0; - auto actual_offset = 0; - for (size_t i = 0; i < numPerBatch.size(); i++) { - auto validNums = numPerBatch[i]; - switch (precision) { - case ov::element::f32: { - switch (expected.get_element_type()) { - case ov::element::f32: - LayerTestsUtils::LayerTestsCommon::Compare( - reinterpret_cast(expectedBuffer) + expected_offset * 6, - reinterpret_cast(actualBuffer) + actual_offset * 6, validNums * 6, 1e-5f); - break; - case ov::element::f64: - LayerTestsUtils::LayerTestsCommon::Compare( - reinterpret_cast(expectedBuffer) + expected_offset * 6, - reinterpret_cast(actualBuffer) + actual_offset * 6, validNums *6, 1e-5f); - break; - default: - break; - } - if (m_outStaticShape) { - const auto fBuffer = static_cast(actual.data()); - for (size_t tailing = validNums * 6; tailing < maxOutputBoxesPerBatch * 6; tailing++) { - ASSERT_TRUE(std::abs(fBuffer[(actual_offset * 6 + tailing)] - -1.f) < 1e-5) - << "Invalid default value: " << fBuffer[i] << " at index: " << i; - } - } - break; - } - case ov::element::i32: { - switch (expected.get_element_type()) { - case ov::element::i32: - LayerTestsUtils::LayerTestsCommon::Compare( - reinterpret_cast(expectedBuffer) + expected_offset, - reinterpret_cast(actualBuffer) + actual_offset, validNums, 0); - break; - case ov::element::i64: - LayerTestsUtils::LayerTestsCommon::Compare( - reinterpret_cast(expectedBuffer) + expected_offset, - reinterpret_cast(actualBuffer) + actual_offset, validNums, 0); - break; - default: - break; - } - if (m_outStaticShape) { - const auto iBuffer = actual.data(); - for (size_t tailing = validNums; tailing < maxOutputBoxesPerBatch; tailing++) { - ASSERT_TRUE(iBuffer[actual_offset + tailing] == -1) << "Invalid default value: " << iBuffer[i] << " at index: " << i; - } - } - break; - } - case ov::element::i64: { - switch (expected.get_element_type()) { - case ov::element::i32: - LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer) + expected_offset, - reinterpret_cast(actualBuffer) + actual_offset, validNums, 0); - break; - case ov::element::i64: - LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer) + expected_offset, - reinterpret_cast(actualBuffer) + actual_offset, validNums, 0); - break; - default: - break; - } - if (m_outStaticShape) { - const auto iBuffer = actual.data(); - for (size_t tailing = validNums; tailing < maxOutputBoxesPerBatch; tailing++) { - ASSERT_TRUE(iBuffer[actual_offset + tailing] == -1) << "Invalid default value: " << iBuffer[i] << " at index: " << i; - } - } - break; - } - default: - FAIL() << "Comparator for " << precision << " precision isn't supported"; - } - if (!m_outStaticShape) { - expected_offset += validNums; - actual_offset += validNums; - } else { - expected_offset += validNums; - actual_offset += maxOutputBoxesPerBatch; - } - } - } else { - if (outputIndex == 2) { - if (expected.get_size() != actual.get_size()) - throw std::runtime_error("Expected and actual size 3rd output have different size"); - } - - const auto& precision = actual.get_element_type(); - size_t size = expected.get_size(); - switch (precision) { - case ov::element::i32: { - switch (expected.get_element_type()) { - case ov::element::i32: - LayerTestsUtils::LayerTestsCommon::Compare( - reinterpret_cast(expectedBuffer), - reinterpret_cast(actualBuffer), size, 0); - break; - case ov::element::i64: - LayerTestsUtils::LayerTestsCommon::Compare( - reinterpret_cast(expectedBuffer), - reinterpret_cast(actualBuffer), size, 0); - break; - default: - break; - } - break; - } - case ov::element::i64: { - switch (expected.get_element_type()) { - case ov::element::i32: - LayerTestsUtils::LayerTestsCommon::Compare( - reinterpret_cast(expectedBuffer), - reinterpret_cast(actualBuffer), size, 0); - break; - case ov::element::i64: - LayerTestsUtils::LayerTestsCommon::Compare( - reinterpret_cast(expectedBuffer), - reinterpret_cast(actualBuffer), size, 0); - break; - default: - break; - } - break; - } - default: - FAIL() << "Comparator for " << precision << " precision isn't supported"; - } - } - } -} - -void MatrixNmsLayerTest::SetUp() { - std::vector shapes; - InputPrecisions inPrecisions; - TopKParams topKParams; - ThresholdParams thresholdParams; - - std::tie(shapes, inPrecisions, m_attrs.sort_result_type, m_attrs.output_type, topKParams, thresholdParams, - m_attrs.background_class, m_attrs.normalized, m_attrs.decay_function, m_outStaticShape, targetDevice) = this->GetParam(); - - std::tie(m_attrs.nms_top_k, m_attrs.keep_top_k) = topKParams; - std::tie(m_attrs.score_threshold, m_attrs.gaussian_sigma, m_attrs.post_threshold) = thresholdParams; - - init_input_shapes(shapes); - - ElementType paramsPrec, maxBoxPrec, thrPrec; - std::tie(paramsPrec, maxBoxPrec, thrPrec) = inPrecisions; - ov::ParameterVector params; - for (auto&& shape : inputDynamicShapes) { - params.push_back(std::make_shared(paramsPrec, shape)); - } - auto nms = std::make_shared(params[0], params[1], m_attrs); - - function = std::make_shared(nms, params, "MatrixNMS"); -} - -} // namespace subgraph -} // namespace test -} // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/single_layer/memory.cpp b/src/tests/functional/shared_test_classes/src/single_layer/memory.cpp deleted file mode 100644 index 87a6a2133857ad..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/memory.cpp +++ /dev/null @@ -1,208 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include - -#include -#include - -#include "openvino/pass/low_latency.hpp" -#include "openvino/op/util/variable.hpp" -#include "openvino/op/util/variable_context.hpp" -#include "openvino/opsets/opset7.hpp" -#include "ov_models/builders.hpp" -#include "shared_test_classes/single_layer/memory.hpp" - -using namespace ngraph; -using ov::op::v1::Add; -using ov::op::v0::TensorIterator; -using ov::op::v0::Result; - -namespace LayerTestsDefinitions { - -std::string MemoryTest::getTestCaseName(const testing::TestParamInfo& obj) { - int64_t iteration_count; - InferenceEngine::Precision netPrecision; - InferenceEngine::SizeVector inputShape; - std::string targetDevice; - ngraph::helpers::MemoryTransformation transformation; - std::tie(transformation, iteration_count, inputShape, netPrecision, targetDevice) = obj.param; - - std::ostringstream result; - result << "transformation=" << transformation << "_"; - result << "iteration_count=" << iteration_count << "_"; - result << "IS=" << ov::test::utils::vec2str(inputShape) << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "trgDev=" << targetDevice; - result << ")"; - return result.str(); -} - -void MemoryTest::SetUp() { - std::tie(transformation, iteration_count, inputShape, netPrecision, targetDevice) = this->GetParam(); - ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - - if (transformation == ngraph::helpers::MemoryTransformation::NONE) { - CreateCommonFunc(); - } else { - CreateTIFunc(); - ApplyLowLatency(); - } - - auto tensor = ov::Tensor(ngPrc, inputShape); - auto variable_context = ov::op::util::VariableContext(); - auto variable_value = std::make_shared(tensor); - variable_context.set_variable_value(function->get_variable_by_id("v0"), variable_value); - eval_context["VariableContext"] = variable_context; -} - -void MemoryTest::Run() { - functionRefs = function->clone(); - SKIP_IF_CURRENT_TEST_IS_DISABLED() - using namespace LayerTestsUtils; - auto crashHandler = [](int errCode) { - auto& s = ov::test::utils::OpSummary::getInstance(); - s.saveReport(); - std::cout << "Unexpected application crash!" << std::endl; - std::abort(); - }; - signal(SIGSEGV, crashHandler); - - auto& s = ov::test::utils::OpSummary::getInstance(); - s.setDeviceName(targetDevice); - if (ov::test::utils::current_test_is_disabled()) { - s.updateOPsStats(function, ov::test::utils::PassRate::Statuses::SKIPPED); - GTEST_SKIP() << "Disabled test due to configuration" << std::endl; - } else { - s.updateOPsStats(function, ov::test::utils::PassRate::Statuses::CRASHED); - } - - try { - if (transformation != ngraph::helpers::MemoryTransformation::LOW_LATENCY_V2_REGULAR_API) { - LoadNetwork(); - } else { - CoreConfiguration(this); - ConfigureNetwork(); - executableNetwork = core->LoadNetwork(cnnNetwork, targetDevice, configuration); - } - inferRequest = executableNetwork.CreateInferRequest(); - GenerateInputs(); - for (int64_t i = 0; i < iteration_count; ++i) { - Infer(); - Validate(); - } - s.updateOPsStats(functionRefs, ov::test::utils::PassRate::Statuses::PASSED); - } catch (const std::runtime_error& re) { - s.updateOPsStats(functionRefs, ov::test::utils::PassRate::Statuses::FAILED); - GTEST_FATAL_FAILURE_(re.what()); - } catch (const std::exception& ex) { - s.updateOPsStats(functionRefs, ov::test::utils::PassRate::Statuses::FAILED); - GTEST_FATAL_FAILURE_(ex.what()); - } catch (...) { - s.updateOPsStats(functionRefs, ov::test::utils::PassRate::Statuses::FAILED); - GTEST_FATAL_FAILURE_("Unknown failure occurred."); - } -} - -void MemoryTest::Infer() { - ConfigureInferRequest(); - inferRequest.Infer(); -} - -std::vector>> MemoryTest::CalculateRefs() { - using namespace ngraph; - function->validate_nodes_and_infer_types(); - - auto referenceInputs = std::vector>(inputs.size()); - auto refInputsTypes = std::vector(inputs.size()); - ov::TensorVector inputTensors; - for (auto& input : inputs) { - const auto& dataSize = input->byteSize(); - const auto& tensorDesc = input->getTensorDesc(); - - auto memory = InferenceEngine::as(input); - OPENVINO_ASSERT(memory); - const auto lockedMemory = memory->wmap(); - const auto buffer = lockedMemory.as(); - - inputTensors.emplace_back(FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(tensorDesc.getPrecision()), - tensorDesc.getDims()); - std::memcpy(inputTensors.back().data(), buffer, dataSize); - } - - // evaluate method is not implemented for TI op. - ov::pass::Manager manager; - manager.register_pass(); - manager.run_passes(function); - - const auto& outInfo = executableNetwork.GetOutputsInfo(); - ov::TensorVector outputTensors(outInfo.size()); - function->evaluate(outputTensors, inputTensors, eval_context); - - std::vector>> outputs(outInfo.size()); - for (size_t idx = 0; idx < outInfo.size(); ++idx) { - outputs[idx].first = outputTensors[idx].get_element_type(); - outputs[idx].second.resize(outputTensors[idx].get_byte_size()); - std::memcpy(outputs[idx].second.data(), outputTensors[idx].data(), outputTensors[idx].get_byte_size()); - } - return outputs; -} - -void MemoryTest::CreateTIFunc() { - auto param = std::make_shared(ngPrc, ov::Shape(inputShape)); - std::vector> shape = {{static_cast(iteration_count), 1}}; - auto iter_count = - std::make_shared(ngPrc, ov::Shape{static_cast(iteration_count), 1}); - - // Body - auto X = std::make_shared(ngPrc, ov::Shape(inputShape)); - auto Y = std::make_shared(ngPrc, ov::Shape(inputShape)); - auto Iter = std::make_shared(ngPrc, ov::Shape{1, 1}); - auto add = std::make_shared(X, Y); - auto res = std::make_shared(add); - auto Iter_res = std::make_shared(Iter); - auto body = std::make_shared(ov::OutputVector{res, Iter_res}, ov::ParameterVector{X, Y, Iter}); - - // TI construction - auto tensor_iterator = std::make_shared(); - tensor_iterator->set_body(body); - - tensor_iterator->set_merged_input(X, param, res); - tensor_iterator->set_invariant_input(Y, param); - tensor_iterator->set_sliced_input(Iter, iter_count, 0, 1, 1, -1, 0); - - auto output = tensor_iterator->get_iter_value(res, -1); - auto output_iter = tensor_iterator->get_concatenated_slices(Iter_res, 0, 1, 1, -1, 0); - function = - std::make_shared(ov::OutputVector{output, output_iter}, ov::ParameterVector{param, iter_count}, "PureTI"); -} - -void MemoryTest::CreateCommonFunc() { - ov::ParameterVector param{std::make_shared(ngPrc, ov::Shape(inputShape))}; - const auto variable_info = targetDevice == ov::test::utils::DEVICE_GPU - ? ov::op::util::VariableInfo{Shape{inputShape}, ngPrc, "v0"} - : ov::op::util::VariableInfo{inputShape, ngPrc, "v0"}; - auto variable = std::make_shared(variable_info); - auto read_value = CreateReadValueOp(param.at(0), variable); - auto add = std::make_shared(read_value, param.at(0)); - auto assign = CreateAssignOp(add, variable); - auto res = std::make_shared(add); - function = std::make_shared(ov::ResultVector{res}, ov::SinkVector{assign}, param, "TestMemory"); -} - -void MemoryTest::ApplyLowLatency() { - if (transformation == ngraph::helpers::MemoryTransformation::LOW_LATENCY_V2) { - function->validate_nodes_and_infer_types(); - ov::pass::Manager manager; - manager.register_pass(); - manager.run_passes(function); - } else if (transformation == ngraph::helpers::MemoryTransformation::LOW_LATENCY_V2_ORIGINAL_INIT) { - function->validate_nodes_and_infer_types(); - ov::pass::Manager manager; - manager.register_pass(false); - manager.run_passes(function); - } -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/minimum_maximum.cpp b/src/tests/functional/shared_test_classes/src/single_layer/minimum_maximum.cpp deleted file mode 100644 index 9873fe73416b82..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/minimum_maximum.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/minimum_maximum.hpp" - -namespace LayerTestsDefinitions { - std::string MaxMinLayerTest::getTestCaseName(const testing::TestParamInfo &obj) { - std::vector> inputShapes; - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - std::string targetName; - ngraph::helpers::InputLayerType inputType; - ngraph::helpers::MinMaxOpType opType; - std::tie(inputShapes, opType, netPrecision, inPrc, outPrc, inLayout, outLayout, inputType, targetName) = obj.param; - std::ostringstream results; - - results << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - results << "OpType=" << opType << "_"; - results << "SecondaryInputType=" << inputType << "_"; - results << "netPRC=" << netPrecision.name() << "_"; - results << "inPRC=" << inPrc.name() << "_"; - results << "outPRC=" << outPrc.name() << "_"; - results << "inL=" << inLayout << "_"; - results << "outL=" << outLayout << "_"; - results << "trgDev=" << targetName << "_"; - return results.str(); - } - - void MaxMinLayerTest::SetUp() { - std::vector> inputShapes; - InferenceEngine::Precision netPrecision; - ngraph::helpers::InputLayerType inputType; - ngraph::helpers::MinMaxOpType opType; - std::tie(inputShapes, opType, netPrecision, inPrc, outPrc, inLayout, outLayout, inputType, targetDevice) = this->GetParam(); - if (inputShapes.size() != 2) { - IE_THROW() << "Unsupported inputs number for Minimum/Maximum operaton"; - } - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector input{std::make_shared(ngPrc, ov::Shape(inputShapes[0]))}; - OPENVINO_SUPPRESS_DEPRECATED_START - auto secondaryInput = ngraph::builder::makeInputLayer(ngPrc, inputType, {inputShapes[1]}); - OPENVINO_SUPPRESS_DEPRECATED_END - if (inputType == ngraph::helpers::InputLayerType::PARAMETER) { - input.push_back(std::dynamic_pointer_cast(secondaryInput)); - } - - OPENVINO_SUPPRESS_DEPRECATED_START - auto op = ngraph::builder::makeMinMax(input[0], secondaryInput, opType); - OPENVINO_SUPPRESS_DEPRECATED_END - function = std::make_shared(op, input, "MinMax"); - } -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/multiclass_nms.cpp b/src/tests/functional/shared_test_classes/src/single_layer/multiclass_nms.cpp deleted file mode 100644 index b26258f22d179b..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/multiclass_nms.cpp +++ /dev/null @@ -1,405 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ov_models/builders.hpp" -#include -#include "shared_test_classes/single_layer/multiclass_nms.hpp" -#include "shared_test_classes/base/layer_test_utils.hpp" - -#include "functional_test_utils/plugin_cache.hpp" - -namespace ov { -namespace test { -namespace subgraph { - -using namespace ngraph; -using namespace InferenceEngine; -using ngraph::helpers::operator<<; - -std::string MulticlassNmsLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - std::vector shapes; - InputPrecisions inPrecisions; - int32_t nmsTopK, backgroundClass, keepTopK; - element::Type outType; - - op::util::MulticlassNmsBase::SortResultType sortResultType; - - InputfloatVar inFloatVar; - InputboolVar inboolVar; - - bool outputStatic; - - std::string targetDevice; - - std::tie(shapes, inPrecisions, nmsTopK, inFloatVar, backgroundClass, keepTopK, outType, sortResultType, inboolVar, outputStatic, targetDevice) = obj.param; - - ElementType paramsPrec, roisnumPrec, maxBoxPrec, thrPrec; - std::tie(paramsPrec, roisnumPrec, maxBoxPrec, thrPrec) = inPrecisions; - - float iouThr, scoreThr, nmsEta; - std::tie(iouThr, scoreThr, nmsEta) = inFloatVar; - - bool sortResCB, normalized; - std::tie(sortResCB, normalized) = inboolVar; - - std::ostringstream result; - result << "IS=("; - for (const auto& shape : shapes) { - result << ov::test::utils::partialShape2str({shape.first}) << "_"; - } - result << ")_TS=("; - for (const auto& shape : shapes) { - for (const auto& item : shape.second) { - result << ov::test::utils::vec2str(item) << "_"; - } - } - - result << ")_paramsPrec=" << paramsPrec << "_roisnumPrec=" << roisnumPrec << "_maxBoxPrec=" << maxBoxPrec << "_thrPrec=" << thrPrec << "_"; - result << "nmsTopK=" << nmsTopK << "_"; - result << "iouThr=" << iouThr << "_scoreThr=" << scoreThr << "_backgroundClass=" << backgroundClass << "_"; - result << "keepTopK=" << keepTopK << "_outType=" << outType << "_"; - result << "sortResultType=" << sortResultType << "_sortResCrossBatch=" << sortResCB << "_nmsEta=" << nmsEta << "_normalized=" << normalized << "_"; - result << "outputStatic=" << outputStatic; - result << "TargetDevice=" << targetDevice; - return result.str(); -} - -void MulticlassNmsLayerTest::generate_inputs(const std::vector& targetInputStaticShapes) { - inputs.clear(); - - const auto& funcInputs = function->inputs(); - ASSERT_TRUE(funcInputs.size() == 2 || funcInputs.size() == 3) << "Expected 3 inputs or 2 inputs."; - for (int i = 0; i < funcInputs.size(); ++i) { - const auto& funcInput = funcInputs[i]; - ov::Tensor tensor; - - if (i == 1) { // scores - tensor = ov::Tensor(funcInput.get_element_type(), targetInputStaticShapes[i]); - - const size_t range = 1; - const size_t startFrom = 0; - const size_t k = 1000; - const int seed = 1; - std::default_random_engine random(seed); - std::uniform_int_distribution distribution(k * startFrom, k * (startFrom + range)); - - auto *dataPtr = tensor.data(); - for (size_t i = 0; i < tensor.get_size(); i++) { - auto value = static_cast(distribution(random)); - dataPtr[i] = value / static_cast(k); - } - } else if (i == 0) { // bboxes - tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i]); - } else { // roisnum - /* sum of rois is no larger than num_bboxes. */ - ASSERT_TRUE(targetInputStaticShapes[i].size() == 1) << "Expected shape size 1 for input roisnum, got: " << targetInputStaticShapes[i]; - - // returns num random values whose sum is max_num. - auto _generate_roisnum = [](int num, int max_num) { - std::vector array; - std::vector results(num); - - array.push_back(0); - for (auto i = 0; i < num-1; i++) { - array.push_back(std::rand() % max_num); - } - array.push_back(max_num); - - std::sort(array.begin(), array.end()); - - for (auto i = 0; i < num; i++) { - results[i] = array[i+1] - array[i]; - } - - return results; - }; - auto roisnum = _generate_roisnum(targetInputStaticShapes[i][0], targetInputStaticShapes[0][1]/*num_bboxes*/); - - tensor = ov::Tensor(funcInput.get_element_type(), targetInputStaticShapes[i]); - if (tensor.get_element_type() == ov::element::i32) { - auto dataPtr = tensor.data(); - for (size_t i = 0; i < roisnum.size(); i++) { - dataPtr[i] = static_cast(roisnum[i]); - } - } else { - auto dataPtr = tensor.data(); - for (size_t i = 0; i < roisnum.size(); i++) { - dataPtr[i] = static_cast(roisnum[i]); - } - } - } - - inputs.insert({funcInput.get_node_shared_ptr(), tensor}); - } -} - -void MulticlassNmsLayerTest::GetOutputParams(size_t& numBatches, size_t& maxOutputBoxesPerBatch) { - const auto& funcInputs = function->inputs(); - const auto& boxes_dims = inputs[funcInputs[0].get_node_shared_ptr()].get_shape(); - const auto& scores_dims = inputs[funcInputs[1].get_node_shared_ptr()].get_shape(); - - const auto shared = (scores_dims.size() == 3); - if (!shared) - ASSERT_TRUE(funcInputs.size() > 2) << "Expected 3 inputs when input 'score' is 2D."; - - const auto& roisnum_dims = funcInputs.size() >2 ? inputs[funcInputs[2].get_node_shared_ptr()].get_shape() : Shape(); - - const auto numBoxes = shared ? boxes_dims[1] : boxes_dims[1]; - auto numClasses = shared ? scores_dims[1] : boxes_dims[0]; - numBatches = shared ? scores_dims[0] : roisnum_dims[0]; - - ASSERT_TRUE(numBatches > 0 && numBoxes > 0 && numClasses > 0) - << "Expected numBatches, numBoxes, numClasses > 0, got:" << numBatches << ", " << numBoxes << ", " << numClasses; - - auto realClasses = numClasses; - if (m_attrs.background_class >= 0 && m_attrs.background_class < numClasses) { - realClasses = realClasses - 1; - } - - size_t maxOutputBoxesPerClass = 0; - if (m_attrs.nms_top_k >= 0) - maxOutputBoxesPerClass = std::min(numBoxes, static_cast(m_attrs.nms_top_k)); - else - maxOutputBoxesPerClass = numBoxes; - - maxOutputBoxesPerBatch = maxOutputBoxesPerClass * realClasses; - if (m_attrs.keep_top_k >= 0) - maxOutputBoxesPerBatch = - std::min(maxOutputBoxesPerBatch, static_cast(m_attrs.keep_top_k)); -} - -void MulticlassNmsLayerTest::compare(const std::vector &expectedOutputs, - const std::vector &actualOutputs) { - auto batchIndex = -1; // output index for output 'selected_num' - size_t numBatches(0), maxOutputBoxesPerBatch(0); - GetOutputParams(numBatches, maxOutputBoxesPerBatch); - std::vector numPerBatch(numBatches); - - ASSERT_TRUE(expectedOutputs.size() == 3) << "Expect 3 outputs, got: " << expectedOutputs.size(); - - for (int outputIndex = static_cast(expectedOutputs.size()) - 1; outputIndex >= 0; outputIndex--) { - const auto& actual = actualOutputs[outputIndex]; - const auto _dims = actual.get_shape(); - if (_dims.size() == 1) { // 'selected_num' - ASSERT_TRUE(_dims[0] == numBatches) << "Expect output 'selected_num' has shape of " << numBatches << ", got: " << _dims[0]; - batchIndex = outputIndex; - if (actual.get_element_type() == ov::element::i32) { - auto buffer = actual.data(); - std::copy_n(buffer, numBatches, numPerBatch.begin()); - } else { - auto buffer = actual.data(); - std::copy_n(buffer, numBatches, numPerBatch.begin()); - } - - break; - } - } - ASSERT_TRUE(batchIndex > -1) << "Expect to get output index for 'selected_num'"; - - // reserve order could make sure output 'selected_num' get checked first. - for (int outputIndex = static_cast(expectedOutputs.size()) - 1; outputIndex >= 0; outputIndex--) { - const auto& expected = expectedOutputs[outputIndex]; - const auto& actual = actualOutputs[outputIndex]; - const auto actualBuffer = static_cast(actual.data()); - const auto expectedBuffer = static_cast(expected.data()); - - const auto expected_shape = expected.get_shape(); - const auto actual_shape = actual.get_shape(); - - // Compare Selected Outputs & Selected Indices - if (outputIndex != batchIndex) { - if (m_outStaticShape) { - ASSERT_TRUE(expected_shape[0] <= actual_shape[0]) << "Expected the compatible shape, got: " << expected_shape << " and " << actual_shape; - } else { - ASSERT_TRUE(expected_shape == actual_shape) << "Expected the same shape, got: " << expected_shape << " and " << actual_shape; - } - - const auto& precision = actual.get_element_type(); - auto expected_offset = 0; - auto actual_offset = 0; - for (size_t i = 0; i < numPerBatch.size(); i++) { - auto validNums = numPerBatch[i]; - switch (precision) { - case ov::element::f32: { - switch (expected.get_element_type()) { - case ov::element::f32: - LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer) + expected_offset * 6, - reinterpret_cast(actualBuffer) + actual_offset * 6, validNums * 6, 1e-5f); - break; - case ov::element::f64: - LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer) + expected_offset * 6, - reinterpret_cast(actualBuffer) + actual_offset * 6, validNums * 6, 1e-5f); - break; - default: - break; - } - - if (m_outStaticShape) { - const auto fBuffer = static_cast(actual.data()); - for (size_t tailing = validNums * 6; tailing < maxOutputBoxesPerBatch * 6; tailing++) { - ASSERT_TRUE(std::abs(fBuffer[(actual_offset * 6 + tailing)] - -1.f) < 1e-5) - << "Invalid default value: " << fBuffer[i] << " at index: " << i; - } - } - break; - } - case ov::element::i32: { - switch (expected.get_element_type()) { - case ov::element::i32: - LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer) + expected_offset, - reinterpret_cast(actualBuffer) + actual_offset, validNums, 0); - break; - case ov::element::i64: - LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer) + expected_offset, - reinterpret_cast(actualBuffer) + actual_offset, validNums, 0); - break; - default: - break; - } - if (m_outStaticShape) { - const auto iBuffer = actual.data(); - for (size_t tailing = validNums; tailing < maxOutputBoxesPerBatch; tailing++) { - ASSERT_TRUE(iBuffer[actual_offset + tailing] == -1) << "Invalid default value: " << iBuffer[i] << " at index: " << i; - } - } - break; - } - case ov::element::i64: { - switch (expected.get_element_type()) { - case ov::element::i32: - LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer) + expected_offset, - reinterpret_cast(actualBuffer) + actual_offset, validNums, 0); - break; - case ov::element::i64: - LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer) + expected_offset, - reinterpret_cast(actualBuffer) + actual_offset, validNums, 0); - break; - default: - break; - } - if (m_outStaticShape) { - const auto iBuffer = actual.data(); - for (size_t tailing = validNums; tailing < maxOutputBoxesPerBatch; tailing++) { - ASSERT_TRUE(iBuffer[actual_offset + tailing] == -1) << "Invalid default value: " << iBuffer[i] << " at index: " << i; - } - } - break; - } - default: - FAIL() << "Comparator for " << precision << " precision isn't supported"; - } - if (!m_outStaticShape) { - expected_offset += validNums; - actual_offset += validNums; - } else { - expected_offset += validNums; - actual_offset += maxOutputBoxesPerBatch; - } - } - } else { - ASSERT_TRUE(expected_shape == actual_shape) << "Expected the same shape, got: " << expected_shape << " and " << actual_shape; - - const auto& precision = actual.get_element_type(); - size_t size = expected.get_size(); - switch (precision) { - case ov::element::i32: { - switch (expected.get_element_type()) { - case ov::element::i32: - LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), reinterpret_cast(actualBuffer), - size, 0); - break; - case ov::element::i64: - LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), reinterpret_cast(actualBuffer), - size, 0); - break; - default: - break; - } - break; - } - case ov::element::i64: { - switch (expected.get_element_type()) { - case ov::element::i32: - LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), reinterpret_cast(actualBuffer), - size, 0); - break; - case ov::element::i64: - LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), reinterpret_cast(actualBuffer), - size, 0); - break; - default: - break; - } - break; - } - default: - FAIL() << "Comparator for " << precision << " precision isn't supported"; - } - } - } -} - -void MulticlassNmsLayerTest::SetUp() { - std::vector shapes; - InputPrecisions inPrecisions; - size_t maxOutBoxesPerClass, backgroundClass, keepTopK; - element::Type outType; - - op::util::MulticlassNmsBase::SortResultType sortResultType; - - InputfloatVar inFloatVar; - InputboolVar inboolVar; - - std::tie(shapes, inPrecisions, maxOutBoxesPerClass, inFloatVar, backgroundClass, keepTopK, outType, sortResultType, inboolVar, - m_outStaticShape, targetDevice) = this->GetParam(); - - init_input_shapes(shapes); - - ElementType paramsPrec, roisnumPrec, maxBoxPrec, thrPrec; - std::tie(paramsPrec, roisnumPrec, maxBoxPrec, thrPrec) = inPrecisions; - - float iouThr, scoreThr, nmsEta; - std::tie(iouThr, scoreThr, nmsEta) = inFloatVar; - - bool sortResCB, normalized; - std::tie(sortResCB, normalized) = inboolVar; - - ParameterVector params; - if (inputDynamicShapes.size() > 2) { - std::vector types {paramsPrec, paramsPrec, roisnumPrec}; - OPENVINO_ASSERT(types.size() == inputDynamicShapes.size()); - for (size_t i = 0; i < types.size(); i++) { - auto param_node = std::make_shared(types[i], inputDynamicShapes[i]); - params.push_back(param_node); - } - } else { - for (auto&& shape : inputDynamicShapes) { - params.push_back(std::make_shared(paramsPrec, shape)); - } - } - - m_attrs.iou_threshold = iouThr; - m_attrs.score_threshold = scoreThr; - m_attrs.nms_eta = nmsEta; - m_attrs.sort_result_type = sortResultType; - m_attrs.sort_result_across_batch = sortResCB; - m_attrs.output_type = outType; - m_attrs.nms_top_k = maxOutBoxesPerClass; - m_attrs.keep_top_k = keepTopK; - m_attrs.background_class = backgroundClass; - m_attrs.normalized = normalized; - - std::shared_ptr nms; - if (params.size() > 2) { - nms = std::make_shared(params[0], params[1], params[2], m_attrs); - } else { - nms = std::make_shared(params[0], params[1], m_attrs); - } - - function = std::make_shared(nms, params, "MulticlassNMS"); -} - -} // namespace subgraph -} // namespace test -} // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/single_layer/multinomial.cpp b/src/tests/functional/shared_test_classes/src/single_layer/multinomial.cpp deleted file mode 100644 index 2277b8b2bb0a1a..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/multinomial.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (C) 2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// -#include -#include "shared_test_classes/single_layer/multinomial.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace ov { -namespace test { -namespace subgraph { - -std::string MultinomialTest::getTestCaseName(const testing::TestParamInfo &obj) { - ElementType netType, inType, outType; - InputShape shape; - std::int64_t numSamples; - element::Type_t outputType; - bool withReplacement; - bool logProbs; - TargetDevice targetDevice; - Config config; - std::tie(netType, inType, outType, shape, numSamples, outputType, withReplacement, logProbs, targetDevice, config) = obj.param; - - std::ostringstream result; - result << "NetType=" << netType << "_"; - result << "InType=" << inType << "_"; - result << "OutType=" << outType << "_"; - result << "IS=" << ov::test::utils::partialShape2str({shape.first}) << "_"; - result << "TS="; - for (const auto& item : shape.second) { - result << ov::test::utils::vec2str(item) << "_"; - } - result << "NumSamples=" << numSamples << "_"; - result << "OutputType=" << outputType << "_"; - result << "WithReplacement=" << withReplacement << "_"; - result << "LogProbs=" << logProbs << "_"; - result << "Device=" << targetDevice; - - return result.str(); -} - -void MultinomialTest::SetUp() { - InputShape shape; - ElementType ngPrc; - std::int64_t numSamples; - element::Type_t outputType; - bool withReplacement; - bool logProbs; - - std::tie(ngPrc, inType, outType, shape, numSamples, outputType, withReplacement, logProbs, targetDevice, configuration) = this->GetParam(); - init_input_shapes({shape}); - ov::ParameterVector params; - for (auto&& shape : inputDynamicShapes) { - params.push_back(std::make_shared(ngPrc, shape)); - } - - auto numSamplesConstant = std::make_shared( - ov::element::Type_t::i64, ov::Shape{1}, numSamples); - const auto paramOuts = - ngraph::helpers::convert2OutputVector(ngraph::helpers::castOps2Nodes(params)); - - const auto multinomial = std::make_shared( - paramOuts.at(0), - numSamplesConstant, - outputType, - withReplacement, - logProbs, - 0, - 2); - - function = std::make_shared(multinomial, params, "Multinomial"); -} - -} // namespace subgraph -} // namespace test -} // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/single_layer/mvn.cpp b/src/tests/functional/shared_test_classes/src/single_layer/mvn.cpp deleted file mode 100644 index e17821d5cb57f6..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/mvn.cpp +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/mvn.hpp" -#include "ov_models/builders.hpp" -#include "common_test_utils/node_builders/constant.hpp" - -namespace LayerTestsDefinitions { - -std::string Mvn1LayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::SizeVector inputShapes; - InferenceEngine::Precision inputPrecision; - ngraph::AxisSet axes; - bool acrossChannels, normalizeVariance; - double eps; - std::string targetDevice; - std::tie(inputShapes, inputPrecision, axes, acrossChannels, normalizeVariance, eps, targetDevice) = obj.param; - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "Precision=" << inputPrecision.name() << "_"; - if (!axes.empty()) { - result << "ReductionAxes=" << ov::test::utils::vec2str(axes.to_vector()) << "_"; - } else { - result << "AcrossChannels=" << (acrossChannels ? "TRUE" : "FALSE") << "_"; - } - result << "NormalizeVariance=" << (normalizeVariance ? "TRUE" : "FALSE") << "_"; - result << "Epsilon=" << eps << "_"; - result << "TargetDevice=" << targetDevice; - return result.str(); -} - -void Mvn1LayerTest::SetUp() { - InferenceEngine::SizeVector inputShapes; - InferenceEngine::Precision inputPrecision; - ngraph::AxisSet axes; - bool acrossChanels, normalizeVariance; - double eps; - std::tie(inputShapes, inputPrecision, axes, acrossChanels, normalizeVariance, eps, targetDevice) = this->GetParam(); - auto inType = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inputPrecision); - ov::ParameterVector param {std::make_shared(inType, ov::Shape(inputShapes))}; - OPENVINO_SUPPRESS_DEPRECATED_START - auto mvn = std::dynamic_pointer_cast(ngraph::builder::makeMVN(param[0], acrossChanels, normalizeVariance, eps)); - if (!axes.empty()) { - mvn = std::dynamic_pointer_cast(ngraph::builder::makeMVN(param[0], axes, normalizeVariance, eps)); - } - OPENVINO_SUPPRESS_DEPRECATED_END - ov::ResultVector results{std::make_shared(mvn)}; - function = std::make_shared(results, param, "MVN1"); -} - - -std::string Mvn6LayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::SizeVector inputShapes; - InferenceEngine::Precision dataPrecision, axesPrecision; - std::vector axes; - bool normalizeVariance; - float eps; - std::string epsMode; - std::string targetDevice; - std::tie(inputShapes, dataPrecision, axesPrecision, axes, normalizeVariance, eps, epsMode, targetDevice) = obj.param; - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "DataPrc=" << dataPrecision.name() << "_"; - result << "AxPrc=" << axesPrecision.name() << "_"; - result << "Ax=" << ov::test::utils::vec2str(axes) << "_"; - result << "NormVariance=" << (normalizeVariance ? "TRUE" : "FALSE") << "_"; - result << "Eps=" << eps << "_"; - result << "EM=" << epsMode << "_"; - result << "TargetDevice=" << targetDevice; - return result.str(); -} - -void Mvn6LayerTest::SetUp() { - InferenceEngine::SizeVector inputShapes; - InferenceEngine::Precision dataPrecision, axesPrecision; - std::vector axes; - bool normalizeVariance; - float eps; - std::string epsMode; - std::tie(inputShapes, dataPrecision, axesPrecision, axes, normalizeVariance, eps, epsMode, targetDevice) = this->GetParam(); - - auto dataType = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(dataPrecision); - auto axesType = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(axesPrecision); - - ov::ParameterVector param {std::make_shared(dataType, ov::Shape(inputShapes))}; - auto axesNode = ov::test::utils::deprecated::make_constant(axesType, ov::Shape{axes.size()}, axes); - OPENVINO_SUPPRESS_DEPRECATED_START - auto mvn = ngraph::builder::makeMVN6(param[0], axesNode, normalizeVariance, eps, epsMode); - OPENVINO_SUPPRESS_DEPRECATED_END - ov::ResultVector results{std::make_shared(mvn)}; - function = std::make_shared(results, param, "MVN6"); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/nms_rotated.cpp b/src/tests/functional/shared_test_classes/src/single_layer/nms_rotated.cpp deleted file mode 100644 index 80e6cc98db203f..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/nms_rotated.cpp +++ /dev/null @@ -1,230 +0,0 @@ -// Copyright (C) 2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/nms_rotated.hpp" -#include "openvino/op/nms_rotated.hpp" - -#include - -namespace LayerTestsDefinitions { - -using namespace InferenceEngine; -using namespace FuncTestUtils::PrecisionUtils; - -std::string NmsRotatedLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InputShapeParams inShapeParams; - InputPrecisions inPrecisions; - int32_t maxOutBoxesPerClass; - float iouThr, scoreThr; - bool sortResDescend, clockwise; - ov::element::Type outType; - std::string targetDevice; - std::tie(inShapeParams, - inPrecisions, - maxOutBoxesPerClass, - iouThr, - scoreThr, - sortResDescend, - outType, - clockwise, - targetDevice) = obj.param; - - size_t numBatches, numBoxes, numClasses; - std::tie(numBatches, numBoxes, numClasses) = inShapeParams; - - Precision inputPrec, maxBoxPrec, thrPrec; - std::tie(inputPrec, maxBoxPrec, thrPrec) = inPrecisions; - - std::ostringstream result; - result << "numBatches=" << numBatches << "_numBoxes=" << numBoxes << "_numClasses=" << numClasses << "_"; - result << "inputPrec=" << inputPrec << "_maxBoxPrec=" << maxBoxPrec << "_thrPrec=" << thrPrec << "_"; - result << "maxOutBoxesPerClass=" << maxOutBoxesPerClass << "_"; - result << "iouThr=" << iouThr << "_scoreThr=" << scoreThr << "_"; - result << "sortResDescend=" << sortResDescend << "_outType=" << outType << "_"; - result << "clockwise=" << clockwise << "_"; - result << "TargetDevice=" << targetDevice; - return result.str(); -} - -void NmsRotatedLayerTest::GenerateInputs() { - size_t it = 0; - for (const auto& input : cnnNetwork.getInputsInfo()) { - const auto& info = input.second; - Blob::Ptr blob; - - if (it == 1) { - blob = make_blob_with_precision(info->getTensorDesc()); - blob->allocate(); - if (info->getTensorDesc().getPrecision() == Precision::FP32) { - ov::test::utils::fill_data_random_float(blob, 1, 0, 1000); - } else { - ov::test::utils::fill_data_random_float(blob, 1, 0, 1000); - } - } else { - blob = GenerateInput(*info); - } - inputs.push_back(blob); - it++; - } -} - -void NmsRotatedLayerTest::Compare( - const std::vector>>& expectedOutputs, - const std::vector& actualOutputs) { - size_t num_batches, num_boxes, num_classes; - std::tie(num_batches, num_boxes, num_classes) = inShapeParams; - - struct OutBox { - OutBox() = default; - - OutBox(int32_t batchId, int32_t classId, int32_t boxId, float score) { - this->batchId = batchId; - this->classId = classId; - this->boxId = boxId; - this->score = score; - } - - bool operator==(const OutBox& rhs) const { - return batchId == rhs.batchId && classId == rhs.classId && boxId == rhs.boxId; - } - - int32_t batchId; - int32_t classId; - int32_t boxId; - float score; - }; - - std::vector expected; - { - const auto selected_indices_size = expectedOutputs[0].second.size() / expectedOutputs[0].first.size(); - const auto selected_scores_size = expectedOutputs[1].second.size() / expectedOutputs[1].first.size(); - - ASSERT_EQ(selected_indices_size, selected_scores_size); - - const auto boxes_count = selected_indices_size / 3; - expected.resize(boxes_count); - - if (expectedOutputs[0].first.size() == 4) { - auto selected_indices_data = reinterpret_cast(expectedOutputs[0].second.data()); - - for (size_t i = 0; i < selected_indices_size; i += 3) { - expected[i / 3].batchId = selected_indices_data[i + 0]; - expected[i / 3].classId = selected_indices_data[i + 1]; - expected[i / 3].boxId = selected_indices_data[i + 2]; - } - } else { - auto selected_indices_data = reinterpret_cast(expectedOutputs[0].second.data()); - - for (size_t i = 0; i < selected_indices_size; i += 3) { - expected[i / 3].batchId = static_cast(selected_indices_data[i + 0]); - expected[i / 3].classId = static_cast(selected_indices_data[i + 1]); - expected[i / 3].boxId = static_cast(selected_indices_data[i + 2]); - } - } - - if (expectedOutputs[1].first.size() == 4) { - auto selected_scores_data = reinterpret_cast(expectedOutputs[1].second.data()); - for (size_t i = 0; i < selected_scores_size; i += 3) { - expected[i / 3].score = selected_scores_data[i + 2]; - } - } else { - auto selected_scores_data = reinterpret_cast(expectedOutputs[1].second.data()); - for (size_t i = 0; i < selected_scores_size; i += 3) { - expected[i / 3].score = static_cast(selected_scores_data[i + 2]); - } - } - } - - std::vector actual; - { - const auto selected_indices_size = actualOutputs[0]->byteSize() / sizeof(float); - const auto selected_indices_memory = as(actualOutputs[0]); - IE_ASSERT(selected_indices_memory); - const auto selected_indices_lockedMemory = selected_indices_memory->rmap(); - const auto selected_indices_data = selected_indices_lockedMemory.as(); - - const auto selected_scores_memory = as(actualOutputs[1]); - IE_ASSERT(selected_scores_memory); - const auto selected_scores_lockedMemory = selected_scores_memory->rmap(); - const auto selected_scores_data = selected_scores_lockedMemory.as(); - - for (size_t i = 0; i < selected_indices_size; i += 3) { - const int32_t batchId = selected_indices_data[i + 0]; - const int32_t classId = selected_indices_data[i + 1]; - const int32_t boxId = selected_indices_data[i + 2]; - const float score = selected_scores_data[i + 2]; - if (batchId == -1 || classId == -1 || boxId == -1) - break; - - actual.emplace_back(batchId, classId, boxId, score); - } - } - - ASSERT_EQ(expected.size(), actual.size()); - for (size_t i = 0; i < expected.size(); ++i) { - ASSERT_EQ(expected[i], actual[i]) << ", i=" << i; - ASSERT_NEAR(expected[i].score, actual[i].score, abs_threshold) << ", i=" << i; - } -} - -void NmsRotatedLayerTest::SetUp() { - InputPrecisions inPrecisions; - size_t maxOutBoxesPerClass; - float iouThr, scoreThr; - bool sortResDescend, clockwise; - ov::element::Type outType; - std::tie(inShapeParams, - inPrecisions, - maxOutBoxesPerClass, - iouThr, - scoreThr, - sortResDescend, - outType, - clockwise, - targetDevice) = this->GetParam(); - - size_t numBatches, numBoxes, numClasses; - std::tie(numBatches, numBoxes, numClasses) = inShapeParams; - - Precision inputPrec, maxBoxPrec, thrPrec; - std::tie(inputPrec, maxBoxPrec, thrPrec) = inPrecisions; - - if (inputPrec == Precision::FP16) { - abs_threshold = 0.1; - } else { - abs_threshold = std::numeric_limits::epsilon(); - } - - ov::ParameterVector params; - - const std::vector boxesShape{numBatches, numBoxes, 5}, scoresShape{numBatches, numClasses, numBoxes}; - const auto ngPrc = convertIE2nGraphPrc(inputPrec); - - const auto boxesNode = std::make_shared(ngPrc, ov::Shape(boxesShape)); - params.push_back(boxesNode); - const auto scoresNode = std::make_shared(ngPrc, ov::Shape(scoresShape)); - params.push_back(scoresNode); - - const auto maxOutputBoxesPerClassNode = std::make_shared(ov::element::Type_t::u32, - ov::Shape{}, - std::vector{maxOutBoxesPerClass}); - const auto iouThresholdNode = std::make_shared(ov::element::Type_t::f32, - ov::Shape{}, - std::vector{iouThr}); - const auto scoreTresholdNode = std::make_shared(ov::element::Type_t::f32, - ov::Shape{}, - std::vector{scoreThr}); - - const auto nmsNode = std::make_shared(params[0], - params[1], - maxOutputBoxesPerClassNode, - iouThresholdNode, - scoreTresholdNode, - sortResDescend, - outType, - clockwise); - - function = std::make_shared(nmsNode, params, "NMS"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/non_max_suppression.cpp b/src/tests/functional/shared_test_classes/src/single_layer/non_max_suppression.cpp deleted file mode 100644 index 47b3f89f11eded..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/non_max_suppression.cpp +++ /dev/null @@ -1,397 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/non_max_suppression.hpp" - -#include - -namespace LayerTestsDefinitions { - -using namespace ngraph; -using namespace InferenceEngine; -using namespace FuncTestUtils::PrecisionUtils; - -std::string NmsLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InputShapeParams inShapeParams; - InputPrecisions inPrecisions; - int32_t maxOutBoxesPerClass; - float iouThr, scoreThr, softNmsSigma; - ov::op::v5::NonMaxSuppression::BoxEncodingType boxEncoding; - bool sortResDescend; - ov::element::Type outType; - std::string targetDevice; - std::tie(inShapeParams, - inPrecisions, - maxOutBoxesPerClass, - iouThr, - scoreThr, - softNmsSigma, - boxEncoding, - sortResDescend, - outType, - targetDevice) = obj.param; - - size_t numBatches, numBoxes, numClasses; - std::tie(numBatches, numBoxes, numClasses) = inShapeParams; - - Precision paramsPrec, maxBoxPrec, thrPrec; - std::tie(paramsPrec, maxBoxPrec, thrPrec) = inPrecisions; - - std::ostringstream result; - result << "numBatches=" << numBatches << "_numBoxes=" << numBoxes << "_numClasses=" << numClasses << "_"; - result << "paramsPrec=" << paramsPrec << "_maxBoxPrec=" << maxBoxPrec << "_thrPrec=" << thrPrec << "_"; - result << "maxOutBoxesPerClass=" << maxOutBoxesPerClass << "_"; - result << "iouThr=" << iouThr << "_scoreThr=" << scoreThr << "_softNmsSigma=" << softNmsSigma << "_"; - auto boxEncodingStr = (boxEncoding == ov::op::v5::NonMaxSuppression::BoxEncodingType::CENTER) ? "CENTER" : "CORNER"; - result << "boxEncoding=" << boxEncodingStr << "_sortResDescend=" << sortResDescend << "_outType=" << outType << "_"; - result << "TargetDevice=" << targetDevice; - return result.str(); -} - -void NmsLayerTest::GenerateInputs() { - size_t it = 0; - for (const auto& input : cnnNetwork.getInputsInfo()) { - const auto& info = input.second; - Blob::Ptr blob; - - if (it == 1) { - blob = make_blob_with_precision(info->getTensorDesc()); - blob->allocate(); - if (info->getTensorDesc().getPrecision() == Precision::FP32) { - ov::test::utils::fill_data_random_float(blob, 1, 0, 1000); - } else { - ov::test::utils::fill_data_random_float(blob, 1, 0, 1000); - } - } else { - blob = GenerateInput(*info); - } - inputs.push_back(blob); - it++; - } -} - -void NmsLayerTest::Compare( - const std::vector>>& expectedOutputs, - const std::vector& actualOutputs) { - CompareBBoxes(expectedOutputs, actualOutputs); -} - -typedef struct Rect { - int32_t x1; - int32_t y1; - int32_t x2; - int32_t y2; -} Rect; - -class Box { -public: - Box() = default; - - Box(int32_t batchId, int32_t classId, int32_t boxId, Rect rect, float score) { - this->batchId = batchId; - this->classId = classId; - this->boxId = boxId; - this->rect = rect; - this->score = score; - } - - int32_t batchId; - int32_t classId; - int32_t boxId; - Rect rect; - float score; -}; - -/* - * 1: selected_indices - tensor of type T_IND and shape [number of selected boxes, 3] containing information about - * selected boxes as triplets [batch_index, class_index, box_index]. 2: selected_scores - tensor of type T_THRESHOLDS - * and shape [number of selected boxes, 3] containing information about scores for each selected box as triplets - * [batch_index, class_index, box_score]. - * 3: valid_outputs - 1D tensor with 1 element of type T_IND representing the total number of selected boxes. - */ -void NmsLayerTest::CompareBBoxes( - const std::vector>>& expectedOutputs, - const std::vector& actualOutputs) { - size_t numBatches, numBoxes, numClasses; - std::tie(numBatches, numBoxes, numClasses) = inShapeParams; - - auto iouFunc = [](const Box& boxI, const Box& boxJ) { - const Rect& rectI = boxI.rect; - const Rect& rectJ = boxJ.rect; - - float areaI = (rectI.y2 - rectI.y1) * (rectI.x2 - rectI.x1); - float areaJ = (rectJ.y2 - rectJ.y1) * (rectJ.x2 - rectJ.x1); - - if (areaI <= 0.0f || areaJ <= 0.0f) { - return 0.0f; - } - - float intersection_ymin = std::max(rectI.y1, rectJ.y1); - float intersection_xmin = std::max(rectI.x1, rectJ.x1); - float intersection_ymax = std::min(rectI.y2, rectJ.y2); - float intersection_xmax = std::min(rectI.x2, rectJ.x2); - - float intersection_area = std::max(intersection_ymax - intersection_ymin, 0.0f) * - std::max(intersection_xmax - intersection_xmin, 0.0f); - - return intersection_area / (areaI + areaJ - intersection_area); - }; - - // Get input bboxes' coords - std::vector> coordList(numBatches, std::vector(numBoxes)); - { - const auto& input = inputs[0]; - auto memory = InferenceEngine::as(input); - IE_ASSERT(memory); - const auto lockedMemory = memory->rmap(); - const auto buffer = lockedMemory.as(); - for (size_t i = 0; i < numBatches; ++i) { - for (size_t j = 0; j < numBoxes; ++j) { - const int32_t y1 = static_cast(buffer[(i * numBoxes + j) * 4 + 0]); - const int32_t x1 = static_cast(buffer[(i * numBoxes + j) * 4 + 1]); - const int32_t y2 = static_cast(buffer[(i * numBoxes + j) * 4 + 2]); - const int32_t x2 = static_cast(buffer[(i * numBoxes + j) * 4 + 3]); - - coordList[i][j] = {std::min(y1, y2), std::min(x1, x2), std::max(y1, y2), std::max(x1, x2)}; - } - } - } - - auto compareBox = [](const Box& boxA, const Box& boxB) { - return (boxA.batchId < boxB.batchId) || (boxA.batchId == boxB.batchId && boxA.classId < boxB.classId) || - (boxA.batchId == boxB.batchId && boxA.classId == boxB.classId && boxA.boxId < boxB.boxId); - }; - - // Get expected bboxes' index/score - std::vector expectedList; - { - size_t selected_indices_size = expectedOutputs[0].second.size() / expectedOutputs[0].first.size(); - size_t selected_scores_size = expectedOutputs[1].second.size() / expectedOutputs[1].first.size(); - ASSERT_TRUE(selected_indices_size == selected_scores_size); - - expectedList.resize(selected_indices_size); - - if (expectedOutputs[0].first.size() == 4) { - auto selected_indices_data = reinterpret_cast(expectedOutputs[0].second.data()); - - for (size_t i = 0; i < selected_indices_size; i += 3) { - expectedList[i / 3].batchId = selected_indices_data[i + 0]; - expectedList[i / 3].classId = selected_indices_data[i + 1]; - expectedList[i / 3].boxId = selected_indices_data[i + 2]; - expectedList[i / 3].rect = coordList[expectedList[i / 3].batchId][expectedList[i / 3].boxId]; - } - } else { - auto selected_indices_data = reinterpret_cast(expectedOutputs[0].second.data()); - - for (size_t i = 0; i < selected_indices_size; i += 3) { - expectedList[i / 3].batchId = static_cast(selected_indices_data[i + 0]); - expectedList[i / 3].classId = static_cast(selected_indices_data[i + 1]); - expectedList[i / 3].boxId = static_cast(selected_indices_data[i + 2]); - expectedList[i / 3].rect = coordList[expectedList[i / 3].batchId][expectedList[i / 3].boxId]; - } - } - - if (expectedOutputs[1].first.size() == 4) { - auto selected_scores_data = reinterpret_cast(expectedOutputs[0].second.data()); - for (size_t i = 0; i < selected_scores_size; i += 3) { - expectedList[i / 3].score = selected_scores_data[i + 2]; - } - } else { - auto selected_scores_data = reinterpret_cast(expectedOutputs[0].second.data()); - for (size_t i = 0; i < selected_scores_size; i += 3) { - expectedList[i / 3].score = static_cast(selected_scores_data[i + 2]); - } - } - - std::sort(expectedList.begin(), expectedList.end(), compareBox); - } - - // Get actual bboxes' index/score - std::vector actualList; - { - size_t selected_indices_size = actualOutputs[0]->byteSize() / sizeof(float); - auto selected_indices_memory = as(actualOutputs[0]); - IE_ASSERT(selected_indices_memory); - const auto selected_indices_lockedMemory = selected_indices_memory->rmap(); - const auto selected_indices_data = selected_indices_lockedMemory.as(); - - auto selected_scores_memory = as(actualOutputs[1]); - IE_ASSERT(selected_scores_memory); - const auto selected_scores_lockedMemory = selected_scores_memory->rmap(); - const auto selected_scores_data = selected_scores_lockedMemory.as(); - - for (size_t i = 0; i < selected_indices_size; i += 3) { - const int32_t batchId = selected_indices_data[i + 0]; - const int32_t classId = selected_indices_data[i + 1]; - const int32_t boxId = selected_indices_data[i + 2]; - const float score = selected_scores_data[i + 2]; - if (batchId == -1 || classId == -1 || boxId == -1) - break; - - actualList.emplace_back(batchId, classId, boxId, coordList[batchId][boxId], score); - } - std::sort(actualList.begin(), actualList.end(), compareBox); - } - - std::vector intersectionList; - std::vector differenceList; - { - std::list tempExpectedList(expectedList.size()), tempActualList(actualList.size()); - std::copy(expectedList.begin(), expectedList.end(), tempExpectedList.begin()); - std::copy(actualList.begin(), actualList.end(), tempActualList.begin()); - auto sameBox = [](const Box& boxA, const Box& boxB) { - return (boxA.batchId == boxB.batchId) && (boxA.classId == boxB.classId) && (boxA.boxId == boxB.boxId); - }; - - for (auto itA = tempActualList.begin(); itA != tempActualList.end(); ++itA) { - bool found = false; - for (auto itB = tempExpectedList.begin(); itB != tempExpectedList.end(); ++itB) { - if (sameBox(*itA, *itB)) { - intersectionList.emplace_back(*itB); - tempExpectedList.erase(itB); - found = true; - break; - } - } - - if (!found) { - differenceList.emplace_back(*itA); - } - } - differenceList.insert(differenceList.end(), tempExpectedList.begin(), tempExpectedList.end()); - - for (auto& item : differenceList) { - if ((item.rect.x1 == item.rect.x2) || (item.rect.y1 == item.rect.y2)) - continue; - - float maxIou = 0.f; - for (auto& refItem : intersectionList) { - maxIou = std::max(maxIou, iouFunc(item, refItem)); - - if (maxIou > 0.3f) - break; - } - - ASSERT_TRUE(maxIou > 0.3f) << "MaxIOU: " << maxIou << ", expectedList.size(): " << expectedList.size() - << ", actualList.size(): " << actualList.size() - << ", intersectionList.size(): " << intersectionList.size() - << ", diffList.size(): " << differenceList.size() - << ", batchId: " << item.batchId << ", classId: " << item.classId - << ", boxId: " << item.boxId << ", score: " << item.score - << ", coord: " << item.rect.x1 << ", " << item.rect.y1 << ", " << item.rect.x2 - << ", " << item.rect.y2; - } - } -} - -void NmsLayerTest::SetUp() { - InputPrecisions inPrecisions; - size_t maxOutBoxesPerClass; - float iouThr, scoreThr, softNmsSigma; - ov::op::v5::NonMaxSuppression::BoxEncodingType boxEncoding; - bool sortResDescend; - ov::element::Type outType; - std::tie(inShapeParams, - inPrecisions, - maxOutBoxesPerClass, - iouThr, - scoreThr, - softNmsSigma, - boxEncoding, - sortResDescend, - outType, - targetDevice) = this->GetParam(); - - size_t numBatches, numBoxes, numClasses; - std::tie(numBatches, numBoxes, numClasses) = inShapeParams; - - Precision paramsPrec, maxBoxPrec, thrPrec; - std::tie(paramsPrec, maxBoxPrec, thrPrec) = inPrecisions; - - const std::vector boxesShape{numBatches, numBoxes, 4}, scoresShape{numBatches, numClasses, numBoxes}; - auto ngPrc = convertIE2nGraphPrc(paramsPrec); - ov::ParameterVector params {std::make_shared(ngPrc, ov::Shape(boxesShape)), - std::make_shared(ngPrc, ov::Shape(scoresShape))}; - auto paramOuts = helpers::convert2OutputVector(helpers::castOps2Nodes(params)); - - OPENVINO_SUPPRESS_DEPRECATED_START - auto nms = builder::makeNms(paramOuts[0], - paramOuts[1], - convertIE2nGraphPrc(maxBoxPrec), - convertIE2nGraphPrc(thrPrec), - maxOutBoxesPerClass, - iouThr, - scoreThr, - softNmsSigma, - boxEncoding == ov::op::v5::NonMaxSuppression::BoxEncodingType::CENTER, - sortResDescend, - outType); - OPENVINO_SUPPRESS_DEPRECATED_END - - if (targetDevice == ov::test::utils::DEVICE_CPU) { - function = std::make_shared(nms, params, "NMS"); - } else { - auto nms_0_identity = - std::make_shared(nms->output(0), ov::op::v0::Constant::create(outType, Shape{1}, {1})); - auto nms_1_identity = - std::make_shared(nms->output(1), ov::op::v0::Constant::create(ngPrc, Shape{1}, {1})); - auto nms_2_identity = - std::make_shared(nms->output(2), ov::op::v0::Constant::create(outType, Shape{1}, {1})); - nms_0_identity->set_friendly_name("Multiply_0"); - nms_1_identity->set_friendly_name("Multiply_1"); - nms_2_identity->set_friendly_name("Multiply_2"); - function = - std::make_shared(ov::OutputVector{nms_0_identity, nms_1_identity, nms_2_identity}, params, "NMS"); - } -} - -void Nms9LayerTest::SetUp() { - InputPrecisions inPrecisions; - size_t maxOutBoxesPerClass; - float iouThr, scoreThr, softNmsSigma; - ov::op::v5::NonMaxSuppression::BoxEncodingType boxEncoding; - bool sortResDescend; - ov::element::Type outType; - std::tie(inShapeParams, - inPrecisions, - maxOutBoxesPerClass, - iouThr, - scoreThr, - softNmsSigma, - boxEncoding, - sortResDescend, - outType, - targetDevice) = this->GetParam(); - - size_t numBatches, numBoxes, numClasses; - std::tie(numBatches, numBoxes, numClasses) = inShapeParams; - - Precision paramsPrec, maxBoxPrec, thrPrec; - std::tie(paramsPrec, maxBoxPrec, thrPrec) = inPrecisions; - - const std::vector boxesShape{numBatches, numBoxes, 4}, scoresShape{numBatches, numClasses, numBoxes}; - auto ngPrc = convertIE2nGraphPrc(paramsPrec); - ov::ParameterVector params {std::make_shared(ngPrc, ov::Shape(boxesShape)), - std::make_shared(ngPrc, ov::Shape(scoresShape))}; - auto paramOuts = helpers::convert2OutputVector(helpers::castOps2Nodes(params)); - - OPENVINO_SUPPRESS_DEPRECATED_START - auto nms = builder::makeNms(paramOuts[0], - paramOuts[1], - convertIE2nGraphPrc(maxBoxPrec), - convertIE2nGraphPrc(thrPrec), - maxOutBoxesPerClass, - iouThr, - scoreThr, - softNmsSigma, - boxEncoding == ov::op::v5::NonMaxSuppression::BoxEncodingType::CENTER, - sortResDescend, - outType, - ngraph::builder::NmsVersion::NmsVersion9); - OPENVINO_SUPPRESS_DEPRECATED_END - - function = std::make_shared(nms, params, "NMS"); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/nonzero.cpp b/src/tests/functional/shared_test_classes/src/single_layer/nonzero.cpp deleted file mode 100644 index c5606694162f73..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/nonzero.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/nonzero.hpp" - -namespace LayerTestsDefinitions { - -std::string NonZeroLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - std::vector inputShape; - InferenceEngine::Precision inputPrecision; - std::string targetDevice; - ConfigMap additionalConfig; - std::tie(inputShape, inputPrecision, targetDevice, additionalConfig) = obj.param; - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShape) << "_"; - result << "inPRC=" << inputPrecision.name() << "_"; - result << "targetDevice=" << targetDevice; - return result.str(); -} - -void NonZeroLayerTest::SetUp() { - auto inputShape = std::vector{}; - auto inputPrecision = InferenceEngine::Precision::UNSPECIFIED; - ConfigMap additionalConfig; - std::tie(inputShape, inputPrecision, targetDevice, additionalConfig) = GetParam(); - - configuration.insert(additionalConfig.cbegin(), additionalConfig.cend()); - - const auto& precision = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inputPrecision); - const auto& paramNode = std::make_shared(precision, ov::Shape(inputShape)); - - auto nonZeroOp = std::make_shared(paramNode->output(0)); - - ov::ResultVector results{std::make_shared(nonZeroOp)}; - function = std::make_shared(results, ov::ParameterVector{paramNode}, "non_zero"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/normalize_l2.cpp b/src/tests/functional/shared_test_classes/src/single_layer/normalize_l2.cpp deleted file mode 100644 index 0d855787c92fc3..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/normalize_l2.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/normalize_l2.hpp" - -namespace LayerTestsDefinitions { - -std::string NormalizeL2LayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - std::vector axes; - float eps; - ov::op::EpsMode epsMode; - InferenceEngine::SizeVector inputShape; - InferenceEngine::Precision netPrecision; - std::string targetDevice; - std::tie(axes, eps, epsMode, inputShape, netPrecision, targetDevice) = obj.param; - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShape) << "_"; - result << "axes=" << ov::test::utils::vec2str(axes) << "_"; - result << "eps=" << eps << "_"; - result << "epsMode=" << epsMode << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "targetDevice=" << targetDevice; - return result.str(); -} - -InferenceEngine::Blob::Ptr NormalizeL2LayerTest::GenerateInput(const InferenceEngine::InputInfo &info) const { - InferenceEngine::Blob::Ptr blobPtr; - const std::string& name = info.name(); - if (name == "data") { - blobPtr = FuncTestUtils::createAndFillBlobFloat(info.getTensorDesc(), 10, -5, 7, 222); - } else { - blobPtr = LayerTestsUtils::LayerTestsCommon::GenerateInput(info); - } - return blobPtr; -} - -void NormalizeL2LayerTest::SetUp() { - InferenceEngine::SizeVector inputShape; - std::vector axes; - float eps; - ov::op::EpsMode epsMode; - InferenceEngine::Precision netPrecision; - std::tie(axes, eps, epsMode, inputShape, netPrecision, targetDevice) = this->GetParam(); - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - auto data_input = params[0]; - data_input->set_friendly_name("data"); - - auto normAxes = std::make_shared(ov::element::i64, ov::Shape{axes.size()}, axes); - auto norm = std::make_shared(data_input, normAxes, eps, epsMode); - - ov::ResultVector results{std::make_shared(norm)}; - function = std::make_shared(results, params, "NormalizeL2"); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/one_hot.cpp b/src/tests/functional/shared_test_classes/src/single_layer/one_hot.cpp deleted file mode 100644 index 040743cc082b56..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/one_hot.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/one_hot.hpp" - -namespace LayerTestsDefinitions { - -std::string OneHotLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - int64_t axis; - ov::element::Type depth_type, set_type; - int64_t depth_val; - float on_val, off_val; - InferenceEngine::Precision netPrecision; - InferenceEngine::SizeVector inputShape; - LayerTestsUtils::TargetDevice targetDevice; - - std::tie(depth_type, depth_val, set_type, on_val, off_val, axis, netPrecision, inputShape, targetDevice) = obj.param; - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShape) << "_"; - result << "depthType=" << depth_type << "_"; - result << "depth=" << depth_val << "_"; - result << "SetValueType=" << set_type << "_"; - result << "onValue=" << on_val << "_"; - result << "offValue=" << off_val << "_"; - result << "axis=" << axis << "_"; - - result << "netPRC=" << netPrecision.name() << "_"; - result << "trgDev=" << targetDevice; - return result.str(); -} - -void OneHotLayerTest::SetUp() { - InferenceEngine::SizeVector inputShape; - int64_t axis; - ov::element::Type depth_type, set_type; - int64_t depth_val; - float on_val, off_val; - InferenceEngine::Precision netPrecision; - std::tie(depth_type, depth_val, set_type, on_val, off_val, axis, netPrecision, inputShape, targetDevice) = - this->GetParam(); - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - - auto depth_const = std::make_shared(depth_type, ov::Shape{}, depth_val); - auto on_value_const = std::make_shared(set_type, ov::Shape{}, on_val); - auto off_value_const = std::make_shared(set_type, ov::Shape{}, off_val); - auto onehot = std::make_shared(params[0], depth_const, on_value_const, off_value_const, axis); - - ov::ResultVector results{std::make_shared(onehot)}; - function = std::make_shared(results, params, "OneHot"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/pad.cpp b/src/tests/functional/shared_test_classes/src/single_layer/pad.cpp deleted file mode 100644 index d0b492ce5b34db..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/pad.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/pad.hpp" - -namespace LayerTestsDefinitions { - -std::string PadLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout; - InferenceEngine::SizeVector inputShapes; - std::vector padsBegin, padsEnd; - ngraph::helpers::PadMode padMode; - float argPadValue; - std::string targetDevice; - std::tie(padsBegin, padsEnd, argPadValue, padMode, netPrecision, inPrc, outPrc, inLayout, inputShapes, targetDevice) = - obj.param; - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "padsBegin=" << ov::test::utils::vec2str(padsBegin) << "_"; - result << "padsEnd=" << ov::test::utils::vec2str(padsEnd) << "_"; - if (padMode == ngraph::helpers::PadMode::CONSTANT) { - result << "Value=" << argPadValue << "_"; - } - result << "PadMode=" << padMode << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "trgDev=" << targetDevice; - return result.str(); -} - -void PadLayerTest::SetUp() { - InferenceEngine::SizeVector inputShape; - std::vector padsBegin, padsEnd; - float argPadValue; - ngraph::helpers::PadMode padMode; - InferenceEngine::Precision netPrecision; - std::tie(padsBegin, padsEnd, argPadValue, padMode, netPrecision, inPrc, outPrc, inLayout, inputShape, targetDevice) = - this->GetParam(); - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - auto pad = CreatePadOp(params[0], padsBegin, padsEnd, argPadValue, padMode); - ov::ResultVector results{std::make_shared(pad)}; - function = std::make_shared(results, params, "pad"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/pooling.cpp b/src/tests/functional/shared_test_classes/src/single_layer/pooling.cpp deleted file mode 100644 index b05cf229a8ca69..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/pooling.cpp +++ /dev/null @@ -1,230 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/pooling.hpp" - -namespace LayerTestsDefinitions { - -std::string PoolingLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - poolSpecificParams poolParams; - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - std::vector inputShapes; - std::string targetDevice; - std::tie(poolParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShapes, targetDevice) = obj.param; - ngraph::helpers::PoolingTypes poolType; - std::vector kernel, stride; - std::vector padBegin, padEnd; - ov::op::PadType padType; - ov::op::RoundingType roundingType; - bool excludePad; - std::tie(poolType, kernel, stride, padBegin, padEnd, roundingType, padType, excludePad) = poolParams; - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - switch (poolType) { - case ngraph::helpers::PoolingTypes::MAX: - result << "MaxPool_"; - break; - case ngraph::helpers::PoolingTypes::AVG: - result << "AvgPool_"; - result << "ExcludePad=" << excludePad << "_"; - break; - } - result << "K" << ov::test::utils::vec2str(kernel) << "_"; - result << "S" << ov::test::utils::vec2str(stride) << "_"; - result << "PB" << ov::test::utils::vec2str(padBegin) << "_"; - result << "PE" << ov::test::utils::vec2str(padEnd) << "_"; - result << "Rounding=" << roundingType << "_"; - result << "AutoPad=" << padType << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "trgDev=" << targetDevice; - return result.str(); -} - -std::string GlobalPoolingLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - poolSpecificParams poolParams; - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - std::string targetDevice; - size_t channels; - std::tie(poolParams, netPrecision, inPrc, outPrc, inLayout, outLayout, channels, targetDevice) = obj.param; - ngraph::helpers::PoolingTypes poolType; - std::vector kernel, stride; - std::vector padBegin, padEnd; - ov::op::PadType padType; - ov::op::RoundingType roundingType; - bool excludePad; - std::tie(poolType, kernel, stride, padBegin, padEnd, roundingType, padType, excludePad) = poolParams; - - std::vector inputShapes = {1, channels, kernel[0], kernel[1]}; - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - switch (poolType) { - case ngraph::helpers::PoolingTypes::MAX: - result << "MaxPool_"; - break; - case ngraph::helpers::PoolingTypes::AVG: - result << "AvgPool_"; - result << "ExcludePad=" << excludePad << "_"; - break; - } - result << "K" << ov::test::utils::vec2str(kernel) << "_"; - result << "S" << ov::test::utils::vec2str(stride) << "_"; - result << "PB" << ov::test::utils::vec2str(padBegin) << "_"; - result << "PE" << ov::test::utils::vec2str(padEnd) << "_"; - if (padType == ov::op::PadType::EXPLICIT) { - result << "Rounding=" << roundingType << "_"; - } - result << "AutoPad=" << padType << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "trgDev=" << targetDevice; - return result.str(); -} - -std::string MaxPoolingV8LayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - maxPoolV8SpecificParams poolParams; - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - std::vector inputShapes; - std::string targetDevice; - std::tie(poolParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShapes, targetDevice) = obj.param; - std::vector kernel, stride, dilation; - std::vector padBegin, padEnd; - ov::op::PadType padType; - ov::op::RoundingType roundingType; - ov::element::Type indexElementType; - int64_t axis; - std::tie(kernel, stride, dilation, padBegin, padEnd, indexElementType, axis, roundingType, padType) = poolParams; - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "K" << ov::test::utils::vec2str(kernel) << "_"; - result << "S" << ov::test::utils::vec2str(stride) << "_"; - result << "D" << ov::test::utils::vec2str(dilation) << "_"; - result << "PB" << ov::test::utils::vec2str(padBegin) << "_"; - result << "PE" << ov::test::utils::vec2str(padEnd) << "_"; - result << "IET" << indexElementType << "_"; - result << "A" << axis << "_"; - result << "Rounding=" << roundingType << "_"; - result << "AutoPad=" << padType << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "trgDev=" << targetDevice; - return result.str(); -} - -void PoolingLayerTest::SetUp() { - poolSpecificParams poolParams; - std::vector inputShape; - InferenceEngine::Precision netPrecision; - std::tie(poolParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, targetDevice) = this->GetParam(); - ngraph::helpers::PoolingTypes poolType; - std::vector kernel, stride; - std::vector padBegin, padEnd; - ov::op::PadType padType; - ov::op::RoundingType roundingType; - bool excludePad; - std::tie(poolType, kernel, stride, padBegin, padEnd, roundingType, padType, excludePad) = poolParams; - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - - OPENVINO_SUPPRESS_DEPRECATED_START - std::shared_ptr pooling = ngraph::builder::makePooling(params[0], - stride, - padBegin, - padEnd, - kernel, - roundingType, - padType, - excludePad, - poolType); - OPENVINO_SUPPRESS_DEPRECATED_END - - ov::ResultVector results{std::make_shared(pooling)}; - function = std::make_shared(results, params, "pooling"); -} - -void GlobalPoolingLayerTest::SetUp() { - poolSpecificParams poolParams; - InferenceEngine::Precision netPrecision; - size_t channels; - std::tie(poolParams, netPrecision, inPrc, outPrc, inLayout, outLayout, channels, targetDevice) = this->GetParam(); - ngraph::helpers::PoolingTypes poolType; - std::vector kernel, stride; - std::vector padBegin, padEnd; - ov::op::PadType padType; - ov::op::RoundingType roundingType; - bool excludePad; - std::tie(poolType, kernel, stride, padBegin, padEnd, roundingType, padType, excludePad) = poolParams; - - std::vector inputShape = {1, channels, kernel[1], kernel[0]}; - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - - OPENVINO_SUPPRESS_DEPRECATED_START - std::shared_ptr pooling = ngraph::builder::makePooling(params[0], - stride, - padBegin, - padEnd, - kernel, - roundingType, - padType, - excludePad, - poolType); - OPENVINO_SUPPRESS_DEPRECATED_END - - ov::ResultVector results{std::make_shared(pooling)}; - function = std::make_shared(results, params, "pooling"); -} - -void MaxPoolingV8LayerTest::SetUp() { - maxPoolV8SpecificParams poolParams; - std::vector inputShape; - InferenceEngine::Precision netPrecision; - std::tie(poolParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, targetDevice) = this->GetParam(); - std::vector kernel, stride, dilation; - std::vector padBegin, padEnd; - ov::op::PadType padType; - ov::op::RoundingType roundingType; - ov::element::Type indexElementType; - int64_t axis; - std::tie(kernel, stride, dilation, padBegin, padEnd, indexElementType, axis, roundingType, padType) = poolParams; - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - - auto maxPool = std::make_shared(params[0], stride, dilation, padBegin, padEnd, - kernel, roundingType, padType, - indexElementType, axis); - - const auto maxPoolV8_second_output_is_supported = targetDevice == ov::test::utils::DEVICE_GPU; - ov::ResultVector results; - if (maxPoolV8_second_output_is_supported) { - results = {std::make_shared(maxPool->output(0)), - std::make_shared(maxPool->output(1))}; - } else { - results = { std::make_shared(maxPool->output(0)) }; - } - function = std::make_shared(results, params, "MaxPoolV8"); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/power.cpp b/src/tests/functional/shared_test_classes/src/single_layer/power.cpp deleted file mode 100644 index a866f929cf02cf..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/power.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/power.hpp" - -namespace LayerTestsDefinitions { - std::string PowerLayerTest::getTestCaseName(const testing::TestParamInfo &obj) { - std::vector> inputShapes; - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - std::string targetName; - std::vector power; - std::tie(inputShapes, netPrecision, inPrc, outPrc, inLayout, outLayout, targetName, power) = obj.param; - std::ostringstream results; - - results << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - results << "Power=" << ov::test::utils::vec2str(power) << "_"; - results << "netPRC=" << netPrecision.name() << "_"; - results << "inPRC=" << inPrc.name() << "_"; - results << "outPRC=" << outPrc.name() << "_"; - results << "inL=" << inLayout << "_"; - results << "outL=" << outLayout << "_"; - results << "trgDev=" << targetName << "_"; - return results.str(); - } - - void PowerLayerTest::SetUp() { - threshold = 0.04f; - - std::vector> inputShapes; - InferenceEngine::Precision netPrecision; - std::vector power; - std::tie(inputShapes, netPrecision, inPrc, outPrc, inLayout, outLayout, targetDevice, power) = this->GetParam(); - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector paramsIn{std::make_shared(ngPrc, ov::Shape(inputShapes[0]))}; - - auto power_const = std::make_shared(ngPrc, ov::Shape{ 1 }, power); - auto pow = std::make_shared(paramsIn[0], power_const); - - function = std::make_shared(pow, paramsIn, "power"); - } -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/prior_box.cpp b/src/tests/functional/shared_test_classes/src/single_layer/prior_box.cpp deleted file mode 100644 index ad263b33f73450..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/prior_box.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/prior_box.hpp" -#include - -namespace LayerTestsDefinitions { -std::string PriorBoxLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - InferenceEngine::SizeVector inputShapes, imageShapes; - std::string targetDevice; - priorBoxSpecificParams specParams; - std::tie(specParams, - netPrecision, - inPrc, outPrc, inLayout, outLayout, - inputShapes, - imageShapes, - targetDevice) = obj.param; - - std::vector min_size, max_size, aspect_ratio, density, fixed_ratio, fixed_size, variance; - float step, offset; - bool clip, flip, scale_all_sizes, min_max_aspect_ratios_order; - std::tie(min_size, max_size, aspect_ratio, - density, fixed_ratio, fixed_size, clip, - flip, step, offset, variance, scale_all_sizes, min_max_aspect_ratios_order) = specParams; - - std::ostringstream result; - const char separator = '_'; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << separator; - result << "imageS=" << ov::test::utils::vec2str(imageShapes) << separator; - result << "netPRC=" << netPrecision.name() << separator; - result << "inPRC=" << inPrc.name() << separator; - result << "outPRC=" << outPrc.name() << separator; - result << "inL=" << inLayout << separator; - result << "outL=" << outLayout << separator; - result << "min_s=" << ov::test::utils::vec2str(min_size) << separator; - result << "max_s=" << ov::test::utils::vec2str(max_size)<< separator; - result << "asp_r=" << ov::test::utils::vec2str(aspect_ratio)<< separator; - result << "dens=" << ov::test::utils::vec2str(density)<< separator; - result << "fix_r=" << ov::test::utils::vec2str(fixed_ratio)<< separator; - result << "fix_s=" << ov::test::utils::vec2str(fixed_size)<< separator; - result << "var=" << ov::test::utils::vec2str(variance)<< separator; - result << "step=" << step << separator; - result << "off=" << offset << separator; - result << "clip=" << clip << separator; - result << "flip=" << flip<< separator; - result << "scale_all=" << scale_all_sizes << separator; - result << "min_max_aspect_ratios_order=" << min_max_aspect_ratios_order << separator; - result << "trgDev=" << targetDevice; - - return result.str(); -} - -void PriorBoxLayerTest::SetUp() { - priorBoxSpecificParams specParams; - std::tie(specParams, netPrecision, - inPrc, outPrc, inLayout, outLayout, - inputShapes, imageShapes, targetDevice) = GetParam(); - - std::tie(min_size, max_size, aspect_ratio, - density, fixed_ratio, fixed_size, clip, - flip, step, offset, variance, scale_all_sizes, - min_max_aspect_ratios_order) = specParams; - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params {std::make_shared(ngPrc, ov::Shape(inputShapes)), - std::make_shared(ngPrc, ov::Shape(imageShapes))}; - - ov::op::v8::PriorBox::Attributes attributes; - attributes.min_size = min_size; - attributes.max_size = max_size; - attributes.aspect_ratio = aspect_ratio; - attributes.density = density; - attributes.fixed_ratio = fixed_ratio; - attributes.fixed_size = fixed_size; - attributes.variance = variance; - attributes.step = step; - attributes.offset = offset; - attributes.clip = clip; - attributes.flip = flip; - attributes.scale_all_sizes = scale_all_sizes; - attributes.min_max_aspect_ratios_order = min_max_aspect_ratios_order; - - auto shape_of_1 = std::make_shared(params[0]); - auto shape_of_2 = std::make_shared(params[1]); - auto priorBox = std::make_shared( - shape_of_1, - shape_of_2, - attributes); - - ov::pass::disable_constant_folding(priorBox); - - ov::ResultVector results{std::make_shared(priorBox)}; - function = std::make_shared (results, params, "PriorBoxFunction"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/prior_box_clustered.cpp b/src/tests/functional/shared_test_classes/src/single_layer/prior_box_clustered.cpp deleted file mode 100644 index 86b1b3ff4fea70..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/prior_box_clustered.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/prior_box_clustered.hpp" - -namespace LayerTestsDefinitions { -std::string PriorBoxClusteredLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - InferenceEngine::SizeVector inputShapes, imageShapes; - std::string targetDevice; - priorBoxClusteredSpecificParams specParams; - std::tie(specParams, - netPrecision, - inPrc, outPrc, inLayout, outLayout, - inputShapes, - imageShapes, - targetDevice) = obj.param; - - std::vector widths, heights, variances; - float step_width, step_height, step, offset; - bool clip; - std::tie(widths, - heights, - clip, - step_width, - step_height, - step, - offset, - variances) = specParams; - - std::ostringstream result; - const char separator = '_'; - - result << "IS=" << ov::test::utils::vec2str(inputShapes) << separator; - result << "imageS=" << ov::test::utils::vec2str(imageShapes) << separator; - result << "netPRC=" << netPrecision.name() << separator; - result << "inPRC=" << inPrc.name() << separator; - result << "outPRC=" << outPrc.name() << separator; - result << "inL=" << inLayout << separator; - result << "outL=" << outLayout << separator; - result << "widths=" << ov::test::utils::vec2str(widths) << separator; - result << "heights=" << ov::test::utils::vec2str(heights) << separator; - result << "variances="; - if (variances.empty()) - result << "()" << separator; - else - result << ov::test::utils::vec2str(variances) << separator; - result << "stepWidth=" << step_width << separator; - result << "stepHeight=" << step_height << separator; - result << "step=" << step << separator; - result << "offset=" << offset << separator; - result << "clip=" << std::boolalpha << clip << separator; - result << "trgDev=" << targetDevice; - return result.str(); -} - -void PriorBoxClusteredLayerTest::SetUp() { - priorBoxClusteredSpecificParams specParams; - std::tie(specParams, netPrecision, - inPrc, outPrc, inLayout, outLayout, - inputShapes, imageShapes, targetDevice) = GetParam(); - - std::tie(widths, - heights, - clip, - step_width, - step_height, - step, - offset, - variances) = specParams; - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShapes)), - std::make_shared(ngPrc, ov::Shape(inputShapes))}; - - ov::op::v0::PriorBoxClustered::Attributes attributes; - attributes.widths = widths; - attributes.heights = heights; - attributes.clip = clip; - attributes.step_widths = step_width; - attributes.step_heights = step_height; - attributes.step = step; - attributes.offset = offset; - attributes.variances = variances; - - auto shape_of_1 = std::make_shared(params[0]); - auto shape_of_2 = std::make_shared(params[1]); - auto priorBoxClustered = std::make_shared( - shape_of_1, - shape_of_2, - attributes); - - ov::ResultVector results{ std::make_shared(priorBoxClustered) }; - function = std::make_shared(results, params, "PB_Clustered"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/proposal.cpp b/src/tests/functional/shared_test_classes/src/single_layer/proposal.cpp deleted file mode 100644 index 7ec1c8dedfe22a..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/proposal.cpp +++ /dev/null @@ -1,194 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/proposal.hpp" - -namespace LayerTestsDefinitions { - -const normalize_type normalize = true; -const feat_stride_type feat_stride = 1; -const box_size_scale_type box_size_scale = 2.0f; -const box_coordinate_scale_type box_coordinate_scale = 2.0f; - -std::string ProposalLayerTest::SerializeProposalSpecificParams(proposalSpecificParams& params) { - base_size_type base_size; - pre_nms_topn_type pre_nms_topn; - post_nms_topn_type post_nms_topn; - nms_thresh_type nms_thresh; - min_size_type min_size; - ratio_type ratio; - scale_type scale; - clip_before_nms_type clip_before_nms; - clip_after_nms_type clip_after_nms; - framework_type framework; - std::tie(base_size, pre_nms_topn, - post_nms_topn, - nms_thresh, - min_size, - ratio, - scale, - clip_before_nms, - clip_after_nms, - framework) = params; - - std::ostringstream result; - result << "base_size=" << base_size << "_"; - result << "pre_nms_topn=" << pre_nms_topn << "_"; - result << "post_nms_topn=" << post_nms_topn << "_"; - result << "nms_thresh=" << nms_thresh << "_"; - result << "feat_stride=" << feat_stride << "_"; - result << "min_size=" << min_size << "_"; - result << "ratio = " << ov::test::utils::vec2str(ratio) << "_"; - result << "scale = " << ov::test::utils::vec2str(scale) << "_"; - result << "clip_before_nms=" << clip_before_nms << "_"; - result << "clip_after_nms=" << clip_after_nms << "_"; - result << "normalize=" << normalize << "_"; - result << "box_size_scale=" << box_size_scale << "_"; - result << "box_coordinate_scale=" << box_coordinate_scale << "_"; - result << "framework=" << framework << "_"; - - return result.str(); -} - -std::string ProposalLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - proposalSpecificParams proposalParams; - std::string targetDevice; - std::tie(proposalParams, targetDevice) = obj.param; - auto proposalPramString = SerializeProposalSpecificParams(proposalParams); - - std::ostringstream result; - result << "targetDevice=" << targetDevice; - - return proposalPramString + result.str(); -} - -void ProposalLayerTest::Compare( - const std::vector>> &expectedOutputs, - const std::vector &actualOutputs) { - num_selected_boxes = 0; - for (std::size_t outputIndex = 0; outputIndex < expectedOutputs.size(); ++outputIndex) { - const auto &expected = expectedOutputs[outputIndex].second; - const auto &actual = actualOutputs[outputIndex]; - ASSERT_EQ(expected.size(), actual->byteSize()); - const auto &expectedBuffer = expected.data(); - - auto memory = InferenceEngine::as(actual); - IE_ASSERT(memory); - const auto lockedMemory = memory->rmap(); - const auto actualBuffer = lockedMemory.as(); - - const auto &precision = actual->getTensorDesc().getPrecision(); - auto size = actual->size(); - - // verifying the first output if there was less proposals than space - // provided, - // num_selected_boxes was set, take this into consideration while verifying the 2nd - // output - if (outputIndex == 1 && num_selected_boxes) { - size = num_selected_boxes; - } - - switch (precision) { - case InferenceEngine::Precision::BF16: - Compare(reinterpret_cast(expectedBuffer), - reinterpret_cast(actualBuffer), size, - ov::bfloat16(threshold), outputIndex); - break; - case InferenceEngine::Precision::FP16: - Compare(reinterpret_cast(expectedBuffer), - reinterpret_cast(actualBuffer), - size, - ov::float16(threshold), - outputIndex); - break; - case InferenceEngine::Precision::FP32: - Compare(reinterpret_cast(expectedBuffer), - reinterpret_cast(actualBuffer), size, - threshold, outputIndex); - break; - default: - FAIL() << "Comparator for " << precision << " precision isn't supported"; - } - } -} - -void ProposalLayerTest::SetUp() { - proposalSpecificParams proposalParams; - std::vector img_info = {225.0f, 225.0f, 1.0f}; - - std::tie(proposalParams, targetDevice) = this->GetParam(); - base_size_type base_size; - pre_nms_topn_type pre_nms_topn; - post_nms_topn_type post_nms_topn; - nms_thresh_type nms_thresh; - min_size_type min_size; - ratio_type ratio; - scale_type scale; - clip_before_nms_type clip_before_nms; - clip_after_nms_type clip_after_nms; - framework_type framework; - - std::tie(base_size, pre_nms_topn, - post_nms_topn, - nms_thresh, - min_size, - ratio, - scale, - clip_before_nms, - clip_after_nms, - framework) = proposalParams; - - size_t bottom_w = base_size; - size_t bottom_h = base_size; - size_t num_anchors = ratio.size() * scale.size(); - - std::vector scoresShape = {1, 2 * num_anchors, bottom_h, bottom_w}; - std::vector boxesShape = {1, 4 * num_anchors, bottom_h, bottom_w}; - std::vector imageInfoShape = {3}; - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(InferenceEngine::Precision::FP16); - // a_ and b_ are a workaround to solve alphabetic param sorting that destroys ordering - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(scoresShape)), - std::make_shared(ngPrc, ov::Shape(boxesShape))}; - params[0]->set_friendly_name("a_scores"); - params[1]->set_friendly_name("b_boxes"); - - OPENVINO_SUPPRESS_DEPRECATED_START - auto proposal = std::dynamic_pointer_cast( - ngraph::builder::makeProposal(params[0], params[1], img_info, ngPrc, - base_size, - pre_nms_topn, - post_nms_topn, - nms_thresh, - feat_stride, - min_size, - ratio, - scale, - clip_before_nms, - clip_after_nms, - normalize, - box_size_scale, - box_coordinate_scale, - framework)); - OPENVINO_SUPPRESS_DEPRECATED_END - - ov::ResultVector results{ - std::make_shared(proposal->output(0)), - std::make_shared(proposal->output(1))}; - function = std::make_shared(results, params, "proposal"); -} - -InferenceEngine::Blob::Ptr ProposalLayerTest::GenerateInput(const InferenceEngine::InputInfo &info) const { - InferenceEngine::Blob::Ptr blobPtr; - - const std::string name = info.name(); - if (name == "a_scores") { - blobPtr = FuncTestUtils::createAndFillBlobFloat(info.getTensorDesc(), 1, 0, 1000, 8234231); - } else if (name == "b_boxes") { - blobPtr = FuncTestUtils::createAndFillBlobFloatNormalDistribution(info.getTensorDesc(), 0.0f, 0.2f, 7235346); - } - - return blobPtr; -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/psroi_pooling.cpp b/src/tests/functional/shared_test_classes/src/single_layer/psroi_pooling.cpp deleted file mode 100644 index 5c270921d52e91..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/psroi_pooling.cpp +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/psroi_pooling.hpp" - -namespace LayerTestsDefinitions { - -std::string PSROIPoolingLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - std::vector inputShape; - std::vector coordsShape; - size_t outputDim; - size_t groupSize; - float spatialScale; - size_t spatialBinsX; - size_t spatialBinsY; - std::string mode; - InferenceEngine::Precision netPrecision; - std::string targetDevice; - std::tie(inputShape, coordsShape, outputDim, groupSize, spatialScale, spatialBinsX, spatialBinsY, mode, netPrecision, targetDevice) = obj.param; - - std::ostringstream result; - - result << "in_shape=" << ov::test::utils::vec2str(inputShape) << "_"; - result << "coord_shape=" << ov::test::utils::vec2str(coordsShape) << "_"; - result << "out_dim=" << outputDim << "_"; - result << "group_size=" << groupSize << "_"; - result << "scale=" << spatialScale << "_"; - result << "bins_x=" << spatialBinsX << "_"; - result << "bins_y=" << spatialBinsY << "_"; - result << "mode=" << mode << "_"; - result << "prec=" << netPrecision.name() << "_"; - result << "dev=" << targetDevice; - return result.str(); -} - -static int randInt(int low, int high) { - std::random_device rd; - std::mt19937 gen(rd()); - std::uniform_int_distribution dis(low, high); - return dis(gen); -} - - void PSROIPoolingLayerTest::fillROITensor(float* buffer, int numROIs, int batchSize, - int height, int width, int groupSize, - float spatialScale, int spatialBinsX, int spatialBinsY, const std::string& mode) { - int minRoiWidth = groupSize; - int maxRoiWidth = width / groupSize * groupSize; - int minRoiHeight = groupSize; - int maxRoiHeight = height / groupSize * groupSize; - float scaleX = spatialScale; - float scaleY = spatialScale; - if (mode == "bilinear") { - minRoiWidth = spatialBinsX; - maxRoiWidth = width / spatialBinsX * spatialBinsX; - minRoiHeight = spatialBinsY; - maxRoiHeight = height / spatialBinsY * spatialBinsY; - scaleX *= width; - scaleY *= height; - } - int batchId = 0; - for (int i = 0; i < numROIs; i++) { - int sizeX = std::min(width, randInt(std::min(minRoiWidth, maxRoiWidth), std::max(minRoiWidth, maxRoiWidth))); - int sizeY = std::min(height, randInt(std::min(minRoiWidth, maxRoiWidth), std::max(minRoiWidth, maxRoiWidth))); - int startX = randInt(0, std::max(1, width - sizeX - 1)); - int startY = randInt(0, std::max(1, height - sizeY - 1)); - - float* roi = buffer + i * 5; - roi[0] = batchId; - roi[1] = startX / scaleX; - roi[2] = startY / scaleY; - roi[3] = (startX + sizeX - 1) / scaleX; - roi[4] = (startY + sizeY - 1) / scaleY; - - batchId = (batchId + 1) % batchSize; - } -} - -void PSROIPoolingLayerTest::GenerateInputs() { - auto inputShape = cnnNetwork.getInputShapes().begin()->second; - - size_t it = 0; - for (const auto &input : cnnNetwork.getInputsInfo()) { - const auto &info = input.second; - InferenceEngine::Blob::Ptr blob; - - if (it == 1) { - blob = make_blob_with_precision(info->getTensorDesc()); - blob->allocate(); - fillROITensor(blob->buffer(), blob->size() / 5, - inputShape[0], inputShape[2], inputShape[3], groupSize_, - spatialScale_, spatialBinsX_, spatialBinsY_, mode_); - } else { - blob = GenerateInput(*info); - } - inputs.push_back(blob); - it++; - } -} - -void PSROIPoolingLayerTest::SetUp() { - std::vector inputShape; - std::vector coordsShape; - size_t outputDim; - InferenceEngine::Precision netPrecision; - std::tie(inputShape, coordsShape, outputDim, groupSize_, spatialScale_, - spatialBinsX_, spatialBinsY_, mode_, netPrecision, targetDevice) = this->GetParam(); - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params {std::make_shared(ngPrc, ov::Shape(inputShape)), - std::make_shared(ngPrc, ov::Shape(coordsShape))}; - std::shared_ptr psroiPooling = std::make_shared(params[0], - params[1], - outputDim, - groupSize_, - spatialScale_, - spatialBinsX_, - spatialBinsY_, - mode_); - ov::ResultVector results{std::make_shared(psroiPooling)}; - function = std::make_shared(results, params, "psroi_pooling"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/random_uniform.cpp b/src/tests/functional/shared_test_classes/src/single_layer/random_uniform.cpp deleted file mode 100644 index 224ebadf321858..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/random_uniform.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include "shared_test_classes/single_layer/random_uniform.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -namespace LayerTestsDefinitions { - - -std::string RandomUniformLayerTest::getTestCaseName( - const testing::TestParamInfo &obj) { - RandomUniformTypeSpecificParams randomUniformTypeSpecificParams; - ov::Shape output_shape; - int64_t global_seed; - int64_t op_seed; - std::string targetName; - std::tie(output_shape, randomUniformTypeSpecificParams, global_seed, op_seed, targetName) = obj.param; - - std::ostringstream result; - result << "outputShape=" << ov::test::utils::vec2str(output_shape) << "_"; - result << "global_seed=" << global_seed << "_"; - result << "op_seed=" << op_seed << "_"; - result << "outputType=" << randomUniformTypeSpecificParams.precision.name() << "_"; - result << "min_val=" << randomUniformTypeSpecificParams.min_value << "_"; - result << "max_val=" << randomUniformTypeSpecificParams.max_value; - return result.str(); -} - -namespace { - -template -std::shared_ptr -createRangeConst(const typename InferenceEngine::PrecisionTrait

::value_type &value) { - return std::make_shared(FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(p), ov::Shape{1}, - std::vector::value_type>{ - value}); -} - -std::shared_ptr createConstant(InferenceEngine::Precision p, double value) { - using namespace InferenceEngine; - switch (p) { - case Precision::FP32: - return createRangeConst( - static_cast::value_type>(value)); - case Precision::FP16: - return createRangeConst( - static_cast::value_type>(value)); - default: - return createRangeConst( - static_cast::value_type>(value)); - } -} - -} // unnamed namespace - -void RandomUniformLayerTest::SetUp() { - RandomUniformTypeSpecificParams randomUniformParams; - int64_t global_seed; - int64_t op_seed; - ov::Shape output_shape; - std::string targetName; - std::tie(output_shape, randomUniformParams, global_seed, op_seed, targetDevice) = this->GetParam(); - const auto precision = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(randomUniformParams.precision); - - // Use Parameter as input with desired precision to properly configure execution configuration - // in CoreConfiguration() function - auto input = std::make_shared(precision, output_shape); - auto shape_of = std::make_shared(input); - - auto min_value = createConstant(randomUniformParams.precision, randomUniformParams.min_value); - auto max_value = createConstant(randomUniformParams.precision, randomUniformParams.max_value); - auto random_uniform = std::make_shared(shape_of, - min_value, - max_value, - precision, - global_seed, - op_seed); - ov::ResultVector results{std::make_shared(random_uniform)}; - - function = std::make_shared(results, ngraph::ParameterVector{input}, "random_uniform"); -} - -void RandomUniformLayerTest::ConvertRefsParams() { - // we shouldn't use default conversion from f16 to f32 - ngraph::pass::ConvertPrecision().run_on_model(functionRefs); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/range.cpp b/src/tests/functional/shared_test_classes/src/single_layer/range.cpp deleted file mode 100644 index ec8ef181c4afd7..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/range.cpp +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/range.hpp" - -namespace LayerTestsDefinitions { - -std::string RangeLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - float start, stop, step; - std::string targetDevice; - std::tie(start, stop, step, netPrecision, inPrc, outPrc, inLayout, outLayout, targetDevice) = obj.param; - - std::ostringstream result; - const char separator = '_'; - result << "Start=" << start << separator; - result << "Stop=" << stop << separator; - result << "Step=" << step << separator; - result << "netPRC=" << netPrecision.name() << separator; - result << "inPRC=" << inPrc.name() << separator; - result << "outPRC=" << outPrc.name() << separator; - result << "inL=" << inLayout << separator; - result << "outL=" << outLayout << separator; - result << "trgDev=" << targetDevice; - auto str = result.str(); - replace(str.begin(), str.end(), '.', '_'); - return str; -} - -void RangeLayerTest::Infer() { - inferRequest = executableNetwork.CreateInferRequest(); - inputs.clear(); - - auto blobStart = inferRequest.GetBlob("start"); - blobStart = FuncTestUtils::createAndFillBlobWithFloatArray(blobStart->getTensorDesc(), &start, 1); - - auto blobStop = inferRequest.GetBlob("stop"); - blobStop = FuncTestUtils::createAndFillBlobWithFloatArray(blobStop->getTensorDesc(), &stop, 1); - - auto blobStep = inferRequest.GetBlob("step"); - blobStep = FuncTestUtils::createAndFillBlobWithFloatArray(blobStep->getTensorDesc(), &step, 1); - - inferRequest.Infer(); -} - -void RangeLayerTest::SetUp() { - InferenceEngine::Precision netPrecision; - tie(start, stop, step, netPrecision, inPrc, outPrc, inLayout, outLayout, targetDevice) = GetParam(); - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - std::vector>> inputs {{"start", {}}, {"stop", {}}, {"step", {}}}; - ov::ParameterVector params; - for (auto&& shape : inputs) { - auto param = std::make_shared(ngPrc, ov::Shape(shape.second)); - param->set_friendly_name(shape.first); - params.push_back(param); - } - auto range = std::make_shared(params[0], params[1], params[2], ngPrc); - - function = std::make_shared( - std::make_shared(range), - params, - "Range"); -} - -std::string RangeNumpyLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::Precision netPrc; - InferenceEngine::Precision paramPrc; - InferenceEngine::Precision outPrc; - InferenceEngine::Layout inLayout, outLayout; - float start, stop, step; - std::string targetDevice; - std::tie(start, stop, step, paramPrc, netPrc, outPrc, inLayout, outLayout, targetDevice) = obj.param; - - std::ostringstream result; - const char separator = '_'; - result << "Start=" << start << separator; - result << "Stop=" << stop << separator; - result << "Step=" << step << separator; - result << "paramPRC=" << paramPrc.name() << separator; - result << "netPRC=" << netPrc.name() << separator; - result << "inL=" << inLayout << separator; - result << "outL=" << outLayout << separator; - result << "trgDev=" << targetDevice; - return result.str(); -} - -void RangeNumpyLayerTest::Infer() { - inferRequest = executableNetwork.CreateInferRequest(); - inputs.clear(); - - auto blobStart = inferRequest.GetBlob("start"); - blobStart = FuncTestUtils::createAndFillBlobWithFloatArray(blobStart->getTensorDesc(), &start, 1); - - auto blobStop = inferRequest.GetBlob("stop"); - blobStop = FuncTestUtils::createAndFillBlobWithFloatArray(blobStop->getTensorDesc(), &stop, 1); - - auto blobStep = inferRequest.GetBlob("step"); - blobStep = FuncTestUtils::createAndFillBlobWithFloatArray(blobStep->getTensorDesc(), &step, 1); - - inferRequest.Infer(); -} - -void RangeNumpyLayerTest::SetUp() { - InferenceEngine::Precision netPrc; - InferenceEngine::Precision paramPrc; - std::tie(start, stop, step, paramPrc, netPrc, outPrc, inLayout, outLayout, targetDevice) = GetParam(); - auto ngNetPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrc); - auto ngParamPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(paramPrc); - - ov::ParameterVector params{std::make_shared(ngParamPrc, ov::Shape()), - std::make_shared(ngParamPrc, ov::Shape()), - std::make_shared(ngParamPrc, ov::Shape())}; - params[0]->set_friendly_name("start"); - params[1]->set_friendly_name("stop"); - params[2]->set_friendly_name("step"); - - auto range = std::make_shared(params[0], params[1], params[2], ngNetPrc); - const ov::ResultVector results{std::make_shared(range)}; - function = std::make_shared(results, params, "Range"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/rdft.cpp b/src/tests/functional/shared_test_classes/src/single_layer/rdft.cpp deleted file mode 100644 index 432bd72ba8dcbb..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/rdft.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/rdft.hpp" - -namespace LayerTestsDefinitions { - -std::string RDFTLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::SizeVector inputShapes; - InferenceEngine::Precision inputPrecision; - std::vector axes; - std::vector signalSize; - ngraph::helpers::DFTOpType opType; - std::string targetDevice; - std::tie(inputShapes, inputPrecision, axes, signalSize, opType, targetDevice) = obj.param; - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "Precision=" << inputPrecision.name() << "_"; - result << "Axes=" << ov::test::utils::vec2str(axes) << "_"; - result << "SignalSize=" << ov::test::utils::vec2str(signalSize) << "_"; - result << "Inverse=" << (opType == ngraph::helpers::DFTOpType::INVERSE) << "_"; - result << "TargetDevice=" << targetDevice; - return result.str(); -} - -void RDFTLayerTest::SetUp() { - InferenceEngine::SizeVector inputShapes; - InferenceEngine::Precision inputPrecision; - std::vector axes; - std::vector signalSize; - ngraph::helpers::DFTOpType opType; - std::tie(inputShapes, inputPrecision, axes, signalSize, opType, targetDevice) = this->GetParam(); - auto inType = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inputPrecision); - ov::ParameterVector paramVector; - auto paramData = std::make_shared(inType, ov::Shape(inputShapes)); - paramVector.push_back(paramData); - - auto rdft = ngraph::builder::makeRDFT(paramVector[0], axes, signalSize, opType); - - ov::ResultVector results{std::make_shared(rdft)}; - function = std::make_shared(results, paramVector, "RDFT"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/reduce_ops.cpp b/src/tests/functional/shared_test_classes/src/single_layer/reduce_ops.cpp deleted file mode 100644 index 648e8383b4058e..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/reduce_ops.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/reduce_ops.hpp" - -namespace LayerTestsDefinitions { - -std::string ReduceOpsLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout; - bool keepDims; - ngraph::helpers::ReductionType reductionType; - std::vector inputShape; - std::vector axes; - ov::test::utils::OpType opType; - std::string targetDevice; - std::tie(axes, opType, keepDims, reductionType, netPrecision, inPrc, outPrc, inLayout, inputShape, targetDevice) = obj.param; - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShape) << "_"; - result << "axes=" << ov::test::utils::vec2str(axes) << "_"; - result << "opType=" << opType << "_"; - result << "type=" << reductionType << "_"; - if (keepDims) result << "KeepDims_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "trgDev=" << targetDevice; - return result.str(); -} - -void ReduceOpsLayerTest::SetUp() { - InferenceEngine::Precision netPrecision; - bool keepDims; - ngraph::helpers::ReductionType reductionType; - std::vector inputShape; - std::vector axes; - ov::test::utils::OpType opType; - std::tie(axes, opType, keepDims, reductionType, netPrecision, inPrc, outPrc, inLayout, inputShape, targetDevice) = GetParam(); - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - - std::vector shapeAxes; - switch (opType) { - case ov::test::utils::OpType::SCALAR: { - if (axes.size() > 1) - FAIL() << "In reduce op if op type is scalar, 'axis' input's must contain 1 element"; - break; - } - case ov::test::utils::OpType::VECTOR: { - shapeAxes.push_back(axes.size()); - break; - } - default: - FAIL() << "Reduce op doesn't support operation type: " << opType; - } - auto reductionAxesNode = std::dynamic_pointer_cast( - std::make_shared(ov::element::Type_t::i64, ov::Shape(shapeAxes), axes)); - - const auto reduce = ngraph::builder::makeReduce(params[0], reductionAxesNode, keepDims, reductionType); - const ov::ResultVector results{std::make_shared(reduce)}; - function = std::make_shared(results, params, "Reduce"); -} -InferenceEngine::Blob::Ptr ReduceOpsLayerTest::GenerateInput(const InferenceEngine::InputInfo &info) const { - ngraph::helpers::ReductionType reductionType = std::get<3>(GetParam()); - InferenceEngine::Precision netPrecision = std::get<4>(GetParam()); - if (reductionType == ngraph::helpers::ReductionType::LogicalOr || - reductionType == ngraph::helpers::ReductionType::LogicalAnd) { - return FuncTestUtils::createAndFillBlob(info.getTensorDesc(), 2, 0); - } else if (!netPrecision.is_float()) { - return FuncTestUtils::createAndFillBlob(info.getTensorDesc(), 5, 0); - } - auto td = info.getTensorDesc(); - auto blob = make_blob_with_precision(td); - blob->allocate(); - if (reductionType == ngraph::helpers::ReductionType::Max) { - ov::test::utils::fill_data_random_float(blob, 5, -5, 1000); - } else { - ov::test::utils::fill_data_random_float(blob, 5, 0, 1000); - } - return blob; -} - -InferenceEngine::Blob::Ptr ReduceOpsLayerWithSpecificInputTest::GenerateInput(const InferenceEngine::InputInfo &info) const { - auto axis_vec = std::get<0>(GetParam()); - IE_ASSERT(axis_vec.size() == 1); - - auto axis = axis_vec[0]; - auto td = info.getTensorDesc(); - auto dims = td.getDims(); - - // Slice of tensor through axis is {1, 0, 0, ....}, the mean value is 1/slice_size - auto raw_values = std::vector(dims[axis], 0); - raw_values[0] = 1; - - auto blob = make_blob_with_precision(td); - blob->allocate(); - ov::test::utils::fill_data_with_broadcast(blob, axis, raw_values); - return blob; -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/region_yolo.cpp b/src/tests/functional/shared_test_classes/src/single_layer/region_yolo.cpp deleted file mode 100644 index 59561f79df6e74..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/region_yolo.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/region_yolo.hpp" - -namespace LayerTestsDefinitions { - -std::string RegionYoloLayerTest::getTestCaseName(const testing::TestParamInfo &obj) { - ov::Shape inputShape; - size_t classes; - size_t coords; - size_t num_regions; - bool do_softmax; - std::vector mask; - int start_axis; - int end_axis; - InferenceEngine::Precision netPrecision; - std::string targetName; - std::tie(inputShape, classes, coords, num_regions, do_softmax , mask, start_axis, end_axis, netPrecision, targetName) = obj.param; - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShape) << "_"; - result << "classes=" << classes << "_"; - result << "coords=" << coords << "_"; - result << "num=" << num_regions << "_"; - result << "doSoftmax=" << do_softmax << "_"; - result << "axis=" << start_axis << "_"; - result << "endAxis=" << end_axis << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "targetDevice=" << targetName << "_"; - return result.str(); -} - -void RegionYoloLayerTest::SetUp() { - ov::Shape inputShape; - size_t classes; - size_t coords; - size_t num_regions; - bool do_softmax; - std::vector mask; - int start_axis; - int end_axis; - InferenceEngine::Precision netPrecision; - std::tie(inputShape, classes, coords, num_regions, do_softmax, mask, start_axis, end_axis, netPrecision, targetDevice) = this->GetParam(); - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - auto param = std::make_shared(ngPrc, inputShape); - auto region_yolo = std::make_shared(param, coords, classes, num_regions, do_softmax, mask, start_axis, end_axis); - function = std::make_shared(std::make_shared(region_yolo), ov::ParameterVector{param}, "RegionYolo"); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/reorg_yolo.cpp b/src/tests/functional/shared_test_classes/src/single_layer/reorg_yolo.cpp deleted file mode 100644 index 3801a534e2e65c..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/reorg_yolo.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/reorg_yolo.hpp" - -namespace LayerTestsDefinitions { - -std::string ReorgYoloLayerTest::getTestCaseName(const testing::TestParamInfo &obj) { - ov::Shape inputShape; - size_t stride; - InferenceEngine::Precision netPrecision; - std::string targetName; - std::tie(inputShape, stride, netPrecision, targetName) = obj.param; - std::ostringstream result; - result << "IS=" << inputShape << "_"; - result << "stride=" << stride << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "targetDevice=" << targetName << "_"; - return result.str(); -} - -void ReorgYoloLayerTest::SetUp() { - ov::Shape inputShape; - size_t stride; - InferenceEngine::Precision netPrecision; - std::tie(inputShape, stride, netPrecision, targetDevice) = this->GetParam(); - auto param = std::make_shared(ov::element::f32, inputShape); - auto reorg_yolo = std::make_shared(param, stride); - function = std::make_shared(std::make_shared(reorg_yolo), ov::ParameterVector{param}, "ReorgYolo"); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/reshape.cpp b/src/tests/functional/shared_test_classes/src/single_layer/reshape.cpp deleted file mode 100644 index 41c6ec80bb462c..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/reshape.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/reshape.hpp" - -namespace LayerTestsDefinitions { -std::string ReshapeLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - InferenceEngine::SizeVector inputShapes; - std::vector outFormShapes; - std::string targetDevice; - std::map config; - bool specialZero; - std::tie(specialZero, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShapes, outFormShapes, targetDevice, config) = obj.param; - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "OS=" << ov::test::utils::vec2str(outFormShapes) << "_"; - result << "specialZero=" << specialZero << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "trgDev=" << targetDevice; - return result.str(); -} - -void ReshapeLayerTest::SetUp() { - InferenceEngine::SizeVector inputShapes; - std::vector outFormShapes; - bool specialZero; - InferenceEngine::Precision netPrecision; - std::tie(specialZero, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShapes, outFormShapes, targetDevice, configuration) = - this->GetParam(); - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector paramsIn {std::make_shared(ngPrc, ov::Shape(inputShapes))}; - auto constNode = std::make_shared( - ov::element::Type_t::i64, ov::Shape{outFormShapes.size()}, outFormShapes); - auto reshape = std::dynamic_pointer_cast( - std::make_shared(paramsIn[0], constNode, specialZero)); - ov::ResultVector results{std::make_shared(reshape)}; - function = std::make_shared(results, paramsIn, "Reshape"); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/result.cpp b/src/tests/functional/shared_test_classes/src/single_layer/result.cpp deleted file mode 100644 index 7e09567d526fb3..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/result.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/result.hpp" - -namespace LayerTestsDefinitions { - -std::string ResultLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - std::vector inputShape; - InferenceEngine::Precision inputPrecision; - std::string targetDevice; - ConfigMap additionalConfig; - std::tie(inputShape, inputPrecision, targetDevice, additionalConfig) = obj.param; - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShape) << "_"; - result << "inPRC=" << inputPrecision.name() << "_"; - result << "targetDevice=" << targetDevice; - return result.str(); -} - -void ResultLayerTest::SetUp() { - std::vector inputShape; - InferenceEngine::Precision inputPrecision; - std::string targetDevice; - ConfigMap additionalConfig; - std::tie(inputShape, inputPrecision, targetDevice, additionalConfig) = GetParam(); - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inputPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - const ov::ResultVector results{std::make_shared(params[0])}; - function = std::make_shared(results, params, "result"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/reverse.cpp b/src/tests/functional/shared_test_classes/src/single_layer/reverse.cpp deleted file mode 100644 index 44ce5a46449223..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/reverse.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/reverse.hpp" - -#include "ov_models/builders.hpp" -#include "shared_test_classes/single_layer/reverse.hpp" - -using namespace InferenceEngine; -using namespace FuncTestUtils::PrecisionUtils; - -namespace LayerTestsDefinitions { - -std::string ReverseLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - std::vector inputShape; - std::vector axes; - std::string mode; - InferenceEngine::Precision netPrecision; - std::string targetDevice; - std::tie(inputShape, axes, mode, netPrecision, targetDevice) = obj.param; - - std::ostringstream result; - - result << "in_shape=" << ov::test::utils::vec2str(inputShape) << "_"; - result << "axes=" << ov::test::utils::vec2str(axes) << "_"; - result << "mode=" << mode << "_"; - result << "prec=" << netPrecision.name() << "_"; - result << "dev=" << targetDevice; - return result.str(); -} - -void ReverseLayerTest::SetUp() { - std::vector inputShape; - std::vector axes; - std::string mode; - InferenceEngine::Precision netPrecision; - std::tie(inputShape, axes, mode, netPrecision, targetDevice) = GetParam(); - - const auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector paramsVector; - const ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - std::shared_ptr axes_constant; - if (mode == "index") { - axes_constant = std::make_shared(ov::element::i32, ov::Shape{axes.size()}, axes); - } else { - std::vector axesMask(inputShape.size(), false); - for (auto axe : axes) { - axesMask[axe] = true; - } - axes_constant = - std::make_shared(ov::element::boolean, ov::Shape{axesMask.size()}, axesMask); - } - const auto reverse = std::make_shared(params[0], axes_constant, mode); - function = std::make_shared(reverse->outputs(), params, "reverse"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/reverse_sequence.cpp b/src/tests/functional/shared_test_classes/src/single_layer/reverse_sequence.cpp deleted file mode 100644 index efb9a3519d14c4..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/reverse_sequence.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/reverse_sequence.hpp" - -namespace LayerTestsDefinitions { -std::string ReverseSequenceLayerTest::getTestCaseName(const testing::TestParamInfo &obj) { - int64_t batchAxisIndx; - int64_t seqAxisIndx; - InferenceEngine::Precision netPrecision; - std::string targetName; - std::vector inputShape; - std::vector secondInputShape; - ngraph::helpers::InputLayerType secondaryInputType; - - std::tie(batchAxisIndx, seqAxisIndx, inputShape, secondInputShape, secondaryInputType, netPrecision, targetName) = obj.param; - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShape) << "_"; - result << "seqLengthsShape" << ov::test::utils::vec2str(secondInputShape) << "_"; - result << "secondaryInputType=" << secondaryInputType << "_"; - result << "batchAxis=" << batchAxisIndx << "_"; - result << "seqAxis=" << seqAxisIndx << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "targetDevice=" << targetName; - return result.str(); -} - -void ReverseSequenceLayerTest::SetUp() { - InferenceEngine::Precision netPrecision; - int64_t batchAxisIndx; - int64_t seqAxisIndx; - std::vector inputShape; - std::vector secondInputShape; - ngraph::helpers::InputLayerType secondaryInputType; - - std::tie(batchAxisIndx, seqAxisIndx, inputShape, secondInputShape, secondaryInputType, netPrecision, targetDevice) = GetParam(); - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector paramsIn {std::make_shared(ngPrc, ov::Shape(inputShape))}; - - auto secondPrc = ov::element::Type_t::i32; //according to the specification - OPENVINO_SUPPRESS_DEPRECATED_START - auto secondaryInput = ngraph::builder::makeInputLayer(secondPrc, secondaryInputType, secondInputShape); - OPENVINO_SUPPRESS_DEPRECATED_END - if (secondaryInputType == ngraph::helpers::InputLayerType::PARAMETER) { - paramsIn.push_back(std::dynamic_pointer_cast(secondaryInput)); - } - - auto reverse = std::make_shared(paramsIn[0], secondaryInput, batchAxisIndx, seqAxisIndx); - ov::ResultVector results{std::make_shared(reverse)}; - function = std::make_shared(results, paramsIn, "ReverseSequence"); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/rnn_cell.cpp b/src/tests/functional/shared_test_classes/src/single_layer/rnn_cell.cpp deleted file mode 100644 index 25255df0fd6575..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/rnn_cell.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "transformations/op_conversions/rnn_cell_decomposition.hpp" -#include "shared_test_classes/single_layer/rnn_cell.hpp" -#include "common_test_utils/node_builders/constant.hpp" - -namespace LayerTestsDefinitions { - -using ngraph::helpers::InputLayerType; - -std::string RNNCellTest::getTestCaseName(const testing::TestParamInfo &obj) { - bool should_decompose; - size_t batch; - size_t hidden_size; - size_t input_size; - std::vector activations; - float clip; - InputLayerType WType; - InputLayerType RType; - InputLayerType BType; - InferenceEngine::Precision netPrecision; - std::string targetDevice; - std::tie(should_decompose, batch, hidden_size, input_size, activations, clip, WType, RType, BType, - netPrecision, targetDevice) = obj.param; - std::vector> inputShapes = {{batch, input_size}, {batch, hidden_size}, - {hidden_size, input_size}, {hidden_size, hidden_size}, {hidden_size}}; - std::ostringstream result; - result << "decomposition" << should_decompose << "_"; - result << "batch=" << batch << "_"; - result << "hidden_size=" << hidden_size << "_"; - result << "input_size=" << input_size << "_"; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "activations=" << ov::test::utils::vec2str(activations) << "_"; - result << "clip=" << clip << "_"; - result << "WType=" << WType << "_"; - result << "RType=" << RType << "_"; - result << "BType=" << BType << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "targetDevice=" << targetDevice << "_"; - return result.str(); -} - -void RNNCellTest::SetUp() { - bool should_decompose; - size_t batch; - size_t hidden_size; - size_t input_size; - std::vector activations; - std::vector activations_alpha; - std::vector activations_beta; - float clip; - InputLayerType WType; - InputLayerType RType; - InputLayerType BType; - InferenceEngine::Precision netPrecision; - std::tie(should_decompose, batch, hidden_size, input_size, activations, clip, WType, RType, BType, - netPrecision, targetDevice) = this->GetParam(); - std::vector> inputShapes = {{batch, input_size}, {batch, hidden_size}, - {hidden_size, input_size}, {hidden_size, hidden_size}, {hidden_size}}; - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShapes[0])), - std::make_shared(ngPrc, ov::Shape(inputShapes[1]))}; - std::vector WRB = {inputShapes[2], inputShapes[3], inputShapes[4]}; - - std::shared_ptr W; - if (WType == InputLayerType::PARAMETER) { - const auto param = std::make_shared(ngPrc, WRB[0]); - W = param; - params.push_back(param); - } else { - W = ov::test::utils::deprecated::make_constant(ngPrc, WRB[0], {}, true); - } - - std::shared_ptr R; - if (RType == InputLayerType::PARAMETER) { - const auto param = std::make_shared(ngPrc, WRB[1]); - R = param; - params.push_back(param); - } else { - R = ov::test::utils::deprecated::make_constant(ngPrc, WRB[1], {}, true); - } - - std::shared_ptr B; - if (BType == InputLayerType::PARAMETER) { - const auto param = std::make_shared(ngPrc, WRB[2]); - B = param; - params.push_back(param); - } else { - B = ov::test::utils::deprecated::make_constant(ngPrc, WRB[2], {}, true); - } - - auto rnn_cell = std::make_shared(params[0], params[1], W, R, B, hidden_size, activations, - activations_alpha, activations_beta, clip); - ov::ResultVector results{std::make_shared(rnn_cell)}; - function = std::make_shared(results, params, "rnn_cell"); - if (should_decompose) { - ov::pass::Manager m; - m.register_pass(); - m.run_passes(function); - } -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/rnn_sequence.cpp b/src/tests/functional/shared_test_classes/src/single_layer/rnn_sequence.cpp deleted file mode 100644 index c604cebc8ec816..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/rnn_sequence.cpp +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "transformations/op_conversions/bidirectional_sequences_decomposition.hpp" -#include "transformations/op_conversions/convert_sequences_to_tensor_iterator.hpp" -#include "shared_test_classes/single_layer/rnn_sequence.hpp" -#include "common_test_utils/node_builders/constant.hpp" - -namespace LayerTestsDefinitions { - - using ngraph::helpers::InputLayerType; - - std::string RNNSequenceTest::getTestCaseName(const testing::TestParamInfo &obj) { - ngraph::helpers::SequenceTestsMode mode; - size_t seq_lengths; - size_t batch; - size_t hidden_size; - size_t input_size; - std::vector activations; - std::vector activations_alpha; - std::vector activations_beta; - float clip; - ov::op::RecurrentSequenceDirection direction; - InferenceEngine::Precision netPrecision; - InputLayerType WRBType; - std::string targetDevice; - std::tie(mode, seq_lengths, batch, hidden_size, input_size, activations, clip, direction, WRBType, - netPrecision, targetDevice) = obj.param; - std::vector> inputShapes = { - {{batch, input_size}, {batch, hidden_size}, {batch, hidden_size}, {hidden_size, input_size}, - {hidden_size, hidden_size}, {hidden_size}}, - }; - std::ostringstream result; - result << "mode=" << mode << "_"; - result << "seq_lengths=" << seq_lengths << "_"; - result << "batch=" << batch << "_"; - result << "hidden_size=" << hidden_size << "_"; - result << "input_size=" << input_size << "_"; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "activations=" << ov::test::utils::vec2str(activations) << "_"; - result << "direction=" << direction << "_"; - result << "clip=" << clip << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "targetDevice=" << targetDevice << "_"; - return result.str(); - } - - void RNNSequenceTest::SetUp() { - using namespace ngraph::helpers; - size_t seq_lengths; - size_t batch; - size_t hidden_size; - size_t input_size; - std::vector activations; - std::vector activations_alpha; - std::vector activations_beta; - float clip; - ov::op::RecurrentSequenceDirection direction; - InputLayerType WRBType; - InferenceEngine::Precision netPrecision; - std::tie(m_mode, seq_lengths, batch, hidden_size, input_size, activations, clip, direction, WRBType, - netPrecision, targetDevice) = this->GetParam(); - size_t num_directions = direction == ov::op::RecurrentSequenceDirection::BIDIRECTIONAL ? 2 : 1; - std::vector inputShapes = { - {{batch, seq_lengths, input_size}, {batch, num_directions, hidden_size}, {batch}, - {num_directions, hidden_size, input_size}, {num_directions, hidden_size, hidden_size}, - {num_directions, hidden_size}}, - }; - m_max_seq_len = seq_lengths; - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShapes[0])), - std::make_shared(ngPrc, ov::Shape(inputShapes[1]))}; - std::shared_ptr seq_lengths_node; - if (m_mode == SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_PARAM || - m_mode == SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_PARAM || - m_mode == SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM) { - auto param = std::make_shared(ov::element::i64, inputShapes[2]); - param->set_friendly_name("seq_lengths"); - params.push_back(param); - seq_lengths_node = param; - } else if (m_mode == ngraph::helpers::SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_CONST || - m_mode == ngraph::helpers::SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_CONST) { - seq_lengths_node = ov::test::utils::deprecated::make_constant(ov::element::i64, inputShapes[2], {}, true, - static_cast(seq_lengths), 0.f); - } else { - std::vector lengths(batch, seq_lengths); - seq_lengths_node = ov::test::utils::deprecated::make_constant(ov::element::i64, inputShapes[2], lengths, false); - } - - const auto& W_shape = inputShapes[3]; - const auto& R_shape = inputShapes[4]; - const auto& B_shape = inputShapes[5]; - - std::shared_ptr W, R, B; - if (WRBType == InputLayerType::PARAMETER) { - const auto W_param = std::make_shared(ngPrc, W_shape); - const auto R_param = std::make_shared(ngPrc, R_shape); - const auto B_param = std::make_shared(ngPrc, B_shape); - W = W_param; - R = R_param; - B = B_param; - params.push_back(W_param); - params.push_back(R_param); - params.push_back(B_param); - } else { - W = ov::test::utils::deprecated::make_constant(ngPrc, W_shape, {}, true); - R = ov::test::utils::deprecated::make_constant(ngPrc, R_shape, {}, true); - B = ov::test::utils::deprecated::make_constant(ngPrc, B_shape, {}, true); - } - - auto rnn_sequence = std::make_shared(params[0], params[1], seq_lengths_node, W, R, B, hidden_size, direction, - activations, activations_alpha, activations_beta, clip); - ov::ResultVector results{std::make_shared(rnn_sequence->output(0)), - std::make_shared(rnn_sequence->output(1))}; - function = std::make_shared(results, params, "rnn_sequence"); - bool is_pure_sequence = (m_mode == SequenceTestsMode::PURE_SEQ || - m_mode == SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM || - m_mode == SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_CONST); - if (!is_pure_sequence) { - ov::pass::Manager manager; - if (direction == ov::op::RecurrentSequenceDirection::BIDIRECTIONAL) - manager.register_pass(); - manager.register_pass(); - manager.run_passes(function); - bool ti_found = ngraph::helpers::is_tensor_iterator_exist(function); - EXPECT_EQ(ti_found, true); - } else { - bool ti_found = ngraph::helpers::is_tensor_iterator_exist(function); - EXPECT_EQ(ti_found, false); - } - } - - void RNNSequenceTest::GenerateInputs() { - for (const auto &input : executableNetwork.GetInputsInfo()) { - const auto &info = input.second; - auto blob = GenerateInput(*info); - if (input.first == "seq_lengths") { - blob = FuncTestUtils::createAndFillBlob(info->getTensorDesc(), m_max_seq_len, 0); - } - - inputs.push_back(blob); - } - } -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/roi_align.cpp b/src/tests/functional/shared_test_classes/src/single_layer/roi_align.cpp deleted file mode 100644 index 40af92f261c0d3..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/roi_align.cpp +++ /dev/null @@ -1,206 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/roi_align.hpp" - -#include "ov_models/builders.hpp" -#include "openvino/core/enum_names.hpp" -#include "openvino/opsets/opset3.hpp" -#include "ov_models/builders.hpp" -#include "shared_test_classes/single_layer/roi_align.hpp" - -using namespace InferenceEngine; -using namespace FuncTestUtils::PrecisionUtils; - -namespace LayerTestsDefinitions { - -std::string ROIAlignLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - std::vector inputShape; - std::vector coordsShape; - - int pooledH; - int pooledW; - float spatialScale; - int poolingRatio; - std::string poolingMode; - InferenceEngine::Precision netPrecision; - std::string targetDevice; - std::tie(inputShape, coordsShape, pooledH, pooledW, spatialScale, poolingRatio, poolingMode, netPrecision, targetDevice) = obj.param; - - std::ostringstream result; - - result << "in_shape=" << ov::test::utils::vec2str(inputShape) << "_"; - result << "coord_shape=" << ov::test::utils::vec2str(coordsShape) << "_"; - result << "pooled_h=" << pooledH << "_"; - result << "pooled_w=" << pooledW << "_"; - result << "spatial_scale=" << spatialScale << "_"; - result << "pooling_ratio=" << poolingRatio << "_"; - result << "mode=" << poolingMode << "_"; - result << "prec=" << netPrecision.name() << "_"; - result << "dev=" << targetDevice; - return result.str(); -} - -static int randInt(int low, int high) { - std::random_device rd; - std::mt19937 gen(rd()); - std::uniform_int_distribution dis(low, high); - return dis(gen); -} - -void ROIAlignLayerTest::fillCoordTensor(std::vector& coords, int height, int width, - float spatialScale, int pooledRatio, int pooledH, int pooledW) { - int minRoiWidth = pooledW; - int maxRoiWidth = width / pooledRatio; - int minRoiHeight = pooledH; - int maxRoiHeight = height / pooledRatio; - - for (int i = 0; i < coords.size() / 4; i++) { - int sizeX = std::min(width, randInt(minRoiWidth, maxRoiWidth)); - int sizeY = std::min(height, randInt(minRoiHeight, maxRoiHeight)); - int startX = randInt(0, std::max(1, width - sizeX - 1)); - int startY = randInt(0, std::max(1, height - sizeY - 1)); - - coords[i * 4] = startX / spatialScale; - coords[i * 4 + 1] = startY / spatialScale; - coords[i * 4 + 2] = (startX + sizeX - 1) / spatialScale; - coords[i * 4 + 3] = (startY + sizeY - 1) / spatialScale; - } -} -void ROIAlignLayerTest::fillIdxTensor(std::vector& idx, int batchSize) { - int batchId = 0; - for (int i = 0; i < idx.size(); i++) { - idx[i] = batchId; - batchId = (batchId + 1) % batchSize; - } -} - -void ROIAlignLayerTest::SetUp() { - std::vector inputShape; - std::vector coordsShape; - InferenceEngine::Precision netPrecision; - std::tie(inputShape, - coordsShape, - pooledH, - pooledW, - spatialScale, - poolingRatio, - poolingMode, - netPrecision, - targetDevice) = this->GetParam(); - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - std::vector proposalVector; - std::vector roiIdxVector; - proposalVector.resize(coordsShape[0] * 4); - roiIdxVector.resize(coordsShape[0]); - - fillCoordTensor(proposalVector, inputShape[2], inputShape[3], spatialScale, poolingRatio, pooledH, pooledW); - fillIdxTensor(roiIdxVector, inputShape[0]); - ov::Shape idxShape = {coordsShape[0]}; - - auto coords = std::make_shared(ngPrc, coordsShape, proposalVector.data()); - auto roisIdx = std::make_shared(ov::element::i32, idxShape, roiIdxVector.data()); - - std::shared_ptr roiAlign = std::make_shared(params[0], - coords, - roisIdx, - pooledH, - pooledW, - poolingRatio, - spatialScale, - poolingMode); - ov::ResultVector results{std::make_shared(roiAlign)}; - function = std::make_shared(results, params, "roi_align"); -} - -std::string ROIAlignV9LayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - std::vector inputShape; - std::vector coordsShape; - - int pooledH; - int pooledW; - float spatialScale; - int poolingRatio; - std::string poolingMode; - std::string roiAlignedMode; - InferenceEngine::Precision netPrecision; - std::string targetDevice; - std::tie(inputShape, - coordsShape, - pooledH, - pooledW, - spatialScale, - poolingRatio, - poolingMode, - roiAlignedMode, - netPrecision, - targetDevice) = obj.param; - - std::ostringstream result; - - result << "in_shape=" << ov::test::utils::vec2str(inputShape) << "_"; - result << "coord_shape=" << ov::test::utils::vec2str(coordsShape) << "_"; - result << "pooled_h=" << pooledH << "_"; - result << "pooled_w=" << pooledW << "_"; - result << "spatial_scale=" << spatialScale << "_"; - result << "pooling_ratio=" << poolingRatio << "_"; - result << "mode=" << poolingMode << "_"; - result << "mode=" << roiAlignedMode << "_"; - result << "prec=" << netPrecision.name() << "_"; - result << "dev=" << targetDevice; - return result.str(); -} - -void ROIAlignV9LayerTest::SetUp() { - std::vector inputShape; - std::vector coordsShape; - InferenceEngine::Precision netPrecision; - std::tie(inputShape, - coordsShape, - pooledH, - pooledW, - spatialScale, - poolingRatio, - poolingMode, - roiAlignedMode, - netPrecision, - targetDevice) = this->GetParam(); - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - std::vector proposalVector; - std::vector roiIdxVector; - proposalVector.resize(coordsShape[0] * 4); - roiIdxVector.resize(coordsShape[0]); - - ROIAlignLayerTest::fillCoordTensor(proposalVector, - inputShape[2], - inputShape[3], - spatialScale, - poolingRatio, - pooledH, - pooledW); - ROIAlignLayerTest::fillIdxTensor(roiIdxVector, inputShape[0]); - ov::Shape idxShape = {coordsShape[0]}; - - auto coords = std::make_shared(ngPrc, coordsShape, proposalVector.data()); - auto roisIdx = std::make_shared(ov::element::i32, idxShape, roiIdxVector.data()); - - std::shared_ptr roiAlign = std::make_shared( - params[0], - coords, - roisIdx, - pooledH, - pooledW, - poolingRatio, - spatialScale, - ov::EnumNames::as_enum(poolingMode), - ov::EnumNames::as_enum(roiAlignedMode)); - - ov::ResultVector results{std::make_shared(roiAlign)}; - function = std::make_shared(results, params, "roi_align"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/roi_pooling.cpp b/src/tests/functional/shared_test_classes/src/single_layer/roi_pooling.cpp deleted file mode 100644 index d1f87c04c80be8..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/roi_pooling.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/roi_pooling.hpp" - -namespace LayerTestsDefinitions { - - std::string ROIPoolingLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - std::vector inputShape; - std::vector coordsShape; - std::vector poolShape; - float spatial_scale; - ngraph::helpers::ROIPoolingTypes pool_method; - InferenceEngine::Precision netPrecision; - std::string targetDevice; - std::tie(inputShape, coordsShape, poolShape, spatial_scale, pool_method, netPrecision, targetDevice) = obj.param; - - std::ostringstream result; - - result << "IS=" << ov::test::utils::vec2str(inputShape) << "_"; - result << "CS=" << ov::test::utils::vec2str(coordsShape) << "_"; - result << "PS=" << ov::test::utils::vec2str(poolShape) << "_"; - result << "Scale=" << spatial_scale << "_"; - switch (pool_method) { - case ngraph::helpers::ROIPoolingTypes::ROI_MAX: - result << "Max_"; - break; - case ngraph::helpers::ROIPoolingTypes::ROI_BILINEAR: - result << "Bilinear_"; - break; - } - result << "netPRC=" << netPrecision.name() << "_"; - result << "trgDev=" << targetDevice; - return result.str(); - } - - void ROIPoolingLayerTest::GenerateInputs() { - auto feat_map_shape = cnnNetwork.getInputShapes().begin()->second; - - const auto is_roi_max_mode = (pool_method == ngraph::helpers::ROIPoolingTypes::ROI_MAX); - - const int height = is_roi_max_mode ? feat_map_shape[2] / spatial_scale : 1; - const int width = is_roi_max_mode ? feat_map_shape[3] / spatial_scale : 1; - - size_t it = 0; - for (const auto &input : cnnNetwork.getInputsInfo()) { - const auto &info = input.second; - InferenceEngine::Blob::Ptr blob; - - if (it == 1) { - blob = make_blob_with_precision(info->getTensorDesc()); - blob->allocate(); - ov::test::utils::fill_data_roi(blob, feat_map_shape[0] - 1, - height, width, 1.0f, is_roi_max_mode); - } else { - blob = GenerateInput(*info); - } - inputs.push_back(blob); - it++; - } - } - - void ROIPoolingLayerTest::SetUp() { - InferenceEngine::SizeVector inputShape; - InferenceEngine::SizeVector coordsShape; - InferenceEngine::SizeVector poolShape; - InferenceEngine::Precision netPrecision; - - threshold = 0.08f; - - std::tie(inputShape, coordsShape, poolShape, spatial_scale, pool_method, netPrecision, targetDevice) = this->GetParam(); - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params {std::make_shared(ngPrc, ov::Shape(inputShape)), - std::make_shared(ngPrc, ov::Shape(coordsShape))}; - std::shared_ptr roi_pooling; - if (ov::test::utils::ROIPoolingTypes::ROI_MAX == pool_method) { - roi_pooling = std::make_shared(params[0], params[1], poolShape, spatial_scale, "max"); - } else { - roi_pooling = std::make_shared(params[0], params[1], poolShape, spatial_scale, "bilinear"); - } - ov::ResultVector results{std::make_shared(roi_pooling)}; - function = std::make_shared(results, params, "roi_pooling"); - } -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/roll.cpp b/src/tests/functional/shared_test_classes/src/single_layer/roll.cpp deleted file mode 100644 index 396b103ac3b9e5..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/roll.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/roll.hpp" - -namespace LayerTestsDefinitions { - -std::string RollLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::SizeVector inputShapes; - InferenceEngine::Precision inputPrecision; - std::vector shift; - std::vector axes; - std::string targetDevice; - std::tie(inputShapes, inputPrecision, shift, axes, targetDevice) = obj.param; - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "Precision=" << inputPrecision.name() << "_"; - result << "Shift=" << ov::test::utils::vec2str(shift) << "_"; - result << "Axes=" << ov::test::utils::vec2str(axes) << "_"; - result << "TargetDevice=" << targetDevice; - return result.str(); -} - -void RollLayerTest::SetUp() { - InferenceEngine::SizeVector inputShapes; - InferenceEngine::Precision inputPrecision; - std::vector shift; - std::vector axes; - std::tie(inputShapes, inputPrecision, shift, axes, targetDevice) = this->GetParam(); - auto inType = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inputPrecision); - ov::ParameterVector paramVector; - auto paramData = std::make_shared(inType, ov::Shape(inputShapes)); - paramVector.push_back(paramData); - - auto shiftNode = std::make_shared(ov::element::Type_t::i64, ov::Shape{shift.size()}, shift)->output(0); - auto axesNode = std::make_shared(ov::element::Type_t::i64, ov::Shape{axes.size()}, axes)->output(0); - - auto roll = std::make_shared(paramVector[0], shiftNode, axesNode); - - ov::ResultVector results{std::make_shared(roll)}; - function = std::make_shared(results, paramVector, "roll"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/scatter_ND_update.cpp b/src/tests/functional/shared_test_classes/src/single_layer/scatter_ND_update.cpp deleted file mode 100644 index 1f0723e359f7b8..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/scatter_ND_update.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ov_models/builders.hpp" -#include "shared_test_classes/single_layer/scatter_ND_update.hpp" - -namespace LayerTestsDefinitions { - -std::string ScatterNDUpdateLayerTest::getTestCaseName(const testing::TestParamInfo &obj) { - sliceSelectInShape shapeDescript; - std::vector inShape; - std::vector indicesShape; - std::vector indicesValue; - std::vector updateShape; - InferenceEngine::Precision inputPrecision; - InferenceEngine::Precision indicesPrecision; - std::string targetName; - std::tie(shapeDescript, inputPrecision, indicesPrecision, targetName) = obj.param; - std::tie(inShape, indicesShape, indicesValue, updateShape) = shapeDescript; - std::ostringstream result; - result << "InputShape=" << ov::test::utils::vec2str(inShape) << "_"; - result << "IndicesShape=" << ov::test::utils::vec2str(indicesShape) << "_"; - result << "UpdateShape=" << ov::test::utils::vec2str(updateShape) << "_"; - result << "inPrc=" << inputPrecision.name() << "_"; - result << "idxPrc=" << indicesPrecision.name() << "_"; - result << "targetDevice=" << targetName << "_"; - return result.str(); -} - -std::vector ScatterNDUpdateLayerTest::combineShapes( - const std::map, std::map, std::vector>>& inputShapes) { - std::vector resVec; - for (auto& inputShape : inputShapes) { - for (auto& item : inputShape.second) { - auto indiceShape = item.first; - size_t indicesRank = indiceShape.size(); - std::vector updateShape; - for (size_t i = 0; i < indicesRank - 1; i++) { - updateShape.push_back(indiceShape[i]); - } - auto srcShape = inputShape.first; - for (size_t j = indiceShape[indicesRank - 1]; j < srcShape.size(); j++) { - updateShape.push_back(srcShape[j]); - } - resVec.push_back(std::make_tuple(srcShape, indiceShape, item.second, updateShape)); - } - } - return resVec; -} - -void ScatterNDUpdateLayerTest::SetUp() { - sliceSelectInShape shapeDescript; - InferenceEngine::SizeVector inShape; - InferenceEngine::SizeVector indicesShape; - InferenceEngine::SizeVector indicesValue; - InferenceEngine::SizeVector updateShape; - InferenceEngine::Precision inputPrecision; - InferenceEngine::Precision indicesPrecision; - std::tie(shapeDescript, inputPrecision, indicesPrecision, targetDevice) = this->GetParam(); - std::tie(inShape, indicesShape, indicesValue, updateShape) = shapeDescript; - auto inPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inputPrecision); - auto idxPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(indicesPrecision); - ov::ParameterVector paramVector; - auto inputParams = std::make_shared(inPrc, ov::Shape(inShape)); - paramVector.push_back(inputParams); - auto updateParams = std::make_shared(inPrc, ov::Shape(updateShape)); - paramVector.push_back(updateParams); - - auto indicesNode = std::make_shared(idxPrc, ov::Shape(indicesShape), indicesValue); - auto s2d = std::make_shared(paramVector[0], indicesNode, paramVector[1]); - - ov::ResultVector results{std::make_shared(s2d)}; - function = std::make_shared(results, paramVector, "ScatterNDUpdate"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/scatter_elements_update.cpp b/src/tests/functional/shared_test_classes/src/single_layer/scatter_elements_update.cpp deleted file mode 100644 index 0f09a8fcf8d492..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/scatter_elements_update.cpp +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ov_models/builders.hpp" -#include "shared_test_classes/single_layer/scatter_elements_update.hpp" - -#include "openvino/op/scatter_elements_update.hpp" -using ov::op::operator<<; - -namespace LayerTestsDefinitions { - -std::string ScatterElementsUpdateLayerTest::getTestCaseName(const testing::TestParamInfo &obj) { - axisShapeInShape shapeDescript; - InferenceEngine::SizeVector indicesValue; - InferenceEngine::Precision inputPrecision; - InferenceEngine::Precision indicesPrecision; - std::string targetName; - std::tie(shapeDescript, indicesValue, inputPrecision, indicesPrecision, targetName) = obj.param; - std::ostringstream result; - result << "InputShape=" << ov::test::utils::vec2str(std::get<0>(shapeDescript)) << "_"; - result << "IndicesShape=" << ov::test::utils::vec2str(std::get<1>(shapeDescript)) << "_"; - result << "Axis=" << std::get<2>(shapeDescript) << "_"; - result << "inPrc=" << inputPrecision.name() << "_"; - result << "idxPrc=" << indicesPrecision.name() << "_"; - result << "targetDevice=" << targetName << "_"; - return result.str(); -} - -std::vector ScatterElementsUpdateLayerTest::combineShapes( - const std::map, std::map, std::vector>>& inputShapes) { - std::vector resVec; - for (auto& inputShape : inputShapes) { - for (auto& item : inputShape.second) { - for (auto& elt : item.second) { - resVec.push_back(std::make_tuple(inputShape.first, item.first, elt)); - } - } - } - return resVec; -} - -void ScatterElementsUpdateLayerTest::SetUp() { - InferenceEngine::SizeVector inShape; - InferenceEngine::SizeVector indicesShape; - int axis; - axisShapeInShape shapeDescript; - InferenceEngine::SizeVector indicesValue; - InferenceEngine::Precision inputPrecision; - InferenceEngine::Precision indicesPrecision; - std::tie(shapeDescript, indicesValue, inputPrecision, indicesPrecision, targetDevice) = this->GetParam(); - std::tie(inShape, indicesShape, axis) = shapeDescript; - auto inPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inputPrecision); - auto idxPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(indicesPrecision); - ov::ParameterVector paramVector; - auto inputParams = std::make_shared(inPrc, ov::Shape(inShape)); - paramVector.push_back(inputParams); - auto updateParams = std::make_shared(inPrc, ov::Shape(indicesShape)); - paramVector.push_back(updateParams); - - auto indicesNode = std::make_shared(idxPrc, ov::Shape(indicesShape), indicesValue); - auto axis_node = std::make_shared(ov::element::i32, ov::Shape{}, std::vector{axis}); - auto s2d = std::make_shared(paramVector[0], indicesNode, paramVector[1], axis_node); - - ov::ResultVector results{std::make_shared(s2d)}; - function = std::make_shared(results, paramVector, "ScatterElementsUpdate"); -} - -std::string ScatterElementsUpdate12LayerTest::getTestCaseName(const testing::TestParamInfo &obj) { - axisShapeInShape shapeDescript; - std::vector indicesValue; - ov::op::v12::ScatterElementsUpdate::Reduction reduceMode; - bool useInitVal; - InferenceEngine::Precision inputPrecision; - InferenceEngine::Precision indicesPrecision; - std::string targetName; - std::tie(shapeDescript, indicesValue, reduceMode, useInitVal, inputPrecision, indicesPrecision, targetName) = obj.param; - std::ostringstream result; - result << "InputShape=" << ov::test::utils::vec2str(std::get<0>(shapeDescript)) << "_"; - result << "IndicesShape=" << ov::test::utils::vec2str(std::get<1>(shapeDescript)) << "_"; - result << "Axis=" << std::get<2>(shapeDescript) << "_"; - result << "ReduceMode=" << reduceMode << "_"; - result << "UseInitVal=" << useInitVal << "_"; - result << "Indices=" << ov::test::utils::vec2str(indicesValue) << "_"; - result << "inPrc=" << inputPrecision.name() << "_"; - result << "idxPrc=" << indicesPrecision.name() << "_"; - result << "targetDevice=" << targetName << "_"; - return result.str(); -} - -void ScatterElementsUpdate12LayerTest::SetUp() { - InferenceEngine::SizeVector inShape; - InferenceEngine::SizeVector indicesShape; - int axis; - ov::op::v12::ScatterElementsUpdate::Reduction reduceMode; - bool useInitVal; - axisShapeInShape shapeDescript; - std::vector indicesValue; - InferenceEngine::Precision inputPrecision; - InferenceEngine::Precision indicesPrecision; - std::tie(shapeDescript, indicesValue, reduceMode, useInitVal, inputPrecision, indicesPrecision, targetDevice) = this->GetParam(); - std::tie(inShape, indicesShape, axis) = shapeDescript; - const auto inPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inputPrecision); - const auto idxPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(indicesPrecision); - ov::ParameterVector paramVector; - const auto inputParams = std::make_shared(inPrc, ov::Shape(inShape)); - paramVector.push_back(inputParams); - const auto updateParams = std::make_shared(inPrc, ov::Shape(indicesShape)); - paramVector.push_back(updateParams); - - const auto indicesNode = std::make_shared(idxPrc, indicesShape, indicesValue); - const auto axisNode = std::make_shared(ov::element::Type_t::i32, ov::Shape{}, - std::vector{axis}); - const auto seuNode = std::make_shared(paramVector[0], indicesNode, - paramVector[1], axisNode, reduceMode, useInitVal); - - ov::ResultVector results{std::make_shared(seuNode)}; - function = std::make_shared(results, paramVector, "ScatterElementsUpdate"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/scatter_update.cpp b/src/tests/functional/shared_test_classes/src/single_layer/scatter_update.cpp deleted file mode 100644 index fe36bdfcaa8906..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/scatter_update.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ov_models/builders.hpp" -#include "shared_test_classes/single_layer/scatter_update.hpp" - -namespace LayerTestsDefinitions { -std::string ScatterUpdateLayerTest::getTestCaseName(const testing::TestParamInfo &obj) { - axisUpdateShapeInShape shapeDescript; - std::vector inShape; - std::vector indicesShape; - std::vector updateShape; - int64_t axis; - std::vector indicesValue; - InferenceEngine::Precision inputPrecision; - InferenceEngine::Precision indicesPrecision; - std::string targetName; - std::tie(shapeDescript, indicesValue, inputPrecision, indicesPrecision, targetName) = obj.param; - std::tie(inShape, indicesShape, updateShape, axis) = shapeDescript; - std::ostringstream result; - result << "InputShape=" << ov::test::utils::vec2str(inShape) << "_"; - result << "IndicesShape=" << ov::test::utils::vec2str(indicesShape) << "_"; - result << "IndicesValue=" << ov::test::utils::vec2str(indicesValue) << "_"; - result << "UpdateShape=" << ov::test::utils::vec2str(updateShape) << "_"; - result << "Axis=" << axis << "_"; - result << "inPrc=" << inputPrecision.name() << "_"; - result << "idxPrc=" << indicesPrecision.name() << "_"; - result << "targetDevice=" << targetName << "_"; - return result.str(); -} - -std::vector ScatterUpdateLayerTest::combineShapes( - const std::map, std::map, std::vector>>& inputShapes) { - std::vector resVec; - for (auto& inputShape : inputShapes) { - auto srcShape = inputShape.first; - auto srcRank = srcShape.size(); - for (auto& item : inputShape.second) { - auto indicesShape = item.first; - auto indicesRank = indicesShape.size(); - for (auto& axis : item.second) { - auto axisP = axis < 0 ? axis + srcRank : axis; - std::vector updateShape; - for (size_t rs = 0; rs < srcRank; rs++) { - if (rs != axisP) { - updateShape.push_back(srcShape[rs]); - } else { - for (size_t ri = 0; ri < indicesRank; ri++) { - updateShape.push_back(indicesShape[ri]); - } - } - } - resVec.push_back(std::make_tuple(srcShape, indicesShape, updateShape, axis)); - } - } - } - return resVec; -} - -void ScatterUpdateLayerTest::SetUp() { - axisUpdateShapeInShape shapeDescript; - InferenceEngine::SizeVector inShape; - InferenceEngine::SizeVector indicesShape; - InferenceEngine::SizeVector updateShape; - int64_t axis; - std::vector indicesValue; - InferenceEngine::Precision inputPrecision; - InferenceEngine::Precision indicesPrecision; - std::tie(shapeDescript, indicesValue, inputPrecision, indicesPrecision, targetDevice) = this->GetParam(); - std::tie(inShape, indicesShape, updateShape, axis) = shapeDescript; - auto inPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inputPrecision); - auto idxPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(indicesPrecision); - ov::ParameterVector paramVector; - auto inputParams = std::make_shared(inPrc, ov::Shape(inShape)); - paramVector.push_back(inputParams); - auto updateParams = std::make_shared(inPrc, ov::Shape(updateShape)); - paramVector.push_back(updateParams); - - auto indicesNode = std::make_shared(idxPrc, ov::Shape(indicesShape), indicesValue); - auto axis_node = std::make_shared(ov::element::Type_t::i64, ov::Shape{}, std::vector{axis}); - auto s2d = std::make_shared(paramVector[0], indicesNode, paramVector[1], axis_node); - - ov::ResultVector results{std::make_shared(s2d)}; - function = std::make_shared(results, paramVector, "ScatterUpdate"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/select.cpp b/src/tests/functional/shared_test_classes/src/single_layer/select.cpp deleted file mode 100644 index b548f673a46690..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/select.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/select.hpp" - -namespace LayerTestsDefinitions { - enum { CONDITION, THEN, ELSE, numOfInputs }; - - std::string SelectLayerTest::getTestCaseName(const testing::TestParamInfo &obj) { - std::vector> dataShapes(3); - InferenceEngine::Precision dataType; - ov::op::AutoBroadcastSpec broadcast; - std::string targetDevice; - std::tie(dataShapes, dataType, broadcast, targetDevice) = obj.param; - std::ostringstream result; - result << "COND=BOOL_" << ov::test::utils::vec2str(dataShapes[CONDITION]); - result << "_THEN=" << dataType.name() << "_" << ov::test::utils::vec2str(dataShapes[THEN]); - result << "_ELSE=" << dataType.name() << "_" << ov::test::utils::vec2str(dataShapes[ELSE]); - result << "_" << broadcast.m_type; - result << "_targetDevice=" << targetDevice; - return result.str(); - } - - void SelectLayerTest::SetUp() { - std::vector> inputShapes(numOfInputs); - InferenceEngine::Precision inputPrecision; - ov::op::AutoBroadcastSpec broadcast; - std::tie(inputShapes, inputPrecision, broadcast, targetDevice) = this->GetParam(); - - ov::ParameterVector paramNodesVector; - auto paramNode = std::make_shared(ov::element::Type_t::boolean, ov::Shape(inputShapes[CONDITION])); - paramNodesVector.push_back(paramNode); - auto inType = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inputPrecision); - for (size_t i = 1; i < inputShapes.size(); i++) { - paramNode = std::make_shared(inType, ov::Shape(inputShapes[i])); - paramNodesVector.push_back(paramNode); - } - auto select = std::make_shared(paramNodesVector[0], paramNodesVector[1], paramNodesVector[2], broadcast); - ov::ResultVector results{std::make_shared(select)}; - function = std::make_shared(results, paramNodesVector, "select"); - } -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/shape_of.cpp b/src/tests/functional/shared_test_classes/src/single_layer/shape_of.cpp deleted file mode 100644 index 18f82ac6e33092..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/shape_of.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/shape_of.hpp" - -namespace LayerTestsDefinitions { - - std::string ShapeOfLayerTest::getTestCaseName(testing::TestParamInfo obj) { - InferenceEngine::SizeVector inputShapes; - InferenceEngine::Precision inputPrecision; - InferenceEngine::Precision outputPrecision; - std::string targetDevice; - std::tie(inputPrecision, outputPrecision, inputShapes, targetDevice) = obj.param; - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "Precision=" << inputPrecision.name() << "_"; - result << "Output Precision=" << outputPrecision.name() << "_"; - result << "TargetDevice=" << targetDevice; - return result.str(); - } - - void ShapeOfLayerTest::SetUp() { - InferenceEngine::SizeVector inputShapes; - InferenceEngine::Precision inputPrecision; - std::tie(inputPrecision, outPrc, inputShapes, targetDevice) = this->GetParam(); - auto inType = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inputPrecision); - auto outType = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(outPrc); - ov::ParameterVector param {std::make_shared(inType, ov::Shape(inputShapes))}; - auto shapeOf = std::make_shared(param[0], outType); - ov::ResultVector results{std::make_shared(shapeOf)}; - function = std::make_shared(results, param, "shapeOf"); - } - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/shuffle_channels.cpp b/src/tests/functional/shared_test_classes/src/single_layer/shuffle_channels.cpp deleted file mode 100644 index 17e49dfe7484e6..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/shuffle_channels.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ov_models/builders.hpp" -#include "shared_test_classes/single_layer/shuffle_channels.hpp" - -namespace LayerTestsDefinitions { - -std::string ShuffleChannelsLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - shuffleChannelsSpecificParams shuffleChannelsParams; - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - InferenceEngine::SizeVector inputShapes; - std::string targetDevice; - std::tie(shuffleChannelsParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShapes, targetDevice) = obj.param; - int axis, group; - std::tie(axis, group) = shuffleChannelsParams; - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "Axis=" << std::to_string(axis) << "_"; - result << "Group=" << std::to_string(group) << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "trgDev=" << targetDevice; - return result.str(); -} - -void ShuffleChannelsLayerTest::SetUp() { - shuffleChannelsSpecificParams shuffleChannelsParams; - std::vector inputShape; - auto netPrecision = InferenceEngine::Precision::UNSPECIFIED; - std::tie(shuffleChannelsParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, targetDevice) = this->GetParam(); - int axis, group; - std::tie(axis, group) = shuffleChannelsParams; - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - auto shuffleChannels = std::make_shared(params[0], axis, group); - ov::ResultVector results{std::make_shared(shuffleChannels)}; - function = std::make_shared(results, params, "shuffleChannels"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/slice.cpp b/src/tests/functional/shared_test_classes/src/single_layer/slice.cpp deleted file mode 100644 index 869e52bf7af36b..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/slice.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ov_models/builders.hpp" - -#include "shared_test_classes/single_layer/slice.hpp" - -using namespace ngraph; - -namespace LayerTestsDefinitions { - -std::string Slice8LayerTest::getTestCaseName(const testing::TestParamInfo &obj) { - std::vector shapes; - Slice8SpecificParams params; - ov::element::Type_t netPrecision, inPrecision, outPrecision; - InferenceEngine::Layout inLayout, outLayout; - std::string targetName; - std::map additionalConfig; - std::tie(params, netPrecision, inPrecision, outPrecision, inLayout, outLayout, targetName, additionalConfig) = obj.param; - std::ostringstream result; - result << "IS=("; - for (const auto& shape : params.shapes) { - result << ov::test::utils::partialShape2str({shape.first}) << "_"; - } - result << ")_TS=("; - for (const auto& shape : params.shapes) { - for (const auto& item : shape.second) { - result << ov::test::utils::vec2str(item) << "_"; - } - } - result << "start=" << ov::test::utils::vec2str(params.start) << "_"; - result << "stop=" << ov::test::utils::vec2str(params.stop) << "_"; - result << "step=" << ov::test::utils::vec2str(params.step) << "_"; - result << "axes=" << ov::test::utils::vec2str(params.axes) << "_"; - result << "netPRC=" << netPrecision << "_"; - result << "trgDev=" << targetName; - return result.str(); -} - -void Slice8LayerTest::SetUp() { - Slice8SpecificParams sliceParams; - ov::test::ElementType netPrecision, inPrecision, outPrecision; - InferenceEngine::Layout inLayout, outLayout; - std::map additionalConfig; - std::tie(sliceParams, netPrecision, inPrecision, outPrecision, inLayout, outLayout, targetDevice, additionalConfig) = this->GetParam(); - - configuration.insert(additionalConfig.begin(), additionalConfig.end()); - init_input_shapes(sliceParams.shapes); - ov::ParameterVector params; - for (auto&& shape : inputDynamicShapes) { - params.push_back(std::make_shared(netPrecision, shape)); - } - OPENVINO_SUPPRESS_DEPRECATED_START - auto sliceOp = ngraph::builder::makeSlice(params[0], sliceParams.start, sliceParams.stop, sliceParams.step, sliceParams.axes, netPrecision); - OPENVINO_SUPPRESS_DEPRECATED_END - - ov::ResultVector results; - for (int i = 0; i < sliceOp->get_output_size(); i++) - results.push_back(std::make_shared(sliceOp->output(i))); - function = std::make_shared(results, params, "Slice-8"); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/space_to_batch.cpp b/src/tests/functional/shared_test_classes/src/single_layer/space_to_batch.cpp deleted file mode 100644 index 78416211185467..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/space_to_batch.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ov_models/builders.hpp" -#include "shared_test_classes/single_layer/space_to_batch.hpp" - -namespace LayerTestsDefinitions { - -std::string SpaceToBatchLayerTest::getTestCaseName(const testing::TestParamInfo &obj) { - std::vector inShapes; - std::vector blockShape, padsBegin, padsEnd; - InferenceEngine::Precision netPrc; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - std::string targetName; - std::tie(blockShape, padsBegin, padsEnd, inShapes, netPrc, inPrc, outPrc, inLayout, outLayout, targetName) = obj.param; - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inShapes) << "_"; - result << "netPRC=" << netPrc.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "BS=" << ov::test::utils::vec2str(blockShape) << "_"; - result << "PB=" << ov::test::utils::vec2str(padsBegin) << "_"; - result << "PE=" << ov::test::utils::vec2str(padsEnd) << "_"; - result << "trgDev=" << targetName << "_"; - return result.str(); -} - -void SpaceToBatchLayerTest::SetUp() { - std::vector inputShape; - std::vector blockShape, padsBegin, padsEnd; - InferenceEngine::Precision netPrecision; - std::tie(blockShape, padsBegin, padsEnd, inputShape, netPrecision, inPrc, outPrc, inLayout, outLayout, targetDevice) = this->GetParam(); - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - OPENVINO_SUPPRESS_DEPRECATED_START - auto s2b = ngraph::builder::makeSpaceToBatch(params[0], ngPrc, blockShape, padsBegin, padsEnd); - OPENVINO_SUPPRESS_DEPRECATED_END - ov::ResultVector results{std::make_shared(s2b)}; - function = std::make_shared(results, params, "SpaceToBatch"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/space_to_depth.cpp b/src/tests/functional/shared_test_classes/src/single_layer/space_to_depth.cpp deleted file mode 100644 index 1579cf0f1408e1..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/space_to_depth.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ov_models/builders.hpp" -#include "shared_test_classes/single_layer/space_to_depth.hpp" - -namespace LayerTestsDefinitions { - -static inline std::string SpaceToDepthModeToString(const ov::op::v0::SpaceToDepth::SpaceToDepthMode& mode) { - static std::map names = { - {ov::op::v0::SpaceToDepth::SpaceToDepthMode::BLOCKS_FIRST, "BLOCKS_FIRST"}, - {ov::op::v0::SpaceToDepth::SpaceToDepthMode::DEPTH_FIRST, "DEPTH_FIRST"}, - }; - - auto i = names.find(mode); - if (i != names.end()) - return i->second; - else - throw std::runtime_error("Unsupported SpaceToDepthMode"); -} - -std::string SpaceToDepthLayerTest::getTestCaseName(const testing::TestParamInfo &obj) { - std::vector inShape; - ov::op::v0::SpaceToDepth::SpaceToDepthMode mode; - std::size_t blockSize; - InferenceEngine::Precision inputPrecision; - std::string targetName; - std::tie(inShape, inputPrecision, mode, blockSize, targetName) = obj.param; - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inShape) << "_"; - result << "inPrc=" << inputPrecision.name() << "_"; - result << "M=" << SpaceToDepthModeToString(mode) << "_"; - result << "BS=" << blockSize << "_"; - result << "targetDevice=" << targetName << "_"; - return result.str(); -} - -void SpaceToDepthLayerTest::SetUp() { - std::vector inShape; - ov::op::v0::SpaceToDepth::SpaceToDepthMode mode; - std::size_t blockSize; - InferenceEngine::Precision inputPrecision; - std::tie(inShape, inputPrecision, mode, blockSize, targetDevice) = this->GetParam(); - auto inPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inputPrecision); - ov::ParameterVector params {std::make_shared(inPrc, ov::Shape(inShape))}; - auto s2d = std::make_shared(params[0], mode, blockSize); - ov::ResultVector results{std::make_shared(s2d)}; - function = std::make_shared(results, params, "SpaceToDepth"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/split.cpp b/src/tests/functional/shared_test_classes/src/single_layer/split.cpp deleted file mode 100644 index 18686875ba1954..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/split.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/split.hpp" - -namespace LayerTestsDefinitions { - -std::string SplitLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - size_t numSplits; - int64_t axis; - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - InferenceEngine::SizeVector inputShapes, outIndices; - std::string targetDevice; - std::tie(numSplits, axis, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShapes, outIndices, targetDevice) = obj.param; - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "numSplits=" << numSplits << "_"; - result << "axis=" << axis << "_"; - if (!outIndices.empty()) { - result << "outIndices" << ov::test::utils::vec2str(outIndices) << "_"; - } - result << "IS"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "trgDev=" << targetDevice; - return result.str(); -} - -void SplitLayerTest::SetUp() { - size_t axis, numSplits; - std::vector inputShape, outIndices; - InferenceEngine::Precision netPrecision; - std::tie(numSplits, axis, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, outIndices, targetDevice) = this->GetParam(); - if (outIndices.empty()) { - for (int i = 0; i < numSplits; ++i) { - outIndices.push_back(i); - } - } - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - OPENVINO_SUPPRESS_DEPRECATED_START - auto split = std::dynamic_pointer_cast(ngraph::builder::makeSplit(params[0], - ngPrc, numSplits, axis)); - OPENVINO_SUPPRESS_DEPRECATED_END - ov::ResultVector results; - for (int i = 0; i < outIndices.size(); i++) { - results.push_back(std::make_shared(split->output(outIndices[i]))); - } - function = std::make_shared(results, params, "split"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/squeeze_unsqueeze.cpp b/src/tests/functional/shared_test_classes/src/single_layer/squeeze_unsqueeze.cpp deleted file mode 100644 index d7e8ebee7bb6c7..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/squeeze_unsqueeze.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/squeeze_unsqueeze.hpp" - -namespace LayerTestsDefinitions { -std::string SqueezeUnsqueezeLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - ShapeAxesTuple shapeItem; - std::string targetDevice; - ngraph::helpers::SqueezeOpType opType; - std::tie(shapeItem, opType, netPrecision, inPrc, outPrc, inLayout, outLayout, targetDevice) = obj.param; - - std::ostringstream result; - const char separator = '_'; - result << "OpType=" << opType << separator; - result << "IS=" << ov::test::utils::vec2str(shapeItem.first) << separator; - result << "Axes=" << (shapeItem.second.empty() ? "default" : ov::test::utils::vec2str(shapeItem.second)) << separator; - result << "netPRC=" << netPrecision.name() << separator; - result << "inPRC=" << inPrc.name() << separator; - result << "outPRC=" << outPrc.name() << separator; - result << "inL=" << inLayout << separator; - result << "outL=" << outLayout << separator; - result << "trgDev=" << targetDevice; - return result.str(); -} - -void SqueezeUnsqueezeLayerTest::SetUp() { - InferenceEngine::Precision netPrecision; - std::vector inputShapes; - std::vector axesVector; - ShapeAxesTuple shapeItem; - ngraph::helpers::SqueezeOpType opType; - std::tie(shapeItem, opType, netPrecision, inPrc, outPrc, inLayout, outLayout, targetDevice) = GetParam(); - std::tie(inputShapes, axesVector) = shapeItem; - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - - ov::ParameterVector params {std::make_shared(ngPrc, ov::Shape(inputShapes))}; - std::shared_ptr op; - - if (axesVector.empty() && opType == ngraph::helpers::SqueezeOpType::SQUEEZE) { - op = std::make_shared(params.front()); - } else { - OPENVINO_SUPPRESS_DEPRECATED_START - op = ngraph::builder::makeSqueezeUnsqueeze(params.front(), ov::element::i64, axesVector, opType); - OPENVINO_SUPPRESS_DEPRECATED_END - } - - const ov::ResultVector results{std::make_shared(op)}; - function = std::make_shared(results, params, "Squeeze"); -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/strided_slice.cpp b/src/tests/functional/shared_test_classes/src/single_layer/strided_slice.cpp deleted file mode 100644 index 95a7aa4044aec4..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/strided_slice.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ov_models/builders.hpp" - -#include "shared_test_classes/single_layer/strided_slice.hpp" - -namespace LayerTestsDefinitions { - -std::string StridedSliceLayerTest::getTestCaseName(const testing::TestParamInfo &obj) { - StridedSliceSpecificParams params; - InferenceEngine::Precision netPrc; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - std::string targetName; - std::map additionalConfig; - std::tie(params, netPrc, inPrc, outPrc, inLayout, outLayout, targetName, additionalConfig) = obj.param; - std::ostringstream result; - result << "inShape=" << ov::test::utils::vec2str(params.inputShape) << "_"; - result << "netPRC=" << netPrc.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "begin=" << ov::test::utils::vec2str(params.begin) << "_"; - result << "end=" << ov::test::utils::vec2str(params.end) << "_"; - result << "stride=" << ov::test::utils::vec2str(params.strides) << "_"; - result << "begin_m=" << ov::test::utils::vec2str(params.beginMask) << "_"; - result << "end_m=" << ov::test::utils::vec2str(params.endMask) << "_"; - result << "new_axis_m=" << (params.newAxisMask.empty() ? "def" : ov::test::utils::vec2str(params.newAxisMask)) << "_"; - result << "shrink_m=" << (params.shrinkAxisMask.empty() ? "def" : ov::test::utils::vec2str(params.shrinkAxisMask)) << "_"; - result << "ellipsis_m=" << (params.ellipsisAxisMask.empty() ? "def" : ov::test::utils::vec2str(params.ellipsisAxisMask)) << "_"; - result << "trgDev=" << targetName; - return result.str(); -} - -void StridedSliceLayerTest::SetUp() { - StridedSliceSpecificParams ssParams; - InferenceEngine::Precision netPrecision; - std::map additionalConfig; - std::tie(ssParams, netPrecision, inPrc, outPrc, inLayout, outLayout, targetDevice, additionalConfig) = this->GetParam(); - configuration.insert(additionalConfig.begin(), additionalConfig.end()); - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params {std::make_shared(ngPrc, ov::Shape(ssParams.inputShape))}; - - ov::Shape constShape = {ssParams.begin.size()}; - auto beginNode = std::make_shared(ov::element::i64, constShape, ssParams.begin.data()); - auto endNode = std::make_shared(ov::element::i64, constShape, ssParams.end.data()); - auto strideNode = std::make_shared(ov::element::i64, constShape, ssParams.strides.data()); - auto ss = std::make_shared(params[0], - beginNode, - endNode, - strideNode, - ssParams.beginMask, - ssParams.endMask, - ssParams.newAxisMask, - ssParams.shrinkAxisMask, - ssParams.ellipsisAxisMask); - - ov::ResultVector results{std::make_shared(ss)}; - function = std::make_shared(results, params, "StridedSlice"); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/tensor_iterator.cpp b/src/tests/functional/shared_test_classes/src/single_layer/tensor_iterator.cpp deleted file mode 100644 index 7a9a0cc34c9d51..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/tensor_iterator.cpp +++ /dev/null @@ -1,234 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include "shared_test_classes/single_layer/tensor_iterator.hpp" - -namespace LayerTestsDefinitions { - - std::string TensorIteratorTest::getTestCaseName(const testing::TestParamInfo &obj) { - bool should_decompose; - size_t seq_lengths; - size_t batch; - size_t hidden_size; - size_t input_size = 10; - size_t sequence_axis; - ngraph::helpers::TensorIteratorBody ti_body; - float clip; - ov::op::RecurrentSequenceDirection direction; - InferenceEngine::Precision netPrecision; - std::string targetDevice; - std::tie(should_decompose, seq_lengths, batch, hidden_size, sequence_axis, clip, ti_body, direction, netPrecision, - targetDevice) = obj.param; - std::vector> inputShapes = {}; - - switch (ti_body) { - case ngraph::helpers::TensorIteratorBody::LSTM: - inputShapes = { - {{batch, input_size}, {batch, hidden_size}, {batch, hidden_size}, {4 * hidden_size, input_size}, - {4 * hidden_size, hidden_size}, {4 * hidden_size}}, - }; - break; - case ngraph::helpers::TensorIteratorBody::GRU: - inputShapes = { - {{batch, input_size}, {batch, hidden_size}, {3 * hidden_size, input_size}, - {3 * hidden_size, hidden_size}, {3 * hidden_size}}, - }; - break; - case ngraph::helpers::TensorIteratorBody::RNN: - inputShapes = {{batch, input_size}, {batch, hidden_size}, - {hidden_size, input_size}, {hidden_size, hidden_size}, {hidden_size}}; - break; - } - - std::ostringstream result; - result << "unrolling=" << should_decompose << "_"; - result << "seq_len=" << seq_lengths << "_"; - result << "seq_len_axis=" << sequence_axis << "_"; - result << "batch=" << batch << "_"; - result << "hidden_size=" << hidden_size << "_"; - result << "input_size=" << input_size << "_"; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "TensorIteratorBody=" << ti_body << "_"; - result << "direction=" << direction << "_"; - result << "clip=" << clip << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "targetDevice=" << targetDevice << "_"; - return result.str(); - } - - void TensorIteratorTest::SetUp() { - size_t seq_lengths; - bool should_decompose; - size_t batch; - size_t hidden_size; - size_t input_size = 10; - size_t sequence_axis; - ngraph::helpers::TensorIteratorBody ti_body; - float clip; - ov::op::RecurrentSequenceDirection direction; - InferenceEngine::Precision netPrecision; - std::tie(should_decompose, seq_lengths, batch, hidden_size, sequence_axis, clip, ti_body, direction, netPrecision, - targetDevice) = this->GetParam(); - std::vector> inputShapes; - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - auto tensor_iterator = std::make_shared(); - - // Each case consist of 3 steps: - // 1. Create TensorIterator body. - // 2. Set PortMap - // 3. Create outer function - auto axis = std::make_shared(ov::element::i64, ov::Shape{1}, - std::vector{static_cast(sequence_axis)}); - switch (ti_body) { - case ngraph::helpers::TensorIteratorBody::LSTM: { - inputShapes = { - {{batch, seq_lengths, input_size}, {batch, hidden_size}, {batch, hidden_size}, {4 * hidden_size, input_size}, - {4 * hidden_size, hidden_size}, {4 * hidden_size}}, - }; - if (sequence_axis == 0) { - // swap batch and seq_lengths - std::swap(inputShapes[0][0], inputShapes[0][1]); - } - ov::ParameterVector outer_params{std::make_shared(ngPrc, ov::Shape(inputShapes[0])), - std::make_shared(ngPrc, ov::Shape(inputShapes[1])), - std::make_shared(ngPrc, ov::Shape(inputShapes[2]))}; - - // 1. Create TensorIterator body. - inputShapes[0][sequence_axis] = 1; // sliced dimension - ov::ParameterVector body_params{std::make_shared(ngPrc, ov::Shape(inputShapes[0])), - std::make_shared(ngPrc, ov::Shape(inputShapes[1])), - std::make_shared(ngPrc, ov::Shape(inputShapes[2]))}; - - auto squeeze = std::make_shared(body_params[0], axis); - std::vector WRB = {inputShapes[3], inputShapes[4], inputShapes[5]}; - ov::OutputVector out_vector = {squeeze, body_params[1], body_params[2]}; - auto lstm_cell = ngraph::builder::makeLSTM(out_vector, WRB, hidden_size, {"sigmoid", "tanh", "tanh"}, {}, {}, clip); - auto unsqueeze = std::make_shared(lstm_cell->output(0), axis); - ov::ResultVector results{std::make_shared(unsqueeze), - std::make_shared(lstm_cell->output(0)), - std::make_shared(lstm_cell->output(1))}; - auto body = std::make_shared(results, body_params, "lstm_cell"); - tensor_iterator->set_function(body); - - // 2. Set PortMap - if (direction == ov::op::RecurrentSequenceDirection::FORWARD) { - tensor_iterator->set_sliced_input(body_params[0], outer_params[0], 0, 1, 1, -1, sequence_axis); - tensor_iterator->get_concatenated_slices(results[0], 0, 1, 1, -1, sequence_axis); - } else if (direction == ov::op::RecurrentSequenceDirection::REVERSE) { - tensor_iterator->set_sliced_input(body_params[0], outer_params[0], -1, -1, 1, 0, sequence_axis); - tensor_iterator->get_concatenated_slices(results[0], -1, -1, 1, 0, sequence_axis); - } else { - OPENVINO_ASSERT(false, "Bidirectional case is not supported."); - } - - tensor_iterator->set_merged_input(body_params[1], outer_params[1], results[1]); - tensor_iterator->set_merged_input(body_params[2], outer_params[2], results[2]); - tensor_iterator->get_iter_value(results[1]); - tensor_iterator->get_iter_value(results[2]); - - // 3. Outer function - function = std::make_shared(ov::OutputVector{tensor_iterator->output(0), tensor_iterator->output(1), - tensor_iterator->output(2)}, outer_params); - break; - } - case ngraph::helpers::TensorIteratorBody::GRU: { - inputShapes = { - {{batch, seq_lengths, input_size}, {batch, hidden_size}, {3 * hidden_size, input_size}, - {3 * hidden_size, hidden_size}, {3 * hidden_size}}, - }; - if (sequence_axis == 0) { - // swap batch and seq_lengths - std::swap(inputShapes[0][0], inputShapes[0][1]); - } - ov::ParameterVector outer_params{std::make_shared(ngPrc, ov::Shape(inputShapes[0])), - std::make_shared(ngPrc, ov::Shape(inputShapes[1]))}; - - // 1. Create TensorIterator body. - inputShapes[0][sequence_axis] = 1; // sliced dimension - ov::ParameterVector body_params{std::make_shared(ngPrc, ov::Shape(inputShapes[0])), - std::make_shared(ngPrc, ov::Shape(inputShapes[1]))}; - - std::vector WRB = {inputShapes[2], inputShapes[3], inputShapes[4]}; - auto squeeze = std::make_shared(body_params[0], axis); - ov::OutputVector out_vector = {squeeze, body_params[1]}; - auto gru_cell = ngraph::builder::makeGRU(out_vector, WRB, hidden_size, {"sigmoid", "tanh"}, - {}, {}, clip, false); - auto unsqueeze = std::make_shared(gru_cell->output(0), axis); - ov::ResultVector results{std::make_shared(gru_cell->output(0)), - std::make_shared(unsqueeze)}; - auto body = std::make_shared(results, body_params, "gru_cell"); - tensor_iterator->set_function(body); - - // 2. Set PortMap - if (direction == ov::op::RecurrentSequenceDirection::FORWARD) { - tensor_iterator->set_sliced_input(body_params[0], outer_params[0], 0, 1, 1, -1, sequence_axis); - tensor_iterator->get_concatenated_slices(results[1], 0, 1, 1, -1, sequence_axis); - } else if (direction == ov::op::RecurrentSequenceDirection::REVERSE) { - tensor_iterator->set_sliced_input(body_params[0], outer_params[0], -1, -1, 1, 0, sequence_axis); - tensor_iterator->get_concatenated_slices(results[1], -1, -1, 1, 0, sequence_axis); - } else { - OPENVINO_ASSERT(false, "Bidirectional case is not supported."); - } - - tensor_iterator->set_merged_input(body_params[1], outer_params[1], results[0]); - tensor_iterator->get_iter_value(results[0]); - - // 3. Outer function - function = std::make_shared(ov::OutputVector{tensor_iterator->output(0), tensor_iterator->output(1)}, outer_params); - break; - } - case ngraph::helpers::TensorIteratorBody::RNN: { - inputShapes = {{batch, seq_lengths, input_size}, - {batch, hidden_size}, - {hidden_size, input_size}, - {hidden_size, hidden_size}, - {hidden_size}}; - if (sequence_axis == 0) { - // swap batch and seq_lengths - std::swap(inputShapes[0][0], inputShapes[0][1]); - } - ov::ParameterVector outer_params{std::make_shared(ngPrc, ov::Shape(inputShapes[0])), - std::make_shared(ngPrc, ov::Shape(inputShapes[1]))}; - - // 1. Create TensorIterator body. - inputShapes[0][sequence_axis] = 1; // sliced dimension - ov::ParameterVector body_params{std::make_shared(ngPrc, ov::Shape(inputShapes[0])), - std::make_shared(ngPrc, ov::Shape(inputShapes[1]))}; - std::vector WRB = {inputShapes[2], inputShapes[3], inputShapes[4]}; - auto squeeze = std::make_shared(body_params[0], axis); - ov::OutputVector out_vector = {squeeze, body_params[1]}; - auto rnn_cell = ngraph::builder::makeRNN(out_vector, WRB, hidden_size, {"tanh"}, {}, {}, clip); - auto unsqueeze = std::make_shared(rnn_cell->output(0), axis); - ov::ResultVector results{std::make_shared(rnn_cell), - std::make_shared(unsqueeze)}; - auto body = std::make_shared(results, body_params, "rnn_cell"); - tensor_iterator->set_function(body); - - // 2. Set PortMap - if (direction == ov::op::RecurrentSequenceDirection::FORWARD) { - tensor_iterator->set_sliced_input(body_params[0], outer_params[0], 0, 1, 1, -1, sequence_axis); - tensor_iterator->get_concatenated_slices(results[1], 0, 1, 1, -1, sequence_axis); - } else if (direction == ov::op::RecurrentSequenceDirection::REVERSE) { - tensor_iterator->set_sliced_input(body_params[0], outer_params[0], -1, -1, 1, 0, sequence_axis); - tensor_iterator->get_concatenated_slices(results[1], -1, -1, 1, 0, sequence_axis); - } else { - OPENVINO_ASSERT(false, "Bidirectional case is not supported."); - } - - tensor_iterator->set_merged_input(body_params[1], outer_params[1], results[0]); - tensor_iterator->get_iter_value(results[0]); - - // 3. Outer function - function = std::make_shared(ov::OutputVector{tensor_iterator->output(0), tensor_iterator->output(1)}, outer_params); - break; - } - } - if (should_decompose) { - ov::pass::Manager m; - m.register_pass(); - m.run_passes(function); - } - } -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/tile.cpp b/src/tests/functional/shared_test_classes/src/single_layer/tile.cpp deleted file mode 100644 index 74f61406e76596..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/tile.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/tile.hpp" - -namespace LayerTestsDefinitions { - -std::string TileLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - TileSpecificParams tileParams; - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - InferenceEngine::SizeVector inputShapes; - std::string targetDevice; - std::tie(tileParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShapes, targetDevice) = obj.param; - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "Repeats=" << ov::test::utils::vec2str(tileParams) << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "trgDev=" << targetDevice; - return result.str(); -} - -void TileLayerTest::SetUp() { - TileSpecificParams tileParams; - std::vector inputShape; - auto netPrecision = InferenceEngine::Precision::UNSPECIFIED; - std::tie(tileParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, targetDevice) = this->GetParam(); - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - - auto repeatsNode = std::make_shared(ov::element::i64, std::vector{tileParams.size()}, tileParams); - auto tile = std::make_shared(params[0], repeatsNode); - - ov::ResultVector results{std::make_shared(tile)}; - function = std::make_shared(results, params, "tile"); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/topk.cpp b/src/tests/functional/shared_test_classes/src/single_layer/topk.cpp deleted file mode 100644 index 0cac7708c685ff..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/topk.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/topk.hpp" - -namespace LayerTestsDefinitions { - std::string TopKLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout; - InferenceEngine::SizeVector inputShape; - std::string targetDevice; - int64_t keepK, axis; - ov::op::v3::TopK::Mode mode; - ov::op::v3::TopK::SortType sort; - std::tie(keepK, axis, mode, sort, netPrecision, inPrc, outPrc, inLayout, inputShape, targetDevice) = obj.param; - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShape) << "_"; - result << "k=" << keepK << "_"; - result << "axis=" << axis << "_"; - result << "mode=" << mode << "_"; - result << "sort=" << sort << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "trgDev=" << targetDevice; - return result.str(); -} - -void TopKLayerTest::SetUp() { - InferenceEngine::SizeVector inputShape; - InferenceEngine::Precision netPrecision; - int64_t keepK, axis; - ov::op::v3::TopK::Mode mode; - ov::op::v3::TopK::SortType sort; - std::tie(keepK, axis, mode, sort, netPrecision, inPrc, outPrc, inLayout, inputShape, targetDevice) = this->GetParam(); - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - - auto k = std::make_shared(ov::element::Type_t::i64, ov::Shape{}, &keepK); - auto topk = std::dynamic_pointer_cast( - std::make_shared(params[0], k, axis, mode, sort)); - - ov::ResultVector results; - for (size_t i = 0; i < topk->get_output_size(); i++) { - results.push_back(std::make_shared(topk->output(i))); - } - function = std::make_shared(results, params, "TopK"); -} - -InferenceEngine::Blob::Ptr TopKLayerTest::GenerateInput(const InferenceEngine::InputInfo &info) const { - IE_ASSERT(InferenceEngine::Precision::FP32 == info.getTensorDesc().getPrecision() - || InferenceEngine::Precision::BF16 == info.getTensorDesc().getPrecision() - || InferenceEngine::Precision::FP16 == info.getTensorDesc().getPrecision()); - - InferenceEngine::Blob::Ptr blob = make_blob_with_precision(info.getTensorDesc()); - blob->allocate(); - - size_t size = blob->size(); - int start = - static_cast(size / 2); - std::vector data(size); - std::iota(data.begin(), data.end(), start); - std::mt19937 gen(0); - std::shuffle(data.begin(), data.end(), gen); - - float divisor = size / 10.0; - if (InferenceEngine::Precision::FP32 == info.getTensorDesc().getPrecision()) { - auto *rawBlobDataPtr = blob->buffer().as(); - for (size_t i = 0; i < size; i++) { - rawBlobDataPtr[i] = static_cast(data[i] / divisor); - } - } else if (InferenceEngine::Precision::BF16 == info.getTensorDesc().getPrecision()) { - auto *rawBlobDataPtr = blob->buffer().as(); - for (size_t i = 0; i < size; i++) { - rawBlobDataPtr[i] = static_cast(data[i] / divisor); - } - } else if (InferenceEngine::Precision::FP16 == info.getTensorDesc().getPrecision()) { - auto* rawBlobDataPtr = blob->buffer().as(); - for (size_t i = 0; i < size; i++) { - rawBlobDataPtr[i] = static_cast(data[i] / divisor); - } - } - - return blob; -} -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/transpose.cpp b/src/tests/functional/shared_test_classes/src/single_layer/transpose.cpp deleted file mode 100644 index 47347234e8c38a..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/transpose.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/transpose.hpp" - -namespace LayerTestsDefinitions { - -std::string TransposeLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - std::vector inputShapes, inputOrder; - std::string targetDevice; - std::tie(inputOrder, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShapes, targetDevice) = obj.param; - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "inputOrder=" << ov::test::utils::vec2str(inputOrder) << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "trgDev=" << targetDevice; - return result.str(); -} - -void TransposeLayerTest::SetUp() { - std::vector inputShape, inputOrder; - InferenceEngine::Precision netPrecision; - std::tie(inputOrder, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, targetDevice) = this->GetParam(); - - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - - const auto inOrderShape = inputOrder.empty() ? ov::Shape({0}) : ov::Shape({inputShape.size()}); - const auto inputOrderOp = std::make_shared(ov::element::i64, - inOrderShape, - inputOrder); - const auto transpose = std::make_shared(params.at(0), inputOrderOp); - const ov::ResultVector results{std::make_shared(transpose)}; - function = std::make_shared(results, params, "Transpose"); -} - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_layer/variadic_split.cpp b/src/tests/functional/shared_test_classes/src/single_layer/variadic_split.cpp deleted file mode 100644 index 4ae365569e4895..00000000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/variadic_split.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/variadic_split.hpp" - -namespace LayerTestsDefinitions { - - std::string VariadicSplitLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - int64_t axis; - std::vector numSplits; - InferenceEngine::Precision netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - InferenceEngine::SizeVector inputShapes; - std::string targetDevice; - std::tie(numSplits, axis, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShapes, targetDevice) = obj.param; - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "numSplits=" << ov::test::utils::vec2str(numSplits) << "_"; - result << "axis=" << axis << "_"; - result << "IS"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "trgDev=" << targetDevice; - return result.str(); - } - - void VariadicSplitLayerTest::SetUp() { - int64_t axis; - std::vector inputShape, numSplits; - InferenceEngine::Precision netPrecision; - std::tie(numSplits, axis, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, targetDevice) = this->GetParam(); - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - - auto split_axis_op = std::make_shared(ov::element::i64, ov::Shape{}, axis); - auto num_split = std::make_shared(ov::element::u64, ov::Shape{numSplits.size()}, numSplits); - auto VariadicSplit = std::make_shared(params[0], split_axis_op, num_split); - - ov::ResultVector results; - for (int i = 0; i < numSplits.size(); i++) { - results.push_back(std::make_shared(VariadicSplit->output(i))); - } - function = std::make_shared(results, params, "VariadicSplit"); - } - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/single_op/activation.cpp b/src/tests/functional/shared_test_classes/src/single_op/activation.cpp index d4f52dfd61fe71..e459d217052cbc 100644 --- a/src/tests/functional/shared_test_classes/src/single_op/activation.cpp +++ b/src/tests/functional/shared_test_classes/src/single_op/activation.cpp @@ -111,7 +111,7 @@ void ActivationLayerTest::generate_inputs(const std::vector& targetIn const auto& funcInputs = function->inputs(); auto funcInput = funcInputs.begin(); inputs.clear(); - runtime::Tensor data_tensor = ov::test::utils::create_and_fill_tensor_act_dft(funcInput->get_element_type(), + Tensor data_tensor = ov::test::utils::create_and_fill_tensor_act_dft(funcInput->get_element_type(), targetInputStaticShapes[0], data_range, data_start_from, @@ -132,7 +132,7 @@ void ActivationParamLayerTest::generate_inputs(const std::vector& tar const auto& funcInputs = function->inputs(); for (size_t i = 0; i < funcInputs.size(); ++i) { const auto& funcInput = funcInputs[i]; - runtime::Tensor data_tensor; + Tensor data_tensor; const std::string& name = funcInput.get_node()->get_friendly_name(); if (0 == name.compare("negativeSlope")) { ov::test::utils::InputGenerateData in_data; diff --git a/src/tests/functional/shared_test_classes/src/single_op/dft.cpp b/src/tests/functional/shared_test_classes/src/single_op/dft.cpp index 654a7185be1431..94a4c6d9f95e97 100644 --- a/src/tests/functional/shared_test_classes/src/single_op/dft.cpp +++ b/src/tests/functional/shared_test_classes/src/single_op/dft.cpp @@ -52,7 +52,7 @@ void DFTLayerTest::generate_inputs(const std::vector& targetInputStat } inputs.clear(); - runtime::Tensor data_tensor = ov::test::utils::create_and_fill_tensor_act_dft(funcInput->get_element_type(), + Tensor data_tensor = ov::test::utils::create_and_fill_tensor_act_dft(funcInput->get_element_type(), targetInputStaticShapes[0], inGenData.range, inGenData.start_from, inGenData.resolution, inGenData.seed); inputs.insert({funcInput->get_node_shared_ptr(), data_tensor}); diff --git a/src/tests/functional/shared_test_classes/src/single_op/generate_proposals.cpp b/src/tests/functional/shared_test_classes/src/single_op/generate_proposals.cpp index 99e49061376d31..5030a1f3dea04f 100644 --- a/src/tests/functional/shared_test_classes/src/single_op/generate_proposals.cpp +++ b/src/tests/functional/shared_test_classes/src/single_op/generate_proposals.cpp @@ -117,17 +117,17 @@ void GenerateProposalsLayerTest::compare(const std::vector& expected const auto outputSize = i == 0 ? 4 : 1; if (outType == ov::element::f32) { - LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), - reinterpret_cast(actualBuffer), - expectedNumRois * outputSize, - rel_threshold, - abs_threshold); + ov::test::utils::compare_raw_data(reinterpret_cast(expectedBuffer), + reinterpret_cast(actualBuffer), + expectedNumRois * outputSize, + rel_threshold, + abs_threshold); } else { - LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(expectedBuffer), - reinterpret_cast(actualBuffer), - expectedNumRois * outputSize, - rel_threshold, - abs_threshold); + ov::test::utils::compare_raw_data(reinterpret_cast(expectedBuffer), + reinterpret_cast(actualBuffer), + expectedNumRois * outputSize, + rel_threshold, + abs_threshold); } if (expectedNumRois < actualNumRois) { diff --git a/src/tests/functional/shared_test_classes/src/single_op/is_inf.cpp b/src/tests/functional/shared_test_classes/src/single_op/is_inf.cpp index 148dc86cdf1250..8a21fee098e555 100644 --- a/src/tests/functional/shared_test_classes/src/single_op/is_inf.cpp +++ b/src/tests/functional/shared_test_classes/src/single_op/is_inf.cpp @@ -13,7 +13,7 @@ std::string IsInfLayerTest::getTestCaseName(const testing::TestParamInfo additional_config; + ov::AnyMap additional_config; std::tie(shapes, detect_negative, detect_positive, model_type, target_name, additional_config) = obj.param; std::ostringstream result; @@ -35,7 +35,7 @@ std::string IsInfLayerTest::getTestCaseName(const testing::TestParamInfo(); } return result.str(); } @@ -44,7 +44,7 @@ void IsInfLayerTest::SetUp() { std::vector shapes; ElementType model_type; bool detect_negative, detect_positive; - std::map additional_config; + ov::AnyMap additional_config; std::tie(shapes, detect_negative, detect_positive, model_type, targetDevice, additional_config) = this->GetParam(); init_input_shapes(shapes); diff --git a/src/tests/functional/shared_test_classes/src/single_op/rdft.cpp b/src/tests/functional/shared_test_classes/src/single_op/rdft.cpp index bbadca390fb492..361845d61ecd79 100644 --- a/src/tests/functional/shared_test_classes/src/single_op/rdft.cpp +++ b/src/tests/functional/shared_test_classes/src/single_op/rdft.cpp @@ -51,7 +51,7 @@ void RDFTLayerTest::generate_inputs(const std::vector& targetInputSta } inputs.clear(); - runtime::Tensor data_tensor = ov::test::utils::create_and_fill_tensor_act_dft(funcInput->get_element_type(), + Tensor data_tensor = ov::test::utils::create_and_fill_tensor_act_dft(funcInput->get_element_type(), targetInputStaticShapes[0], inGenData.range, inGenData.start_from, inGenData.resolution, inGenData.seed); inputs.insert({funcInput->get_node_shared_ptr(), data_tensor}); diff --git a/src/tests/functional/shared_test_classes/src/single_op/topk.cpp b/src/tests/functional/shared_test_classes/src/single_op/topk.cpp index 1d2b323a26f0b9..e42a0d455c3ecd 100644 --- a/src/tests/functional/shared_test_classes/src/single_op/topk.cpp +++ b/src/tests/functional/shared_test_classes/src/single_op/topk.cpp @@ -53,5 +53,54 @@ void TopKLayerTest::SetUp() { auto topk = std::make_shared(param, k, axis, mode, sort); function = std::make_shared(topk->outputs(), ov::ParameterVector{param}, "TopK"); } + +std::string TopK11LayerTest::getTestCaseName(const testing::TestParamInfo& obj) { + ov::element::Type model_type; + std::vector input_shapes; + std::string target_device; + int64_t keepK, axis; + bool stable; + ov::op::v1::TopK::Mode mode; + ov::op::v1::TopK::SortType sort; + std::tie(keepK, axis, mode, sort, model_type, input_shapes, stable, target_device) = obj.param; + std::ostringstream result; + result << "IS=("; + for (size_t i = 0lu; i < input_shapes.size(); i++) { + result << ov::test::utils::partialShape2str({input_shapes[i].first}) + << (i < input_shapes.size() - 1lu ? "_" : ""); + } + result << ")_TS="; + for (size_t i = 0lu; i < input_shapes.front().second.size(); i++) { + result << "{"; + for (size_t j = 0lu; j < input_shapes.size(); j++) { + result << ov::test::utils::vec2str(input_shapes[j].second[i]) << (j < input_shapes.size() - 1lu ? "_" : ""); + } + result << "}_"; + } + result << "k=" << keepK << "_"; + result << "axis=" << axis << "_"; + result << "mode=" << mode << "_"; + result << "sort=" << sort << "_"; + result << "stable=" << stable << "_"; + result << "modelType=" << model_type.to_string() << "_"; + result << "trgDev=" << target_device; + return result.str(); +} + +void TopK11LayerTest::SetUp() { + std::vector input_shapes; + ov::element::Type model_type; + int64_t keepK, axis; + bool stable; + ov::op::v1::TopK::Mode mode; + ov::op::v1::TopK::SortType sort; + std::tie(keepK, axis, mode, sort, model_type, input_shapes, stable, targetDevice) = this->GetParam(); + init_input_shapes(input_shapes); + + auto param = std::make_shared(model_type, inputDynamicShapes.front()); + auto k = std::make_shared(ov::element::i64, ov::Shape{}, &keepK); + auto topk = std::make_shared(param, k, axis, mode, sort, ov::element::i32, stable); + function = std::make_shared(topk->outputs(), ov::ParameterVector{param}, "TopK"); +} } // namespace test } // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/subgraph/memory_LSTMCell.cpp b/src/tests/functional/shared_test_classes/src/subgraph/memory_LSTMCell.cpp index 55ba0da2d18bd0..6533b799add5ed 100644 --- a/src/tests/functional/shared_test_classes/src/subgraph/memory_LSTMCell.cpp +++ b/src/tests/functional/shared_test_classes/src/subgraph/memory_LSTMCell.cpp @@ -6,15 +6,12 @@ #include "common_test_utils/node_builders/constant.hpp" #include "common_test_utils/node_builders/eltwise.hpp" -#include "functional_test_utils/core_config.hpp" #include "common_test_utils/data_utils.hpp" #include "functional_test_utils/skip_tests_config.hpp" #include "openvino/op/util/variable.hpp" #include "openvino/pass/low_latency.hpp" #include "openvino/pass/manager.hpp" -using namespace ngraph; - namespace ov { namespace test { diff --git a/src/tests/functional/shared_test_classes/src/subgraph/mul_conv_fusion.cpp b/src/tests/functional/shared_test_classes/src/subgraph/mul_conv_fusion.cpp index 07f942798669c9..1c053abb5ac314 100644 --- a/src/tests/functional/shared_test_classes/src/subgraph/mul_conv_fusion.cpp +++ b/src/tests/functional/shared_test_classes/src/subgraph/mul_conv_fusion.cpp @@ -94,7 +94,7 @@ void MulConvFusion::SetUp() { ov::op::v0::Constant::create(ov::element::u64, ov::Shape{const_shape.size()}, const_shape), false); weights = std::make_shared(weights, reshape); - weights = ov::get_constant_from_source(weights); + weights = ov::util::get_constant_from_source(weights); ASSERT_NE(nullptr, weights); conv = std::make_shared(param, weights, strides, pad_begin, pad_end, strides); } else if (conv_type == ov::op::v1::ConvolutionBackpropData::get_type_info_static()) { @@ -106,7 +106,7 @@ void MulConvFusion::SetUp() { ov::op::v0::Constant::create(ov::element::u64, ov::Shape{const_shape.size()}, const_shape), false); weights = std::make_shared(weights, reshape); - weights = ov::get_constant_from_source(weights); + weights = ov::util::get_constant_from_source(weights); ASSERT_NE(nullptr, weights); conv = std::make_shared(param, weights, @@ -125,7 +125,7 @@ void MulConvFusion::SetUp() { ov::op::v0::Constant::create(ov::element::u64, ov::Shape{const_shape.size()}, const_shape), false); weights = std::make_shared(weights, reshape); - weights = ov::get_constant_from_source(weights); + weights = ov::util::get_constant_from_source(weights); ASSERT_NE(nullptr, weights); conv = std::make_shared(param, weights, diff --git a/src/tests/functional/shared_test_classes/src/subgraph/quantized_convolution_backprop_data.cpp b/src/tests/functional/shared_test_classes/src/subgraph/quantized_convolution_backprop_data.cpp index 0d3593478e38c0..c300689016458d 100644 --- a/src/tests/functional/shared_test_classes/src/subgraph/quantized_convolution_backprop_data.cpp +++ b/src/tests/functional/shared_test_classes/src/subgraph/quantized_convolution_backprop_data.cpp @@ -6,7 +6,6 @@ #include "common_test_utils/node_builders/convolution_backprop_data.hpp" #include "common_test_utils/node_builders/constant.hpp" #include "ov_models/utils/ov_helpers.hpp" -#include "ie_common.h" #include "common_test_utils/node_builders/fake_quantize.hpp" namespace ov { @@ -48,7 +47,7 @@ void QuantConvBackpropDataLayerTest::SetUp() { ov::element::Type element_type = ov::element::undefined; std::tie(groupConvBackpropDataParams, element_type, inputShape, targetDevice) = this->GetParam(); ov::op::PadType padType; - InferenceEngine::SizeVector kernel, stride, dilation; + std::vector kernel, stride, dilation; std::vector padBegin, padEnd; size_t convOutChannels; size_t quantLevels; diff --git a/src/tests/functional/shared_test_classes/src/subgraph/quantized_convolution_batch_norm.cpp b/src/tests/functional/shared_test_classes/src/subgraph/quantized_convolution_batch_norm.cpp index 684efb24ae38d3..91fbce8c33f1f0 100644 --- a/src/tests/functional/shared_test_classes/src/subgraph/quantized_convolution_batch_norm.cpp +++ b/src/tests/functional/shared_test_classes/src/subgraph/quantized_convolution_batch_norm.cpp @@ -6,6 +6,7 @@ #include "functional_test_utils/skip_tests_config.hpp" #include "openvino/runtime/exec_model_info.hpp" #include "common_test_utils/node_builders/constant.hpp" +#include "validation_util.hpp" namespace ov { namespace test { @@ -140,9 +141,7 @@ void QuantizedConvolutionBatchNorm::SetUp() { auto output_high_weights = ov::op::v0::Constant::create(element::f32, Shape{}, {254}); weights = std::make_shared(weights, low_weights, high_weights, output_low_weights, output_high_weights, 255); weights = std::make_shared(weights, element::i8); - OPENVINO_SUPPRESS_DEPRECATED_START - weights = get_constant_from_source(weights); - OPENVINO_SUPPRESS_DEPRECATED_END + weights = ov::util::get_constant_from_source(weights); weights = std::make_shared(weights, element::f32); auto scale_weights = ov::op::v0::Constant::create(element::f32, weights_intervals_shape, {2.0 / 255.0}); weights = std::make_shared(weights, scale_weights); diff --git a/src/tests/functional/shared_test_classes/src/subgraph/scale_shift.cpp b/src/tests/functional/shared_test_classes/src/subgraph/scale_shift.cpp index 37482b17c5aaea..f90231a4c0bfb7 100644 --- a/src/tests/functional/shared_test_classes/src/subgraph/scale_shift.cpp +++ b/src/tests/functional/shared_test_classes/src/subgraph/scale_shift.cpp @@ -46,39 +46,3 @@ void ScaleShiftLayerTest::SetUp() { } } // namespace test } // namespace ov - -// legacy impl for npu repo -namespace SubgraphTestsDefinitions { - std::string ScaleShiftLayerTest::getTestCaseName(const testing::TestParamInfo &obj) { - std::vector> inputShapes; - InferenceEngine::Precision netPrecision; - std::string targetName; - std::vector scale, shift; - std::tie(inputShapes, netPrecision, targetName, scale, shift) = obj.param; - std::ostringstream results; - - results << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - results << "Scale=" << ov::test::utils::vec2str(scale) << "_"; - results << "Shift=" << ov::test::utils::vec2str(shift) << "_"; - results << "netPRC=" << netPrecision.name() << "_"; - results << "targetDevice=" << targetName << "_"; - return results.str(); - } - - void ScaleShiftLayerTest::SetUp() { - std::vector> inputShapes; - InferenceEngine::Precision netPrecision; - std::vector scale, shift; - std::tie(inputShapes, netPrecision, targetDevice, scale, shift) = this->GetParam(); - auto paramsShape = ov::Shape{1}; - if (inputShapes.size() > 1) - paramsShape = ov::Shape(inputShapes[1]); - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector paramsIn{std::make_shared(ngPrc, ov::Shape(inputShapes[0]))}; - auto mul_const = std::make_shared(ngPrc, paramsShape, scale); - auto mul = std::make_shared(paramsIn[0], mul_const); - auto add_const = std::make_shared(ngPrc, paramsShape, shift); - auto add = std::make_shared(mul, add_const); - function = std::make_shared(add, paramsIn, "scale_shift"); - } -} // namespace SubgraphTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/src/subgraph/split_conv_concat.cpp b/src/tests/functional/shared_test_classes/src/subgraph/split_conv_concat.cpp index 43c939dbc0e3f0..3fecea21d1208a 100644 --- a/src/tests/functional/shared_test_classes/src/subgraph/split_conv_concat.cpp +++ b/src/tests/functional/shared_test_classes/src/subgraph/split_conv_concat.cpp @@ -5,7 +5,6 @@ #include "shared_test_classes/subgraph/split_conv_concat.hpp" #include "common_test_utils/data_utils.hpp" -#include "ie_common.h" #include "shared_test_classes/base/layer_test_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" #include "common_test_utils/node_builders/convolution.hpp" @@ -75,32 +74,3 @@ void SplitConvConcatBase::configure_test(const ov::test::BasicParams& param) { } // namespace test } // namespace ov - -namespace SubgraphTestsDefinitions { - -std::string SplitConvConcat::getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::Precision precision; - InferenceEngine::SizeVector inputShapes; - std::string targetDevice; - std::tie(precision, inputShapes, targetDevice) = obj.param; - auto element_type = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(precision); - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(inputShapes) << "_"; - result << "ET=" << element_type << "_"; - result << "targetDevice=" << targetDevice; - return result.str(); -} - -void SplitConvConcat::SetUp() { - InferenceEngine::Precision precision; - InferenceEngine::SizeVector inputShapes; - std::tie(precision, inputShapes, targetDevice) = this->GetParam(); - auto element_type = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(precision); - ov::Shape shape = inputShapes; - - ov::test::BasicParams param(element_type, shape, targetDevice); - configure_test(param); -} - -} // namespace SubgraphTestsDefinitions diff --git a/src/tests/ov_helpers/ov_lpt_models/include/ov_lpt_models/pad.hpp b/src/tests/ov_helpers/ov_lpt_models/include/ov_lpt_models/pad.hpp index d8159db593f1ca..9e35a2d9acbc78 100644 --- a/src/tests/ov_helpers/ov_lpt_models/include/ov_lpt_models/pad.hpp +++ b/src/tests/ov_helpers/ov_lpt_models/include/ov_lpt_models/pad.hpp @@ -15,23 +15,25 @@ namespace subgraph { class PadFunction { public: - static std::shared_ptr get(const PartialShape& inputShape, - const ov::element::Type precisionBeforeDequantization, - const builder::subgraph::DequantizationOperations& dequantizationBefore, - const std::vector& padsBegin, - const std::vector& padsEnd, - const op::PadMode mode, - const float padValue, - const ov::element::Type precisionAfterOperation, - const builder::subgraph::DequantizationOperations& dequantizationAfter); +static std::shared_ptr get( + const PartialShape& inputShape, + const element::Type precisionBeforeDequantization, + const builder::subgraph::DequantizationOperations& dequantizationBefore, + const std::vector& padsBegin, + const std::vector& padsEnd, + const op::PadMode mode, + const float padValue, + const element::Type precisionAfterOperation, + const builder::subgraph::DequantizationOperations& dequantizationAfter); - static std::shared_ptr get(const PartialShape& inputShape, - const ov::element::Type inputPrecision, - const builder::subgraph::FakeQuantizeOnData& fakeQuantizeOnData, - const std::vector& padsBegin, - const std::vector& padsEnd, - const op::PadMode mode, - const float padValue = 0.f); +static std::shared_ptr get( + const PartialShape& inputShape, + const element::Type inputPrecision, + const builder::subgraph::FakeQuantizeOnData& fakeQuantizeOnData, + const std::vector& padsBegin, + const std::vector& padsEnd, + const op::PadMode mode, + const float padValue = 0.f); }; } // namespace subgraph } // namespace builder diff --git a/src/tests/ov_helpers/ov_lpt_models/src/align_concat_quantization_parameters.cpp b/src/tests/ov_helpers/ov_lpt_models/src/align_concat_quantization_parameters.cpp index f2775cd36de1e4..f71b898c141df1 100644 --- a/src/tests/ov_helpers/ov_lpt_models/src/align_concat_quantization_parameters.cpp +++ b/src/tests/ov_helpers/ov_lpt_models/src/align_concat_quantization_parameters.cpp @@ -35,7 +35,7 @@ std::shared_ptr AlignConcatQuantizationParametersFunction::getOrigina Shape{ 0, 0 }, Shape{ 2, 2 }, true, - op::RoundingType::FLOOR); + ov::op::RoundingType::FLOOR); parent1->set_friendly_name("avgPool1"); if (additionalLayer == "maxpool") { @@ -45,7 +45,7 @@ std::shared_ptr AlignConcatQuantizationParametersFunction::getOrigina Shape{ 1, 1 }, Shape{ 0, 0 }, Shape{ 2, 2 }, - op::RoundingType::FLOOR); + ov::op::RoundingType::FLOOR); parent1->set_friendly_name("maxPool1"); } @@ -68,7 +68,7 @@ std::shared_ptr AlignConcatQuantizationParametersFunction::getOrigina Shape{ 0, 0 }, Shape{ 2, 2 }, true, - op::RoundingType::FLOOR); + ov::op::RoundingType::FLOOR); parent2->set_friendly_name("avgPool2"); if (additionalLayer == "maxpool") { @@ -78,7 +78,7 @@ std::shared_ptr AlignConcatQuantizationParametersFunction::getOrigina Shape{ 1, 1 }, Shape{ 0, 0 }, Shape{ 2, 2 }, - op::RoundingType::FLOOR); + ov::op::RoundingType::FLOOR); parent2->set_friendly_name("maxPool2"); } @@ -148,7 +148,7 @@ std::shared_ptr AlignConcatQuantizationParametersFunction::getReferen Shape{ 0, 0 }, Shape{ 2, 2 }, true, - op::RoundingType::FLOOR); + ov::op::RoundingType::FLOOR); parent1->set_friendly_name("avgPool1"); if (additionalLayer == "maxpool") { @@ -158,7 +158,7 @@ std::shared_ptr AlignConcatQuantizationParametersFunction::getReferen Shape{ 1, 1 }, Shape{ 0, 0 }, Shape{ 2, 2 }, - op::RoundingType::FLOOR); + ov::op::RoundingType::FLOOR); parent1->set_friendly_name("maxPool1"); } @@ -183,7 +183,7 @@ std::shared_ptr AlignConcatQuantizationParametersFunction::getReferen Shape{ 0, 0 }, Shape{ 2, 2 }, true, - op::RoundingType::FLOOR); + ov::op::RoundingType::FLOOR); parent2->set_friendly_name("avgPool2"); if (additionalLayer == "maxpool") { @@ -193,7 +193,7 @@ std::shared_ptr AlignConcatQuantizationParametersFunction::getReferen Shape{ 1, 1 }, Shape{ 0, 0 }, Shape{ 2, 2 }, - op::RoundingType::FLOOR); + ov::op::RoundingType::FLOOR); parent2->set_friendly_name("maxPool2"); } diff --git a/src/tests/ov_helpers/ov_lpt_models/src/avg_pool.cpp b/src/tests/ov_helpers/ov_lpt_models/src/avg_pool.cpp index 0f181149260f1e..316b5ddd3ccbc4 100644 --- a/src/tests/ov_helpers/ov_lpt_models/src/avg_pool.cpp +++ b/src/tests/ov_helpers/ov_lpt_models/src/avg_pool.cpp @@ -29,25 +29,23 @@ std::shared_ptr AvgPoolFunction::getOriginal( deqBeforeStructure.multiply.outPrecision = precision; const auto dequantization = makeDequantization(input, deqBeforeStructure); - const std::shared_ptr avgPool = std::make_shared( - dequantization, - Strides{ 1, 1 }, - Shape{ 1, 1 }, - Shape{ 0, 0 }, - Shape{ 2, 2 }, - true, - op::RoundingType::FLOOR); + const std::shared_ptr avgPool = std::make_shared(dequantization, + Strides{1, 1}, + Shape{1, 1}, + Shape{0, 0}, + Shape{2, 2}, + true, + ov::op::RoundingType::FLOOR); std::shared_ptr lastLayer = avgPool; for (const std::string& additionalLayer : additionalLayers) { if (additionalLayer == "maxpool") { - lastLayer = std::make_shared( - lastLayer, - Strides{ 1, 1 }, - Shape{ 1, 1 }, - Shape{ 0, 0 }, - Shape{ 2, 2 }, - op::RoundingType::FLOOR); + lastLayer = std::make_shared(lastLayer, + Strides{1, 1}, + Shape{1, 1}, + Shape{0, 0}, + Shape{2, 2}, + ov::op::RoundingType::FLOOR); } else if (additionalLayer == "softmax") { lastLayer = std::make_shared(lastLayer); } else if (additionalLayer == "convolution") { @@ -78,14 +76,13 @@ std::shared_ptr AvgPoolFunction::getOriginal( input, originalFunctionPrecision, fakeQuantizeOnData.quantizationLevel, fakeQuantizeOnData.constantShape, fakeQuantizeOnData.inputLowValues, fakeQuantizeOnData.inputHighValues, fakeQuantizeOnData.outputLowValues, fakeQuantizeOnData.outputHighValues); - const std::shared_ptr avgPool = std::make_shared( - fakeQuantize, - Strides{ 1, 1 }, - Shape{ 1, 1 }, - Shape{ 0, 0 }, - Shape{ 2, 2 }, - true, - op::RoundingType::FLOOR); + const std::shared_ptr avgPool = std::make_shared(fakeQuantize, + Strides{1, 1}, + Shape{1, 1}, + Shape{0, 0}, + Shape{2, 2}, + true, + ov::op::RoundingType::FLOOR); ov::ResultVector results{ std::make_shared(avgPool) }; return std::make_shared(results, ov::ParameterVector{ input }, "AvgPoolTransformation"); @@ -105,16 +102,15 @@ std::shared_ptr AvgPoolFunction::getReference( const auto deqBefore = makeDequantization(input, dequantizationBefore); auto outPrecision = precisionAfterOperation; - const std::shared_ptr avgPool = std::make_shared>( - ov::opset1::AvgPool( - deqBefore, - Strides{ 1, 1 }, - Shape{ 1, 1 }, - Shape{ 0, 0 }, - Shape{ 2, 2 }, - true, - op::RoundingType::FLOOR), - outPrecision); + const std::shared_ptr avgPool = + std::make_shared>(ov::opset1::AvgPool(deqBefore, + Strides{1, 1}, + Shape{1, 1}, + Shape{0, 0}, + Shape{2, 2}, + true, + ov::op::RoundingType::FLOOR), + outPrecision); std::shared_ptr lastLayer = avgPool; @@ -124,13 +120,12 @@ std::shared_ptr AvgPoolFunction::getReference( for (const std::string& additionalLayer : additionalLayers) { if (additionalLayer == "maxpool") { - lastLayer = std::make_shared( - lastLayer, - Strides{ 1, 1 }, - Shape{ 1, 1 }, - Shape{ 0, 0 }, - Shape{ 2, 2 }, - op::RoundingType::FLOOR); + lastLayer = std::make_shared(lastLayer, + Strides{1, 1}, + Shape{1, 1}, + Shape{0, 0}, + Shape{2, 2}, + ov::op::RoundingType::FLOOR); } else if (additionalLayer == "softmax") { lastLayer = std::make_shared(lastLayer); } else if (additionalLayer == "convolution") { diff --git a/src/tests/ov_helpers/ov_lpt_models/src/concat.cpp b/src/tests/ov_helpers/ov_lpt_models/src/concat.cpp index deba0f611b7947..01ae0ff88b4f06 100644 --- a/src/tests/ov_helpers/ov_lpt_models/src/concat.cpp +++ b/src/tests/ov_helpers/ov_lpt_models/src/concat.cpp @@ -392,14 +392,13 @@ std::shared_ptr ConcatFunction::getOriginalWithIntermediateAvgPool( auto& rtInfo = concat->get_rt_info(); rtInfo["Variant::std::string"] = "concat"; - std::shared_ptr parent2 = std::make_shared( - intermediateOp, - Strides{ 1, 1 }, - Shape{ 1, 1 }, - Shape{ 0, 0 }, - Shape{ 2, 2 }, - true, - op::RoundingType::FLOOR); + std::shared_ptr parent2 = std::make_shared(intermediateOp, + Strides{1, 1}, + Shape{1, 1}, + Shape{0, 0}, + Shape{2, 2}, + true, + ov::op::RoundingType::FLOOR); parent2->set_friendly_name("avgPool"); ov::ResultVector results { @@ -1003,14 +1002,13 @@ std::shared_ptr ConcatFunction::get( std::shared_ptr parent = lastDequantization; if (addNotPrecisionPreservedOperation) { - auto avgPool = std::make_shared( - lastDequantization, - Strides{1, 1}, - Shape{1, 1}, - Shape{1, 1}, - Shape{2, 2}, - true, - op::RoundingType::FLOOR); + auto avgPool = std::make_shared(lastDequantization, + Strides{1, 1}, + Shape{1, 1}, + Shape{1, 1}, + Shape{2, 2}, + true, + ov::op::RoundingType::FLOOR); parent = avgPool; } @@ -1055,13 +1053,12 @@ std::shared_ptr ConcatFunction::get( intermediateShape), true); - const auto maxPool = std::make_shared( - reshape1, - Strides{ 1, 1 }, - Shape{ 1, 1 }, - Shape{ 0, 0 }, - Shape{ 2, 2 }, - op::RoundingType::FLOOR); + const auto maxPool = std::make_shared(reshape1, + Strides{1, 1}, + Shape{1, 1}, + Shape{0, 0}, + Shape{2, 2}, + ov::op::RoundingType::FLOOR); const auto reshape2 = std::make_shared( maxPool, @@ -1132,14 +1129,13 @@ std::shared_ptr ConcatFunction::get( } if (addNotPrecisionPreservedOperation) { - auto avgPool = std::make_shared( - parent, - Strides{1, 1}, - Shape{1, 1}, - Shape{1, 1}, - Shape{2, 2}, - true, - op::RoundingType::FLOOR); + auto avgPool = std::make_shared(parent, + Strides{1, 1}, + Shape{1, 1}, + Shape{1, 1}, + Shape{2, 2}, + true, + ov::op::RoundingType::FLOOR); parent = avgPool; } parent->set_friendly_name("output"); @@ -1434,9 +1430,9 @@ std::shared_ptr ConcatFunction::getReferenceWithIntermediateAvgPool( parent1->set_friendly_name("concat"); std::shared_ptr parent2 = std::make_shared>( - std::vector{ov::element::f32, ov::element::f32}, - std::vector{ov::element::f32}, - ov::op::TemporaryReplaceOutputType(intermediateOp, ov::element::f32).get(), + std::vector{element::f32, element::f32}, + std::vector{element::f32}, + ov::op::TemporaryReplaceOutputType(intermediateOp, element::f32).get(), Strides{1, 1}, Shape{1, 1}, Shape{0, 0}, diff --git a/src/tests/ov_helpers/ov_lpt_models/src/convolution_backprop_data.cpp b/src/tests/ov_helpers/ov_lpt_models/src/convolution_backprop_data.cpp index 1a788e24401aa6..65f8e71364acc4 100644 --- a/src/tests/ov_helpers/ov_lpt_models/src/convolution_backprop_data.cpp +++ b/src/tests/ov_helpers/ov_lpt_models/src/convolution_backprop_data.cpp @@ -38,7 +38,7 @@ std::shared_ptr ConvolutionBackpropDataFunction::get(const ov::elemen convolutionBackpropData->set_friendly_name("convolutionBackpropData"); ov::ResultVector results{ std::make_shared(convolutionBackpropData) }; - return std::make_shared(results, ParameterVector{ input }, "ConvolutionBackpropDataTransformation"); + return std::make_shared(results, ov::ParameterVector{ input }, "ConvolutionBackpropDataTransformation"); } std::shared_ptr ConvolutionBackpropDataFunction::getWeights( @@ -124,7 +124,7 @@ std::shared_ptr ConvolutionBackpropDataFunction::getOriginal( convolutionBackpropData->set_friendly_name("output"); ov::ResultVector results{ std::make_shared(convolutionBackpropData) }; - return std::make_shared(results, ParameterVector{ input }, "ConvolutionBackpropDataTransformation"); + return std::make_shared(results, ov::ParameterVector{ input }, "ConvolutionBackpropDataTransformation"); } std::shared_ptr ConvolutionBackpropDataFunction::getReference( @@ -155,7 +155,7 @@ std::shared_ptr ConvolutionBackpropDataFunction::getReference( const auto result = makeDequantization(convolutionBackpropData, dequantizationStructureAfter); result->set_friendly_name("output"); ov::ResultVector results{ std::make_shared(result) }; - return std::make_shared(results, ParameterVector{ input }, "ConvolutionBackpropDataTransformation"); + return std::make_shared(results, ov::ParameterVector{ input }, "ConvolutionBackpropDataTransformation"); } } // namespace subgraph diff --git a/src/tests/ov_helpers/ov_lpt_models/src/elementwise.cpp b/src/tests/ov_helpers/ov_lpt_models/src/elementwise.cpp index 29cf2813869e01..9ce22a37c02cc5 100644 --- a/src/tests/ov_helpers/ov_lpt_models/src/elementwise.cpp +++ b/src/tests/ov_helpers/ov_lpt_models/src/elementwise.cpp @@ -97,13 +97,12 @@ std::shared_ptr ElementwiseFunction::getOriginalSubgraphWithConvoluti result = makeFakeQuantizeWithNames(result, precision, fqOnDataAfter, "fakeQuantizeAfter"); // we need a some operation to move dequantization operations away from FakeQuantize to avoid cleanup fuse - result = std::make_shared( - result, - Strides{ 1, 1 }, - Shape{ 1, 1 }, - Shape{ 0, 0 }, - Shape{ 2, 2 }, - op::RoundingType::FLOOR); + result = std::make_shared(result, + Strides{1, 1}, + Shape{1, 1}, + Shape{0, 0}, + Shape{2, 2}, + ov::op::RoundingType::FLOOR); result->set_friendly_name("maxPool"); } diff --git a/src/tests/ov_helpers/ov_lpt_models/src/fake_quantize.cpp b/src/tests/ov_helpers/ov_lpt_models/src/fake_quantize.cpp index 875423b4b9c71c..988ac2a025d279 100644 --- a/src/tests/ov_helpers/ov_lpt_models/src/fake_quantize.cpp +++ b/src/tests/ov_helpers/ov_lpt_models/src/fake_quantize.cpp @@ -64,14 +64,13 @@ std::shared_ptr FakeQuantizeFunction::getOriginal( std::shared_ptr lastOperation = fakeQuantize; if (addNotPrecisionPreservedOperation) { - lastOperation = std::make_shared( - fakeQuantize, - Strides{ 1, 1 }, - Shape{ 1, 1 }, - Shape{ 1, 1 }, - Shape{ 2, 2 }, - true, - op::RoundingType::FLOOR); + lastOperation = std::make_shared(fakeQuantize, + Strides{1, 1}, + Shape{1, 1}, + Shape{1, 1}, + Shape{2, 2}, + true, + ov::op::RoundingType::FLOOR); } lastOperation->set_friendly_name("lastOperation"); @@ -99,9 +98,9 @@ std::shared_ptr FakeQuantizeFunction::getReference( std::shared_ptr lastOperation = fakeQuantize; if (addNotPrecisionPreservedOperation) { lastOperation = std::make_shared>( - std::vector{ov::element::f32}, - std::vector{ov::element::f32}, - ov::op::TemporaryReplaceOutputType(fakeQuantize, ov::element::f32).get(), + std::vector{element::f32}, + std::vector{element::f32}, + ov::op::TemporaryReplaceOutputType(fakeQuantize, element::f32).get(), Strides{1, 1}, Shape{1, 1}, Shape{1, 1}, diff --git a/src/tests/ov_helpers/ov_lpt_models/src/fake_quantize_and_convolution.cpp b/src/tests/ov_helpers/ov_lpt_models/src/fake_quantize_and_convolution.cpp index 98600ef160df90..dba21a3a6b48b6 100644 --- a/src/tests/ov_helpers/ov_lpt_models/src/fake_quantize_and_convolution.cpp +++ b/src/tests/ov_helpers/ov_lpt_models/src/fake_quantize_and_convolution.cpp @@ -40,13 +40,12 @@ std::shared_ptr FakeQuantizeAndConvolutionFunction::get( (ov::Shape{ outputChannelsCount, inputChannelsCount, 1, 1 }), std::vector(outputChannelsCount * inputChannelsCount, 1)); - auto maxPool = std::make_shared( - fqOnData.empty() ? input : fakeQuantizeOnActivations, - Strides(rankLength - 2, 1ul), - Shape(rankLength - 2, 1ul), - Shape(rankLength - 2, 0ul), - Shape(rankLength - 2, 2ul), - op::RoundingType::FLOOR); + auto maxPool = std::make_shared(fqOnData.empty() ? input : fakeQuantizeOnActivations, + Strides(rankLength - 2, 1ul), + Shape(rankLength - 2, 1ul), + Shape(rankLength - 2, 0ul), + Shape(rankLength - 2, 2ul), + ov::op::RoundingType::FLOOR); maxPool->set_friendly_name("maxPool"); const auto convolution = std::make_shared( diff --git a/src/tests/ov_helpers/ov_lpt_models/src/fake_quantize_precision_selection.cpp b/src/tests/ov_helpers/ov_lpt_models/src/fake_quantize_precision_selection.cpp index 06f06e8a887a93..a8ebcfc9c8f66f 100644 --- a/src/tests/ov_helpers/ov_lpt_models/src/fake_quantize_precision_selection.cpp +++ b/src/tests/ov_helpers/ov_lpt_models/src/fake_quantize_precision_selection.cpp @@ -39,17 +39,18 @@ std::shared_ptr FakeQuantizePrecisionSelectionFunction::getOriginal( // branch with limitation precision operation (Convolution) std::shared_ptr branch1Operation = values.operationBeforeLimitedOperationIsPrecisionTransparent - ? std::dynamic_pointer_cast(std::make_shared(fakeQuantize, - Strides{1, 1}, - Shape{1, 1}, - Shape{0, 0}, - Shape{2, 2}, - op::RoundingType::FLOOR)) + ? std::dynamic_pointer_cast( + std::make_shared(fakeQuantize, + Strides{1, 1}, + Shape{1, 1}, + Shape{0, 0}, + Shape{2, 2}, + op::RoundingType::FLOOR)) : std::make_shared>( ov::opset1::PRelu( fakeQuantize, - std::make_shared(ov::element::f32, Shape{}, std::vector{0.01})), - ov::element::f32); + std::make_shared(element::f32, Shape{}, std::vector{0.01})), + element::f32); const size_t inputChannelsCount = inputShape[1].get_length(); const size_t outputChannelsCount = 2 * inputShape[1].get_length(); @@ -122,7 +123,7 @@ std::shared_ptr FakeQuantizePrecisionSelectionFunction::getReference( op::RoundingType::FLOOR)) : std::make_shared>( fakeQuantize, - std::make_shared(ov::element::f32, Shape{}, std::vector{0.01})); + std::make_shared(element::f32, Shape{}, std::vector{0.01})); const size_t inputChannelsCount = inputShape[1]; const size_t outputChannelsCount = 2 * inputShape[1]; diff --git a/src/tests/ov_helpers/ov_lpt_models/src/markup_avg_pool_precisions.cpp b/src/tests/ov_helpers/ov_lpt_models/src/markup_avg_pool_precisions.cpp index 15eeef441fd074..3b0bbe0c45ab6f 100644 --- a/src/tests/ov_helpers/ov_lpt_models/src/markup_avg_pool_precisions.cpp +++ b/src/tests/ov_helpers/ov_lpt_models/src/markup_avg_pool_precisions.cpp @@ -73,16 +73,16 @@ std::shared_ptr MarkupAvgPoolPrecisionsFunction::getOriginal( auto newParent = ov::test::utils::make_fake_quantize(parent, precision, 256, {}, { -1.28 }, { 1.27 }, { -1.28 }, { 1.27 }); newParent->set_friendly_name("fakeQuantizeOnActivations"); - //if (additionalLayer == "maxpool") { - // newParent = std::make_shared( - // newParent, - // Strides{ 1, 1 }, - // Shape{ 1, 1 }, - // Shape{ 0, 0 }, - // Shape{ 2, 2 }, - // op::RoundingType::FLOOR); - // newParent->set_friendly_name("maxPool1"); - //} + // if (additionalLayer == "maxpool") { + // newParent = std::make_shared( + // newParent, + // Strides{ 1, 1 }, + // Shape{ 1, 1 }, + // Shape{ 0, 0 }, + // Shape{ 2, 2 }, + // ov::op::RoundingType::FLOOR); + // newParent->set_friendly_name("maxPool1"); + // } return newParent; }; input1 = std::make_shared(inputPrecision, ov::Shape(inputShape)); @@ -95,26 +95,38 @@ std::shared_ptr MarkupAvgPoolPrecisionsFunction::getOriginal( parent = parent1; } - parent = std::make_shared( - parent, - Strides{ 1, 1 }, - Shape{ 1, 1 }, - Shape{ 0, 0 }, - Shape{ 2, 2 }, - true, - op::RoundingType::FLOOR); + parent = std::make_shared(parent, + Strides{1, 1}, + Shape{1, 1}, + Shape{0, 0}, + Shape{2, 2}, + true, + ov::op::RoundingType::FLOOR); parent->set_friendly_name("avgPool"); if (additionalLayer == "maxpool") { - parent = std::make_shared(parent, Strides{ 1, 1 }, Shape{ 1, 1 }, Shape{ 0, 0 }, Shape{ 2, 2 }, op::RoundingType::FLOOR); + parent = std::make_shared(parent, + Strides{1, 1}, + Shape{1, 1}, + Shape{0, 0}, + Shape{2, 2}, + ov::op::RoundingType::FLOOR); parent->set_friendly_name("maxPool2"); } - std::shared_ptr parent1 = std::make_shared( - parent, Strides{ 1, 1 }, Shape{ 1, 1 }, Shape{ 0, 0 }, Shape{ 2, 2 }, op::RoundingType::FLOOR); + std::shared_ptr parent1 = std::make_shared(parent, + Strides{1, 1}, + Shape{1, 1}, + Shape{0, 0}, + Shape{2, 2}, + ov::op::RoundingType::FLOOR); - std::shared_ptr parent2 = std::make_shared( - parent, Strides{ 1, 1 }, Shape{ 1, 1 }, Shape{ 0, 0 }, Shape{ 2, 2 }, op::RoundingType::FLOOR); + std::shared_ptr parent2 = std::make_shared(parent, + Strides{1, 1}, + Shape{1, 1}, + Shape{0, 0}, + Shape{2, 2}, + ov::op::RoundingType::FLOOR); //if (addFQ) { // parent1 = ov::test::utils::make_fake_quantize(parent1, precision, 256, {}, { 0 }, { 255 }, { 0 }, { 255 }); @@ -167,14 +179,13 @@ std::shared_ptr MarkupAvgPoolPrecisionsFunction::getOriginal( input, originalFunctionPrecision, fakeQuantizeOnData.quantizationLevel, fakeQuantizeOnData.constantShape, fakeQuantizeOnData.inputLowValues, fakeQuantizeOnData.inputHighValues, fakeQuantizeOnData.outputLowValues, fakeQuantizeOnData.outputHighValues); - const std::shared_ptr avgPool = std::make_shared( - fakeQuantize, - Strides{ 1, 1 }, - Shape{ 1, 1 }, - Shape{ 0, 0 }, - Shape{ 2, 2 }, - true, - op::RoundingType::FLOOR); + const std::shared_ptr avgPool = std::make_shared(fakeQuantize, + Strides{1, 1}, + Shape{1, 1}, + Shape{0, 0}, + Shape{2, 2}, + true, + ov::op::RoundingType::FLOOR); ov::ResultVector results{ std::make_shared(avgPool) }; return std::make_shared(results, ov::ParameterVector{ input }, "MarkupAvgPoolPrecisions"); @@ -193,26 +204,24 @@ std::shared_ptr MarkupAvgPoolPrecisionsFunction::getReference( const auto deqBefore = makeDequantization(input, dequantizationBefore); auto outPrecision = precisionAfterOperation; - const std::shared_ptr avgPool = std::make_shared>( - ov::opset1::AvgPool( - deqBefore, - Strides{ 1, 1 }, - Shape{ 1, 1 }, - Shape{ 0, 0 }, - Shape{ 2, 2 }, - true, - op::RoundingType::FLOOR), - outPrecision); + const std::shared_ptr avgPool = + std::make_shared>(ov::opset1::AvgPool(deqBefore, + Strides{1, 1}, + Shape{1, 1}, + Shape{0, 0}, + Shape{2, 2}, + true, + ov::op::RoundingType::FLOOR), + outPrecision); std::shared_ptr lastLayer = avgPool; if (additionalLayer == "maxpool") { - lastLayer = std::make_shared( - lastLayer, - Strides{ 1, 1 }, - Shape{ 1, 1 }, - Shape{ 0, 0 }, - Shape{ 2, 2 }, - op::RoundingType::FLOOR); + lastLayer = std::make_shared(lastLayer, + Strides{1, 1}, + Shape{1, 1}, + Shape{0, 0}, + Shape{2, 2}, + ov::op::RoundingType::FLOOR); } auto deqAfterStructure = dequantizationAfter; deqAfterStructure.multiply.outPrecision = precision; diff --git a/src/tests/ov_helpers/ov_lpt_models/src/max_pool.cpp b/src/tests/ov_helpers/ov_lpt_models/src/max_pool.cpp index 8b7dfc7ab8e229..dc57b822b29f1b 100644 --- a/src/tests/ov_helpers/ov_lpt_models/src/max_pool.cpp +++ b/src/tests/ov_helpers/ov_lpt_models/src/max_pool.cpp @@ -24,13 +24,12 @@ std::shared_ptr MaxPoolFunction::getOriginal( input, originalFunctionPrecision, fakeQuantizeOnData.quantizationLevel, fakeQuantizeOnData.constantShape, fakeQuantizeOnData.inputLowValues, fakeQuantizeOnData.inputHighValues, fakeQuantizeOnData.outputLowValues, fakeQuantizeOnData.outputHighValues); - const std::shared_ptr maxPool = std::make_shared( - fakeQuantize, - Strides{ 1, 1 }, - Shape{ 1, 1 }, - Shape{ 0, 0 }, - Shape{ 2, 2 }, - op::RoundingType::FLOOR); + const std::shared_ptr maxPool = std::make_shared(fakeQuantize, + Strides{1, 1}, + Shape{1, 1}, + Shape{0, 0}, + Shape{2, 2}, + ov::op::RoundingType::FLOOR); ov::ResultVector results{ std::make_shared(maxPool) }; return std::make_shared(results, ov::ParameterVector{ input }, "MaxPoolTransformation"); @@ -47,13 +46,12 @@ std::shared_ptr MaxPoolFunction::get( parent = makeDequantization(parent, dequantizationBefore); - const auto maxPool = std::make_shared( - parent, - Strides{ 1, 1 }, - Shape{ 1, 1 }, - Shape{ 0, 0 }, - Shape{ 2, 2 }, - op::RoundingType::FLOOR); + const auto maxPool = std::make_shared(parent, + Strides{1, 1}, + Shape{1, 1}, + Shape{0, 0}, + Shape{2, 2}, + ov::op::RoundingType::FLOOR); parent = maxPool; ov::pass::low_precision::NetworkHelper::setOutDataPrecision(maxPool, precisionAfterOperation); diff --git a/src/tests/ov_helpers/ov_lpt_models/src/move_dequantization_after.cpp b/src/tests/ov_helpers/ov_lpt_models/src/move_dequantization_after.cpp index a15dbfe137c46a..ba01fe7d965261 100644 --- a/src/tests/ov_helpers/ov_lpt_models/src/move_dequantization_after.cpp +++ b/src/tests/ov_helpers/ov_lpt_models/src/move_dequantization_after.cpp @@ -20,13 +20,8 @@ namespace subgraph { const auto input = std::make_shared(precision, inputShape); const auto deq = makeDequantization(input, dequantization); - const auto op = ov::opset1::MaxPool( - deq, - Strides{ 1, 1 }, - Shape{ 1, 1 }, - Shape{ 0, 0 }, - Shape{ 2, 2 }, - op::RoundingType::FLOOR); + const auto op = + ov::opset1::MaxPool(deq, Strides{1, 1}, Shape{1, 1}, Shape{0, 0}, Shape{2, 2}, ov::op::RoundingType::FLOOR); const auto targetOp = std::make_shared>( op, std::vector{ov::element::f32, ov::element::f32}, @@ -49,13 +44,12 @@ namespace subgraph { const auto input = std::make_shared(precision, inputShape); const auto deqBefore = makeDequantization(input, dequantizationBefore); - const auto op = ov::opset1::MaxPool( - deqBefore, - Strides{ 1, 1 }, - Shape{ 1, 1 }, - Shape{ 0, 0 }, - Shape{ 2, 2 }, - op::RoundingType::FLOOR); + const auto op = ov::opset1::MaxPool(deqBefore, + Strides{1, 1}, + Shape{1, 1}, + Shape{0, 0}, + Shape{2, 2}, + ov::op::RoundingType::FLOOR); const auto targetOp = std::make_shared>( op, std::vector{ov::element::f32, ov::element::f32}, diff --git a/src/tests/ov_helpers/ov_lpt_models/src/mvn.cpp b/src/tests/ov_helpers/ov_lpt_models/src/mvn.cpp index 885fea1a35e7e6..dec78ae31e08e5 100644 --- a/src/tests/ov_helpers/ov_lpt_models/src/mvn.cpp +++ b/src/tests/ov_helpers/ov_lpt_models/src/mvn.cpp @@ -15,7 +15,7 @@ namespace subgraph { std::shared_ptr MVNFunction::getOriginal( const ov::element::Type precision, const ov::PartialShape& inputShape, - const AxisSet& reductionAxes, + const ov::AxisSet& reductionAxes, const bool& normalizeVariance, const ov::element::Type precisionBeforeDequantization, const ov::builder::subgraph::DequantizationOperations& dequantization, @@ -47,7 +47,7 @@ std::shared_ptr MVNFunction::getOriginal( std::shared_ptr MVNFunction::getOriginal( const ov::element::Type precision, const ov::PartialShape& inputShape, - const AxisSet& reductionAxes, + const ov::AxisSet& reductionAxes, const bool& normalizeVariance) { float k = 50.f; @@ -64,7 +64,7 @@ std::shared_ptr MVNFunction::getOriginal( std::shared_ptr MVNFunction::getReference( const ov::element::Type precision, const ov::PartialShape& inputShape, - const AxisSet& reductionAxes, + const ov::AxisSet& reductionAxes, const bool& normalizeVariance, const ov::element::Type precisionBeforeDequantization, const ov::builder::subgraph::DequantizationOperations& dequantizationBefore, diff --git a/src/tests/ov_helpers/ov_lpt_models/src/normalize_dequantization.cpp b/src/tests/ov_helpers/ov_lpt_models/src/normalize_dequantization.cpp index 498174f6455194..81172744f25edd 100644 --- a/src/tests/ov_helpers/ov_lpt_models/src/normalize_dequantization.cpp +++ b/src/tests/ov_helpers/ov_lpt_models/src/normalize_dequantization.cpp @@ -19,13 +19,8 @@ namespace subgraph { const auto deq = makeDequantization(input, dequantization); - const auto op = ov::opset1::MaxPool( - deq, - Strides{ 1, 1 }, - Shape{ 1, 1 }, - Shape{ 0, 0 }, - Shape{ 2, 2 }, - op::RoundingType::FLOOR); + const auto op = + ov::opset1::MaxPool(deq, Strides{1, 1}, Shape{1, 1}, Shape{0, 0}, Shape{2, 2}, ov::op::RoundingType::FLOOR); const auto targetOp = std::make_shared>( op, std::vector{ov::element::f32, ov::element::f32}, diff --git a/src/tests/ov_helpers/ov_lpt_models/src/pad.cpp b/src/tests/ov_helpers/ov_lpt_models/src/pad.cpp index 72972ba3bb8813..ba5da044747d81 100644 --- a/src/tests/ov_helpers/ov_lpt_models/src/pad.cpp +++ b/src/tests/ov_helpers/ov_lpt_models/src/pad.cpp @@ -14,13 +14,13 @@ namespace ov { namespace builder { namespace subgraph { std::shared_ptr PadFunction::get(const PartialShape& inputShape, - const ov::element::Type precisionBeforeDequantization, + const element::Type precisionBeforeDequantization, const builder::subgraph::DequantizationOperations& dequantizationBefore, const std::vector& padsBegin, const std::vector& padsEnd, const op::PadMode mode, const float padValue, - const ov::element::Type precisionAfterOperation, + const element::Type precisionAfterOperation, const builder::subgraph::DequantizationOperations& dequantizationAfter) { const auto input = std::make_shared(precisionBeforeDequantization, inputShape); const auto deqBefore = makeDequantization(input, dequantizationBefore); @@ -52,7 +52,7 @@ std::shared_ptr PadFunction::get(const PartialShape& inputShape, } std::shared_ptr PadFunction::get(const PartialShape& inputShape, - const ov::element::Type inputPrecision, + const element::Type inputPrecision, const builder::subgraph::FakeQuantizeOnData& fakeQuantize, const std::vector& padsBegin, const std::vector& padsEnd, @@ -67,9 +67,9 @@ std::shared_ptr PadFunction::get(const PartialShape& inputShape, const auto pad = std::make_shared(fqOnData, padsBeginConst, padsEndConst, padsValueConst, mode); pad->set_friendly_name("Pad"); - const auto function = std::make_shared( - ResultVector{ std::make_shared(pad) }, - ParameterVector{ input }, "PadTransformation"); + const auto function = std::make_shared(ResultVector{std::make_shared(pad)}, + ov::ParameterVector{input}, + "PadTransformation"); return function; } diff --git a/src/tests/ov_helpers/ov_lpt_models/src/recurrent_cell.cpp b/src/tests/ov_helpers/ov_lpt_models/src/recurrent_cell.cpp index dd04f421287e6f..7be3fca1217403 100644 --- a/src/tests/ov_helpers/ov_lpt_models/src/recurrent_cell.cpp +++ b/src/tests/ov_helpers/ov_lpt_models/src/recurrent_cell.cpp @@ -83,7 +83,7 @@ std::shared_ptr RecurrentCellFunction::get( parent_R, B, 128, - op::RecurrentSequenceDirection::FORWARD); + ov::op::RecurrentSequenceDirection::FORWARD); rnn_layer->set_friendly_name("lstm_sequense"); break; case RNNType::GRUSequence: @@ -94,7 +94,7 @@ std::shared_ptr RecurrentCellFunction::get( parent_R, B, 3, - op::RecurrentSequenceDirection::FORWARD); + ov::op::RecurrentSequenceDirection::FORWARD); rnn_layer->set_friendly_name("gru_sequence"); break; default: diff --git a/src/tests/ov_helpers/ov_lpt_models/src/shuffle_channels.cpp b/src/tests/ov_helpers/ov_lpt_models/src/shuffle_channels.cpp index 6baebfc4ebc9f0..04878943c174d3 100644 --- a/src/tests/ov_helpers/ov_lpt_models/src/shuffle_channels.cpp +++ b/src/tests/ov_helpers/ov_lpt_models/src/shuffle_channels.cpp @@ -24,10 +24,10 @@ std::shared_ptr ShuffleChannelsFunction::getOriginal( const auto shuffleChannels = std::make_shared(dequantization, axis, group); shuffleChannels->set_friendly_name("output"); - const auto function = std::make_shared( - ResultVector{ std::make_shared(shuffleChannels) }, - ParameterVector{ input }, - "ShuffleChannelsFunction"); + const auto function = + std::make_shared(ResultVector{std::make_shared(shuffleChannels)}, + ov::ParameterVector{input}, + "ShuffleChannelsFunction"); return function; } @@ -44,10 +44,10 @@ std::shared_ptr ShuffleChannelsFunction::getOriginal( const auto shuffleChannels = std::make_shared(fakeQuantize, axis, group); shuffleChannels->set_friendly_name("output"); - const auto function = std::make_shared( - ResultVector{ std::make_shared(shuffleChannels) }, - ParameterVector{ input }, - "ShuffleChannelsFunction"); + const auto function = + std::make_shared(ResultVector{std::make_shared(shuffleChannels)}, + ov::ParameterVector{input}, + "ShuffleChannelsFunction"); return function; } @@ -69,10 +69,10 @@ std::shared_ptr ShuffleChannelsFunction::getReference( const auto dequantizationAfter = makeDequantization(shuffleChannels, deqAfter); dequantizationAfter->set_friendly_name("output"); - const auto function = std::make_shared( - ResultVector{ std::make_shared(dequantizationAfter) }, - ParameterVector{ input }, - "ShuffleChannelsFunction"); + const auto function = + std::make_shared(ResultVector{std::make_shared(dequantizationAfter)}, + ov::ParameterVector{input}, + "ShuffleChannelsFunction"); return function; } diff --git a/src/tests/ov_helpers/ov_lpt_models/src/transformations_after_split.cpp b/src/tests/ov_helpers/ov_lpt_models/src/transformations_after_split.cpp index 3dfe07257799e0..2f406f9ab49e56 100644 --- a/src/tests/ov_helpers/ov_lpt_models/src/transformations_after_split.cpp +++ b/src/tests/ov_helpers/ov_lpt_models/src/transformations_after_split.cpp @@ -52,15 +52,14 @@ std::shared_ptr TransformationsAfterSplitFunction::getLayerByTransformatio return std::make_shared(dequantization, addConstant); } if (transformationName == "AvgPoolTransformation") { - const auto dequantization = makeDequantization(parent, {{ov::element::f32}, {}, {0.1f}}); - return std::make_shared( - dequantization, - Strides{ 1, 1 }, - Shape{ 1, 1 }, - Shape{ 0, 0 }, - Shape{ 2, 2 }, - true, - op::RoundingType::FLOOR); + const auto dequantization = makeDequantization(parent, { {ov::element::f32}, {}, { 0.1f } }); + return std::make_shared(dequantization, + Strides{1, 1}, + Shape{1, 1}, + Shape{0, 0}, + Shape{2, 2}, + true, + ov::op::RoundingType::FLOOR); } if (transformationName == "ClampTransformation") { const auto dequantization = makeDequantization(parent, {{ov::element::f32}, {}, {0.1f}}); @@ -103,7 +102,7 @@ std::shared_ptr TransformationsAfterSplitFunction::getLayerByTransformatio const auto outShape = ov::opset1::Constant::create(ov::element::i64, Shape{4}, {1, 4, 32, 32}); ov::op::v0::Interpolate::Attributes attributes; - attributes.axes = AxisSet{ 2, 3 }; + attributes.axes = ov::AxisSet{ 2, 3 }; attributes.mode = "nearest"; attributes.align_corners = false; attributes.antialias = false; @@ -133,7 +132,7 @@ std::shared_ptr TransformationsAfterSplitFunction::getLayerByTransformatio } if (transformationName == "MVNTransformation") { const auto dequantization = makeDequantization(parent, {{ov::element::f32}, {}, {0.1f}}); - return std::make_shared(dequantization, AxisSet{ 2, 3 }); + return std::make_shared(dequantization, ov::AxisSet{ 2, 3 }); } if (transformationName == "NormalizeL2Transformation") { const auto dequantization = makeDequantization(parent, {{ov::element::f32}, {}, {0.1f}}); diff --git a/src/tests/ov_helpers/ov_models/CMakeLists.txt b/src/tests/ov_helpers/ov_models/CMakeLists.txt index 8203855b2bde43..69631bd82ba2a0 100644 --- a/src/tests/ov_helpers/ov_models/CMakeLists.txt +++ b/src/tests/ov_helpers/ov_models/CMakeLists.txt @@ -23,8 +23,6 @@ ov_add_target( openvino::runtime::dev common_test_utils ADD_CLANG_FORMAT - EXCLUDED_SOURCE_PATHS - "${CMAKE_CURRENT_SOURCE_DIR}/ov_builders" ) ov_build_target_faster(${TARGET_NAME} @@ -36,5 +34,3 @@ ov_build_target_faster(${TARGET_NAME} ov_developer_package_export_targets(TARGET ${TARGET_NAME} INSTALL_INCLUDE_DIRECTORIES "${PUBLIC_HEADERS_DIR}/") - -add_subdirectory(ov_builders) \ No newline at end of file diff --git a/src/tests/ov_helpers/ov_models/include/ov_models/builders.hpp b/src/tests/ov_helpers/ov_models/include/ov_models/builders.hpp index 511754f4e93b89..462c83f7662532 100644 --- a/src/tests/ov_helpers/ov_models/include/ov_models/builders.hpp +++ b/src/tests/ov_helpers/ov_models/include/ov_models/builders.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -72,7 +72,7 @@ std::shared_ptr makeInputLayer(const ov::element::Type& type, ov::test::utils::InputLayerType inputType, const std::vector& shape); -std::shared_ptr makeConvolution(const ov::Output& in, +std::shared_ptr makeConvolution(const ov::Output& in, const ov::element::Type& type, const std::vector& filterSize, const std::vector& strides, @@ -85,8 +85,8 @@ std::shared_ptr makeConvolution(const ov::Output& in, const std::vector& filterWeights = {}, const std::vector& biasesWeights = {}); -std::shared_ptr makeConvolution(const ov::Output& in_data, - const ov::Output& in_weights, +std::shared_ptr makeConvolution(const ov::Output& in_data, + const ov::Output& in_weights, const ov::element::Type& type, const std::vector& filterSize, const std::vector& strides, @@ -98,7 +98,7 @@ std::shared_ptr makeConvolution(const ov::Output& in_data, bool addBiases = false, const std::vector& biasesWeights = {}); -std::shared_ptr makeGroupConvolution(const ov::Output& in, +std::shared_ptr makeGroupConvolution(const ov::Output& in, const ov::element::Type& type, const std::vector& filterSize, const std::vector& strides, @@ -112,8 +112,8 @@ std::shared_ptr makeGroupConvolution(const ov::Output& in, const std::vector& filterWeights = {}, const std::vector& biasesWeights = {}); -std::shared_ptr makeGroupConvolution(const ov::Output& in, - const ov::Output& weights, +std::shared_ptr makeGroupConvolution(const ov::Output& in, + const ov::Output& weights, const ov::element::Type& type, const std::vector& strides, const std::vector& padsBegin, @@ -123,7 +123,7 @@ std::shared_ptr makeGroupConvolution(const ov::Output& in, bool addBiases = false, const std::vector& biasesWeights = {}); -std::shared_ptr makeConvolutionBackpropData(const ov::Output& in, +std::shared_ptr makeConvolutionBackpropData(const ov::Output& in, const ov::element::Type& type, const std::vector& filterSize, const std::vector& strides, @@ -137,8 +137,8 @@ std::shared_ptr makeConvolutionBackpropData(const ov::Output& in const std::vector& filterWeights = {}, const std::vector& biasesWeights = {}); -std::shared_ptr makeConvolutionBackpropData(const ov::Output& in, - const ov::Output& weights, +std::shared_ptr makeConvolutionBackpropData(const ov::Output& in, + const ov::Output& weights, const ov::element::Type& type, const std::vector& strides, const std::vector& padsBegin, @@ -149,8 +149,8 @@ std::shared_ptr makeConvolutionBackpropData(const ov::Output& in const std::vector& outputPadding = {}, const std::vector& biasesWeights = {}); -std::shared_ptr makeConvolutionBackpropData(const ov::Output& in, - const ov::Output& outputShape, +std::shared_ptr makeConvolutionBackpropData(const ov::Output& in, + const ov::Output& outputShape, const ov::element::Type& type, const std::vector& filterSize, const std::vector& strides, @@ -165,23 +165,23 @@ std::shared_ptr makeConvolutionBackpropData(const ov::Output& in const std::vector& biasesWeights = {}); OPENVINO_DEPRECATED("This function is deprecated and will be removed soon.") -std::shared_ptr makeCTCGreedyDecoder(const ov::Output& inputData, const bool mergeRepeated); +std::shared_ptr makeCTCGreedyDecoder(const ov::Output& inputData, const bool mergeRepeated); OPENVINO_DEPRECATED("This function is deprecated and will be removed soon.") -std::shared_ptr makeCTCGreedyDecoderSeqLen(const ov::Output& inputData, - const ov::Output& sequenceLength, +std::shared_ptr makeCTCGreedyDecoderSeqLen(const ov::Output& inputData, + const ov::Output& sequenceLength, int blankIndex, bool mergeRepeated, const ov::element::Type& idxPrecision = ov::element::i32); OPENVINO_DEPRECATED("This function is deprecated and will be removed soon.") -std::shared_ptr makeCTCGreedyDecoderSeqLen(const ov::Output& inputData, +std::shared_ptr makeCTCGreedyDecoderSeqLen(const ov::Output& inputData, int blankIndex, bool mergeRepeated, const ov::element::Type& idxPrecision = ov::element::i32); OPENVINO_DEPRECATED("This function is deprecated and will be removed soon.") -std::shared_ptr makeCTCLoss(const ov::Output& logitsNode, +std::shared_ptr makeCTCLoss(const ov::Output& logitsNode, std::vector& logitsLength, std::vector>& labels, std::vector& labelsLength, @@ -192,7 +192,7 @@ std::shared_ptr makeCTCLoss(const ov::Output& logitsNode, const bool ctcMergeRepeated, const bool unique); -std::shared_ptr makeGroupConvolutionBackpropData(const ov::Output& in, +std::shared_ptr makeGroupConvolutionBackpropData(const ov::Output& in, const ov::element::Type& type, const std::vector& filterSize, const std::vector& strides, @@ -207,8 +207,8 @@ std::shared_ptr makeGroupConvolutionBackpropData(const ov::Output& filterWeights = {}, const std::vector& biasesWeights = {}); -std::shared_ptr makeGroupConvolutionBackpropData(const ov::Output& in, - const ov::Output& weights, +std::shared_ptr makeGroupConvolutionBackpropData(const ov::Output& in, + const ov::Output& weights, const ov::element::Type& type, const std::vector& strides, const std::vector& padsBegin, @@ -219,8 +219,8 @@ std::shared_ptr makeGroupConvolutionBackpropData(const ov::Output& outputPadding = {}, const std::vector& biasesWeights = {}); -std::shared_ptr makeGroupConvolutionBackpropData(const ov::Output& in, - const ov::Output& outputShape, +std::shared_ptr makeGroupConvolutionBackpropData(const ov::Output& in, + const ov::Output& outputShape, const ov::element::Type& type, const std::vector& filterSize, const std::vector& strides, @@ -235,7 +235,7 @@ std::shared_ptr makeGroupConvolutionBackpropData(const ov::Output& filterWeights = {}, const std::vector& biasesWeights = {}); -std::shared_ptr makeBinaryConvolution(const ov::Output& in, +std::shared_ptr makeBinaryConvolution(const ov::Output& in, const std::vector& filterSize, const std::vector& strides, const std::vector& padsBegin, @@ -247,12 +247,12 @@ std::shared_ptr makeBinaryConvolution(const ov::Output& in, const std::vector& filterWeihgts = {}); OPENVINO_DEPRECATED("This function is deprecated and will be removed soon.") -std::shared_ptr makeSplit(const ov::Output& in, +std::shared_ptr makeSplit(const ov::Output& in, const ov::element::Type& type, size_t numSplits, int64_t axis); -std::shared_ptr makeActivation(const ov::Output& in, +std::shared_ptr makeActivation(const ov::Output& in, const ov::element::Type& type, ov::test::utils::ActivationTypes activationType, std::vector inShape = {}, @@ -262,26 +262,26 @@ std::shared_ptr makeActivation(const ov::ParameterVector& parameters, const ov::element::Type& type, ov::test::utils::ActivationTypes activationType); -std::shared_ptr makeEltwise(const ov::Output& in0, - const ov::Output& in1, +std::shared_ptr makeEltwise(const ov::Output& in0, + const ov::Output& in1, ov::test::utils::EltwiseTypes eltwiseType); OPENVINO_DEPRECATED("This function is deprecated and will be removed soon.") -std::shared_ptr makeBatchToSpace(const ov::Output& in, +std::shared_ptr makeBatchToSpace(const ov::Output& in, const ov::element::Type& type, const std::vector& blockShape, const std::vector& cropsBegin, const std::vector& cropsEnd); OPENVINO_DEPRECATED("This function is deprecated and will be removed soon.") -std::shared_ptr makeSpaceToBatch(const ov::Output& in, +std::shared_ptr makeSpaceToBatch(const ov::Output& in, const ov::element::Type& type, const std::vector& blockShape, const std::vector& padsBegin, const std::vector& padsEnd); OPENVINO_DEPRECATED("This function is deprecated and will be removed soon.") -std::shared_ptr makeSlice(const ov::Output& in, +std::shared_ptr makeSlice(const ov::Output& in, const std::vector& begin, const std::vector& end, const std::vector& stride, @@ -289,48 +289,51 @@ std::shared_ptr makeSlice(const ov::Output& in, const ov::element::Type& type); OPENVINO_DEPRECATED("This function is deprecated and will be removed soon.") -std::shared_ptr makeSlice(const ov::Output& in, - const ov::Output& begin, - const ov::Output& end, - const ov::Output& stride, - const ov::Output& axes); +std::shared_ptr makeSlice(const ov::Output& in, + const ov::Output& begin, + const ov::Output& end, + const ov::Output& stride, + const ov::Output& axes); OPENVINO_DEPRECATED("This function is deprecated and will be removed soon.") -std::shared_ptr makeSlice(const ov::Output& in, - const ov::Output& begin, - const ov::Output& end, - const ov::Output& stride); +std::shared_ptr makeSlice(const ov::Output& in, + const ov::Output& begin, + const ov::Output& end, + const ov::Output& stride); OPENVINO_DEPRECATED("This function is deprecated and will be removed soon.") -std::shared_ptr makeMVN(const ov::Output& in, bool acrossChannels, bool normalizeVariance, double eps); +std::shared_ptr makeMVN(const ov::Output& in, + bool acrossChannels, + bool normalizeVariance, + double eps); OPENVINO_DEPRECATED("This function is deprecated and will be removed soon.") -std::shared_ptr makeMVN(const ov::Output& in, +std::shared_ptr makeMVN(const ov::Output& in, const ov::AxisSet& axes, bool normalizeVariance, double eps); OPENVINO_DEPRECATED("This function is deprecated and will be removed soon.") -std::shared_ptr makeMVN6(const ov::Output& in, - const ov::Output& axesNode, +std::shared_ptr makeMVN6(const ov::Output& in, + const ov::Output& axesNode, bool normalizeVariance, float eps, std::string& epsMode); OPENVINO_DEPRECATED("This function is deprecated and will be removed soon.") -std::shared_ptr makeSqueezeUnsqueeze(const ov::Output& in, +std::shared_ptr makeSqueezeUnsqueeze(const ov::Output& in, const ov::element::Type& type, const std::vector& squeeze_indices, ov::test::utils::SqueezeOpType opType); OPENVINO_DEPRECATED("This function is deprecated and will be removed soon.") -std::shared_ptr makeMinMax(const ov::Output& in1, - const ov::Output& in2, +std::shared_ptr makeMinMax(const ov::Output& in1, + const ov::Output& in2, ov::test::utils::MinMaxOpType opType); OPENVINO_DEPRECATED("This function is deprecated and will be removed soon.") -std::shared_ptr makeProposal(const ov::Output& class_probs, - const ov::Output& class_logits, +std::shared_ptr makeProposal(const ov::Output& class_probs, + const ov::Output& class_logits, const std::vector& image_info, const ov::element::Type& type, size_t base_size, @@ -348,24 +351,24 @@ std::shared_ptr makeProposal(const ov::Output& class_probs, float box_coordinate_scale, std::string framework); -std::shared_ptr makeFakeQuantize(const ov::Output& in, - const ov::element::Type& type, - std::size_t levels, - std::vector constShapes, - const std::vector& inputLowData, - const std::vector& inputHighData, - const std::vector& outputLowData, - const std::vector& outputHighData); - -std::shared_ptr makeFakeQuantize(const ov::Output& in, - const ov::element::Type& type, - std::size_t levels, - std::vector constShapes, - const int32_t seed = 1); +std::shared_ptr makeFakeQuantize(const ov::Output& in, + const ov::element::Type& type, + std::size_t levels, + std::vector constShapes, + const std::vector& inputLowData, + const std::vector& inputHighData, + const std::vector& outputLowData, + const std::vector& outputHighData); + +std::shared_ptr makeFakeQuantize(const ov::Output& in, + const ov::element::Type& type, + std::size_t levels, + std::vector constShapes, + const int32_t seed = 1); std::shared_ptr makeEmbeddingBagOffsetsSum(const ov::element::Type& dataType, const ov::element::Type& indicesType, - const ov::Output& emb_table_node, + const ov::Output& emb_table_node, const std::vector& indices, const std::vector& offsets, size_t default_index, @@ -374,7 +377,7 @@ std::shared_ptr makeEmbeddingBagOffsetsSum(const ov::element::Type& da std::shared_ptr makeEmbeddingSegmentsSum(const ov::element::Type& dataType, const ov::element::Type& indicesType, - const ov::Output& emb_table_node, + const ov::Output& emb_table_node, const std::vector& indices, const std::vector& segment_ids, size_t num_segments, @@ -382,33 +385,33 @@ std::shared_ptr makeEmbeddingSegmentsSum(const ov::element::Type& data bool with_weights, bool with_default_index); -std::shared_ptr makeReduce(const ov::Output& data, - const ov::Output& axes, +std::shared_ptr makeReduce(const ov::Output& data, + const ov::Output& axes, bool keepDims, ov::test::utils::ReductionType reductionType); OPENVINO_DEPRECATED("This function is deprecated and will be removed soon.") -std::shared_ptr makePooling(const ov::Output& in, - const std::vector& strides, - const std::vector& padsBegin, - const std::vector& padsEnd, - const std::vector& kernel, - const ov::op::RoundingType& roundingType, - const ov::op::PadType& padType, - bool excludePad, - const ov::test::utils::PoolingTypes& poolType); - -std::shared_ptr makeComparison(const ov::Output& in0, - const ov::Output& in1, +std::shared_ptr makePooling(const ov::Output& in, + const std::vector& strides, + const std::vector& padsBegin, + const std::vector& padsEnd, + const std::vector& kernel, + const ov::op::RoundingType& roundingType, + const ov::op::PadType& padType, + bool excludePad, + const ov::test::utils::PoolingTypes& poolType); + +std::shared_ptr makeComparison(const ov::Output& in0, + const ov::Output& in1, ov::test::utils::ComparisonTypes comparisonType); -std::shared_ptr makeLogical(const ov::Output& in0, - const ov::Output& in1, +std::shared_ptr makeLogical(const ov::Output& in0, + const ov::Output& in1, ov::test::utils::LogicalTypes logicalType); std::shared_ptr makeLogical(const ov::ParameterVector& inputs, ov::test::utils::LogicalTypes logicalType); -std::shared_ptr makeFullyConnected(const ov::Output& in, +std::shared_ptr makeFullyConnected(const ov::Output& in, const ov::element::Type& type, const size_t outputSize, bool addBias = true, @@ -417,7 +420,7 @@ std::shared_ptr makeFullyConnected(const ov::Output& in, const std::vector& biasWeights = {}); OPENVINO_DEPRECATED("This function is deprecated and will be removed soon.") -std::shared_ptr makePad(const ov::Output& data, +std::shared_ptr makePad(const ov::Output& data, const std::vector& padsBegin, const std::vector& padsEnd, float argPadValue, @@ -462,12 +465,12 @@ std::shared_ptr makeRNN( ov::op::RecurrentSequenceDirection direction = ov::op::RecurrentSequenceDirection::FORWARD, ov::test::utils::SequenceTestsMode mode = ov::test::utils::SequenceTestsMode::PURE_SEQ); -std::shared_ptr makeGatherND(const ov::Output& dataNode, +std::shared_ptr makeGatherND(const ov::Output& dataNode, const ov::Shape& indicesShape, const ov::element::Type& indicesType, const std::size_t batchDims); -std::shared_ptr makeGatherND8(const ov::Output& dataNode, +std::shared_ptr makeGatherND8(const ov::Output& dataNode, const ov::Shape& indicesShape, const ov::element::Type& indicesType, const std::size_t batchDims); @@ -475,8 +478,8 @@ std::shared_ptr makeGatherND8(const ov::Output& dataNode, enum class NmsVersion { NmsVersion5, NmsVersion9 }; OPENVINO_DEPRECATED("This function is deprecated and will be removed soon.") -std::shared_ptr makeNms(const ov::Output& boxes, - const ov::Output& scores, +std::shared_ptr makeNms(const ov::Output& boxes, + const ov::Output& scores, const ov::element::Type& maxBoxesPrec, const ov::element::Type& thrPrec, const int32_t& maxOutBoxesPerClass, @@ -488,12 +491,12 @@ std::shared_ptr makeNms(const ov::Output& boxes, const ov::element::Type& outType, const NmsVersion nmsVersion = NmsVersion::NmsVersion5); -std::shared_ptr makeDFT(const ov::Output& dataNode, +std::shared_ptr makeDFT(const ov::Output& dataNode, const std::vector& axes, const std::vector& signalSize, const ov::test::utils::DFTOpType opType); -std::shared_ptr makeRDFT(const ov::Output& dataNode, +std::shared_ptr makeRDFT(const ov::Output& dataNode, const std::vector& axes, const std::vector& signalSize, const ov::test::utils::DFTOpType opType); diff --git a/src/tests/ov_helpers/ov_models/include/ov_models/pass/convert_prc.hpp b/src/tests/ov_helpers/ov_models/include/ov_models/pass/convert_prc.hpp index 0bc2e4b0b04550..bf2258bac02e4a 100644 --- a/src/tests/ov_helpers/ov_models/include/ov_models/pass/convert_prc.hpp +++ b/src/tests/ov_helpers/ov_models/include/ov_models/pass/convert_prc.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -50,7 +50,7 @@ template class ConvertParametersPrecision : public ov::pass::MatcherPass { public: ConvertParametersPrecision() { - auto constant = std::make_shared(to, Shape{1}); + auto constant = std::make_shared(to, ov::Shape{1}); ov::matcher_pass_callback callback = [](ov::pass::pattern::Matcher& m) { auto parameter = std::dynamic_pointer_cast(m.get_match_root()); diff --git a/src/tests/ov_helpers/ov_models/ov_builders/CMakeLists.txt b/src/tests/ov_helpers/ov_models/ov_builders/CMakeLists.txt deleted file mode 100644 index fa65f42d554a15..00000000000000 --- a/src/tests/ov_helpers/ov_models/ov_builders/CMakeLists.txt +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright (C) 2018-2023 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 -# - -set(TARGET_NAME ov_builders) - -set(BUILDER_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include/) - -file(GLOB_RECURSE LIBRARY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp) -file(GLOB_RECURSE PUBLIC_HEADERS ${BUILDER_INCLUDE_DIR}/*.hpp) - -# Create named folders for the sources within the .vcproj -# Empty name lists them directly under the .vcproj - -source_group("src" FILES ${LIBRARY_SRC}) -source_group("include" FILES ${PUBLIC_HEADERS}) - -# Create static library -add_library(${TARGET_NAME} STATIC ${LIBRARY_SRC} ${PUBLIC_HEADERS}) - -add_library(openvino::builders ALIAS ${TARGET_NAME}) -set_target_properties(${TARGET_NAME} PROPERTIES EXPORT_NAME builders) - -ov_build_target_faster(${TARGET_NAME} UNITY) - -target_include_directories(${TARGET_NAME} PUBLIC - $ - $) - -if(NOT BUILD_SHARED_LIBS) - target_compile_definitions(${TARGET_NAME} PUBLIC OPENVINO_STATIC_LIBRARY) -endif() - -target_link_libraries(${TARGET_NAME} PRIVATE openvino::runtime) - -ov_add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME}) - -# install & export - -ov_install_static_lib(${TARGET_NAME} ${OV_CPACK_COMP_CORE}) - -ov_developer_package_export_targets(TARGET ${TARGET_NAME} - INSTALL_INCLUDE_DIRECTORIES "${BUILDER_INCLUDE_DIR}/") \ No newline at end of file diff --git a/src/tests/ov_helpers/ov_models/ov_builders/include/ov_models/ov_builders/broadcast.hpp b/src/tests/ov_helpers/ov_models/ov_builders/include/ov_models/ov_builders/broadcast.hpp deleted file mode 100644 index 364198387fc982..00000000000000 --- a/src/tests/ov_helpers/ov_models/ov_builders/include/ov_models/ov_builders/broadcast.hpp +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2018-2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "openvino/core/node.hpp" - -namespace ov { -namespace op { -namespace util { -Output make_broadcast(const Output& node, const Shape& target_shape, const AxisSet& broadcast_axes); - -Output make_broadcast(const Output& node, const Shape& target_shape, std::size_t start_match_axis); -} // namespace util -} // namespace op -} // namespace ov diff --git a/src/tests/ov_helpers/ov_models/ov_builders/include/ov_models/ov_builders/reshape.hpp b/src/tests/ov_helpers/ov_models/ov_builders/include/ov_models/ov_builders/reshape.hpp deleted file mode 100644 index 0e1be4a7c761df..00000000000000 --- a/src/tests/ov_helpers/ov_models/ov_builders/include/ov_models/ov_builders/reshape.hpp +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2018-2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "openvino/core/node.hpp" - -namespace ov { -namespace op { -namespace util { -/// \brief Change shape of a value -/// -/// \param[in] value The value to be reshaped. -/// \param[in] shape The new shape. -/// -/// \return Reshape:v1 op. -std::shared_ptr reshape(const Output& value, const Shape& shape); - -/// \brief Permute axes according to specified axes_order parameter. -/// -/// \param The vlaue whose axes we want to permute. -/// \param axes_order The permutation of axes. -/// -/// \return Transpose:v1 op. -std::shared_ptr reorder_axes(const Output& value, std::vector axes_order = {}); - -/// \brief Return transposed value (with axes in reversed order). -/// -/// \param Value to transpose. -/// -/// \return Transpose:v1 op. -std::shared_ptr transpose(const Output& value); - -/// \brief Flatten a value into a 2D matrix, with a static dividing axis. -/// -/// \param The tensor to be flattened. -/// \param The axis dividing shape. -/// -/// \return The new value will be a 2D matrix representing the flattened input -/// node. -std::shared_ptr flatten(const Output& value, int axis); -} // namespace util -} // namespace op -} // namespace ov diff --git a/src/tests/ov_helpers/ov_models/ov_builders/src/reshape.cpp b/src/tests/ov_helpers/ov_models/ov_builders/src/reshape.cpp deleted file mode 100644 index 0766df37cae572..00000000000000 --- a/src/tests/ov_helpers/ov_models/ov_builders/src/reshape.cpp +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright (C) 2018-2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ov_models/ov_builders/reshape.hpp" - -#include "openvino/op/add.hpp" -#include "openvino/op/broadcast.hpp" -#include "openvino/op/concat.hpp" -#include "openvino/op/constant.hpp" -#include "openvino/op/convert.hpp" -#include "openvino/op/range.hpp" -#include "openvino/op/reduce_prod.hpp" -#include "openvino/op/reshape.hpp" -#include "openvino/op/shape_of.hpp" -#include "openvino/op/squeeze.hpp" -#include "openvino/op/strided_slice.hpp" -#include "openvino/op/subtract.hpp" -#include "openvino/op/transpose.hpp" -#include "openvino/op/variadic_split.hpp" - -namespace ov { -namespace op { -namespace util { -std::shared_ptr reshape(const Output& value, const Shape& shape) { - if (value.get_partial_shape().same_scheme(shape)) { - return value.get_node_shared_ptr(); - } else if (is_scalar(shape)) { - auto value_rank = value.get_shape().size(); - AxisVector axes_vector(value_rank); - std::iota(axes_vector.begin(), axes_vector.end(), 0); - auto axes = ov::op::v0::Constant::create(ov::element::i64, Shape{value_rank}, axes_vector); - return std::make_shared(value, axes); - } else { - auto out_pattern = ov::op::v0::Constant::create(ov::element::i64, - Shape{shape.size()}, - std::vector(shape.begin(), shape.end())); - - return std::make_shared(value, out_pattern, false); - } -} - -std::shared_ptr reorder_axes(const Output& value, std::vector axes_order) { - const auto axes_order_const = - ov::op::v0::Constant::create(ov::element::i64, - Shape{axes_order.size()}, - std::vector(axes_order.begin(), axes_order.end())); - return std::make_shared(value, axes_order_const); -} - -std::shared_ptr transpose(const Output& value) { - // This part is left to preserve backward compatibility and ensure passing ONNX tests. - if (value.get_partial_shape().is_static()) { - std::vector axes_order(value.get_shape().size()); - std::iota(begin(axes_order), end(axes_order), 0); - std::reverse(begin(axes_order), end(axes_order)); - return reorder_axes(value, axes_order); - } - - const auto input_rank = std::make_shared(std::make_shared(value)); - const auto neg_one = ov::op::v0::Constant::create(ov::element::i64, Shape{}, {-1}); - const auto start_node = std::make_shared(input_rank, neg_one); - const auto reverse_axes_order = std::make_shared(reshape(start_node, Shape{}), // start - neg_one, // stop (exclusive) - neg_one); // step - return std::make_shared(value, reverse_axes_order); -} - -namespace { -/// -/// \brief Return the node representing normalized axis with respect to -/// provided rank. -/// -/// \param[in] node_rank The node representing rank used for normalization. -/// \param[in] axis The axis value to be normalized. -/// -/// \return The new Constant node representing normalized axis value. -/// -std::shared_ptr get_normalized_axis_node(const std::shared_ptr node_rank, int64_t axis) { - auto axis_node = ov::op::v0::Constant::create(ov::element::i64, Shape{1}, {axis}); - // shortcut for already positive value - if (axis >= 0) { - return axis_node; - } - - // TODO: What if axis value is beyond acceptable values? [-node_rank, - // node_rank-1] - return std::make_shared(node_rank, axis_node); -} -} // namespace - -std::shared_ptr flatten(const Output& value, int axis) { - // First dimension of output tensor is the product of [d_0, ... d_{axis-1}] dimensions of - // input tensor. The last dimension is the product of the rest of input tensor dimensions: - // [d_{axis}, ..., d_n] - std::shared_ptr output_shape; - if (axis == 0) { - output_shape = ov::op::v0::Constant::create(ov::element::i64, Shape{2}, {1, -1}); - } else if (axis == 1) { - output_shape = ov::op::v0::Constant::create(ov::element::i64, Shape{2}, {0, -1}); - } else { - const auto value_shape = std::make_shared(value); - const auto value_rank = std::make_shared(value_shape); - const auto axis_node = get_normalized_axis_node(value_rank, axis); - - const auto first_part_dims = - std::make_shared(value_shape, - ov::op::v0::Constant::create(ov::element::i64, {1}, {0}), - axis_node, - std::vector{0}, - std::vector{0}); - const auto first_part_dims_length = - std::make_shared(first_part_dims, - ov::op::v0::Constant::create(ov::element::i64, {}, {0}), - true); - - const auto remaining_part_length = ov::op::v0::Constant::create(ov::element::i64, {1}, {-1}); - - output_shape = - std::make_shared(ov::OutputVector{first_part_dims_length, remaining_part_length}, 0); - } - return std::make_shared(value, output_shape, true); -} -} // namespace util -} // namespace op -} // namespace ov diff --git a/src/tests/ov_helpers/ov_models/src/activation.cpp b/src/tests/ov_helpers/ov_models/src/activation.cpp index 4d246b0f6b3fb1..5282048fe91d71 100644 --- a/src/tests/ov_helpers/ov_models/src/activation.cpp +++ b/src/tests/ov_helpers/ov_models/src/activation.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -50,7 +50,7 @@ namespace ngraph { namespace builder { -std::shared_ptr makeActivation(const ov::Output& in, +std::shared_ptr makeActivation(const ov::Output& in, const ov::element::Type& type, ov::test::utils::ActivationTypes activationType, std::vector inShape, diff --git a/src/tests/ov_helpers/ov_models/src/batch_to_space.cpp b/src/tests/ov_helpers/ov_models/src/batch_to_space.cpp index 2e08f8219e5593..f71e8dfd069604 100644 --- a/src/tests/ov_helpers/ov_models/src/batch_to_space.cpp +++ b/src/tests/ov_helpers/ov_models/src/batch_to_space.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -9,7 +9,7 @@ namespace ngraph { namespace builder { -std::shared_ptr makeBatchToSpace(const ov::Output& in, +std::shared_ptr makeBatchToSpace(const ov::Output& in, const ov::element::Type& type, const std::vector& blockShape, const std::vector& cropsBegin, diff --git a/src/tests/ov_helpers/ov_models/src/binary_convolution.cpp b/src/tests/ov_helpers/ov_models/src/binary_convolution.cpp index fc8703ebd29114..8e5123a8153978 100644 --- a/src/tests/ov_helpers/ov_models/src/binary_convolution.cpp +++ b/src/tests/ov_helpers/ov_models/src/binary_convolution.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -13,16 +13,16 @@ namespace ngraph { namespace builder { -std::shared_ptr makeBinaryConvolution(const ov::Output& in, - const std::vector& filterSize, - const std::vector& strides, - const std::vector& padsBegin, - const std::vector& padsEnd, - const std::vector& dilations, - const ov::op::PadType& autoPad, - size_t numOutChannels, - float padValue, - const std::vector& filterWeihgts) { +std::shared_ptr makeBinaryConvolution(const ov::Output& in, + const std::vector& filterSize, + const std::vector& strides, + const std::vector& padsBegin, + const std::vector& padsEnd, + const std::vector& dilations, + const ov::op::PadType& autoPad, + size_t numOutChannels, + float padValue, + const std::vector& filterWeihgts) { auto shape = in.get_shape(); std::vector filterWeightsShape = {numOutChannels, shape[1]}; filterWeightsShape.insert(filterWeightsShape.end(), filterSize.begin(), filterSize.end()); diff --git a/src/tests/ov_helpers/ov_models/src/comparison.cpp b/src/tests/ov_helpers/ov_models/src/comparison.cpp index 3f823a79d798dd..e573e7b73aea10 100644 --- a/src/tests/ov_helpers/ov_models/src/comparison.cpp +++ b/src/tests/ov_helpers/ov_models/src/comparison.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -10,8 +10,8 @@ namespace ngraph { namespace builder { -std::shared_ptr makeComparison(const ov::Output& in0, - const ov::Output& in1, +std::shared_ptr makeComparison(const ov::Output& in0, + const ov::Output& in1, ov::test::utils::ComparisonTypes comparisonType) { switch (comparisonType) { case ov::test::utils::ComparisonTypes::EQUAL: diff --git a/src/tests/ov_helpers/ov_models/src/convolution.cpp b/src/tests/ov_helpers/ov_models/src/convolution.cpp index a1617e6ea961cf..2bdc11ce2219f0 100644 --- a/src/tests/ov_helpers/ov_models/src/convolution.cpp +++ b/src/tests/ov_helpers/ov_models/src/convolution.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -14,18 +14,18 @@ namespace ngraph { namespace builder { -std::shared_ptr makeConvolution(const ov::Output& in, - const ov::element::Type& type, - const std::vector& filterSize, - const std::vector& strides, - const std::vector& padsBegin, - const std::vector& padsEnd, - const std::vector& dilations, - const ov::op::PadType& autoPad, - size_t numOutChannels, - bool addBiases, - const std::vector& filterWeights, - const std::vector& biasesWeights) { +std::shared_ptr makeConvolution(const ov::Output& in, + const ov::element::Type& type, + const std::vector& filterSize, + const std::vector& strides, + const std::vector& padsBegin, + const std::vector& padsEnd, + const std::vector& dilations, + const ov::op::PadType& autoPad, + size_t numOutChannels, + bool addBiases, + const std::vector& filterWeights, + const std::vector& biasesWeights) { bool randomFilterWeights = filterWeights.empty(); auto shape = in.get_partial_shape(); std::vector filterWeightsShape = {numOutChannels, static_cast(shape[1].get_length())}; @@ -50,18 +50,18 @@ std::shared_ptr makeConvolution(const ov::Output& in, } } -std::shared_ptr makeConvolution(const ov::Output& in_data, - const ov::Output& in_weights, - const ov::element::Type& type, - const std::vector& filterSize, - const std::vector& strides, - const std::vector& padsBegin, - const std::vector& padsEnd, - const std::vector& dilations, - const ov::op::PadType& autoPad, - size_t numOutChannels, - bool addBiases, - const std::vector& biasesWeights) { +std::shared_ptr makeConvolution(const ov::Output& in_data, + const ov::Output& in_weights, + const ov::element::Type& type, + const std::vector& filterSize, + const std::vector& strides, + const std::vector& padsBegin, + const std::vector& padsEnd, + const std::vector& dilations, + const ov::op::PadType& autoPad, + size_t numOutChannels, + bool addBiases, + const std::vector& biasesWeights) { auto shape = in_data.get_partial_shape(); auto conv = std::make_shared(in_data, in_weights, strides, padsBegin, padsEnd, dilations, autoPad); diff --git a/src/tests/ov_helpers/ov_models/src/convolution_backprop_data.cpp b/src/tests/ov_helpers/ov_models/src/convolution_backprop_data.cpp index 14234d7107634e..02c7e2d705b007 100644 --- a/src/tests/ov_helpers/ov_models/src/convolution_backprop_data.cpp +++ b/src/tests/ov_helpers/ov_models/src/convolution_backprop_data.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -13,19 +13,19 @@ namespace ngraph { namespace builder { -std::shared_ptr makeConvolutionBackpropData(const ov::Output& in, - const ov::element::Type& type, - const std::vector& filterSize, - const std::vector& strides, - const std::vector& padsBegin, - const std::vector& padsEnd, - const std::vector& dilations, - const ov::op::PadType& autoPad, - size_t numOutChannels, - bool addBiases, - const std::vector& outputPadding, - const std::vector& filterWeights, - const std::vector& biasesWeights) { +std::shared_ptr makeConvolutionBackpropData(const ov::Output& in, + const ov::element::Type& type, + const std::vector& filterSize, + const std::vector& strides, + const std::vector& padsBegin, + const std::vector& padsEnd, + const std::vector& dilations, + const ov::op::PadType& autoPad, + size_t numOutChannels, + bool addBiases, + const std::vector& outputPadding, + const std::vector& filterWeights, + const std::vector& biasesWeights) { bool randomFilterWeights = filterWeights.empty(); auto shape = in.get_partial_shape(); std::vector filterWeightsShape = {static_cast(shape[1].get_length()), numOutChannels}; @@ -46,17 +46,17 @@ std::shared_ptr makeConvolutionBackpropData(const ov::Output& in, biasesWeights); } -std::shared_ptr makeConvolutionBackpropData(const ov::Output& in, - const ov::Output& weights, - const ov::element::Type& type, - const std::vector& strides, - const std::vector& padsBegin, - const std::vector& padsEnd, - const std::vector& dilations, - const ov::op::PadType& autoPad, - bool addBiases, - const std::vector& outputPadding, - const std::vector& biasesWeights) { +std::shared_ptr makeConvolutionBackpropData(const ov::Output& in, + const ov::Output& weights, + const ov::element::Type& type, + const std::vector& strides, + const std::vector& padsBegin, + const std::vector& padsEnd, + const std::vector& dilations, + const ov::op::PadType& autoPad, + bool addBiases, + const std::vector& outputPadding, + const std::vector& biasesWeights) { auto deconv = std::make_shared(in, weights, strides, @@ -86,20 +86,20 @@ std::shared_ptr makeConvolutionBackpropData(const ov::Output& in, } } -std::shared_ptr makeConvolutionBackpropData(const ov::Output& in, - const ov::Output& outputShape, - const ov::element::Type& type, - const std::vector& filterSize, - const std::vector& strides, - const std::vector& padsBegin, - const std::vector& padsEnd, - const std::vector& dilations, - const ov::op::PadType& autoPad, - size_t numOutChannels, - bool addBiases, - const std::vector& outputPadding, - const std::vector& filterWeights, - const std::vector& biasesWeights) { +std::shared_ptr makeConvolutionBackpropData(const ov::Output& in, + const ov::Output& outputShape, + const ov::element::Type& type, + const std::vector& filterSize, + const std::vector& strides, + const std::vector& padsBegin, + const std::vector& padsEnd, + const std::vector& dilations, + const ov::op::PadType& autoPad, + size_t numOutChannels, + bool addBiases, + const std::vector& outputPadding, + const std::vector& filterWeights, + const std::vector& biasesWeights) { bool randomFilterWeights = filterWeights.empty(); auto shape = in.get_partial_shape(); std::vector filterWeightsShape = {static_cast(shape[1].get_length()), numOutChannels}; diff --git a/src/tests/ov_helpers/ov_models/src/ctc_greedy_decoder.cpp b/src/tests/ov_helpers/ov_models/src/ctc_greedy_decoder.cpp index ae281b1d26830c..dc8ce10f0f397b 100644 --- a/src/tests/ov_helpers/ov_models/src/ctc_greedy_decoder.cpp +++ b/src/tests/ov_helpers/ov_models/src/ctc_greedy_decoder.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -13,7 +13,7 @@ namespace ngraph { namespace builder { -std::shared_ptr makeCTCGreedyDecoder(const ov::Output& inputData, const bool mergeRepeated) { +std::shared_ptr makeCTCGreedyDecoder(const ov::Output& inputData, const bool mergeRepeated) { auto inputDataShape = inputData.get_shape(); size_t T = inputDataShape[0]; size_t B = inputDataShape[1]; diff --git a/src/tests/ov_helpers/ov_models/src/ctc_greedy_decoder_seq_len.cpp b/src/tests/ov_helpers/ov_models/src/ctc_greedy_decoder_seq_len.cpp index 34b75a96e9004a..e2626029b68864 100644 --- a/src/tests/ov_helpers/ov_models/src/ctc_greedy_decoder_seq_len.cpp +++ b/src/tests/ov_helpers/ov_models/src/ctc_greedy_decoder_seq_len.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -13,8 +13,8 @@ namespace ngraph { namespace builder { -std::shared_ptr makeCTCGreedyDecoderSeqLen(const ov::Output& inputData, - const ov::Output& sequenceLengthData, +std::shared_ptr makeCTCGreedyDecoderSeqLen(const ov::Output& inputData, + const ov::Output& sequenceLengthData, int32_t blankIndex, bool mergeRepeated, const ov::element::Type& idxPrecision) { @@ -37,7 +37,7 @@ std::shared_ptr makeCTCGreedyDecoderSeqLen(const ov::Output& inp idxPrecision); } -std::shared_ptr makeCTCGreedyDecoderSeqLen(const ov::Output& inputData, +std::shared_ptr makeCTCGreedyDecoderSeqLen(const ov::Output& inputData, int32_t blankIndex, bool mergeRepeated, const ov::element::Type& idxPrecision) { diff --git a/src/tests/ov_helpers/ov_models/src/ctc_loss.cpp b/src/tests/ov_helpers/ov_models/src/ctc_loss.cpp index 768071ed174892..91abb6dfa21e82 100644 --- a/src/tests/ov_helpers/ov_models/src/ctc_loss.cpp +++ b/src/tests/ov_helpers/ov_models/src/ctc_loss.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -13,16 +13,16 @@ namespace ngraph { namespace builder { -std::shared_ptr makeCTCLoss(const ov::Output& logitsNode, - std::vector& logitsLength, - std::vector>& labels, - std::vector& labelsLength, - int blankIndex, - const ov::element::Type& fType, - const ov::element::Type& iType, - const bool preprocessCollapseRepeated, - const bool ctcMergeRepeated, - const bool unique) { +std::shared_ptr makeCTCLoss(const ov::Output& logitsNode, + std::vector& logitsLength, + std::vector>& labels, + std::vector& labelsLength, + int blankIndex, + const ov::element::Type& fType, + const ov::element::Type& iType, + const bool preprocessCollapseRepeated, + const bool ctcMergeRepeated, + const bool unique) { auto logitsShape = logitsNode.get_shape(); size_t N = logitsShape[0]; size_t T = logitsShape[1]; diff --git a/src/tests/ov_helpers/ov_models/src/dft.cpp b/src/tests/ov_helpers/ov_models/src/dft.cpp index ca2dd0479621d8..ccae4463eb99fc 100644 --- a/src/tests/ov_helpers/ov_models/src/dft.cpp +++ b/src/tests/ov_helpers/ov_models/src/dft.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -27,7 +27,7 @@ std::shared_ptr CallDftCtorWithArgs(const ov::test::utils::DFTOpType o } } // namespace -std::shared_ptr makeDFT(const ov::Output& dataNode, +std::shared_ptr makeDFT(const ov::Output& dataNode, const std::vector& axes, const std::vector& signalSize, const ov::test::utils::DFTOpType opType) { diff --git a/src/tests/ov_helpers/ov_models/src/eltwise.cpp b/src/tests/ov_helpers/ov_models/src/eltwise.cpp index c5892b9600ab46..576ad6ccf492ce 100644 --- a/src/tests/ov_helpers/ov_models/src/eltwise.cpp +++ b/src/tests/ov_helpers/ov_models/src/eltwise.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -11,8 +11,8 @@ namespace ngraph { namespace builder { -std::shared_ptr makeEltwise(const ov::Output& in0, - const ov::Output& in1, +std::shared_ptr makeEltwise(const ov::Output& in0, + const ov::Output& in1, ov::test::utils::EltwiseTypes eltwiseType) { switch (eltwiseType) { case ov::test::utils::EltwiseTypes::ADD: @@ -48,4 +48,4 @@ std::shared_ptr makeEltwise(const ov::Output& in0, } } // namespace builder -} // namespace ngraph \ No newline at end of file +} // namespace ngraph diff --git a/src/tests/ov_helpers/ov_models/src/embedding_bag_offsets_sum.cpp b/src/tests/ov_helpers/ov_models/src/embedding_bag_offsets_sum.cpp index 0fe0eb4677cdb4..278630c93d0616 100644 --- a/src/tests/ov_helpers/ov_models/src/embedding_bag_offsets_sum.cpp +++ b/src/tests/ov_helpers/ov_models/src/embedding_bag_offsets_sum.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -12,20 +12,20 @@ namespace ngraph { namespace builder { -std::shared_ptr makeEmbeddingBagOffsetsSum(const ov::element::Type& dataType, - const ov::element::Type& indicesType, - const ov::Output& embTableNode, - const std::vector& indices, - const std::vector& offsets, - size_t default_index, - bool with_weights, - bool with_default_index) { +std::shared_ptr makeEmbeddingBagOffsetsSum(const ov::element::Type& dataType, + const ov::element::Type& indicesType, + const ov::Output& embTableNode, + const std::vector& indices, + const std::vector& offsets, + size_t default_index, + bool with_weights, + bool with_default_index) { std::vector i_shape = {indices.size()}; auto indicesNode = std::make_shared(indicesType, i_shape, indices); std::vector o_shape = {offsets.size()}; auto offsetsNode = std::make_shared(indicesType, o_shape, offsets); - std::shared_ptr embBag; + std::shared_ptr embBag; if (with_default_index) { std::vector d_shape = {}; auto defIdxNode = std::make_shared(indicesType, d_shape, default_index); diff --git a/src/tests/ov_helpers/ov_models/src/embedding_segments_sum.cpp b/src/tests/ov_helpers/ov_models/src/embedding_segments_sum.cpp index e700375e3644a0..fefd6be6fcbb66 100644 --- a/src/tests/ov_helpers/ov_models/src/embedding_segments_sum.cpp +++ b/src/tests/ov_helpers/ov_models/src/embedding_segments_sum.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -13,15 +13,15 @@ namespace ngraph { namespace builder { -std::shared_ptr makeEmbeddingSegmentsSum(const ov::element::Type& dataType, - const ov::element::Type& indicesType, - const ov::Output& embTableNode, - const std::vector& indices, - const std::vector& segment_ids, - size_t num_segments, - size_t default_index, - bool with_weights, - bool with_default_index) { +std::shared_ptr makeEmbeddingSegmentsSum(const ov::element::Type& dataType, + const ov::element::Type& indicesType, + const ov::Output& embTableNode, + const std::vector& indices, + const std::vector& segment_ids, + size_t num_segments, + size_t default_index, + bool with_weights, + bool with_default_index) { std::vector i_shape = {indices.size()}; auto indicesNode = std::make_shared(indicesType, i_shape, indices); std::vector o_shape = {segment_ids.size()}; @@ -29,7 +29,7 @@ std::shared_ptr makeEmbeddingSegmentsSum(const ov::element::Type& dataType std::vector shape_0 = {}; auto segmentNumNode = std::make_shared(indicesType, shape_0, num_segments); - std::shared_ptr embBag; + std::shared_ptr embBag; if (with_default_index) { auto defIdxNode = std::make_shared(indicesType, shape_0, default_index); if (with_weights) { diff --git a/src/tests/ov_helpers/ov_models/src/fake_quantize.cpp b/src/tests/ov_helpers/ov_models/src/fake_quantize.cpp index 514c75728aed38..13dd5262954e5d 100644 --- a/src/tests/ov_helpers/ov_models/src/fake_quantize.cpp +++ b/src/tests/ov_helpers/ov_models/src/fake_quantize.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -13,14 +13,14 @@ namespace ngraph { namespace builder { -std::shared_ptr makeFakeQuantize(const ov::Output& in, - const ov::element::Type& constantType, - std::size_t levels, - std::vector constShapes, - const std::vector& inputLowData, - const std::vector& inputHighData, - const std::vector& outputLowData, - const std::vector& outputHighData) { +std::shared_ptr makeFakeQuantize(const ov::Output& in, + const ov::element::Type& constantType, + std::size_t levels, + std::vector constShapes, + const std::vector& inputLowData, + const std::vector& inputHighData, + const std::vector& outputLowData, + const std::vector& outputHighData) { auto inputLowNode = ov::test::utils::deprecated::make_constant(constantType, constShapes, inputLowData, inputLowData.empty()); auto inputHighNode = diff --git a/src/tests/ov_helpers/ov_models/src/fully_connected.cpp b/src/tests/ov_helpers/ov_models/src/fully_connected.cpp index f5da3e34312eec..375e5c5e99b0e3 100644 --- a/src/tests/ov_helpers/ov_models/src/fully_connected.cpp +++ b/src/tests/ov_helpers/ov_models/src/fully_connected.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -13,13 +13,13 @@ namespace ngraph { namespace builder { -std::shared_ptr makeFullyConnected(const ov::Output& in, - const ov::element::Type& type, - const size_t outputSize, - bool addBias, - const ov::Shape& weightsShape, - const std::vector& weights, - const std::vector& biasWeights) { +std::shared_ptr makeFullyConnected(const ov::Output& in, + const ov::element::Type& type, + const size_t outputSize, + bool addBias, + const ov::Shape& weightsShape, + const std::vector& weights, + const std::vector& biasWeights) { auto shape = weightsShape; if (shape.empty()) { auto inputShape = in.get_shape(); diff --git a/src/tests/ov_helpers/ov_models/src/gather_nd.cpp b/src/tests/ov_helpers/ov_models/src/gather_nd.cpp index 1d3493ada888ce..48dcfb5e5f1f65 100644 --- a/src/tests/ov_helpers/ov_models/src/gather_nd.cpp +++ b/src/tests/ov_helpers/ov_models/src/gather_nd.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -13,10 +13,10 @@ namespace ngraph { namespace builder { -std::shared_ptr makeGatherND(const ov::Output& dataNode, - const ov::Shape& indicesShape, - const ov::element::Type& indicesType, - const std::size_t batchDims) { +std::shared_ptr makeGatherND(const ov::Output& dataNode, + const ov::Shape& indicesShape, + const ov::element::Type& indicesType, + const std::size_t batchDims) { const auto indices = [&] { const auto& dataShape = dataNode.get_shape(); const auto indicesCount = @@ -43,10 +43,10 @@ std::shared_ptr makeGatherND(const ov::Output& dataNode, return gatherNdNode; } -std::shared_ptr makeGatherND8(const ov::Output& dataNode, - const ov::Shape& indicesShape, - const ov::element::Type& indicesType, - const std::size_t batchDims) { +std::shared_ptr makeGatherND8(const ov::Output& dataNode, + const ov::Shape& indicesShape, + const ov::element::Type& indicesType, + const std::size_t batchDims) { const auto indices = [&] { const auto& dataShape = dataNode.get_shape(); const auto indicesCount = diff --git a/src/tests/ov_helpers/ov_models/src/group_convolution.cpp b/src/tests/ov_helpers/ov_models/src/group_convolution.cpp index 4996137128d6c2..6e2a221b6995bf 100644 --- a/src/tests/ov_helpers/ov_models/src/group_convolution.cpp +++ b/src/tests/ov_helpers/ov_models/src/group_convolution.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -13,19 +13,19 @@ namespace ngraph { namespace builder { -std::shared_ptr makeGroupConvolution(const ov::Output& in, - const ov::element::Type& type, - const std::vector& filterSize, - const std::vector& strides, - const std::vector& padsBegin, - const std::vector& padsEnd, - const std::vector& dilations, - const ov::op::PadType& autoPad, - size_t numOutChannels, - size_t numGroups, - bool addBiases, - const std::vector& filterWeights, - const std::vector& biasesWeights) { +std::shared_ptr makeGroupConvolution(const ov::Output& in, + const ov::element::Type& type, + const std::vector& filterSize, + const std::vector& strides, + const std::vector& padsBegin, + const std::vector& padsEnd, + const std::vector& dilations, + const ov::op::PadType& autoPad, + size_t numOutChannels, + size_t numGroups, + bool addBiases, + const std::vector& filterWeights, + const std::vector& biasesWeights) { bool randomFilterWeights = filterWeights.empty(); auto shape = in.get_partial_shape(); std::vector filterWeightsShape = {numOutChannels, static_cast(shape[1].get_length())}; @@ -50,16 +50,16 @@ std::shared_ptr makeGroupConvolution(const ov::Output& in, biasesWeights); } -std::shared_ptr makeGroupConvolution(const ov::Output& in, - const ov::Output& weights, - const ov::element::Type& type, - const std::vector& strides, - const std::vector& padsBegin, - const std::vector& padsEnd, - const std::vector& dilations, - const ov::op::PadType& autoPad, - bool addBiases, - const std::vector& biasesWeights) { +std::shared_ptr makeGroupConvolution(const ov::Output& in, + const ov::Output& weights, + const ov::element::Type& type, + const std::vector& strides, + const std::vector& padsBegin, + const std::vector& padsEnd, + const std::vector& dilations, + const ov::op::PadType& autoPad, + bool addBiases, + const std::vector& biasesWeights) { auto conv = std::make_shared(in, weights, strides, padsBegin, padsEnd, dilations, autoPad); if (addBiases) { diff --git a/src/tests/ov_helpers/ov_models/src/group_convolution_backprop_data.cpp b/src/tests/ov_helpers/ov_models/src/group_convolution_backprop_data.cpp index 3f85d358e1cce1..c4ca29863ea9ab 100644 --- a/src/tests/ov_helpers/ov_models/src/group_convolution_backprop_data.cpp +++ b/src/tests/ov_helpers/ov_models/src/group_convolution_backprop_data.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -13,20 +13,20 @@ namespace ngraph { namespace builder { -std::shared_ptr makeGroupConvolutionBackpropData(const ov::Output& in, - const ov::element::Type& type, - const std::vector& filterSize, - const std::vector& strides, - const std::vector& padsBegin, - const std::vector& padsEnd, - const std::vector& dilations, - const ov::op::PadType& autoPad, - size_t numOutChannels, - size_t numGroups, - bool addBiases, - const std::vector& outputPadding, - const std::vector& filterWeights, - const std::vector& biasesWeights) { +std::shared_ptr makeGroupConvolutionBackpropData(const ov::Output& in, + const ov::element::Type& type, + const std::vector& filterSize, + const std::vector& strides, + const std::vector& padsBegin, + const std::vector& padsEnd, + const std::vector& dilations, + const ov::op::PadType& autoPad, + size_t numOutChannels, + size_t numGroups, + bool addBiases, + const std::vector& outputPadding, + const std::vector& filterWeights, + const std::vector& biasesWeights) { bool randomFilterWeights = filterWeights.empty(); auto shape = in.get_partial_shape(); std::vector filterWeightsShape = {static_cast(shape[1].get_length()), numOutChannels}; @@ -52,17 +52,17 @@ std::shared_ptr makeGroupConvolutionBackpropData(const ov::Output& i biasesWeights); } -std::shared_ptr makeGroupConvolutionBackpropData(const ov::Output& in, - const ov::Output& weights, - const ov::element::Type& type, - const std::vector& strides, - const std::vector& padsBegin, - const std::vector& padsEnd, - const std::vector& dilations, - const ov::op::PadType& autoPad, - bool addBiases, - const std::vector& outputPadding, - const std::vector& biasesWeights) { +std::shared_ptr makeGroupConvolutionBackpropData(const ov::Output& in, + const ov::Output& weights, + const ov::element::Type& type, + const std::vector& strides, + const std::vector& padsBegin, + const std::vector& padsEnd, + const std::vector& dilations, + const ov::op::PadType& autoPad, + bool addBiases, + const std::vector& outputPadding, + const std::vector& biasesWeights) { auto deconv = std::make_shared(in, weights, strides, @@ -91,21 +91,21 @@ std::shared_ptr makeGroupConvolutionBackpropData(const ov::Output& i } } -std::shared_ptr makeGroupConvolutionBackpropData(const ov::Output& in, - const ov::Output& outputShape, - const ov::element::Type& type, - const std::vector& filterSize, - const std::vector& strides, - const std::vector& padsBegin, - const std::vector& padsEnd, - const std::vector& dilations, - const ov::op::PadType& autoPad, - size_t numOutChannels, - size_t numGroups, - bool addBiases, - const std::vector& outputPadding, - const std::vector& filterWeights, - const std::vector& biasesWeights) { +std::shared_ptr makeGroupConvolutionBackpropData(const ov::Output& in, + const ov::Output& outputShape, + const ov::element::Type& type, + const std::vector& filterSize, + const std::vector& strides, + const std::vector& padsBegin, + const std::vector& padsEnd, + const std::vector& dilations, + const ov::op::PadType& autoPad, + size_t numOutChannels, + size_t numGroups, + bool addBiases, + const std::vector& outputPadding, + const std::vector& filterWeights, + const std::vector& biasesWeights) { bool randomFilterWeights = filterWeights.empty(); auto shape = in.get_partial_shape(); std::vector filterWeightsShape = {static_cast(shape[1].get_length()), numOutChannels}; diff --git a/src/tests/ov_helpers/ov_models/src/gru_cell.cpp b/src/tests/ov_helpers/ov_models/src/gru_cell.cpp index f030a692cb1347..d754e096e3e2ca 100644 --- a/src/tests/ov_helpers/ov_models/src/gru_cell.cpp +++ b/src/tests/ov_helpers/ov_models/src/gru_cell.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -57,7 +57,7 @@ std::shared_ptr makeGRU(const ov::OutputVector& in, clip, linear_before_reset); } else { - std::shared_ptr seq_lengths; + std::shared_ptr seq_lengths; switch (mode) { case ov::test::utils::SequenceTestsMode::PURE_SEQ: case ov::test::utils::SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_CONST: { diff --git a/src/tests/ov_helpers/ov_models/src/logical.cpp b/src/tests/ov_helpers/ov_models/src/logical.cpp index e8fb6a56c016e3..d7f0df22b27136 100644 --- a/src/tests/ov_helpers/ov_models/src/logical.cpp +++ b/src/tests/ov_helpers/ov_models/src/logical.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -10,8 +10,8 @@ namespace ngraph { namespace builder { -std::shared_ptr makeLogical(const ov::Output& in0, - const ov::Output& in1, +std::shared_ptr makeLogical(const ov::Output& in0, + const ov::Output& in1, ov::test::utils::LogicalTypes logicalType) { switch (logicalType) { case ov::test::utils::LogicalTypes::LOGICAL_AND: diff --git a/src/tests/ov_helpers/ov_models/src/lstm_cell.cpp b/src/tests/ov_helpers/ov_models/src/lstm_cell.cpp index e9a586d3faf22d..425f7d5a04e3c8 100644 --- a/src/tests/ov_helpers/ov_models/src/lstm_cell.cpp +++ b/src/tests/ov_helpers/ov_models/src/lstm_cell.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -12,7 +12,7 @@ namespace ngraph { namespace builder { -std::shared_ptr makeLSTM(const std::vector>& in, +std::shared_ptr makeLSTM(const std::vector>& in, const std::vector& constants, std::size_t hidden_size, const std::vector& activations, @@ -76,7 +76,7 @@ std::shared_ptr makeLSTM(const std::vector>& in, activations, clip); } else { - std::shared_ptr seq_lengths; + std::shared_ptr seq_lengths; switch (mode) { case ov::test::utils::SequenceTestsMode::PURE_SEQ: case ov::test::utils::SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_CONST: { diff --git a/src/tests/ov_helpers/ov_models/src/minimum_maximum.cpp b/src/tests/ov_helpers/ov_models/src/minimum_maximum.cpp index e14274953ac76a..09ff33ac7307a4 100644 --- a/src/tests/ov_helpers/ov_models/src/minimum_maximum.cpp +++ b/src/tests/ov_helpers/ov_models/src/minimum_maximum.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -9,8 +9,8 @@ namespace ngraph { namespace builder { -std::shared_ptr makeMinMax(const ov::Output& in1, - const ov::Output& in2, +std::shared_ptr makeMinMax(const ov::Output& in1, + const ov::Output& in2, ov::test::utils::MinMaxOpType opType) { switch (opType) { case ov::test::utils::MinMaxOpType::MINIMUM: diff --git a/src/tests/ov_helpers/ov_models/src/mvn.cpp b/src/tests/ov_helpers/ov_models/src/mvn.cpp index a55bbec6dbc9f2..8c850fcab1f57e 100644 --- a/src/tests/ov_helpers/ov_models/src/mvn.cpp +++ b/src/tests/ov_helpers/ov_models/src/mvn.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -9,7 +9,10 @@ namespace ngraph { namespace builder { -std::shared_ptr makeMVN(const ov::Output& in, bool acrossChannels, bool normalizeVariance, double eps) { +std::shared_ptr makeMVN(const ov::Output& in, + bool acrossChannels, + bool normalizeVariance, + double eps) { auto mvnNode = std::make_shared(in, acrossChannels, normalizeVariance, eps); // OpenVINO MVN implementation implicitly adds 0th dimension to reduction axes set which is not valid behavior @@ -23,7 +26,7 @@ std::shared_ptr makeMVN(const ov::Output& in, bool acrossChannel return mvnNode; } -std::shared_ptr makeMVN(const ov::Output& in, +std::shared_ptr makeMVN(const ov::Output& in, const ov::AxisSet& axes, bool normalizeVariance, double eps) { @@ -32,11 +35,11 @@ std::shared_ptr makeMVN(const ov::Output& in, return mvnNode; } -std::shared_ptr makeMVN6(const ov::Output& in, - const ov::Output& axesNode, - bool normalizeVariance, - float eps, - std::string& epsMode) { +std::shared_ptr makeMVN6(const ov::Output& in, + const ov::Output& axesNode, + bool normalizeVariance, + float eps, + std::string& epsMode) { ov::op::MVNEpsMode nEpsMode = ov::op::MVNEpsMode::INSIDE_SQRT; if (epsMode == "outside_sqrt") nEpsMode = ov::op::MVNEpsMode::OUTSIDE_SQRT; diff --git a/src/tests/ov_helpers/ov_models/src/non_max_suppression.cpp b/src/tests/ov_helpers/ov_models/src/non_max_suppression.cpp index d318bed19e8105..5f45374b3bc239 100644 --- a/src/tests/ov_helpers/ov_models/src/non_max_suppression.cpp +++ b/src/tests/ov_helpers/ov_models/src/non_max_suppression.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -11,8 +11,8 @@ namespace ngraph { namespace builder { template -std::shared_ptr makeNms(const ov::Output& boxes, - const ov::Output& scores, +std::shared_ptr makeNms(const ov::Output& boxes, + const ov::Output& scores, const ov::element::Type& maxBoxesPrec, const ov::element::Type& thrPrec, const int32_t& maxOutBoxesPerClass, @@ -46,8 +46,8 @@ std::shared_ptr makeNms(const ov::Output& boxes, outType); } -std::shared_ptr makeNms(const ov::Output& boxes, - const ov::Output& scores, +std::shared_ptr makeNms(const ov::Output& boxes, + const ov::Output& scores, const ov::element::Type& maxBoxesPrec, const ov::element::Type& thrPrec, const int32_t& maxOutBoxesPerClass, diff --git a/src/tests/ov_helpers/ov_models/src/pad.cpp b/src/tests/ov_helpers/ov_models/src/pad.cpp index ddb226d130e787..49544a98c51981 100644 --- a/src/tests/ov_helpers/ov_models/src/pad.cpp +++ b/src/tests/ov_helpers/ov_models/src/pad.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -11,7 +11,7 @@ namespace ngraph { namespace builder { -std::shared_ptr makePad(const ov::Output& data, +std::shared_ptr makePad(const ov::Output& data, const std::vector& padsBegin, const std::vector& padsEnd, float argPadValue, diff --git a/src/tests/ov_helpers/ov_models/src/pooling.cpp b/src/tests/ov_helpers/ov_models/src/pooling.cpp index ba611099b2dc67..6429ce6784ba68 100644 --- a/src/tests/ov_helpers/ov_models/src/pooling.cpp +++ b/src/tests/ov_helpers/ov_models/src/pooling.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -12,15 +12,15 @@ namespace ngraph { namespace builder { -std::shared_ptr makePooling(const ov::Output& in, - const std::vector& strides, - const std::vector& padsBegin, - const std::vector& padsEnd, - const std::vector& kernel, - const ov::op::RoundingType& roundingType, - const ov::op::PadType& padType, - bool excludePad, - const ov::test::utils::PoolingTypes& poolType) { +std::shared_ptr makePooling(const ov::Output& in, + const std::vector& strides, + const std::vector& padsBegin, + const std::vector& padsEnd, + const std::vector& kernel, + const ov::op::RoundingType& roundingType, + const ov::op::PadType& padType, + bool excludePad, + const ov::test::utils::PoolingTypes& poolType) { std::shared_ptr pooling; switch (poolType) { case ov::test::utils::PoolingTypes::MAX: diff --git a/src/tests/ov_helpers/ov_models/src/proposal.cpp b/src/tests/ov_helpers/ov_models/src/proposal.cpp index 801bb6228f57bb..fbb5455bbd0fe7 100644 --- a/src/tests/ov_helpers/ov_models/src/proposal.cpp +++ b/src/tests/ov_helpers/ov_models/src/proposal.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -13,24 +13,24 @@ namespace ngraph { namespace builder { -std::shared_ptr makeProposal(const ov::Output& class_probs, - const ov::Output& class_logits, - const std::vector& image_info, - const ov::element::Type& type, - size_t base_size, - size_t pre_nms_topn, - size_t post_nms_topn, - float nms_thresh, - size_t feat_stride, - size_t min_size, - const std::vector& ratio, - const std::vector& scale, - bool clip_before_nms, - bool clip_after_nms, - bool normalize, - float box_size_scale, - float box_coordinate_scale, - std::string framework) { +std::shared_ptr makeProposal(const ov::Output& class_probs, + const ov::Output& class_logits, + const std::vector& image_info, + const ov::element::Type& type, + size_t base_size, + size_t pre_nms_topn, + size_t post_nms_topn, + float nms_thresh, + size_t feat_stride, + size_t min_size, + const std::vector& ratio, + const std::vector& scale, + bool clip_before_nms, + bool clip_after_nms, + bool normalize, + float box_size_scale, + float box_coordinate_scale, + std::string framework) { ov::op::v4::Proposal::Attributes attrs; attrs.base_size = base_size; attrs.pre_nms_topn = pre_nms_topn; diff --git a/src/tests/ov_helpers/ov_models/src/rdft.cpp b/src/tests/ov_helpers/ov_models/src/rdft.cpp index 7e67180eab7d4b..eb7667fdcc08a8 100644 --- a/src/tests/ov_helpers/ov_models/src/rdft.cpp +++ b/src/tests/ov_helpers/ov_models/src/rdft.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -29,7 +29,7 @@ std::shared_ptr CallDftCtorWithArgs(const ov::test::utils::DFTOpType o } } // namespace -std::shared_ptr makeRDFT(const ov::Output& dataNode, +std::shared_ptr makeRDFT(const ov::Output& dataNode, const std::vector& axes, const std::vector& signalSize, const ov::test::utils::DFTOpType opType) { diff --git a/src/tests/ov_helpers/ov_models/src/rnn_cell.cpp b/src/tests/ov_helpers/ov_models/src/rnn_cell.cpp index 8a87aec5cb59ac..377ce46c023851 100644 --- a/src/tests/ov_helpers/ov_models/src/rnn_cell.cpp +++ b/src/tests/ov_helpers/ov_models/src/rnn_cell.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -54,7 +54,7 @@ std::shared_ptr makeRNN(const ov::OutputVector& in, activations_beta, clip); } else { - std::shared_ptr seq_lengths; + std::shared_ptr seq_lengths; switch (mode) { case ov::test::utils::SequenceTestsMode::PURE_SEQ: case ov::test::utils::SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_CONST: { diff --git a/src/tests/ov_helpers/ov_models/src/space_to_batch.cpp b/src/tests/ov_helpers/ov_models/src/space_to_batch.cpp index 30bdfd87fc3a76..88466c6de7e802 100644 --- a/src/tests/ov_helpers/ov_models/src/space_to_batch.cpp +++ b/src/tests/ov_helpers/ov_models/src/space_to_batch.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -9,7 +9,7 @@ namespace ngraph { namespace builder { -std::shared_ptr makeSpaceToBatch(const ov::Output& in, +std::shared_ptr makeSpaceToBatch(const ov::Output& in, const ov::element::Type& type, const std::vector& blockShape, const std::vector& padsBegin, diff --git a/src/tests/ov_helpers/ov_models/src/split.cpp b/src/tests/ov_helpers/ov_models/src/split.cpp index 2a78f8e5a8a66b..ed282d65bfc1c0 100644 --- a/src/tests/ov_helpers/ov_models/src/split.cpp +++ b/src/tests/ov_helpers/ov_models/src/split.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -11,7 +11,7 @@ namespace ngraph { namespace builder { -std::shared_ptr makeSplit(const ov::Output& in, +std::shared_ptr makeSplit(const ov::Output& in, const ov::element::Type& type, size_t numSplits, int64_t axis) { diff --git a/src/tests/ov_helpers/ov_models/src/squeeze_unsqueeze.cpp b/src/tests/ov_helpers/ov_models/src/squeeze_unsqueeze.cpp index 6c77012b02a978..02384aac5b4f81 100644 --- a/src/tests/ov_helpers/ov_models/src/squeeze_unsqueeze.cpp +++ b/src/tests/ov_helpers/ov_models/src/squeeze_unsqueeze.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -12,7 +12,7 @@ namespace ngraph { namespace builder { -std::shared_ptr makeSqueezeUnsqueeze(const ov::Output& in, +std::shared_ptr makeSqueezeUnsqueeze(const ov::Output& in, const ov::element::Type& type, const std::vector& squeeze_indices, ov::test::utils::SqueezeOpType opType) { diff --git a/src/tests/ov_helpers/ov_models/src/strided_slice.cpp b/src/tests/ov_helpers/ov_models/src/strided_slice.cpp index e617e23ed3cfb2..676691e42894d1 100644 --- a/src/tests/ov_helpers/ov_models/src/strided_slice.cpp +++ b/src/tests/ov_helpers/ov_models/src/strided_slice.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -9,7 +9,7 @@ namespace ngraph { namespace builder { -std::shared_ptr makeSlice(const ov::Output& in, +std::shared_ptr makeSlice(const ov::Output& in, const std::vector& begin, const std::vector& end, const std::vector& stride, @@ -27,18 +27,18 @@ std::shared_ptr makeSlice(const ov::Output& in, } } -std::shared_ptr makeSlice(const ov::Output& in, - const ov::Output& begin, - const ov::Output& end, - const ov::Output& stride, - const ov::Output& axes) { +std::shared_ptr makeSlice(const ov::Output& in, + const ov::Output& begin, + const ov::Output& end, + const ov::Output& stride, + const ov::Output& axes) { return std::make_shared(in, begin, end, stride, axes); } -std::shared_ptr makeSlice(const ov::Output& in, - const ov::Output& begin, - const ov::Output& end, - const ov::Output& stride) { +std::shared_ptr makeSlice(const ov::Output& in, + const ov::Output& begin, + const ov::Output& end, + const ov::Output& stride) { return std::make_shared(in, begin, end, stride); } } // namespace builder diff --git a/src/tests/ov_helpers/ov_models/src/utils/ov_helpers.cpp b/src/tests/ov_helpers/ov_models/src/utils/ov_helpers.cpp index a1b670d757b775..2b92b45c1521c8 100644 --- a/src/tests/ov_helpers/ov_models/src/utils/ov_helpers.cpp +++ b/src/tests/ov_helpers/ov_models/src/utils/ov_helpers.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -10,8 +10,8 @@ #include #include "backend.hpp" +#include "common_test_utils/specialize_function.hpp" #include "common_test_utils/test_enums.hpp" -#include "ngraph/specialize_function.hpp" #include "openvino/core/node.hpp" #include "openvino/op/tensor_iterator.hpp" #include "openvino/op/util/attr_types.hpp" @@ -226,9 +226,7 @@ std::shared_ptr foldFunction(const std::shared_ptr& functi } } - NGRAPH_SUPPRESS_DEPRECATED_START; - const auto& foldedFunc = ngraph::specialize_function(function, paramElementTypes, paramShapes, inBuffers); - NGRAPH_SUPPRESS_DEPRECATED_END; + const auto& foldedFunc = ov::test::utils::specialize_function(function, paramElementTypes, paramShapes, inBuffers); ov::pass::ConstantFolding().run_on_model(foldedFunc); for (const auto& op : foldedFunc->get_ops()) { OPENVINO_ASSERT(ov::op::util::is_constant(op) || ov::op::util::is_output(op) || ov::op::util::is_parameter(op), diff --git a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_simple.cpp b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_simple.cpp index 4821cc6d700cdb..79ddd5ca00c641 100644 --- a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_simple.cpp +++ b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_simple.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2022-2023 Intel Corporation +// Copyright (C) 2022-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -209,7 +209,7 @@ std::shared_ptr EltwiseTwoResultsFunction::initOriginal() const { auto relu = std::make_shared(hswish); relu->set_friendly_name("relu"); - NGRAPH_SUPPRESS_DEPRECATED_START + OPENVINO_SUPPRESS_DEPRECATED_START auto& out_tensor0 = add->get_output_tensor(0); ov::descriptor::set_ov_tensor_legacy_name(out_tensor0, "add_out"); out_tensor0.set_names({"add_out", "y0"}); @@ -217,7 +217,7 @@ std::shared_ptr EltwiseTwoResultsFunction::initOriginal() const { auto& out_tensor1 = relu->get_output_tensor(0); ov::descriptor::set_ov_tensor_legacy_name(out_tensor1, "relu_out"); out_tensor1.set_names({"relu_out", "y1"}); - NGRAPH_SUPPRESS_DEPRECATED_END + OPENVINO_SUPPRESS_DEPRECATED_END auto res0 = std::make_shared(add); res0->set_friendly_name("res0"); @@ -248,7 +248,7 @@ std::shared_ptr EltwiseTwoResultsFunction::initReference() const { std::make_shared(NodeVector{relu}, ParameterVector{indata2})); subgraph1->set_friendly_name("relu"); - NGRAPH_SUPPRESS_DEPRECATED_START + OPENVINO_SUPPRESS_DEPRECATED_START auto& out_tensor0 = subgraph0->get_output_tensor(0); ov::descriptor::set_ov_tensor_legacy_name(out_tensor0, "add_out"); out_tensor0.set_names({"add_out", "y0"}); @@ -256,7 +256,7 @@ std::shared_ptr EltwiseTwoResultsFunction::initReference() const { auto& out_tensor1 = subgraph1->get_output_tensor(0); ov::descriptor::set_ov_tensor_legacy_name(out_tensor1, "relu_out"); out_tensor1.set_names({"relu_out", "y1"}); - NGRAPH_SUPPRESS_DEPRECATED_END + OPENVINO_SUPPRESS_DEPRECATED_END auto res0 = std::make_shared(subgraph0->output(0)); res0->set_friendly_name("res0"); @@ -352,4 +352,4 @@ std::shared_ptr EdgeReplaceFunction::initOriginal() const { } } // namespace snippets } // namespace test -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/tests/test_utils/common_test_utils/CMakeLists.txt b/src/tests/test_utils/common_test_utils/CMakeLists.txt index 10caf4fb836540..0eca7bc46b9bd0 100644 --- a/src/tests/test_utils/common_test_utils/CMakeLists.txt +++ b/src/tests/test_utils/common_test_utils/CMakeLists.txt @@ -31,7 +31,6 @@ function(add_common_utils ADD_TARGET_NAME) ov_models openvino::runtime openvino::runtime::dev - openvino::builders PRIVATE openvino::util openvino::shape_inference diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/data_utils.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/data_utils.hpp index a64ae64f01e9e7..a41bbd4e61b2ff 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/data_utils.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/data_utils.hpp @@ -170,7 +170,7 @@ void fill_psroi(ov::Tensor& tensor, int spatialBinsY, const std::string& mode); -void fill_data_roi(ov::runtime::Tensor& tensor, +void fill_data_roi(ov::Tensor& tensor, const uint32_t range, const int height, const int width, @@ -547,6 +547,52 @@ inline ov::float8_e5m2 ie_abs(const ov::float8_e5m2& val) { return ov::float8_e5m2::from_bits(val.to_bits() & 0x7F); } +template +static void compare_raw_data(const T_EXPECTED* expected, + const T_ACTUAL* actual, + std::size_t size, + float threshold, + float abs_threshold = -1.f) { + for (std::size_t i = 0; i < size; ++i) { + const T_EXPECTED& ref = expected[i]; + const auto& res = actual[i]; + const auto absoluteDifference = ov::test::utils::ie_abs(res - ref); + if (abs_threshold > 0.f && absoluteDifference > abs_threshold) { + OPENVINO_THROW("Absolute comparison of values expected: ", + std::to_string(ref), + " and actual: ", + std::to_string(res), + " at index ", + i, + " with absolute threshold ", + abs_threshold, + " failed"); + } + if (absoluteDifference <= threshold) { + continue; + } + double max; + if (sizeof(T_ACTUAL) < sizeof(T_EXPECTED)) { + max = static_cast(std::max(ov::test::utils::ie_abs(T_EXPECTED(res)), ov::test::utils::ie_abs(ref))); + } else { + max = static_cast(std::max(ov::test::utils::ie_abs(res), ov::test::utils::ie_abs(T_ACTUAL(ref)))); + } + double diff = static_cast(absoluteDifference) / max; + if (max == 0 || (diff > static_cast(threshold)) || + (std::isnan(static_cast(res)) ^ std::isnan(static_cast(ref)))) { + OPENVINO_THROW("Relative comparison of values expected: ", + std::to_string(ref), + " and actual: ", + std::to_string(res), + " at index ", + i, + " with threshold ", + threshold, + " failed"); + } + } +} + } // namespace utils } // namespace test } // namespace ov diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/broadcast.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/broadcast.hpp new file mode 100644 index 00000000000000..c3e9cb4ae2cd07 --- /dev/null +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/broadcast.hpp @@ -0,0 +1,19 @@ +// Copyright (C) 2018-2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "openvino/core/node.hpp" + +namespace ov { +namespace test { +namespace utils { +std::shared_ptr make_broadcast(const Output& node, + const Shape& target_shape, + const AxisSet& broadcast_axes); + +std::shared_ptr make_broadcast(const Output& node, const Shape& target_shape, std::size_t start_match_axis); +} // namespace utils +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/reshape.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/reshape.hpp new file mode 100644 index 00000000000000..3c13af77d110ca --- /dev/null +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/reshape.hpp @@ -0,0 +1,21 @@ +// Copyright (C) 2018-2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "openvino/core/node.hpp" + +namespace ov { +namespace test { +namespace utils { +/// \brief Change shape of a value +/// +/// \param[in] value The value to be reshaped. +/// \param[in] shape The new shape. +/// +/// \return Reshape:v1 op. +std::shared_ptr reshape(const Output& value, const Shape& shape); +} // namespace utils +} // namespace test +} // namespace ov diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/ov_tensor_utils.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/ov_tensor_utils.hpp index 3c9d97eeb72822..0bd6140e2133ad 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/ov_tensor_utils.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/ov_tensor_utils.hpp @@ -36,46 +36,46 @@ ov::Tensor create_and_fill_tensor(const ov::element::Type element_type, const int seed = 1); template -static ov::runtime::Tensor create_tensor(const ov::element::Type& element_type, - const ov::Shape& shape, - const std::vector& values, - const size_t size = 0) { +static ov::Tensor create_tensor(const ov::element::Type& element_type, + const ov::Shape& shape, + const std::vector& values, + const size_t size = 0) { const size_t real_size = size ? size : values.size() * sizeof(T) / element_type.size(); - ov::runtime::Tensor tensor{element_type, shape}; + ov::Tensor tensor{element_type, shape}; std::memcpy(tensor.data(), values.data(), std::min(real_size * element_type.size(), sizeof(T) * values.size())); return tensor; } -ov::runtime::Tensor create_and_fill_tensor_act_dft(const ov::element::Type element_type, - const ov::Shape& shape, - const uint32_t range = 10, - const double_t start_from = 0, - const int32_t resolution = 1, - const int seed = 1); +ov::Tensor create_and_fill_tensor_act_dft(const ov::element::Type element_type, + const ov::Shape& shape, + const uint32_t range = 10, + const double_t start_from = 0, + const int32_t resolution = 1, + const int seed = 1); -ov::runtime::Tensor create_and_fill_tensor_unique_sequence(const ov::element::Type element_type, - const ov::Shape& shape, - const int32_t start_from = 0, - const int32_t resolution = 1, - const int seed = 1); +ov::Tensor create_and_fill_tensor_unique_sequence(const ov::element::Type element_type, + const ov::Shape& shape, + const int32_t start_from = 0, + const int32_t resolution = 1, + const int seed = 1); -ov::runtime::Tensor create_and_fill_tensor_normal_distribution(const ov::element::Type element_type, - const ov::Shape& shape, - const float mean, - const float stddev, - const int seed = 1); +ov::Tensor create_and_fill_tensor_normal_distribution(const ov::element::Type element_type, + const ov::Shape& shape, + const float mean, + const float stddev, + const int seed = 1); -ov::runtime::Tensor create_and_fill_tensor_consistently(const ov::element::Type element_type, - const ov::Shape& shape, - const uint32_t range, - const int32_t start_from, - const int32_t resolution); +ov::Tensor create_and_fill_tensor_consistently(const ov::element::Type element_type, + const ov::Shape& shape, + const uint32_t range, + const int32_t start_from, + const int32_t resolution); -ov::runtime::Tensor create_and_fill_tensor_real_distribution(const ov::element::Type element_type, - const ov::Shape& shape, - const float min, - const float max, - const int seed); +ov::Tensor create_and_fill_tensor_real_distribution(const ov::element::Type element_type, + const ov::Shape& shape, + const float min, + const float max, + const int seed); void compare(const ov::Tensor& expected, const ov::Tensor& actual, diff --git a/src/core/include/ngraph/specialize_function.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/specialize_function.hpp similarity index 81% rename from src/core/include/ngraph/specialize_function.hpp rename to src/tests/test_utils/common_test_utils/include/common_test_utils/specialize_function.hpp index 67c3c0636ff7a1..15686cc4492526 100644 --- a/src/core/include/ngraph/specialize_function.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/specialize_function.hpp @@ -1,28 +1,16 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #pragma once -#if !defined(IN_OV_COMPONENT) && !defined(NGRAPH_LEGACY_HEADER_INCLUDED) -# define NGRAPH_LEGACY_HEADER_INCLUDED -# ifdef _MSC_VER -# pragma message( \ - "The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# else -# warning("The nGraph API is deprecated and will be removed in the 2024.0 release. For instructions on transitioning to the new API, please refer to https://docs.openvino.ai/latest/openvino_2_0_transition_guide.html") -# endif -#endif - -#include - -#include "ngraph/deprecated.hpp" -#include "ngraph/ngraph_visibility.hpp" #include "openvino/core/model.hpp" #include "openvino/core/shape.hpp" #include "openvino/core/type.hpp" -namespace ngraph { +namespace ov { +namespace test { +namespace utils { /// \brief Creates a "specialized" clone of a function. The partial shapes and element types of /// the function's parameters may be narrowed to more specific shapes and element type /// and constant values may optionally be substituted for any or all of the parameters. @@ -49,7 +37,7 @@ namespace ngraph { /// param2: {?,?,4} /// ``` /// -/// Shape specialization would allow us to create a clone of f where the shapes are (for +/// ov::Shape specialization would allow us to create a clone of f where the shapes are (for /// example): /// /// ``` @@ -96,7 +84,7 @@ namespace ngraph { /// same as the number of f's parameters. /// 2. Each shape in parameter_shapes is a refinement of the shape of the corresponding /// parameter of f. Roughly speaking, a shape s1 is said to "refine" s2 if s1 can be -/// obtained from s2 by filling in s2's question marks. See PartialShape::refines for +/// obtained from s2 by filling in s2's question marks. See ov::PartialShape::refines for /// more details. /// 3. For all i, either the element type of fp_i is dynamic, or fp_i is the same as /// parameter_element_types[i]. (Here fp_i is the ith parameter of f.) @@ -105,10 +93,10 @@ namespace ngraph { /// which a Constant node with element type parameter_element_types[i] and shape /// parameter_shapes[i] can be created. /// -NGRAPH_API_DEPRECATED -NGRAPH_API -std::shared_ptr specialize_function(std::shared_ptr f, +std::shared_ptr specialize_function(std::shared_ptr model, const std::vector& parameter_element_types, const std::vector& parameter_shapes, const std::vector& parameter_values); -} // namespace ngraph +} // namespace utils +} // namespace test +} // namespace ov diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/unicode_utils.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/unicode_utils.hpp index 9b72fa448ee8b3..df0260400f27d9 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/unicode_utils.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/unicode_utils.hpp @@ -11,8 +11,8 @@ #include "common_test_utils/common_utils.hpp" #include "common_test_utils/w_dirent.h" -#include "file_utils.h" #include "gtest/gtest.h" +#include "openvino/util/file_util.hpp" #ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT @@ -95,7 +95,7 @@ inline int removeFilesWithExt(std::wstring path, std::wstring ext) { _WDIR* dir = _wopendir(path.c_str()); if (dir != nullptr) { while ((ent = _wreaddir(dir)) != NULL) { - auto file = ::FileUtils::makePath(path, std::wstring(ent->wd_name)); + auto file = ov::util::make_path(path, std::wstring(ent->wd_name)); struct _stat64i32 stat_path; _wstat(file.c_str(), &stat_path); if (!S_ISDIR(stat_path.st_mode) && endsWith(file, L"." + ext)) { @@ -116,7 +116,7 @@ inline int removeFilesWithExt(std::wstring path, std::wstring ext) { DIR* dir = opendir(path_mb.c_str()); if (dir != nullptr) { while ((ent = readdir(dir)) != NULL) { - std::string file = ::FileUtils::makePath(path_mb, std::string(ent->d_name)); + std::string file = ov::util::make_path(path_mb, std::string(ent->d_name)); struct stat stat_path; stat(file.c_str(), &stat_path); if (!S_ISDIR(stat_path.st_mode) && endsWith(file, "." + ext_mb)) { diff --git a/src/tests/test_utils/common_test_utils/src/data_utils.cpp b/src/tests/test_utils/common_test_utils/src/data_utils.cpp index dc43186c7f3142..c9c25f82235cec 100644 --- a/src/tests/test_utils/common_test_utils/src/data_utils.cpp +++ b/src/tests/test_utils/common_test_utils/src/data_utils.cpp @@ -338,7 +338,7 @@ void fill_psroi(ov::Tensor& tensor, } template -inline void fill_data_roi_impl(ov::runtime::Tensor& tensor, +inline void fill_data_roi_impl(ov::Tensor& tensor, const uint32_t range, const int height, const int width, @@ -384,7 +384,7 @@ inline void fill_data_roi_impl(ov::runtime::Tensor& tensor, } } -void fill_data_roi(ov::runtime::Tensor& tensor, +void fill_data_roi(ov::Tensor& tensor, const uint32_t range, const int height, const int width, diff --git a/src/tests/test_utils/common_test_utils/src/graph_comparator.cpp b/src/tests/test_utils/common_test_utils/src/graph_comparator.cpp index 5b4fa456fb7e5c..b5e4c2d116b528 100644 --- a/src/tests/test_utils/common_test_utils/src/graph_comparator.cpp +++ b/src/tests/test_utils/common_test_utils/src/graph_comparator.cpp @@ -6,7 +6,6 @@ #include "common_test_utils/ov_tensor_utils.hpp" #include "gtest/gtest.h" -#include "ie_common.h" #include "openvino/op/constant.hpp" #include "openvino/op/loop.hpp" #include "openvino/op/result.hpp" @@ -1024,7 +1023,7 @@ AccuracyCheckResult accuracy_check(const std::shared_ptr& ref_functio return AccuracyCheckResult{true, ""}; } try { - IE_ASSERT(ref_function->get_parameters().size() == cur_function->get_parameters().size()); + OPENVINO_ASSERT(ref_function->get_parameters().size() == cur_function->get_parameters().size()); std::map, ov::Tensor> ref_input_data; std::map, ov::Tensor> cur_input_data; @@ -1038,7 +1037,7 @@ AccuracyCheckResult accuracy_check(const std::shared_ptr& ref_functio auto ref_outputs = ngraph::helpers::interpretFunction(ref_function, ref_input_data); auto outputs = ngraph::helpers::interpretFunction(cur_function, cur_input_data); - IE_ASSERT(ref_outputs.size() == outputs.size()); + OPENVINO_ASSERT(ref_outputs.size() == outputs.size()); for (int i = 0; i < ref_outputs.size(); i++) { ov::test::utils::compare(ref_outputs[i], outputs[i], abs_threshold, rel_threshold); diff --git a/src/tests/ov_helpers/ov_models/ov_builders/src/broadcast.cpp b/src/tests/test_utils/common_test_utils/src/node_builders/broadcast.cpp similarity index 70% rename from src/tests/ov_helpers/ov_models/ov_builders/src/broadcast.cpp rename to src/tests/test_utils/common_test_utils/src/node_builders/broadcast.cpp index 521aec892c72ab..e282821c19fedf 100644 --- a/src/tests/ov_helpers/ov_models/ov_builders/src/broadcast.cpp +++ b/src/tests/test_utils/common_test_utils/src/node_builders/broadcast.cpp @@ -1,9 +1,10 @@ -// Copyright (C) 2018-2022 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // -#include "ov_models/ov_builders/broadcast.hpp" +#include "common_test_utils/node_builders/broadcast.hpp" +#include "common_test_utils/node_builders/reshape.hpp" #include "openvino/op/add.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/constant.hpp" @@ -11,11 +12,10 @@ #include "openvino/op/range.hpp" #include "openvino/op/reshape.hpp" #include "openvino/op/shape_of.hpp" -#include "ov_models/ov_builders/reshape.hpp" namespace ov { -namespace op { -namespace util { +namespace test { +namespace utils { namespace { /// /// \brief Reconstructs axes mapping vector for Broadcast:v1 operation. @@ -43,19 +43,19 @@ std::vector get_axes_mapping(const Shape& output_shape, const AxisSet& b /// /// \return The Output object with Node returning axes mapping. /// -Output get_axes_mapping_output(const Shape& output_shape, const AxisSet& broadcast_axes) { +Output get_axes_mapping_output(const Shape& output_shape, const AxisSet& broadcast_axes) { std::vector axes_mapping{get_axes_mapping(output_shape, broadcast_axes)}; return ov::op::v0::Constant::create(ov::element::i64, Shape{axes_mapping.size()}, axes_mapping); } -static Output get_axes_mapping_output(const PartialShape& output_shape, - const Output& input_shape, - std::size_t start_match_axis) { +Output get_axes_mapping_output(const PartialShape& output_shape, + const Output& input_shape, + std::size_t start_match_axis) { const auto one_node = ov::op::v0::Constant::create(ov::element::i64, Shape{}, {1}); const auto zero_node = ov::op::v0::Constant::create(ov::element::i64, Shape{}, {0}); const auto start_match_axis_node = ov::op::v0::Constant::create(ov::element::i64, Shape{}, {start_match_axis}); const auto target_shape_rank_node = - ov::op::util::reshape(std::make_shared(input_shape), Shape{}); + ov::test::utils::reshape(std::make_shared(input_shape), Shape{}); const auto range_node = std::make_shared(zero_node, target_shape_rank_node, one_node, element::i64); @@ -65,25 +65,28 @@ static Output get_axes_mapping_output(const PartialShape& output_shape, std::make_shared(range_node, start_match_axis_node->get_element_type()); // end of workaround - const auto result = std::make_shared(range_node_converted, start_match_axis_node); - return result; + return std::make_shared(range_node_converted, start_match_axis_node); } } // namespace -Output make_broadcast(const Output& node, const Shape& target_shape, const AxisSet& broadcast_axes) { +std::shared_ptr make_broadcast(const Output& node, + const Shape& target_shape, + const AxisSet& broadcast_axes) { return std::make_shared( node, ov::op::v0::Constant::create(ov::element::i64, Shape{target_shape.size()}, target_shape), get_axes_mapping_output(target_shape, broadcast_axes)); } -Output make_broadcast(const Output& node, const Shape& target_shape, size_t start_match_axis) { +std::shared_ptr make_broadcast(const Output& node, + const Shape& target_shape, + size_t start_match_axis) { const auto node_shape = std::make_shared(node); return std::make_shared( node, ov::op::v0::Constant::create(ov::element::i64, Shape{target_shape.size()}, target_shape), get_axes_mapping_output(target_shape, node_shape, start_match_axis)); } -} // namespace util -} // namespace op +} // namespace utils +} // namespace test } // namespace ov diff --git a/src/tests/test_utils/common_test_utils/src/node_builders/reshape.cpp b/src/tests/test_utils/common_test_utils/src/node_builders/reshape.cpp new file mode 100644 index 00000000000000..7ea8196f39eaf0 --- /dev/null +++ b/src/tests/test_utils/common_test_utils/src/node_builders/reshape.cpp @@ -0,0 +1,44 @@ +// Copyright (C) 2018-2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "common_test_utils/node_builders/reshape.hpp" + +#include "openvino/op/add.hpp" +#include "openvino/op/broadcast.hpp" +#include "openvino/op/concat.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/convert.hpp" +#include "openvino/op/range.hpp" +#include "openvino/op/reduce_prod.hpp" +#include "openvino/op/reshape.hpp" +#include "openvino/op/shape_of.hpp" +#include "openvino/op/squeeze.hpp" +#include "openvino/op/strided_slice.hpp" +#include "openvino/op/subtract.hpp" +#include "openvino/op/transpose.hpp" +#include "openvino/op/variadic_split.hpp" + +namespace ov { +namespace test { +namespace utils { +std::shared_ptr reshape(const Output& value, const Shape& shape) { + if (value.get_partial_shape().same_scheme(shape)) { + return value.get_node_shared_ptr(); + } else if (is_scalar(shape)) { + auto value_rank = value.get_shape().size(); + AxisVector axes_vector(value_rank); + std::iota(axes_vector.begin(), axes_vector.end(), 0); + auto axes = ov::op::v0::Constant::create(ov::element::i64, Shape{value_rank}, axes_vector); + return std::make_shared(value, axes); + } else { + auto out_pattern = ov::op::v0::Constant::create(ov::element::i64, + Shape{shape.size()}, + std::vector(shape.begin(), shape.end())); + + return std::make_shared(value, out_pattern, false); + } +} +} // namespace utils +} // namespace test +} // namespace ov diff --git a/src/tests/test_utils/common_test_utils/src/ov_tensor_utils.cpp b/src/tests/test_utils/common_test_utils/src/ov_tensor_utils.cpp index 281310fb4e83c7..ee85e0c88cebad 100644 --- a/src/tests/test_utils/common_test_utils/src/ov_tensor_utils.cpp +++ b/src/tests/test_utils/common_test_utils/src/ov_tensor_utils.cpp @@ -174,12 +174,12 @@ ov::Tensor create_and_fill_tensor_unique_sequence(const ov::element::Type elemen return tensor; } -ov::runtime::Tensor create_and_fill_tensor_normal_distribution(const ov::element::Type element_type, - const ov::Shape& shape, - const float mean, - const float stddev, - const int seed) { - auto tensor = ov::runtime::Tensor{element_type, shape}; +ov::Tensor create_and_fill_tensor_normal_distribution(const ov::element::Type element_type, + const ov::Shape& shape, + const float mean, + const float stddev, + const int seed) { + auto tensor = ov::Tensor{element_type, shape}; #define CASE(X) \ case X: \ fill_data_ptr_normal_random_float(tensor.data::value_type>(), \ @@ -218,12 +218,12 @@ ov::runtime::Tensor create_and_fill_tensor_normal_distribution(const ov::element return tensor; } -ov::runtime::Tensor create_and_fill_tensor_real_distribution(const ov::element::Type element_type, - const ov::Shape& shape, - const float min, - const float max, - const int seed) { - auto tensor = ov::runtime::Tensor{element_type, shape}; +ov::Tensor create_and_fill_tensor_real_distribution(const ov::element::Type element_type, + const ov::Shape& shape, + const float min, + const float max, + const int seed) { + auto tensor = ov::Tensor{element_type, shape}; #define CASE(X) \ case X: \ fill_data_ptr_real_random_float(tensor.data::value_type>(), \ @@ -258,12 +258,12 @@ ov::runtime::Tensor create_and_fill_tensor_real_distribution(const ov::element:: return tensor; } -ov::runtime::Tensor create_and_fill_tensor_consistently(const ov::element::Type element_type, - const ov::Shape& shape, - const uint32_t range, - const int32_t start_from, - const int32_t resolution) { - auto tensor = ov::runtime::Tensor{element_type, shape}; +ov::Tensor create_and_fill_tensor_consistently(const ov::element::Type element_type, + const ov::Shape& shape, + const uint32_t range, + const int32_t start_from, + const int32_t resolution) { + auto tensor = ov::Tensor{element_type, shape}; #define CASE(X) \ case X: \ fill_data_ptr_consistently(tensor.data::value_type>(), \ diff --git a/src/tests/test_utils/common_test_utils/src/specialize_function.cpp b/src/tests/test_utils/common_test_utils/src/specialize_function.cpp new file mode 100644 index 00000000000000..b27c724c5398af --- /dev/null +++ b/src/tests/test_utils/common_test_utils/src/specialize_function.cpp @@ -0,0 +1,96 @@ +// Copyright (C) 2018-2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "common_test_utils/specialize_function.hpp" + +#include "openvino/op/constant.hpp" +#include "openvino/op/parameter.hpp" +#include "openvino/op/util/op_types.hpp" + +namespace ov { +namespace test { +namespace utils { +std::shared_ptr specialize_function(std::shared_ptr model, + const std::vector& parameter_element_types, + const std::vector& parameter_shapes, + const std::vector& parameter_values) { + OPENVINO_ASSERT(model->get_parameters().size() == parameter_shapes.size()); + OPENVINO_ASSERT(model->get_parameters().size() == parameter_element_types.size()); + OPENVINO_ASSERT(model->get_parameters().size() == parameter_values.size()); + + std::unordered_map> nodes; + + for (size_t i = 0; i < parameter_shapes.size(); i++) { + OPENVINO_ASSERT(model->get_parameters()[i]->get_element_type().is_dynamic() || + parameter_element_types[i] == model->get_parameters()[i]->get_element_type()); + + if (parameter_values[i] != nullptr && parameter_shapes[i].is_static() && + parameter_element_types[i].is_static()) { + nodes[model->get_parameters()[i].get()] = std::make_shared(parameter_element_types[i], + parameter_shapes[i].to_shape(), + parameter_values[i]); + } else { + nodes[model->get_parameters()[i].get()] = + std::make_shared(parameter_element_types[i], parameter_shapes[i]); + } + auto rt_info = model->get_parameters()[i]->get_rt_info(); + nodes[model->get_parameters()[i].get()]->get_rt_info() = rt_info; + } + + for (auto old_node : model->get_ordered_ops()) { + if (op::util::is_parameter(old_node)) { + continue; + } + + OutputVector new_args; + for (auto input : old_node->inputs()) { + auto output = input.get_source_output(); + new_args.push_back(output.for_node(nodes[output.get_node()])); + } + + NodeVector cloned_dependencies; + for (auto& dependency : old_node->get_control_dependencies()) { + std::shared_ptr dependent = nodes.at(dependency.get()); + if (find(cloned_dependencies.begin(), cloned_dependencies.end(), dependent) == cloned_dependencies.end()) { + cloned_dependencies.push_back(dependent); + } + } + nodes[old_node.get()] = old_node->copy_with_new_inputs(new_args, cloned_dependencies); + + auto rt_info = old_node->get_rt_info(); + nodes[old_node.get()]->get_rt_info() = rt_info; + + nodes[old_node.get()]->set_friendly_name(old_node->get_friendly_name()); + } + + ParameterVector new_parameters = model->get_parameters(); + for (size_t i = 0; i < new_parameters.size(); i++) { + auto name = new_parameters[i]->get_friendly_name(); + new_parameters[i] = as_type_ptr(nodes[new_parameters[i].get()]); + + // If the replacement for a Parameter is not itself a Parameter, we must have replaced it + // with a constant. We will insert a dead Parameter into the clone's parameters, in order + // to maintain the arity of the original function. + if (new_parameters[i] == nullptr) { + new_parameters[i] = std::make_shared(parameter_element_types[i], parameter_shapes[i]); + } + new_parameters[i]->set_friendly_name(name); + } + + ResultVector new_results = model->get_results(); + for (size_t i = 0; i < new_results.size(); i++) { + auto name = new_results[i]->get_friendly_name(); + new_results[i] = std::static_pointer_cast(nodes[new_results[i].get()]); + new_results[i]->set_friendly_name(name); + } + auto new_sinks = model->get_sinks(); + for (size_t i = 0; i < new_sinks.size(); i++) { + new_sinks[i] = std::static_pointer_cast(nodes[new_sinks[i].get()]); + } + + return std::make_shared(new_results, new_sinks, new_parameters); +} +} // namespace utils +} // namespace test +} // namespace ov diff --git a/src/core/tests/specialize_function.cpp b/src/tests/test_utils/common_test_utils/tests/specialize_function.cpp similarity index 97% rename from src/core/tests/specialize_function.cpp rename to src/tests/test_utils/common_test_utils/tests/specialize_function.cpp index 9da33c1bd18c75..e8eb4bc4f565c7 100644 --- a/src/core/tests/specialize_function.cpp +++ b/src/tests/test_utils/common_test_utils/tests/specialize_function.cpp @@ -1,18 +1,18 @@ -// Copyright (C) 2018-2023 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // -#include "ngraph/specialize_function.hpp" +#include "common_test_utils/specialize_function.hpp" #include "gtest/gtest.h" #include "openvino/op/add.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/convert.hpp" -using namespace ngraph; using namespace ov; -NGRAPH_SUPPRESS_DEPRECATED_START; +using namespace ov::test::utils; +using ov::Shape; using ov::op::v0::Constant; using ov::op::v0::Convert; using ov::op::v0::Parameter; @@ -209,7 +209,7 @@ TEST(specialize_function, et_static_shape_rank_static_dynamic_rank_mismatch) { {ov::PartialShape{1, 2, 3}, ov::PartialShape{1, 2, 3, 4}}, param_vals); }, - CheckFailure); + ov::AssertFailure); } // Test specialization of rank-static dynamic shapes, where the replacement shapes have wrong @@ -236,7 +236,7 @@ TEST(specialize_function, et_static_shape_rank_static_dynamic_dim_mismatch) { {ov::PartialShape{1, 2, 3}, ov::PartialShape{1, 9, 4}}, param_vals); }, - CheckFailure); + ov::AssertFailure); } // Test for failure when we supply the wrong number of replacement element types. @@ -258,7 +258,7 @@ TEST(specialize_function, et_count_wrong) { {ov::PartialShape{1, 2, 3}, ov::PartialShape{1, 2, 3}}, param_vals); }, - CheckFailure); + ov::AssertFailure); } // Test for failure when we supply the wrong number of replacement shapes. @@ -280,7 +280,7 @@ TEST(specialize_function, shape_count_wrong) { {ov::PartialShape{1, 2, 3}, ov::PartialShape{1, 2, 3}, ov::PartialShape{4, 5, 6}}, param_vals); }, - CheckFailure); + ov::AssertFailure); } // Test for failure when we supply the wrong number of replacement parameter values. @@ -302,5 +302,5 @@ TEST(specialize_function, value_count_wrong) { {ov::PartialShape{1, 2, 3}, ov::PartialShape{1, 2, 3}}, param_vals); }, - CheckFailure); + ov::AssertFailure); } diff --git a/src/tests/test_utils/functional_test_utils/include/functional_test_utils/blob_utils.hpp b/src/tests/test_utils/functional_test_utils/include/functional_test_utils/blob_utils.hpp index e38e925897fbbf..ed45a216537072 100644 --- a/src/tests/test_utils/functional_test_utils/include/functional_test_utils/blob_utils.hpp +++ b/src/tests/test_utils/functional_test_utils/include/functional_test_utils/blob_utils.hpp @@ -13,12 +13,9 @@ #include #include "blob_factory.hpp" -#include "blob_transform.hpp" #include "common_test_utils/data_utils.hpp" #include "common_test_utils/test_constants.hpp" -#include "ie_ngraph_utils.hpp" #include "openvino/runtime/common.hpp" -#include "precision_utils.h" namespace FuncTestUtils { namespace Bf16TestUtils { @@ -226,93 +223,6 @@ inline void compareRawBuffers(const std::vector res, compareRawBuffers(res, ref, resSizes, refSizes, CompareType::ABS_AND_REL, thr, thr, printData); } -template -inline void compareBlobData(const InferenceEngine::Blob::Ptr& res, - const InferenceEngine::Blob::Ptr& ref, - float max_diff = 0.01, - const std::string& assertDetails = "", - bool printData = false) { - using dataType = typename InferenceEngine::PrecisionTrait::value_type; - const dataType* res_ptr = res->cbuffer().as(); - size_t res_size = res->byteSize(); - - const dataType* ref_ptr = ref->cbuffer().as(); - size_t ref_size = ref->byteSize(); - - ASSERT_EQ(res_size, ref_size) << "Comparing blobs have different size. " << assertDetails; - if (printData) { - std::cout << "Reference results: " << std::endl; - for (size_t i = 0; i < ref_size / sizeof(dataType); i++) { - std::cout << ref_ptr[i] << " "; - } - std::cout << std::endl; - std::cout << "Test results: " << std::endl; - for (size_t i = 0; i < res_size / sizeof(dataType); i++) { - std::cout << res_ptr[i] << " "; - } - std::cout << std::endl; - } - - for (size_t i = 0; i < ref_size / sizeof(dataType); i++) { - auto resVal = PRC == InferenceEngine::Precision::FP16 - ? InferenceEngine::PrecisionUtils::f16tof32(static_cast(res_ptr[i])) - : static_cast(res_ptr[i]); - auto refVal = PRC == InferenceEngine::Precision::FP16 - ? InferenceEngine::PrecisionUtils::f16tof32(static_cast(ref_ptr[i])) - : static_cast(ref_ptr[i]); - float absDiff = std::abs(resVal - refVal); - if (absDiff > max_diff) { - float relDiff = absDiff / std::max(res_ptr[i], ref_ptr[i]); - ASSERT_LE(relDiff, max_diff) << "Relative comparison of values ref: " << ref_ptr[i] - << " and res: " << res_ptr[i] << " , index in blobs: " << i << " failed!" - << assertDetails; - } - } -} - -template -inline void compareBlobData(const std::vector& res, - const std::vector& ref, - float max_diff = 0.01, - const std::string& assertDetails = "", - bool printData = false) { - IE_ASSERT(res.size() == ref.size()) << "Length of comparing and references blobs vector are not equal!" - << assertDetails; - for (size_t i = 0; i < res.size(); i++) { - if (printData) - std::cout << "BEGIN CHECK BLOB [" << i << "]" << std::endl; - compareBlobData(res[i], ref[i], max_diff, assertDetails, printData); - if (printData) - std::cout << "END CHECK BLOB [" << i << "]" << std::endl; - } -} - -inline void compareBlobs(const InferenceEngine::Blob::Ptr& res, - const InferenceEngine::Blob::Ptr& ref, - float max_diff = 0.01, - const std::string& assertDetails = "", - bool printData = false) { - ASSERT_EQ(res->byteSize(), ref->byteSize()) - << "Blobs have different byteSize(): " << res->byteSize() << " and " << ref->byteSize(); - - ASSERT_EQ(res->getTensorDesc(), ref->getTensorDesc()) << "Blobs have different TensorDesc()"; - - switch (res->getTensorDesc().getPrecision()) { -#define COMPARE_WITH_REF(TYPE) \ - case TYPE: { \ - FuncTestUtils::compareBlobData(res, ref, max_diff, assertDetails, printData); \ - break; \ - } - COMPARE_WITH_REF(InferenceEngine::Precision::FP32); - COMPARE_WITH_REF(InferenceEngine::Precision::FP16); - COMPARE_WITH_REF(InferenceEngine::Precision::I64); -#undef COMPARE_WITH_REF - default: - IE_THROW() << "Precision " << res->getTensorDesc().getPrecision().name() - << " is not covered by FuncTestUtils::compareBlobs() method"; - } -} - inline void GetComparisonThreshold(InferenceEngine::Precision prc, float& absoluteThreshold, float& relativeThreshold) { switch (prc) { case InferenceEngine::Precision::FP32: @@ -349,13 +259,6 @@ inline void convertArrayPrecision(typename InferenceEngine::PrecisionTrait -inline void convertArrayPrecision(float* dst, - const short* src, - size_t nelem) { - InferenceEngine::PrecisionUtils::f16tof32Arrays(dst, src, nelem, 1.0f, 0.0f); -} - template <> inline void convertArrayPrecision(float* dst, const short* src, @@ -380,39 +283,6 @@ inline InferenceEngine::Blob::Ptr convertBlobPrecision(const InferenceEngine::Bl convertArrayPrecision(target, source, blob->size()); return new_blob; } -// Copy from net_pass.h - -template -inline InferenceEngine::Blob::Ptr copyBlobWithCast(const InferenceEngine::Blob::Ptr& blob) { - InferenceEngine::Blob::Ptr newBlob; - switch (blob->getTensorDesc().getPrecision()) { - case InferenceEngine::Precision::FP32: - newBlob = FuncTestUtils::convertBlobPrecision(blob); - break; - case InferenceEngine::Precision::FP16: - newBlob = FuncTestUtils::convertBlobPrecision(blob); - break; - case InferenceEngine::Precision::I16: - newBlob = FuncTestUtils::convertBlobPrecision(blob); - break; - case InferenceEngine::Precision::I8: - newBlob = FuncTestUtils::convertBlobPrecision(blob); - break; - case InferenceEngine::Precision::U8: - newBlob = FuncTestUtils::convertBlobPrecision(blob); - break; - case InferenceEngine::Precision::I32: - newBlob = FuncTestUtils::convertBlobPrecision(blob); - break; - case InferenceEngine::Precision::BOOL: - newBlob = FuncTestUtils::convertBlobPrecision(blob); - break; - default: - IE_THROW() << "Conversion from blob with precision " << blob->getTensorDesc().getPrecision().name() - << " not implemented yet!"; - } - return newBlob; -} inline InferenceEngine::Blob::Ptr createAndFillBlobFloatNormalDistribution(const InferenceEngine::TensorDesc& td, const float mean, @@ -591,26 +461,6 @@ inline InferenceEngine::Blob::Ptr createAndFillBlobUniqueSequence(const Inferenc return blob; } -inline InferenceEngine::Blob::Ptr convertBlobLayout(const InferenceEngine::Blob::Ptr& in, - InferenceEngine::Layout layout) { - IE_ASSERT(in != nullptr) << "Got NULL pointer"; - - const auto& inDesc = in->getTensorDesc(); - - if (inDesc.getLayout() == layout) { - return in; - } - - const auto outDesc = InferenceEngine::TensorDesc(inDesc.getPrecision(), inDesc.getDims(), layout); - - const auto out = make_blob_with_precision(outDesc); - out->allocate(); - - InferenceEngine::blob_copy(in, out); - - return out; -} - template inline void fillInputsBySinValues(dType* data, size_t size) { if (std::is_same::value) { diff --git a/src/tests/test_utils/functional_test_utils/include/functional_test_utils/precision_utils.hpp b/src/tests/test_utils/functional_test_utils/include/functional_test_utils/precision_utils.hpp index 1585517b3a7fd4..38ba8b8ea515f3 100644 --- a/src/tests/test_utils/functional_test_utils/include/functional_test_utils/precision_utils.hpp +++ b/src/tests/test_utils/functional_test_utils/include/functional_test_utils/precision_utils.hpp @@ -59,4 +59,4 @@ inline ::ov::element::Type convertIE2nGraphPrc(const InferenceEngine::Precision& } } // namespace PrecisionUtils -} // namespace FuncTestUtils +} // namespace FuncTestUtils \ No newline at end of file diff --git a/src/tests/test_utils/functional_test_utils/layer_tests_summary/github/skip_configs/CPU/expected_failures_API.csv b/src/tests/test_utils/functional_test_utils/layer_tests_summary/github/skip_configs/CPU/expected_failures_API.csv index 7503ce6ddc92ef..52b257b6251142 100644 --- a/src/tests/test_utils/functional_test_utils/layer_tests_summary/github/skip_configs/CPU/expected_failures_API.csv +++ b/src/tests/test_utils/functional_test_utils/layer_tests_summary/github/skip_configs/CPU/expected_failures_API.csv @@ -1,6 +1,5 @@ Test Name,Fix Priority ov_plugin_mandatory/OVCheckChangePropComplieModleGetPropTests_InferencePrecision.ChangeCorrectProperties/target_device=CPU_,1.0 -ov_plugin_mandatory/OVClassModelTestP.ImportModelWithNullContextThrows/0,1 ov_compiled_model_mandatory/OVClassCompiledModelGetPropertyTest_MODEL_PRIORITY.GetMetricNoThrow/3,1.0 ov_compiled_model_mandatory/OVClassCompiledModelGetPropertyTest_MODEL_PRIORITY.GetMetricNoThrow/2,1.0 ov_compiled_model_mandatory/OVClassCompiledModelGetPropertyTest_MODEL_PRIORITY.GetMetricNoThrow/1,1.0 diff --git a/src/tests/test_utils/functional_test_utils/src/ov_plugin_cache.cpp b/src/tests/test_utils/functional_test_utils/src/ov_plugin_cache.cpp index 3483506fc1e185..0ef81108ed8823 100644 --- a/src/tests/test_utils/functional_test_utils/src/ov_plugin_cache.cpp +++ b/src/tests/test_utils/functional_test_utils/src/ov_plugin_cache.cpp @@ -7,7 +7,6 @@ #include #include -#include #include #include "common_test_utils/file_utils.hpp" diff --git a/src/tests/test_utils/functional_test_utils/src/plugin_cache.cpp b/src/tests/test_utils/functional_test_utils/src/plugin_cache.cpp index 9c7e34af62ddc2..e809f9d260ca89 100644 --- a/src/tests/test_utils/functional_test_utils/src/plugin_cache.cpp +++ b/src/tests/test_utils/functional_test_utils/src/plugin_cache.cpp @@ -13,7 +13,6 @@ #include "common_test_utils/test_constants.hpp" #include "functional_test_utils/ov_plugin_cache.hpp" #include "ie_core.hpp" -#include "ie_plugin_config.hpp" #include "openvino/util/file_util.hpp" namespace { @@ -69,13 +68,13 @@ std::shared_ptr PluginCache::ie(const std::string& device std::vector metrics; if (deviceToCheck.find(':') != std::string::npos) { std::string realDevice = deviceToCheck.substr(0, deviceToCheck.find(':')); - metrics = {ie_core->GetMetric(realDevice, METRIC_KEY(SUPPORTED_METRICS)).as()}; + metrics = {ie_core->GetMetric(realDevice, ov::supported_properties.name()).as()}; } else { - metrics = {ie_core->GetMetric(deviceToCheck, METRIC_KEY(SUPPORTED_METRICS)).as()}; + metrics = {ie_core->GetMetric(deviceToCheck, ov::supported_properties.name()).as()}; } - if (std::find(metrics.begin(), metrics.end(), METRIC_KEY(AVAILABLE_DEVICES)) != metrics.end()) { + if (std::find(metrics.begin(), metrics.end(), ov::supported_properties.name()) != metrics.end()) { auto availableDevices = - ie_core->GetMetric(deviceToCheck, METRIC_KEY(AVAILABLE_DEVICES)).as>(); + ie_core->GetMetric(deviceToCheck, ov::supported_properties.name()).as>(); if (availableDevices.empty()) { std::cerr << "No available devices for " << deviceToCheck << std::endl; diff --git a/src/tests/test_utils/unit_test_utils/mock.cpp b/src/tests/test_utils/unit_test_utils/mock.cpp deleted file mode 100644 index ef76f4a137182e..00000000000000 --- a/src/tests/test_utils/unit_test_utils/mock.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "openvino/op/relu.hpp" -#include "unit_test_utils/mocks/cpp_interfaces/impl/mock_inference_plugin_internal.hpp" -#include "unit_test_utils/mocks/cpp_interfaces/interface/mock_iexecutable_network_internal.hpp" -#include "unit_test_utils/mocks/cpp_interfaces/interface/mock_iinfer_request_internal.hpp" -#include "unit_test_utils/mocks/cpp_interfaces/interface/mock_iinference_plugin.hpp" -#include "unit_test_utils/mocks/cpp_interfaces/interface/mock_ivariable_state_internal.hpp" -#include "unit_test_utils/mocks/cpp_interfaces/mock_task_executor.hpp" -#include "unit_test_utils/mocks/mock_allocator.hpp" -#include "unit_test_utils/mocks/mock_icnn_network.hpp" -#include "unit_test_utils/mocks/mock_iexecutable_network.hpp" -#include "unit_test_utils/mocks/mock_iinfer_request.hpp" -#include "unit_test_utils/mocks/mock_not_empty_icnn_network.hpp" - -using namespace InferenceEngine; - -void MockNotEmptyICNNNetwork::getOutputsInfo(OutputsDataMap& out) const noexcept { - IE_SUPPRESS_DEPRECATED_START - auto data = std::make_shared(MockNotEmptyICNNNetwork::OUTPUT_BLOB_NAME, Precision::UNSPECIFIED); - out[MockNotEmptyICNNNetwork::OUTPUT_BLOB_NAME] = data; - IE_SUPPRESS_DEPRECATED_END -} - -void MockNotEmptyICNNNetwork::getInputsInfo(InputsDataMap& inputs) const noexcept { - IE_SUPPRESS_DEPRECATED_START - auto inputInfo = std::make_shared(); - - auto inData = std::make_shared(MockNotEmptyICNNNetwork::INPUT_BLOB_NAME, Precision::UNSPECIFIED); - inData->setDims(MockNotEmptyICNNNetwork::INPUT_DIMENSIONS); - inData->setLayout(Layout::NCHW); - inputInfo->setInputData(inData); - - auto outData = std::make_shared(MockNotEmptyICNNNetwork::OUTPUT_BLOB_NAME, Precision::UNSPECIFIED); - outData->setDims(MockNotEmptyICNNNetwork::OUTPUT_DIMENSIONS); - outData->setLayout(Layout::NCHW); - - inputs[MockNotEmptyICNNNetwork::INPUT_BLOB_NAME] = inputInfo; - IE_SUPPRESS_DEPRECATED_END -} - -std::shared_ptr MockNotEmptyICNNNetwork::getFunction() noexcept { - ov::ParameterVector parameters; - parameters.push_back(std::make_shared( - ov::element::f32, - std::vector{INPUT_DIMENSIONS.begin(), INPUT_DIMENSIONS.end()})); - parameters.back()->set_friendly_name(INPUT_BLOB_NAME); - auto relu = std::make_shared(parameters.back()); - relu->set_friendly_name(OUTPUT_BLOB_NAME); - ov::ResultVector results; - results.push_back(std::make_shared(relu)); - return std::make_shared(results, parameters, "empty_function"); -} - -std::shared_ptr MockNotEmptyICNNNetwork::getFunction() const noexcept { - ov::ParameterVector parameters; - parameters.push_back(std::make_shared( - ov::element::f32, - std::vector{INPUT_DIMENSIONS.begin(), INPUT_DIMENSIONS.end()})); - parameters.back()->set_friendly_name(INPUT_BLOB_NAME); - auto relu = std::make_shared(parameters.back()); - relu->set_friendly_name(OUTPUT_BLOB_NAME); - ov::ResultVector results; - results.push_back(std::make_shared(relu)); - return std::make_shared(results, parameters, "empty_function"); -} diff --git a/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/impl/mock_inference_plugin_internal.hpp b/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/impl/mock_inference_plugin_internal.hpp deleted file mode 100644 index db1a288804c5a9..00000000000000 --- a/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/impl/mock_inference_plugin_internal.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -#include -#include -#include -#include -#include -#include - -#include "ie_icore.hpp" -#include "openvino/runtime/iplugin.hpp" - -class MockInferencePluginInternal : public InferenceEngine::IInferencePlugin { -public: - MOCK_METHOD2( - LoadExeNetworkImpl, - std::shared_ptr(const InferenceEngine::CNNNetwork&, - const std::map&)); - MOCK_METHOD1(AddExtension, void(const std::shared_ptr&)); - MOCK_METHOD1(SetConfig, void(const std::map&)); - - std::shared_ptr ImportNetwork( - std::istream& stream, - const std::map&) { - return {}; - } - - std::string importedString; -}; \ No newline at end of file diff --git a/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iexecutable_network_internal.hpp b/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iexecutable_network_internal.hpp deleted file mode 100644 index 501ddc34bd6ccf..00000000000000 --- a/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iexecutable_network_internal.hpp +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -#include -#include -#include -#include - -#include "ie_input_info.hpp" -#include "unit_test_utils/mocks/cpp_interfaces/interface/mock_iinfer_request_internal.hpp" - -using namespace InferenceEngine; - -class MockIExecutableNetworkInternal : public IExecutableNetworkInternal { -public: - MOCK_CONST_METHOD0(GetOutputsInfo, ConstOutputsDataMap(void)); - MOCK_CONST_METHOD0(GetInputsInfo, ConstInputsDataMap(void)); - MOCK_METHOD0(CreateInferRequest, IInferRequestInternal::Ptr(void)); - MOCK_METHOD1(Export, void(const std::string&)); - void Export(std::ostream&) override{}; - MOCK_METHOD0(GetExecGraphInfo, std::shared_ptr(void)); - - MOCK_METHOD1(SetConfig, void(const std::map& config)); - MOCK_CONST_METHOD1(GetConfig, Parameter(const std::string& name)); - MOCK_CONST_METHOD1(GetMetric, Parameter(const std::string& name)); - void WrapOstreamExport(std::ostream& networkModel) { - IExecutableNetworkInternal::Export(networkModel); - } -}; diff --git a/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iinfer_request_internal.hpp b/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iinfer_request_internal.hpp deleted file mode 100644 index 03307ae842818d..00000000000000 --- a/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iinfer_request_internal.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -#include -#include -#include -#include -#include - -class MockIInferRequestInternal : public InferenceEngine::IInferRequestInternal { -public: - using InferenceEngine::IInferRequestInternal::IInferRequestInternal; - MOCK_METHOD0(StartAsync, void()); - MOCK_METHOD1(Wait, InferenceEngine::StatusCode(int64_t)); - MOCK_METHOD0(Infer, void()); - MOCK_CONST_METHOD0(GetPerformanceCounts, std::map()); - MOCK_METHOD2(SetBlob, void(const std::string&, const InferenceEngine::Blob::Ptr&)); - MOCK_METHOD1(GetBlob, InferenceEngine::Blob::Ptr(const std::string&)); - MOCK_METHOD1(SetCallback, void(std::function)); - MOCK_METHOD0(QueryState, std::vector()); - MOCK_METHOD0(Cancel, void()); - MOCK_METHOD0(StartAsyncImpl, void()); - MOCK_METHOD0(InferImpl, void()); - MOCK_METHOD0(checkBlobs, void()); -}; diff --git a/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iinference_plugin.hpp b/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iinference_plugin.hpp deleted file mode 100644 index c5df4baefb87dd..00000000000000 --- a/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iinference_plugin.hpp +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -#include -#include - -#include "cpp_interfaces/interface/ie_iplugin_internal.hpp" -#include "ie_icore.hpp" - -class MockIInferencePlugin : public InferenceEngine::IInferencePlugin { -public: - MOCK_METHOD1(AddExtension, void(const std::shared_ptr&)); - MOCK_METHOD2( - LoadNetwork, - std::shared_ptr(const InferenceEngine::CNNNetwork&, - const std::map&)); - MOCK_METHOD2(LoadNetwork, - ov::SoPtr(const std::string&, - const std::map&)); - MOCK_METHOD2( - ImportNetwork, - std::shared_ptr(const std::string&, - const std::map&)); - MOCK_METHOD1(SetConfig, void(const std::map&)); - - MOCK_METHOD(void, SetName, (const std::string&), (noexcept)); - MOCK_METHOD(std::string, GetName, (), (const, noexcept)); - MOCK_METHOD(void, SetCore, (std::weak_ptr), (noexcept)); - MOCK_METHOD(std::shared_ptr, GetCore, (), (const, noexcept)); - MOCK_METHOD(bool, IsNewAPI, (), (const, noexcept)); - MOCK_CONST_METHOD2(GetConfig, - InferenceEngine::Parameter(const std::string&, - const std::map&)); - MOCK_CONST_METHOD2(GetMetric, - InferenceEngine::Parameter(const std::string&, - const std::map&)); - MOCK_METHOD2( - ImportNetwork, - std::shared_ptr(std::istream&, - const std::map&)); - MOCK_CONST_METHOD2(QueryNetwork, - InferenceEngine::QueryNetworkResult(const InferenceEngine::CNNNetwork&, - const std::map&)); -}; diff --git a/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_ivariable_state_internal.hpp b/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_ivariable_state_internal.hpp deleted file mode 100644 index 88fef91a51ef40..00000000000000 --- a/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_ivariable_state_internal.hpp +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -#include -#include -#include - -class MockIVariableStateInternal : public InferenceEngine::IVariableStateInternal { -public: - MockIVariableStateInternal() : InferenceEngine::IVariableStateInternal{"MockIVariableStateInternal"} {} - MOCK_CONST_METHOD0(GetName, std::string()); - MOCK_METHOD0(Reset, void()); - MOCK_METHOD1(SetState, void(const InferenceEngine::Blob::Ptr&)); - MOCK_CONST_METHOD0(GetState, InferenceEngine::Blob::CPtr()); -}; diff --git a/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/mock_task_executor.hpp b/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/mock_task_executor.hpp deleted file mode 100644 index ce74aba12da624..00000000000000 --- a/src/tests/test_utils/unit_test_utils/mocks/cpp_interfaces/mock_task_executor.hpp +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -#include - -#include "openvino/runtime/threading/itask_executor.hpp" - -class MockTaskExecutor : public ov::threading::ITaskExecutor { -public: - typedef std::shared_ptr Ptr; - - MOCK_METHOD1(run, void(ov::threading::Task)); -}; diff --git a/src/tests/test_utils/unit_test_utils/mocks/mock_allocator.hpp b/src/tests/test_utils/unit_test_utils/mocks/mock_allocator.hpp deleted file mode 100644 index 383efaa4873de5..00000000000000 --- a/src/tests/test_utils/unit_test_utils/mocks/mock_allocator.hpp +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -// -// Created by user on 20.10.16. -// - -#pragma once - -#include - -#include "ie_allocator.hpp" - -IE_SUPPRESS_DEPRECATED_START -class MockAllocator : public InferenceEngine::IAllocator { -public: - MOCK_METHOD(void*, lock, (void*, InferenceEngine::LockOp), (noexcept)); - MOCK_METHOD(void, unlock, (void*), (noexcept)); - MOCK_METHOD(void*, alloc, (size_t), (noexcept)); - MOCK_METHOD(bool, free, (void*), (noexcept)); // NOLINT(readability/casting) -}; -IE_SUPPRESS_DEPRECATED_END diff --git a/src/tests/test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.cpp b/src/tests/test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.cpp index 6ca6a9e5caab65..a528596a468884 100644 --- a/src/tests/test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.cpp +++ b/src/tests/test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.cpp @@ -14,7 +14,6 @@ #include "cpp_interfaces/interface/ie_iplugin_internal.hpp" #include "description_buffer.hpp" -#include "ie_icore.hpp" #include "openvino/core/except.hpp" #include "openvino/runtime/common.hpp" #include "openvino/runtime/icore.hpp" diff --git a/src/tests/test_utils/unit_test_utils/mocks/mock_icnn_network.hpp b/src/tests/test_utils/unit_test_utils/mocks/mock_icnn_network.hpp deleted file mode 100644 index afe0ea0aa2dd87..00000000000000 --- a/src/tests/test_utils/unit_test_utils/mocks/mock_icnn_network.hpp +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/** - * \brief header file for MockICNNNetwork - * \file mock_icnn_network.hpp - */ -#pragma once - -#include - -#include -#include - -#include "ie_icnn_network.hpp" - -IE_SUPPRESS_DEPRECATED_START - -namespace InferenceEngine { -class CNNLayer; -} // namespace InferenceEngine - -/** - * @class MockICNNNetwork - * @brief Main interface to describe the NN topology - */ -class MockICNNNetwork final : public InferenceEngine::ICNNNetwork { -public: - MOCK_METHOD(std::shared_ptr, getFunction, (), (const, noexcept)); - MOCK_METHOD(std::shared_ptr, getFunction, (), (noexcept)); - MOCK_METHOD(void, getOutputsInfo, (InferenceEngine::OutputsDataMap & out), (const, noexcept)); - MOCK_METHOD(void, getInputsInfo, (InferenceEngine::InputsDataMap & inputs), (const, noexcept)); - MOCK_METHOD(InferenceEngine::InputInfo::Ptr, getInput, (const std::string& inputName), (const, noexcept)); - MOCK_METHOD(size_t, layerCount, (), (const, noexcept)); - MOCK_METHOD(const std::string&, getName, (), (const, noexcept)); - MOCK_METHOD(InferenceEngine::StatusCode, - addOutput, - (const std::string&, size_t, InferenceEngine::ResponseDesc*), - (noexcept)); - MOCK_METHOD(InferenceEngine::StatusCode, - getLayerByName, - (const char*, std::shared_ptr&, InferenceEngine::ResponseDesc*), - (const, noexcept)); - MOCK_METHOD(InferenceEngine::StatusCode, - setBatchSize, - (const size_t size, InferenceEngine::ResponseDesc*), - (noexcept)); - MOCK_METHOD(size_t, getBatchSize, (), (const, noexcept)); - MOCK_METHOD(void, getInputShapes, (InferenceEngine::ICNNNetwork::InputShapes&), (const, noexcept)); - MOCK_METHOD(InferenceEngine::StatusCode, - reshape, - (const InferenceEngine::ICNNNetwork::InputShapes&, InferenceEngine::ResponseDesc*), - (const, noexcept)); - MOCK_METHOD(InferenceEngine::StatusCode, - serialize, - (const std::string&, const std::string&, InferenceEngine::ResponseDesc*), - (const, noexcept)); - MOCK_METHOD(InferenceEngine::StatusCode, - serialize, - (std::ostream&, std::ostream&, InferenceEngine::ResponseDesc*), - (const, noexcept)); - MOCK_METHOD(InferenceEngine::StatusCode, - serialize, - (std::ostream&, InferenceEngine::Blob::Ptr&, InferenceEngine::ResponseDesc*), - (const, noexcept)); -}; diff --git a/src/tests/test_utils/unit_test_utils/mocks/mock_iexecutable_network.hpp b/src/tests/test_utils/unit_test_utils/mocks/mock_iexecutable_network.hpp deleted file mode 100644 index c3a2b428acbfe2..00000000000000 --- a/src/tests/test_utils/unit_test_utils/mocks/mock_iexecutable_network.hpp +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/** - * \brief header file for MockIExecutableNetwork - * \file mock_iexecutable_network.hpp - */ -#pragma once - -#include - -#include -#include -#include - -#include "ie_iexecutable_network.hpp" - -using namespace InferenceEngine; - -IE_SUPPRESS_DEPRECATED_START - -class MockIExecutableNetwork : public IExecutableNetwork { -public: - MOCK_METHOD(StatusCode, GetOutputsInfo, (ConstOutputsDataMap&, ResponseDesc*), (const, noexcept)); - MOCK_METHOD(StatusCode, GetInputsInfo, (ConstInputsDataMap&, ResponseDesc*), (const, noexcept)); - MOCK_METHOD(StatusCode, CreateInferRequest, (IInferRequest::Ptr&, ResponseDesc*), (noexcept)); - MOCK_METHOD(StatusCode, Export, (const std::string&, ResponseDesc*), (noexcept)); - MOCK_METHOD(StatusCode, Export, (std::ostream&, ResponseDesc*), (noexcept)); - MOCK_METHOD(StatusCode, GetExecGraphInfo, (ICNNNetwork::Ptr&, ResponseDesc*), (noexcept)); - MOCK_METHOD(StatusCode, - SetConfig, - ((const std::map& config), ResponseDesc* resp), - (noexcept)); - MOCK_METHOD(StatusCode, - GetConfig, - (const std::string& name, Parameter& result, ResponseDesc* resp), - (const, noexcept)); - MOCK_METHOD(StatusCode, - GetMetric, - (const std::string& name, Parameter& result, ResponseDesc* resp), - (const, noexcept)); -}; - -IE_SUPPRESS_DEPRECATED_END diff --git a/src/tests/test_utils/unit_test_utils/mocks/mock_iinfer_request.hpp b/src/tests/test_utils/unit_test_utils/mocks/mock_iinfer_request.hpp deleted file mode 100644 index 2677416523e799..00000000000000 --- a/src/tests/test_utils/unit_test_utils/mocks/mock_iinfer_request.hpp +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/** - * \brief header file for MockIInferRequest - * \file mock_iinfer_request.hpp - */ -#pragma once - -#include - -#include -#include -#include - -#include "ie_iinfer_request.hpp" - -using namespace InferenceEngine; - -IE_SUPPRESS_DEPRECATED_START - -class MockIInferRequest : public IInferRequest { -public: - MOCK_METHOD(StatusCode, StartAsync, (ResponseDesc*), (noexcept)); - MOCK_METHOD(StatusCode, Wait, (int64_t, ResponseDesc*), (noexcept)); - MOCK_METHOD(StatusCode, GetUserData, (void**, ResponseDesc*), (noexcept)); - MOCK_METHOD(StatusCode, SetUserData, (void*, ResponseDesc*), (noexcept)); - MOCK_METHOD(StatusCode, SetCompletionCallback, (IInferRequest::CompletionCallback), (noexcept)); - MOCK_METHOD(StatusCode, Infer, (ResponseDesc*), (noexcept)); - MOCK_METHOD(StatusCode, - GetPerformanceCounts, - ((std::map&), ResponseDesc*), - (const, noexcept)); - MOCK_METHOD(StatusCode, GetBlob, (const char*, Blob::Ptr&, ResponseDesc*), (noexcept)); - MOCK_METHOD(StatusCode, SetBlob, (const char*, const Blob::Ptr&, ResponseDesc*), (noexcept)); - MOCK_METHOD(StatusCode, Cancel, (ResponseDesc*), (noexcept)); -}; - -IE_SUPPRESS_DEPRECATED_END diff --git a/src/tests/test_utils/unit_test_utils/mocks/mock_not_empty_icnn_network.hpp b/src/tests/test_utils/unit_test_utils/mocks/mock_not_empty_icnn_network.hpp deleted file mode 100644 index bc03e62c0d0e77..00000000000000 --- a/src/tests/test_utils/unit_test_utils/mocks/mock_not_empty_icnn_network.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -#include -#include -#include - -#include "ie_icnn_network.hpp" - -namespace InferenceEngine { - -IE_SUPPRESS_DEPRECATED_START - -class MockNotEmptyICNNNetwork final : public ICNNNetwork { -public: - static constexpr const char* INPUT_BLOB_NAME = "first_input"; - const SizeVector INPUT_DIMENSIONS = {1, 3, 299, 299}; - static constexpr const char* OUTPUT_BLOB_NAME = "first_output"; - const SizeVector OUTPUT_DIMENSIONS = {1, 3, 299, 299}; - const std::string name = "test"; - const std::string& getName() const noexcept override { - return name; - } - void getOutputsInfo(OutputsDataMap& out) const noexcept override; - void getInputsInfo(InputsDataMap& inputs) const noexcept override; - std::shared_ptr getFunction() noexcept override; - std::shared_ptr getFunction() const noexcept override; - MOCK_METHOD(InputInfo::Ptr, getInput, (const std::string& inputName), (const, noexcept)); - MOCK_METHOD(size_t, layerCount, (), (const, noexcept)); - MOCK_METHOD(StatusCode, addOutput, (const std::string&, size_t, ResponseDesc*), (noexcept)); - MOCK_METHOD(StatusCode, setBatchSize, (const size_t size, ResponseDesc*), (noexcept)); - MOCK_METHOD(size_t, getBatchSize, (), (const, noexcept)); - MOCK_METHOD(void, getInputShapes, (ICNNNetwork::InputShapes&), (const, noexcept)); - MOCK_METHOD(StatusCode, reshape, (const ICNNNetwork::InputShapes&, ResponseDesc*), (noexcept)); - MOCK_METHOD(StatusCode, - serialize, - (const std::string&, const std::string&, InferenceEngine::ResponseDesc*), - (const, noexcept)); - MOCK_METHOD(StatusCode, - serialize, - (std::ostream&, std::ostream&, InferenceEngine::ResponseDesc*), - (const, noexcept)); - MOCK_METHOD(StatusCode, serialize, (std::ostream&, Blob::Ptr&, InferenceEngine::ResponseDesc*), (const, noexcept)); -}; - -IE_SUPPRESS_DEPRECATED_END - -} // namespace InferenceEngine diff --git a/src/tests/test_utils/unit_test_utils/mocks/openvino/runtime/mock_icore.hpp b/src/tests/test_utils/unit_test_utils/mocks/openvino/runtime/mock_icore.hpp index f4a903be89eefc..7c73a9f4bd017b 100644 --- a/src/tests/test_utils/unit_test_utils/mocks/openvino/runtime/mock_icore.hpp +++ b/src/tests/test_utils/unit_test_utils/mocks/openvino/runtime/mock_icore.hpp @@ -6,8 +6,8 @@ #include -#include "ie_icore.hpp" #include "openvino/runtime/icompiled_model.hpp" +#include "openvino/runtime/icore.hpp" namespace ov { @@ -15,7 +15,7 @@ class MockICore : public ov::ICore { public: MOCK_METHOD(ov::Any, get_property, (const std::string&, const std::string&, const ov::AnyMap&), (const)); MOCK_METHOD(ov::Any, get_property, (const std::string&, const std::string&), (const)); - MOCK_METHOD(ov::AnyMap, get_supported_property, (const std::string&, const ov::AnyMap&), (const)); + MOCK_METHOD(ov::AnyMap, get_supported_property, (const std::string&, const ov::AnyMap&, const bool), (const)); MOCK_METHOD(bool, is_new_api, (), (const)); MOCK_METHOD(ov::SoPtr, diff --git a/tests/fuzz/src/CMakeLists.txt b/tests/fuzz/src/CMakeLists.txt index fc154c2f5fc74b..6f18bab6476889 100644 --- a/tests/fuzz/src/CMakeLists.txt +++ b/tests/fuzz/src/CMakeLists.txt @@ -17,7 +17,7 @@ foreach(test_source ${tests}) add_fuzzer(${test_name} ${test_source}) target_link_libraries(${test_name} PRIVATE - openvino::runtime cnpy zlib) + openvino::runtime openvino::cnpy openvino::zlib) add_dependencies(fuzz ${test_name}) diff --git a/tests/layer_tests/py_frontend_tests/test_torch_frontend.py b/tests/layer_tests/py_frontend_tests/test_torch_frontend.py index 7c0051c0feea11..338825f27aa451 100644 --- a/tests/layer_tests/py_frontend_tests/test_torch_frontend.py +++ b/tests/layer_tests/py_frontend_tests/test_torch_frontend.py @@ -314,7 +314,45 @@ def test_state_dict_names(): for n in om.get_ops(): if "Constant" in n.get_type_name(): for name in n.output(0).names: - matches = [k for k in state_dict_keys if name.startswith("self." + k)] + matches = [ + k for k in state_dict_keys if name.startswith("self." + k)] if (len(matches) > 0): common_names.update(matches) assert state_dict_keys == common_names, f"Not all names exist:\nstate_dict:{state_dict_keys}" + + +class ShareWeghtsConvAndShareLinearModel(torch.nn.Module): + INPUT_SIZE = [1, 1, 4, 4] + + def __init__(self): + super().__init__() + self.conv = torch.nn.Conv2d(1, 1, 1) + self.linear = torch.nn.Linear(4, 4) + self.linear.weight.data = torch.randn((4, 4), dtype=torch.float32) + self.linear.bias.data = torch.randn((1, 4), dtype=torch.float32) + + def forward(self, x): + for _ in range(2): + x = self.conv(x) + x = self.linear(x) + return x + + +def test_shared_consts_reused(): + from openvino.frontend.pytorch.ts_decoder import TorchScriptPythonDecoder + + model = ShareWeghtsConvAndShareLinearModel() + decoder = TorchScriptPythonDecoder(model, example_input=(torch.rand(model.INPUT_SIZE),)) + fe_manager = FrontEndManager() + fe = fe_manager.load_by_framework("pytorch") + im = fe.load(decoder) + om = fe.convert(im) + const_names = ["self.conv.weight", "self.linear.weight", "self.linear.bias"] + # self.conv.bias is not reused because of ConstantFolding + for n in om.get_ops(): + if "Constant" in n.get_type_name(): + for name in n.output(0).names: + if name in const_names: + const_names.remove(name) + assert len(n.output(0).get_target_inputs()) == 2, f"Constant {n} is not reused" + assert len(const_names) == 0, f"Not all constants were found: {const_names}" diff --git a/tests/layer_tests/pytest.ini b/tests/layer_tests/pytest.ini index db450888077375..042dbb6d50a1d7 100644 --- a/tests/layer_tests/pytest.ini +++ b/tests/layer_tests/pytest.ini @@ -5,4 +5,5 @@ markers = precommit_tf_fe precommit_ts_backend precommit_fx_backend + precommit_torch_export timeout diff --git a/tests/layer_tests/pytorch_tests/pytorch_layer_test_class.py b/tests/layer_tests/pytorch_tests/pytorch_layer_test_class.py index f89af6688ae3b9..3d9064479787fa 100644 --- a/tests/layer_tests/pytorch_tests/pytorch_layer_test_class.py +++ b/tests/layer_tests/pytorch_tests/pytorch_layer_test_class.py @@ -9,10 +9,12 @@ import numpy as np from common.constants import test_device, test_precision from openvino.frontend.pytorch.ts_decoder import TorchScriptPythonDecoder +from openvino.frontend.pytorch.fx_decoder import TorchFXPythonDecoder from openvino.frontend import FrontEndManager from openvino.runtime import Core, Type, PartialShape import torch +from packaging import version import openvino.frontend.pytorch.torchdynamo.backend @@ -74,27 +76,59 @@ def use_torch_compile_backend(): return True return False + def use_torch_export(): + torch_compile_env = os.getenv("PYTORCH_TRACING_MODE") + if torch_compile_env is not None: + return torch_compile_env == "EXPORT" + return False + ov_inputs = flattenize_inputs(inputs) if use_torch_compile_backend(): self.torch_compile_backend_test(model, torch_inputs, custom_eps) else: - trace_model = kwargs.get('trace_model', False) - freeze_model = kwargs.get('freeze_model', True) - with torch.no_grad(): - if kwargs.get('use_convert_model', False): - smodel, converted_model = self.convert_via_mo( - model, torch_inputs, trace_model, dynamic_shapes, ov_inputs, freeze_model) - else: - smodel, converted_model = self.convert_directly_via_frontend( - model, torch_inputs, trace_model, dynamic_shapes, ov_inputs, freeze_model) - - if kind is not None and not isinstance(kind, (tuple, list)): - kind = [kind] - if kind is not None: - for op in kind: - assert self._check_kind_exist( - smodel.inlined_graph, op), f"Operation {op} type doesn't exist in provided graph" + if use_torch_export(): + from openvino import convert_model + from torch.export import export + from torch.fx.experimental.proxy_tensor import make_fx + + em = export(model, tuple(torch_inputs)) + if version.parse(torch.__version__) >= version.parse("2.2"): + em = em.run_decompositions() + print(em.graph_module.code) + + try: + gm = make_fx(em)(*torch_inputs) + except: + gm = make_fx(em, tracing_mode='symbolic')(*torch_inputs) + + input_shapes = [] + input_types = [] + for input_data in torch_inputs: + input_types.append(input_data.type()) + input_shapes.append(input_data.size()) + + decoder = TorchFXPythonDecoder(gm, gm, input_shapes=input_shapes, input_types=input_types) + converted_model = convert_model(decoder, example_input=torch_inputs) + self._resolve_input_shape_dtype( + converted_model, ov_inputs, dynamic_shapes) + smodel = model + else: + trace_model = kwargs.get('trace_model', False) + freeze_model = kwargs.get('freeze_model', True) + with torch.no_grad(): + if kwargs.get('use_convert_model', False): + smodel, converted_model = self.convert_via_mo( + model, torch_inputs, trace_model, dynamic_shapes, ov_inputs, freeze_model) + else: + smodel, converted_model = self.convert_directly_via_frontend( + model, torch_inputs, trace_model, dynamic_shapes, ov_inputs, freeze_model) + if kind is not None and not isinstance(kind, (tuple, list)): + kind = [kind] + if kind is not None: + for op in kind: + assert self._check_kind_exist( + smodel.inlined_graph, op), f"Operation {op} type doesn't exist in provided graph" # OV infer: core = Core() compiled = core.compile_model(converted_model, ie_device) diff --git a/tests/layer_tests/pytorch_tests/test_adaptive_avg_pool.py b/tests/layer_tests/pytorch_tests/test_adaptive_avg_pool.py index bedd9beb0d4bcf..3b48ef2bfe347c 100644 --- a/tests/layer_tests/pytorch_tests/test_adaptive_avg_pool.py +++ b/tests/layer_tests/pytorch_tests/test_adaptive_avg_pool.py @@ -31,6 +31,7 @@ def forward(self, input_tensor): @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export @pytest.mark.precommit_ts_backend @pytest.mark.precommit_fx_backend def test_adaptive_avg_pool3d(self, ie_device, precision, ir_version, input_tensor, output_size): @@ -61,6 +62,7 @@ def forward(self, input_tensor): @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export @pytest.mark.precommit_ts_backend @pytest.mark.precommit_fx_backend def test_adaptive_avg_pool2d(self, ie_device, precision, ir_version, input_shape, output_size): @@ -91,6 +93,7 @@ def forward(self, input_tensor): @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export @pytest.mark.precommit_ts_backend @pytest.mark.precommit_fx_backend def test_adaptive_avg_pool1d(self, ie_device, precision, ir_version, input_shape, output_size): diff --git a/tests/layer_tests/pytorch_tests/test_adaptive_max_pool.py b/tests/layer_tests/pytorch_tests/test_adaptive_max_pool.py index b80a82a4a9dee7..5ab0da52ff83e0 100644 --- a/tests/layer_tests/pytorch_tests/test_adaptive_max_pool.py +++ b/tests/layer_tests/pytorch_tests/test_adaptive_max_pool.py @@ -47,6 +47,7 @@ def forward(self, input_tensor): ])) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export @pytest.mark.precommit_ts_backend @pytest.mark.precommit_fx_backend @pytest.mark.xfail(condition=platform.system() == 'Darwin' and platform.machine() == 'arm64', @@ -92,6 +93,7 @@ def forward(self, input_tensor): ])) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export @pytest.mark.precommit_ts_backend @pytest.mark.precommit_fx_backend @pytest.mark.xfail(condition=platform.system() == 'Darwin' and platform.machine() == 'arm64', @@ -139,6 +141,7 @@ def forward(self, input_tensor): ])) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export @pytest.mark.precommit_ts_backend @pytest.mark.precommit_fx_backend @pytest.mark.xfail(condition=platform.system() == 'Darwin' and platform.machine() == 'arm64', diff --git a/tests/layer_tests/pytorch_tests/test_addcmul.py b/tests/layer_tests/pytorch_tests/test_addcmul.py index 18acaf7d201ff4..5ac9aa51b5f4a7 100644 --- a/tests/layer_tests/pytorch_tests/test_addcmul.py +++ b/tests/layer_tests/pytorch_tests/test_addcmul.py @@ -46,6 +46,7 @@ def forward(self, x, y, z): ]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_addcmul(self, input_type, value, ie_device, precision, ir_version): self.input_type = input_type self._test(*self.create_model(value), ie_device, precision, ir_version) diff --git a/tests/layer_tests/pytorch_tests/test_addmm.py b/tests/layer_tests/pytorch_tests/test_addmm.py index f73894766e812f..ac5a78c4fb2eea 100644 --- a/tests/layer_tests/pytorch_tests/test_addmm.py +++ b/tests/layer_tests/pytorch_tests/test_addmm.py @@ -44,6 +44,7 @@ def forward(self, m0, m1, m2): (1, 1)]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_addmm(self, kwargs_to_prepare_input, alpha, beta, ie_device, precision, ir_version): self._test(*self.create_model(alpha, beta), ie_device, precision, ir_version, kwargs_to_prepare_input=kwargs_to_prepare_input) @@ -93,6 +94,7 @@ def forward(self, m0, m1, m2): ]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_baddbmm(self, kwargs_to_prepare_input, alpha, beta, ie_device, precision, ir_version): self._test(*self.create_model(alpha, beta), ie_device, precision, ir_version, kwargs_to_prepare_input=kwargs_to_prepare_input) diff --git a/tests/layer_tests/pytorch_tests/test_and.py b/tests/layer_tests/pytorch_tests/test_and.py index 07e9b1d660d6a3..35b3f51ae370fb 100644 --- a/tests/layer_tests/pytorch_tests/test_and.py +++ b/tests/layer_tests/pytorch_tests/test_and.py @@ -50,6 +50,7 @@ def forward(self, int_a: int, int_b: int): @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_and_tensor(self, ie_device, precision, ir_version): self.input_data = ( np.array([True, False, False], dtype=np.bool_), @@ -59,18 +60,21 @@ def test_and_tensor(self, ie_device, precision, ir_version): @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_and_bool(self, ie_device, precision, ir_version): self.input_data = (np.array(True, dtype=np.bool_), np.array(True, dtype=np.bool_)) self._test(*self.create_model_bool_input(), ie_device, precision, ir_version) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_and_int(self, ie_device, precision, ir_version): self.input_data = (np.array(3, dtype=np.int32), np.array(4, dtype=np.int32)) self._test(*self.create_model_int_input(), ie_device, precision, ir_version) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_and_tensor(self, ie_device, precision, ir_version): self.input_data = (np.array([3, 5, 8], dtype=np.int32), np.array([7, 11, 2], dtype=np.int32)) self._test( diff --git a/tests/layer_tests/pytorch_tests/test_as_strided.py b/tests/layer_tests/pytorch_tests/test_as_strided.py index 9bfaa66d3a7f6b..fbacb1c81adf61 100644 --- a/tests/layer_tests/pytorch_tests/test_as_strided.py +++ b/tests/layer_tests/pytorch_tests/test_as_strided.py @@ -40,6 +40,7 @@ def forward(self, x): @pytest.mark.parametrize("offset", [None, 1, 3, 7]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_as_strided(self, size, stride, offset, ie_device, precision, ir_version): self._test(*self.create_model(size, stride, offset), ie_device, precision, ir_version, trace_model=True) @@ -90,6 +91,7 @@ def forward_size_const(self, x, size_shape_tensor, stride_shape_tensor): @pytest.mark.parametrize("mode", ["no_const", "stride_const", "size_const"]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_as_strided_list_construct(self, size, stride, offset, mode, ie_device, precision, ir_version): inp_kwargs = {"size_shape_tensor": size, "stride_shape_tensor": stride} self._test( @@ -121,5 +123,6 @@ def forward(self, x): @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_as_strided_lf(self, ie_device, precision, ir_version): self._test(*self.create_model(), ie_device, precision, ir_version, trace_model=True, freeze_model=False) diff --git a/tests/layer_tests/pytorch_tests/test_batch_norm.py b/tests/layer_tests/pytorch_tests/test_batch_norm.py index 94208c7359a583..2275f53960ae45 100644 --- a/tests/layer_tests/pytorch_tests/test_batch_norm.py +++ b/tests/layer_tests/pytorch_tests/test_batch_norm.py @@ -59,6 +59,7 @@ def forward(self, x): @pytest.mark.precommit @pytest.mark.precommit_ts_backend @pytest.mark.precommit_fx_backend + @pytest.mark.precommit_torch_export def test_batch_norm(self, weights, bias, eps, train, running_stats, ie_device, precision, ir_version, kwargs_to_prepare_input): self._test(*self.create_model(weights, bias, eps, train, running_stats), ie_device, precision, ir_version, kwargs_to_prepare_input=kwargs_to_prepare_input, dynamic_shapes=False, use_mo_convert=False) \ No newline at end of file diff --git a/tests/layer_tests/pytorch_tests/test_broadcast_tensors.py b/tests/layer_tests/pytorch_tests/test_broadcast_tensors.py index b405f0114b5a4b..2042dde0c460ee 100644 --- a/tests/layer_tests/pytorch_tests/test_broadcast_tensors.py +++ b/tests/layer_tests/pytorch_tests/test_broadcast_tensors.py @@ -31,6 +31,7 @@ def forward(self, x, y, z): @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export @pytest.mark.parametrize("x_shape", [[1, ], [2, 1], [2, 2, 1]]) @pytest.mark.parametrize("y_shape", [[2, ], [1, 2], [1, 2, 1]]) @pytest.mark.parametrize("z_shape", [[1, 2], [2, 2], [1, 2, 1, 1]]) diff --git a/tests/layer_tests/pytorch_tests/test_clone.py b/tests/layer_tests/pytorch_tests/test_clone.py index f56aac44e9d575..18e07d0efd01da 100644 --- a/tests/layer_tests/pytorch_tests/test_clone.py +++ b/tests/layer_tests/pytorch_tests/test_clone.py @@ -25,5 +25,6 @@ def forward(self, x): @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_clone(self, ie_device, precision, ir_version): self._test(*self.create_model(), ie_device, precision, ir_version) diff --git a/tests/layer_tests/pytorch_tests/test_conv_transposend.py b/tests/layer_tests/pytorch_tests/test_conv_transposend.py index db0350d649eae8..7b3229188598ec 100644 --- a/tests/layer_tests/pytorch_tests/test_conv_transposend.py +++ b/tests/layer_tests/pytorch_tests/test_conv_transposend.py @@ -62,6 +62,7 @@ def forward(self, x): @pytest.mark.parametrize("bias", [True, False]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_conv_transpose2d(self, params, bias, ie_device, precision, ir_version): self._test(*self.create_model(**params, bias=bias), ie_device, precision, ir_version, dynamic_shapes=params['groups'] == 1) @@ -121,6 +122,7 @@ def forward(self, x): @pytest.mark.parametrize("bias", [True, False]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_conv_transpose1d(self, params, bias, ie_device, precision, ir_version): self._test(*self.create_model(**params, bias=bias), ie_device, precision, ir_version, dynamic_shapes=params['groups'] == 1) @@ -191,6 +193,7 @@ def forward(self, x): @pytest.mark.parametrize("bias", [True, False]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_conv_transpose3d(self, params, bias, ie_device, precision, ir_version): self._test(*self.create_model(**params, bias=bias), ie_device, precision, ir_version, dynamic_shapes=params['groups'] == 1) diff --git a/tests/layer_tests/pytorch_tests/test_convolution.py b/tests/layer_tests/pytorch_tests/test_convolution.py index 5ac994f9d79760..19e4c9b7cee338 100644 --- a/tests/layer_tests/pytorch_tests/test_convolution.py +++ b/tests/layer_tests/pytorch_tests/test_convolution.py @@ -209,6 +209,7 @@ def forward(self, x): @pytest.mark.precommit @pytest.mark.precommit_ts_backend @pytest.mark.precommit_fx_backend + @pytest.mark.precommit_torch_export def test_convolution1d(self, params, bias, underscore, ie_device, precision, ir_version): self._test(*self.create_model(**params, bias=bias, underscore=underscore), ie_device, precision, ir_version, dynamic_shapes=params['groups'] == 1, @@ -221,6 +222,7 @@ def test_convolution1d(self, params, bias, underscore, ie_device, precision, ir_ @pytest.mark.precommit @pytest.mark.precommit_ts_backend @pytest.mark.precommit_fx_backend + @pytest.mark.precommit_torch_export def test_convolution2d(self, params, bias, underscore, ie_device, precision, ir_version): self._test(*self.create_model(**params, bias=bias, underscore=underscore), ie_device, precision, ir_version, dynamic_shapes=params['groups'] == 1) diff --git a/tests/layer_tests/pytorch_tests/test_device.py b/tests/layer_tests/pytorch_tests/test_device.py index 2efdf5c85c50fa..72982f7a6774c3 100644 --- a/tests/layer_tests/pytorch_tests/test_device.py +++ b/tests/layer_tests/pytorch_tests/test_device.py @@ -50,6 +50,7 @@ def forward(self, x): @pytest.mark.parametrize("device_string", ["cpu", "cuda"]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_device(self, device_string, ie_device, precision, ir_version): self._test( *self.create_model_device(device_string), @@ -63,6 +64,7 @@ def test_device(self, device_string, ie_device, precision, ir_version): @pytest.mark.parametrize("device_string", ["cpu", "cuda"]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_device_type(self, device_string, ie_device, precision, ir_version): self._test( *self.create_model_type(device_string), diff --git a/tests/layer_tests/pytorch_tests/test_div.py b/tests/layer_tests/pytorch_tests/test_div.py index 22243e1a591698..a2809b1fa68899 100644 --- a/tests/layer_tests/pytorch_tests/test_div.py +++ b/tests/layer_tests/pytorch_tests/test_div.py @@ -43,6 +43,7 @@ def forward(self, input_tensor, other_tensor): ])) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_div_pt_spec(self, input_array, other_array, rounding_mode, ie_device, precision, ir_version): self.input_array = input_array self.input_type = np.float32 @@ -118,6 +119,7 @@ def forward3(self, lhs, rhs): ])) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export @pytest.mark.xfail(condition=platform.system() in ('Darwin', 'Linux') and platform.machine() in ('arm', 'armv7l', 'aarch64', 'arm64', 'ARM64'), diff --git a/tests/layer_tests/pytorch_tests/test_embedding.py b/tests/layer_tests/pytorch_tests/test_embedding.py index a448e21d3ff04e..901f72d4d761fb 100644 --- a/tests/layer_tests/pytorch_tests/test_embedding.py +++ b/tests/layer_tests/pytorch_tests/test_embedding.py @@ -26,6 +26,7 @@ def forward(self, indicies, weight): @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export @pytest.mark.parametrize("indicies_size", [1, 2, 3, 4]) @pytest.mark.parametrize("indicies_dtype", ["int", "int32"]) def test_embedding(self, ie_device, precision, ir_version, indicies_size, indicies_dtype): diff --git a/tests/layer_tests/pytorch_tests/test_empty.py b/tests/layer_tests/pytorch_tests/test_empty.py index da5cff320f8b93..e358f95c9997c1 100644 --- a/tests/layer_tests/pytorch_tests/test_empty.py +++ b/tests/layer_tests/pytorch_tests/test_empty.py @@ -55,11 +55,11 @@ def _prepare_input(self, shape, dtype=np.float32, out=False): return (np.random.randn(*shape).astype(dtype if dtype is not None else np.float32),) return (np.random.randn(*shape), np.ones(shape, dtype=(dtype if dtype is not None else np.float32))) - def create_model(self, dtype, out): + def create_model(self, dtype, out, no_expose_dtype=False): class aten_empty_like(torch.nn.Module): - def __init__(self, dtype=None, out=False): + def __init__(self, dtype=None, out=False, no_expose_dtype=False): dtype_map = { "float32": torch.float32, "float64": torch.float64, @@ -72,6 +72,8 @@ def __init__(self, dtype=None, out=False): self.dtype = dtype_map.get(dtype, None) if out: self.forward = self.forward_out + if no_expose_dtype: + self.forward = self.forward_input_dtype def forward(self, input_tensor): empty = torch.empty_like(input_tensor, dtype=self.dtype) @@ -80,6 +82,14 @@ def forward(self, input_tensor): # produce sporadic errors if nan would be in empty. return torch.zeros_like(empty) + def forward_input_dtype(self, input_tensor): + # We don't want to compare values, just shape and type, + # so we call zeros_like on data. Multiplying by zero would + # produce sporadic errors if nan would be in empty. + input_tensor.to(self.dtype) + empty = torch.empty_like(input_tensor) + return torch.zeros_like(empty) + def forward_out(self, input_tensor, out_tensor): torch.empty_like(input_tensor, out=out_tensor) # We don't want to compare values, just shape and type, @@ -89,17 +99,25 @@ def forward_out(self, input_tensor, out_tensor): ref_net = None - return aten_empty_like(dtype, out), ref_net, "aten::empty_like" + return aten_empty_like(dtype, out, no_expose_dtype), ref_net, "aten::empty_like" @pytest.mark.parametrize('dtype', (None, "float32", "float64", "int64", "int32", "uint8", "int8")) @pytest.mark.parametrize("input_shape", [[2,], [1, 10], [10, 5, 2]]) @pytest.mark.parametrize("out", [True, False]) @pytest.mark.nightly @pytest.mark.precommit - def test_empty(self, ie_device, precision, ir_version, dtype, input_shape, out): + def test_empty_like(self, ie_device, precision, ir_version, dtype, input_shape, out): self._test(*self.create_model(dtype, out), ie_device, precision, ir_version, kwargs_to_prepare_input={"shape": input_shape, "out": out, "dtype": dtype}) + @pytest.mark.parametrize('dtype', (None, "float32", "float64", "int64", "int32", "uint8", "int8")) + @pytest.mark.parametrize("input_shape", [[2,], [1, 10], [10, 5, 2]]) + @pytest.mark.nightly + @pytest.mark.precommit + def test_empty_like_no_dtype(self, ie_device, precision, ir_version, dtype, input_shape): + self._test(*self.create_model(dtype, out=False, no_expose_dtype=True), ie_device, precision, ir_version, + kwargs_to_prepare_input={"shape": input_shape, "out": False, "dtype": dtype}) + class TestEmptyBoolean(PytorchLayerTest): diff --git a/tests/layer_tests/pytorch_tests/test_eq.py b/tests/layer_tests/pytorch_tests/test_eq.py index 6fa5f4ecfba5eb..1a73084359bdc1 100644 --- a/tests/layer_tests/pytorch_tests/test_eq.py +++ b/tests/layer_tests/pytorch_tests/test_eq.py @@ -40,6 +40,7 @@ def forward(self, input_tensor, other_tensor): ]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_eq_pt_spec(self, input_array, other_array, types, ie_device, precision, ir_version): self.input_array = input_array self.input_type = types[0] diff --git a/tests/layer_tests/pytorch_tests/test_expand.py b/tests/layer_tests/pytorch_tests/test_expand.py index 5848aca8fa8028..63453fce9d1ec6 100644 --- a/tests/layer_tests/pytorch_tests/test_expand.py +++ b/tests/layer_tests/pytorch_tests/test_expand.py @@ -35,6 +35,7 @@ def forward_broadcast(self, x): @pytest.mark.parametrize("op_type", ["expand", "broadcast_to"]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_expand(self, dims, op_type, ie_device, precision, ir_version): self._test(*self.create_model(dims, op_type), ie_device, precision, ir_version) @@ -68,6 +69,7 @@ def forward_broadcast(self, x, y): @pytest.mark.parametrize("op_type", ["expand", "broadcast_to"]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_expand(self, dims, op_type, ie_device, precision, ir_version): self._test(*self.create_model(op_type), ie_device, precision, ir_version, kwargs_to_prepare_input={"broadcast_shape": dims}) @@ -104,6 +106,7 @@ def forward(self, x, y): ]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_expand(self, ie_device, precision, ir_version, kwargs_to_prepare_input): self._test(*self.create_model(), ie_device, precision, ir_version, kwargs_to_prepare_input=kwargs_to_prepare_input) diff --git a/tests/layer_tests/pytorch_tests/test_flatten.py b/tests/layer_tests/pytorch_tests/test_flatten.py index 285c86d812cecf..c696962332545e 100644 --- a/tests/layer_tests/pytorch_tests/test_flatten.py +++ b/tests/layer_tests/pytorch_tests/test_flatten.py @@ -37,6 +37,7 @@ def forward(self, x): [2, 3]]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_flatten(self, dim0, dim1, ie_device, precision, ir_version): self._test(*self.create_model(dim0, dim1), ie_device, precision, ir_version) diff --git a/tests/layer_tests/pytorch_tests/test_floor_divide.py b/tests/layer_tests/pytorch_tests/test_floor_divide.py index 40d1eb5afa7fed..bd8827b258819d 100644 --- a/tests/layer_tests/pytorch_tests/test_floor_divide.py +++ b/tests/layer_tests/pytorch_tests/test_floor_divide.py @@ -51,6 +51,7 @@ def forward(self, input_tensor, other_tensor): ])) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export @pytest.mark.xfail(condition=platform.system() == 'Darwin' and platform.machine() == 'arm64', reason='Ticket - 122715') def test_floor_divide(self, input_tensor, other_tensor, ie_device, precision, ir_version): @@ -79,6 +80,7 @@ def test_floor_divide(self, input_tensor, other_tensor, ie_device, precision, ir ]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_floor_divide_int(self, input_data, other_data, ie_device, precision, ir_version): input_tensor = input_data["tensor"] if type(input_tensor) is list: diff --git a/tests/layer_tests/pytorch_tests/test_gelu.py b/tests/layer_tests/pytorch_tests/test_gelu.py index 87177c4cde67b7..6a6d5e61a57600 100644 --- a/tests/layer_tests/pytorch_tests/test_gelu.py +++ b/tests/layer_tests/pytorch_tests/test_gelu.py @@ -29,6 +29,7 @@ def forward(self, x): @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export @pytest.mark.parametrize("approximate", ["none", "tanh"]) def test_glu(self, approximate, ie_device, precision, ir_version): self._test(*self.create_model(approximate), ie_device, precision, ir_version) \ No newline at end of file diff --git a/tests/layer_tests/pytorch_tests/test_glu.py b/tests/layer_tests/pytorch_tests/test_glu.py index 718604abc7b31c..aa77fb7d77664c 100644 --- a/tests/layer_tests/pytorch_tests/test_glu.py +++ b/tests/layer_tests/pytorch_tests/test_glu.py @@ -29,6 +29,7 @@ def forward(self, x): @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export @pytest.mark.parametrize("dim", [0, 1, 2, 3, -1, -2]) def test_glu(self, dim, ie_device, precision, ir_version): self._test(*self.create_model(dim), ie_device, precision, ir_version) \ No newline at end of file diff --git a/tests/layer_tests/pytorch_tests/test_group_norm.py b/tests/layer_tests/pytorch_tests/test_group_norm.py index effb8ea90485d3..347d1e013a3c3d 100644 --- a/tests/layer_tests/pytorch_tests/test_group_norm.py +++ b/tests/layer_tests/pytorch_tests/test_group_norm.py @@ -53,6 +53,7 @@ def forward(self, x): ]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_group_norm(self, params, ie_device, precision, ir_version, kwargs_to_prepare_input): self._test(*self.create_model(**params), ie_device, precision, ir_version, kwargs_to_prepare_input=kwargs_to_prepare_input) diff --git a/tests/layer_tests/pytorch_tests/test_index.py b/tests/layer_tests/pytorch_tests/test_index.py index 4b4e53690f927e..d7f3a18469a170 100644 --- a/tests/layer_tests/pytorch_tests/test_index.py +++ b/tests/layer_tests/pytorch_tests/test_index.py @@ -3,6 +3,7 @@ import pytest import numpy as np +import torch from pytorch_layer_test_class import PytorchLayerTest @@ -115,6 +116,7 @@ def forward(self, x, y): def test_index_range(self, input_shape, idx, ie_device, precision, ir_version): self._test(*self.create_model(), ie_device, precision, ir_version, kwargs_to_prepare_input={ "input_shape": input_shape, "idx": idx}, trace_model=True, dynamic_shapes=False) + @pytest.mark.nightly @pytest.mark.precommit @pytest.mark.parametrize(("input_shape", "idx"), ( @@ -126,6 +128,7 @@ def test_index_range_free_dims(self, input_shape, idx, ie_device, precision, ir_ self._test(*self.create_model2(), ie_device, precision, ir_version, kwargs_to_prepare_input={ "input_shape": input_shape, "idx": idx}, trace_model=True, dynamic_shapes=False) + class TestIndexMask(PytorchLayerTest): def _prepare_input(self, input_shape): import numpy as np @@ -151,3 +154,27 @@ def forward(self, x): def test_index_mask(self, input_shape, ie_device, precision, ir_version): self._test(*self.create_model(), ie_device, precision, ir_version, kwargs_to_prepare_input={ "input_shape": input_shape}, trace_model=True, use_convert_model=True) + + +class TestIndexNone(PytorchLayerTest): + def _prepare_input(self, input_shape): + import numpy as np + return (np.random.randn(*input_shape).astype(np.float32),) + + class aten_index_list(torch.nn.Module): + def __init__(self, idxs): + super(TestIndexNone.aten_index_list, self).__init__() + self.idxs = idxs + + def forward(self, x): + return x[self.idxs] + + @pytest.mark.nightly + @pytest.mark.parametrize(("input_shape,idxs"), [ + ((2, 3, 4, 5), (torch.unsqueeze(torch.randint(0, 2, [14], dtype=torch.int32), 1),)), + ((2, 3, 4, 5), (torch.unsqueeze(torch.randint(0, 2, [14], dtype=torch.int32), 1), torch.randint(0, 3, [14], dtype=torch.int32))), + ((2, 3, 4, 5), (None, None, torch.unsqueeze(torch.randint(0, 2, [14], dtype=torch.int32), 1), torch.randint(0, 3, [14], dtype=torch.int32))), + ]) + def test_index(self, input_shape, idxs, ie_device, precision, ir_version): + self._test(self.aten_index_list(idxs), None, "aten::index", ie_device, precision, + ir_version,kwargs_to_prepare_input={"input_shape": input_shape}, use_convert_model=True, trace_model=True) diff --git a/tests/layer_tests/pytorch_tests/test_lstm.py b/tests/layer_tests/pytorch_tests/test_lstm.py index 3fef1b1e761d25..8ffc3c73afe111 100644 --- a/tests/layer_tests/pytorch_tests/test_lstm.py +++ b/tests/layer_tests/pytorch_tests/test_lstm.py @@ -22,6 +22,29 @@ def forward(self, input_tensor, h0, c0): return self.lstm(input_tensor, (h0, c0)) +class aten_lstm_packed(torch.nn.Module): + def __init__(self, input_size, hidden_size, num_layers, has_bias, bidirectional, batch_first): + torch.nn.Module.__init__(self) + self.rnn = torch.nn.LSTM(input_size=input_size, + hidden_size=hidden_size, + num_layers=num_layers, + batch_first=batch_first, + bidirectional=bidirectional, + bias=has_bias, + ) + self.batch_first = batch_first + + def forward(self, seq, lengths): + seq1 = torch.nn.utils.rnn.pack_padded_sequence(seq, + lengths, + batch_first=self.batch_first) + seq2, hid2 = self.rnn(seq1) + seq = torch.nn.utils.rnn.pad_packed_sequence(seq2, + batch_first=self.batch_first)[0] + + return seq, hid2 + + class aten_gru(torch.nn.Module): def __init__(self, input_size, hidden_size, num_layers, has_bias, bidirectional, batch_first): torch.nn.Module.__init__(self) @@ -81,6 +104,43 @@ def test_lstm(self, input_size, hidden_size, num_layers, has_bias, bidirectional ie_device, precision, ir_version, trace_model=True) +class TestLSTMPacked(PytorchLayerTest): + def _prepare_input(self): + batch = 15 + if self.batch_first: + input = np.random.randn( + batch, 50, self.input_size).astype(np.float32) + else: + input = np.random.randn( + 50, batch, self.input_size).astype(np.float32) + lengths = np.array(list(sorted(np.random.randint( + 1, 50, [batch - 1]).tolist() + [50], reverse=True)), dtype=np.int32) + return (input, lengths) + + @pytest.mark.parametrize("input_size,hidden_size", [(10, 20),]) + @pytest.mark.parametrize("num_layers", [1, 2, 7]) + @pytest.mark.parametrize("has_bias", [True, False]) + @pytest.mark.parametrize("bidirectional", [True, False]) + @pytest.mark.parametrize("batch_first", [True, False]) + @pytest.mark.nightly + @pytest.mark.precommit + def test_lstm_packed(self, input_size, hidden_size, num_layers, has_bias, bidirectional, batch_first, ie_device, precision, ir_version): + self.input_size = input_size + self.hidden_size = hidden_size + self.num_layers = num_layers + self.bidirectional = bidirectional + self.batch_first = batch_first + self._test(aten_lstm_packed(input_size, hidden_size, num_layers, has_bias, bidirectional, batch_first), + None, + "aten::lstm", + ie_device, + precision, + ir_version, + trace_model=True, + dynamic_shapes=False # ticket 131432 + ) + + class TestGRU(PytorchLayerTest): def _prepare_input(self): n = self.num_layers diff --git a/tests/layer_tests/pytorch_tests/test_mm.py b/tests/layer_tests/pytorch_tests/test_mm.py index b0f920e47f518e..83de1188d11232 100644 --- a/tests/layer_tests/pytorch_tests/test_mm.py +++ b/tests/layer_tests/pytorch_tests/test_mm.py @@ -41,6 +41,7 @@ def forward(self, m1, m2): ]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_mm(self, kwargs_to_prepare_input, ie_device, precision, ir_version): self._test(*self.create_model('aten::mm'), ie_device, precision, ir_version, kwargs_to_prepare_input=kwargs_to_prepare_input) @@ -55,6 +56,7 @@ def test_mm(self, kwargs_to_prepare_input, ie_device, precision, ir_version): ]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_bmm(self, kwargs_to_prepare_input, ie_device, precision, ir_version): self._test(*self.create_model('aten::bmm'), ie_device, precision, ir_version, kwargs_to_prepare_input=kwargs_to_prepare_input) @@ -81,6 +83,7 @@ def test_bmm(self, kwargs_to_prepare_input, ie_device, precision, ir_version): ]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_matmul(self, kwargs_to_prepare_input, ie_device, precision, ir_version): self._test(*self.create_model('aten::matmul'), ie_device, precision, ir_version, kwargs_to_prepare_input=kwargs_to_prepare_input) diff --git a/tests/layer_tests/pytorch_tests/test_mul.py b/tests/layer_tests/pytorch_tests/test_mul.py index c7aea00ee8ad89..1eca86c6e17498 100644 --- a/tests/layer_tests/pytorch_tests/test_mul.py +++ b/tests/layer_tests/pytorch_tests/test_mul.py @@ -32,6 +32,7 @@ def forward(self, input_tensor, other_tensor): ]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_mul_pt_spec(self, input_array, other_array, ie_device, precision, ir_version): self.input_array = input_array self.input_type = np.float32 @@ -100,6 +101,7 @@ def forward3(self, lhs, rhs): ]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_mul_types(self, ie_device, precision, ir_version, lhs_type, lhs_shape, rhs_type, rhs_shape): self.lhs_type = lhs_type self.lhs_shape = lhs_shape diff --git a/tests/layer_tests/pytorch_tests/test_permute.py b/tests/layer_tests/pytorch_tests/test_permute.py index b0efdb72a5d86d..f5a234fc419ccb 100644 --- a/tests/layer_tests/pytorch_tests/test_permute.py +++ b/tests/layer_tests/pytorch_tests/test_permute.py @@ -29,6 +29,7 @@ def forward(self, x): @pytest.mark.parametrize("order", [[0, 2, 3, 1], [0, 3, 1, 2]]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_permute(self, order, ie_device, precision, ir_version): self._test(*self.create_model(order), ie_device, precision, ir_version) @@ -53,5 +54,6 @@ def forward(self, x, y): @pytest.mark.parametrize("order", [[1, 3, 4, 2], [1, 4, 2, 3]]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_permute(self, order, ie_device, precision, ir_version): self._test(*self.create_model(), ie_device, precision, ir_version, kwargs_to_prepare_input={"permute_shape": order}) diff --git a/tests/layer_tests/pytorch_tests/test_reshape.py b/tests/layer_tests/pytorch_tests/test_reshape.py index 5b89cab94d03da..f093c8e3bcbed1 100644 --- a/tests/layer_tests/pytorch_tests/test_reshape.py +++ b/tests/layer_tests/pytorch_tests/test_reshape.py @@ -38,5 +38,6 @@ def forward(self, x): ]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_reshape(self, shape, ie_device, precision, ir_version): self._test(*self.create_model(shape), ie_device, precision, ir_version) diff --git a/tests/layer_tests/pytorch_tests/test_reshape_as.py b/tests/layer_tests/pytorch_tests/test_reshape_as.py index d354a530884a92..1d5c00cc05f283 100644 --- a/tests/layer_tests/pytorch_tests/test_reshape_as.py +++ b/tests/layer_tests/pytorch_tests/test_reshape_as.py @@ -32,6 +32,7 @@ def forward_view(self, input_tensor, shape_tensor): @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export @pytest.mark.parametrize("op", ["reshape_as", "view_as"]) @pytest.mark.parametrize('input_tensor_shapes',( ((3, 6), (2, 9)), ((2, 2, 3), (6, 2)), ((6, 2), (2, 2, 3)))) def test_reshape_as(self, op, input_tensor_shapes, ie_device, precision, ir_version): diff --git a/tests/layer_tests/pytorch_tests/test_resolve_conj_neg.py b/tests/layer_tests/pytorch_tests/test_resolve_conj_neg.py index 87097b88af30aa..b26173e94a2741 100644 --- a/tests/layer_tests/pytorch_tests/test_resolve_conj_neg.py +++ b/tests/layer_tests/pytorch_tests/test_resolve_conj_neg.py @@ -40,6 +40,7 @@ def forward(self, x): @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export @pytest.mark.parametrize("op_type", ["resolve_neg", "resolve_conj"]) @pytest.mark.parametrize("dtype", ["float32", "int32"]) def test_reslove(self, op_type, dtype, ie_device, precision, ir_version): @@ -47,6 +48,7 @@ def test_reslove(self, op_type, dtype, ie_device, precision, ir_version): @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export @pytest.mark.parametrize("op_type", ["resolve_neg", "resolve_conj"]) @pytest.mark.xfail(reason="complex dtype is not supported yet") def test_resolve_complex(self, op_type, ie_device, precision, ir_version): diff --git a/tests/layer_tests/pytorch_tests/test_scaled_dot_product_attention.py b/tests/layer_tests/pytorch_tests/test_scaled_dot_product_attention.py index d442b9e86a424e..94e7b43be85eb9 100644 --- a/tests/layer_tests/pytorch_tests/test_scaled_dot_product_attention.py +++ b/tests/layer_tests/pytorch_tests/test_scaled_dot_product_attention.py @@ -12,13 +12,13 @@ class TestScaledDotProductAttention(PytorchLayerTest): def _prepare_input(self, dtype): return (np.random.randn(1, 2, 8, 4).astype(dtype), np.random.randn(1, 2, 8, 4).astype(dtype), np.random.randn(1, 2, 8, 4).astype(dtype)) - def create_model(self, mask, is_causal, scale, dtype): + def create_model(self, mask, is_causal, dtype): import torch.nn.functional as F import torch class aten_scaled_dot_product_atten(torch.nn.Module): - def __init__(self, mask=False, is_causal=False, scale=False, dtype=np.float32) -> None: + def __init__(self, mask=False, is_causal=False, dtype=np.float32) -> None: super().__init__() self.mask = None if not mask else torch.from_numpy( @@ -28,22 +28,20 @@ def __init__(self, mask=False, is_causal=False, scale=False, dtype=np.float32) - self.mask.to(torch.bool) self.is_causal = False - self.scale = None if not scale else torch.tensor( - 5, dtype=torch.float) - def forward(self, query, key, value): - return F.scaled_dot_product_attention(query, key, value, attn_mask=self.mask, is_causal=self.is_causal, scale=self.scale) - - ref_net = None + # torch export struggles with dynamic scale + a = F.scaled_dot_product_attention(query, key, value, attn_mask=self.mask, is_causal=self.is_causal) + b = F.scaled_dot_product_attention(query, key, value, attn_mask=self.mask, is_causal=self.is_causal, scale=torch.tensor(5, dtype=torch.float)) + return a, b - return aten_scaled_dot_product_atten(mask, is_causal, scale, dtype), ref_net, 'aten::scaled_dot_product_attention' + return aten_scaled_dot_product_atten(mask, is_causal, dtype), None, 'aten::scaled_dot_product_attention' @pytest.mark.nightly @pytest.mark.precommit @pytest.mark.precommit_fx_backend + @pytest.mark.precommit_torch_export @pytest.mark.parametrize(['mask', 'is_causal'], [(False, False), (False, True), (True, True), (True, False)]) - @pytest.mark.parametrize('scale', [False, True]) @pytest.mark.parametrize("dtype", (np.float32, np.float64)) - def test_scaled_dot_product_atten(self, ie_device, precision, ir_version, mask, is_causal, scale, dtype): - self._test(*self.create_model(mask, is_causal, scale, dtype), + def test_scaled_dot_product_atten(self, ie_device, precision, ir_version, mask, is_causal, dtype): + self._test(*self.create_model(mask, is_causal, dtype), ie_device, precision, ir_version, kwargs_to_prepare_input={"dtype": dtype}) diff --git a/tests/layer_tests/pytorch_tests/test_select.py b/tests/layer_tests/pytorch_tests/test_select.py index fd1c325d4a64a6..e11f4a6f102a43 100644 --- a/tests/layer_tests/pytorch_tests/test_select.py +++ b/tests/layer_tests/pytorch_tests/test_select.py @@ -32,6 +32,7 @@ def forward(self, input_tensor): @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_select(self, ie_device, precision, ir_version, input_dim, input_index): self._test(*self.create_model(input_dim, input_index), ie_device, precision, ir_version) diff --git a/tests/layer_tests/pytorch_tests/test_silu.py b/tests/layer_tests/pytorch_tests/test_silu.py index 4477184dba7d2a..3c206b073de1ed 100644 --- a/tests/layer_tests/pytorch_tests/test_silu.py +++ b/tests/layer_tests/pytorch_tests/test_silu.py @@ -28,5 +28,6 @@ def forward(self, x): @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_silu(self, ie_device, precision, ir_version): self._test(*self.create_model(), ie_device, precision, ir_version) diff --git a/tests/layer_tests/pytorch_tests/test_softmax.py b/tests/layer_tests/pytorch_tests/test_softmax.py index eac3f9ba3c6c69..820e99fad178e9 100644 --- a/tests/layer_tests/pytorch_tests/test_softmax.py +++ b/tests/layer_tests/pytorch_tests/test_softmax.py @@ -49,6 +49,7 @@ def forward_prim_dtype(self, x, y): @pytest.mark.parametrize("dim", [-1, 3]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_softmax(self, dim, ie_device, precision, ir_version): self._test(*self.create_model(dim), ie_device, precision, ir_version) @@ -57,6 +58,7 @@ def test_softmax(self, dim, ie_device, precision, ir_version): @pytest.mark.parametrize("use_prim_dtype", [True, False]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_softmax(self, dim, dtype, use_prim_dtype, ie_device, precision, ir_version): input_kwargs = {} if use_prim_dtype: diff --git a/tests/layer_tests/pytorch_tests/test_sub.py b/tests/layer_tests/pytorch_tests/test_sub.py index 5ba3f1a5506053..e24a878239e332 100644 --- a/tests/layer_tests/pytorch_tests/test_sub.py +++ b/tests/layer_tests/pytorch_tests/test_sub.py @@ -110,6 +110,7 @@ def forward3(self, lhs, rhs): ]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_sub_types(self, ie_device, precision, ir_version, lhs_type, lhs_shape, rhs_type, rhs_shape): self.lhs_type = lhs_type self.lhs_shape = lhs_shape diff --git a/tests/layer_tests/pytorch_tests/test_tensor_split.py b/tests/layer_tests/pytorch_tests/test_tensor_split.py index 168cbd6f60f1b1..eeeea7542fb868 100644 --- a/tests/layer_tests/pytorch_tests/test_tensor_split.py +++ b/tests/layer_tests/pytorch_tests/test_tensor_split.py @@ -61,6 +61,7 @@ def forward_4(self, input_tensor): @pytest.mark.parametrize("axis", [0, 1, -1]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_tensor_split(self, input_shape, splits, axis, ie_device, precision, ir_version): self.input_shape = input_shape self._test(*self.create_model(splits, axis), ie_device, precision, ir_version) diff --git a/tests/layer_tests/pytorch_tests/test_type_as.py b/tests/layer_tests/pytorch_tests/test_type_as.py index 35fe0732602097..3f520305794289 100644 --- a/tests/layer_tests/pytorch_tests/test_type_as.py +++ b/tests/layer_tests/pytorch_tests/test_type_as.py @@ -28,6 +28,7 @@ def forward(self, x, y): @pytest.mark.parametrize("cast_dtype", [np.float64, np.float32, np.int64, np.int32, np.int16, np.int8, np.uint8]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_type_as(self, input_dtype, cast_dtype, ie_device, precision, ir_version): self._test(*self.create_model(), ie_device, precision, ir_version, kwargs_to_prepare_input={"input_dtype": input_dtype, "cast_dtype": cast_dtype}) diff --git a/tests/layer_tests/pytorch_tests/test_unflatten.py b/tests/layer_tests/pytorch_tests/test_unflatten.py index 3f8e9de3a2b9f1..0c9537912bf6eb 100644 --- a/tests/layer_tests/pytorch_tests/test_unflatten.py +++ b/tests/layer_tests/pytorch_tests/test_unflatten.py @@ -31,6 +31,7 @@ def forward(self, x): @pytest.mark.parametrize("dtype", ["float32", "int32"]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_unflatten(self, dim, shape, dtype, ie_device, precision, ir_version): self._test(*self.create_model(dim, shape), ie_device, precision, ir_version, kwargs_to_prepare_input={"dtype": dtype}) @@ -65,5 +66,6 @@ def forward(self, x): @pytest.mark.parametrize("dtype", ["float32", "int32"]) @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_unflatten(self, dim, dtype, ie_device, precision, ir_version): self._test(*self.create_model(dim), ie_device, precision, ir_version, kwargs_to_prepare_input={"dtype": dtype}) \ No newline at end of file diff --git a/tests/layer_tests/pytorch_tests/test_unfold.py b/tests/layer_tests/pytorch_tests/test_unfold.py index b4138fa772bb02..37a0e467544e55 100644 --- a/tests/layer_tests/pytorch_tests/test_unfold.py +++ b/tests/layer_tests/pytorch_tests/test_unfold.py @@ -38,6 +38,7 @@ def forward(self, input_tensor): @pytest.mark.nightly @pytest.mark.precommit + @pytest.mark.precommit_torch_export def test_unfold(self, ie_device, precision, ir_version, dimension, size, step, input_shape): self.input_tensor = np.random.randn(*input_shape).astype(np.float32) self._test(*self.create_model(dimension, size, step), diff --git a/tests/layer_tests/tensorflow_tests/test_tf_Conj.py b/tests/layer_tests/tensorflow_tests/test_tf_Conj.py new file mode 100644 index 00000000000000..788dae942d62d5 --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_Conj.py @@ -0,0 +1,61 @@ +# Copyright (C) 2018-2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest +import numpy as np +import tensorflow as tf +from common.tf_layer_test_class import CommonTFLayerTest + +# Testing operation Conj +# Documentation: https://www.tensorflow.org/api_docs/python/tf/raw_ops/Conj + +class TestComplexConjugate(CommonTFLayerTest): + + def _prepare_input(self, inputs_info): + + rng = np.random.default_rng() + assert 'real_part' in inputs_info + real_part_shape = inputs_info['real_part'] + assert 'imag_part' in inputs_info + imag_part_shape = inputs_info['imag_part'] + + inputs_data = {} + inputs_data['real_part'] = 4 * rng.random(real_part_shape).astype(np.float32) - 2 + inputs_data['imag_part'] = 4 * rng.random(imag_part_shape).astype(np.float32) - 2 + + return inputs_data + def create_complex_conjugate_net(self, input_shape): + """ + TensorFlow net IR net + Placeholder->Conjugate => Placeholder->Conjugate + """ + + tf.compat.v1.reset_default_graph() + + # Create the graph and model + with tf.compat.v1.Session() as sess: + real_part = tf.compat.v1.placeholder(np.float32, input_shape, 'real_part') + imag_part = tf.compat.v1.placeholder(np.float32, input_shape, 'imag_part') + + complex_input = tf.raw_ops.Complex(real=real_part, imag=imag_part) + + conj= tf.raw_ops.Conj(input=complex_input, name = "Operation") + real = tf.raw_ops.Real(input=conj) + img = tf.raw_ops.Imag(input=conj) + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + ref_net = None + + return tf_net, ref_net + + + @pytest.mark.parametrize("input_shape", [[1,2], [1,2,3], [1,2,3,4], [1,2,3,4,5,6]]) + @pytest.mark.precommit_tf_fe + @pytest.mark.nightly + def test_conjugate(self, input_shape, ie_device, precision, ir_version, temp_dir, + use_new_frontend): + self._test(*self.create_complex_conjugate_net(input_shape), + ie_device, precision, ir_version, temp_dir=temp_dir, + use_new_frontend=use_new_frontend) \ No newline at end of file diff --git a/tests/layer_tests/tensorflow_tests/test_tf_LookupTableFind.py b/tests/layer_tests/tensorflow_tests/test_tf_LookupTableFind.py new file mode 100644 index 00000000000000..ec49f728e7da7c --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_LookupTableFind.py @@ -0,0 +1,81 @@ +# Copyright (C) 2018-2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import pytest +import tensorflow as tf +from common.tf_layer_test_class import CommonTFLayerTest +from common.utils.tf_utils import mix_array_with_value + +rng = np.random.default_rng() + + +class TestLookupTableFindOps(CommonTFLayerTest): + def _prepare_input(self, inputs_info): + assert 'keys' in inputs_info, "Test error: inputs_info must contain `x`" + keys_shape = inputs_info['keys'] + inputs_data = {} + if np.issubdtype(self.keys_type, np.integer): + data = rng.choice(self.all_keys, keys_shape) + inputs_data['keys'] = mix_array_with_value(data, self.invalid_key) + else: + raise "Unsupported type {}".format(self.keys_type) + + return inputs_data + + def create_lookup_table_find_net(self, hash_table_type, keys_shape, keys_type, values_type, + all_keys, all_values, default_value, invalid_key): + hash_table_op = tf.raw_ops.HashTable if hash_table_type == 0 else tf.raw_ops.HashTableV2 + import_table_op = tf.raw_ops.LookupTableImport if hash_table_type == 0 else tf.raw_ops.LookupTableImportV2 + lookup_table_op = tf.raw_ops.LookupTableFind if hash_table_type == 0 else tf.raw_ops.LookupTableFindV2 + + self.keys_type = keys_type + self.all_keys = all_keys + self.invalid_key = invalid_key + tf.compat.v1.reset_default_graph() + # Create the graph and model + with tf.compat.v1.Session() as sess: + keys = tf.compat.v1.placeholder(keys_type, keys_shape, 'keys') + all_keys = tf.constant(all_keys, dtype=keys_type) + all_values = tf.constant(all_values, dtype=values_type) + default_value = tf.constant(default_value, dtype=values_type) + hash_table = hash_table_op(key_dtype=keys_type, value_dtype=values_type) + import_hash_table = import_table_op(table_handle=hash_table, keys=all_keys, + values=all_values) + with tf.control_dependencies([import_hash_table]): + lookup_table_op(table_handle=hash_table, keys=keys, + default_value=default_value, + name='LookupTableFind') + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + return tf_net, None + + test_data = [ + dict(keys_type=np.int32, values_type=np.float32, all_keys=[0, 1, 2, 3, 4, 5], + all_values=[2.0, 13.0, -2.0, 0.0, 3.0, 1.0], default_value=-100.0, invalid_key=-100), + dict(keys_type=np.int64, values_type=np.int32, all_keys=[0, 1, 2, 3, 4, 5], + all_values=[2, 13, -2, 0, 3, 1], default_value=-100, invalid_key=-100), + dict(keys_type=np.int32, values_type=np.float32, all_keys=[2, 0, 3, -2, 4, 10], + all_values=[2.0, 13.0, -2.0, 0.0, 3.0, 1.0], default_value=-100.0, invalid_key=1000), + dict(keys_type=np.int64, values_type=np.float32, all_keys=[2, 0, 3, -2, 4, 10], + all_values=[2.0, 13.0, -2.0, 0.0, 3.0, 1.0], default_value=-100.0, invalid_key=1000), + pytest.param( + dict(keys_type=np.int32, values_type=tf.string, all_keys=[20, 10, 33, -22, 44, 11], + all_values=['PyTorch', 'TensorFlow', 'JAX', 'Lightning', 'MindSpore', 'OpenVINO'], + default_value='UNKNOWN', invalid_key=1000), + marks=pytest.mark.skip(reason='130688: Gather string support needed')) + ] + + @pytest.mark.parametrize("hash_table_type", [0, 1]) + @pytest.mark.parametrize("keys_shape", [[], [2], [3, 4], [3, 2, 1, 4]]) + @pytest.mark.parametrize("params", test_data) + @pytest.mark.precommit_tf_fe + @pytest.mark.nightly + def test_lookup_table_find(self, hash_table_type, keys_shape, params, ie_device, precision, ir_version, temp_dir, + use_new_frontend): + self._test(*self.create_lookup_table_find_net(hash_table_type=hash_table_type, + keys_shape=keys_shape, **params), + ie_device, precision, ir_version, temp_dir=temp_dir, + use_new_frontend=use_new_frontend) diff --git a/tests/model_hub_tests/models_hub_common/test_convert_model.py b/tests/model_hub_tests/models_hub_common/test_convert_model.py index 40b8a56a997ee3..f2456805d2b68e 100644 --- a/tests/model_hub_tests/models_hub_common/test_convert_model.py +++ b/tests/model_hub_tests/models_hub_common/test_convert_model.py @@ -3,18 +3,13 @@ import gc import numpy as np +# noinspection PyUnresolvedReferences +import openvino_tokenizers # do not delete, needed for text models from models_hub_common.multiprocessing_utils import multiprocessing_run from models_hub_common.utils import compare_two_tensors from openvino import convert_model from openvino.runtime import Core -try: - # 129480 - remove try-except when openvino-tokenizers wheel is built in OpenVINO GHA Workflow - # noinspection PyUnresolvedReferences - import openvino_tokenizers # do not delete, needed for text models -except: - pass - # set seed to have deterministic input data generation # to avoid sporadic issues in inference results rng = np.random.default_rng(seed=56190) diff --git a/tests/model_hub_tests/tf_hub_tests/precommit_models b/tests/model_hub_tests/tf_hub_tests/precommit_models index 4a5ab7f5a2ec70..e59d678d605e48 100644 --- a/tests/model_hub_tests/tf_hub_tests/precommit_models +++ b/tests/model_hub_tests/tf_hub_tests/precommit_models @@ -24,4 +24,4 @@ planet/vision/classifier/planet_v2,https://www.kaggle.com/models/google/planet-v # TF1 models in .pb format i3d-rgb,https://storage.openvinotoolkit.org/repositories/open_model_zoo/public/2022.1/i3d-rgb-tf/rgb.frozen.pb # Model with SentencePiece tokenizer, use openvino-tokenizers package -universal-sentence-encoder-multilingual,https://www.kaggle.com/models/google/universal-sentence-encoder/frameworks/tensorFlow2/variations/multilingual/versions/2,skip, 129480 - Add openvino-tokenizers wheel build to OpenVINO GHA Workflow \ No newline at end of file +universal-sentence-encoder-multilingual,https://www.kaggle.com/models/google/universal-sentence-encoder/frameworks/tensorFlow2/variations/multilingual/versions/2,skip,131659 - UnicodeDecodeError utf-8 codec cannot decode byte for SentencePieceOp attribute sp_model \ No newline at end of file diff --git a/tests/model_hub_tests/torch_tests/requirements.txt b/tests/model_hub_tests/torch_tests/requirements.txt index af6f4cf22128af..b734007dafa15c 100644 --- a/tests/model_hub_tests/torch_tests/requirements.txt +++ b/tests/model_hub_tests/torch_tests/requirements.txt @@ -7,6 +7,7 @@ datasets facexlib numpy optimum +packaging pandas protobuf pyctcdecode diff --git a/tests/model_hub_tests/torch_tests/test_aliked.py b/tests/model_hub_tests/torch_tests/test_aliked.py index ad29187de068ce..a2e93c7ce3c0b2 100644 --- a/tests/model_hub_tests/torch_tests/test_aliked.py +++ b/tests/model_hub_tests/torch_tests/test_aliked.py @@ -84,7 +84,7 @@ def setup_class(self): subprocess.check_call(["sh", "build.sh"], cwd=os.path.join( self.repo_dir.name, "custom_ops")) - def load_model(self, model_name, model_link): + def load_model_impl(self, model_name, model_link): sys.path.append(self.repo_dir.name) from nets.aliked import ALIKED diff --git a/tests/model_hub_tests/torch_tests/test_detectron2.py b/tests/model_hub_tests/torch_tests/test_detectron2.py index 5c2ea9a1d9e153..0c6c9eddb0f8ea 100644 --- a/tests/model_hub_tests/torch_tests/test_detectron2.py +++ b/tests/model_hub_tests/torch_tests/test_detectron2.py @@ -23,7 +23,7 @@ def setup_class(self): subprocess.run([sys.executable, "-m", "pip", "install", "git+https://github.com/facebookresearch/detectron2.git@017abbfa5f2c2a2afa045200c2af9ccf2fc6227f"]) - def load_model(self, model_name, model_link): + def load_model_impl(self, model_name, model_link): from detectron2 import model_zoo, export from detectron2.modeling import build_model, PanopticFPN from detectron2.checkpoint import DetectionCheckpointer diff --git a/tests/model_hub_tests/torch_tests/test_edsr.py b/tests/model_hub_tests/torch_tests/test_edsr.py index 9d4a9d183e85e6..960af9fd5586cf 100644 --- a/tests/model_hub_tests/torch_tests/test_edsr.py +++ b/tests/model_hub_tests/torch_tests/test_edsr.py @@ -38,7 +38,7 @@ class TestEdsrConvertModel(TestTorchConvertModel): - def load_model(self, model_name, model_link): + def load_model_impl(self, model_name, model_link): # image link from https://github.com/eugenesiow/super-image url = 'https://paperswithcode.com/media/datasets/Set5-0000002728-07a9793f_zA3bDjj.jpg' image = Image.open(requests.get(url, stream=True).raw) diff --git a/tests/model_hub_tests/torch_tests/test_gfpgan.py b/tests/model_hub_tests/torch_tests/test_gfpgan.py index 90784926183906..ca22789023b648 100644 --- a/tests/model_hub_tests/torch_tests/test_gfpgan.py +++ b/tests/model_hub_tests/torch_tests/test_gfpgan.py @@ -28,7 +28,7 @@ def setup_class(self): subprocess.check_call( ["wget", "-nv", checkpoint_url], cwd=self.repo_dir.name) - def load_model(self, model_name, model_link): + def load_model_impl(self, model_name, model_link): sys.path.append(self.repo_dir.name) from gfpgan import GFPGANer diff --git a/tests/model_hub_tests/torch_tests/test_hf_transformers.py b/tests/model_hub_tests/torch_tests/test_hf_transformers.py index 1e8c3d76983120..b6360ae6ca0dab 100644 --- a/tests/model_hub_tests/torch_tests/test_hf_transformers.py +++ b/tests/model_hub_tests/torch_tests/test_hf_transformers.py @@ -98,7 +98,7 @@ def setup_class(self): self.image = Image.open(requests.get(url, stream=True).raw) self.cuda_available, self.gptq_postinit = None, None - def load_model(self, name, type): + def load_model_impl(self, name, type): import torch name_suffix = '' from transformers import AutoConfig diff --git a/tests/model_hub_tests/torch_tests/test_speech-transformer.py b/tests/model_hub_tests/torch_tests/test_speech-transformer.py index e08526d7a7b553..a9e7013bdd2cb4 100644 --- a/tests/model_hub_tests/torch_tests/test_speech-transformer.py +++ b/tests/model_hub_tests/torch_tests/test_speech-transformer.py @@ -24,7 +24,7 @@ def setup_class(self): checkpoint_url = "https://github.com/foamliu/Speech-Transformer/releases/download/v1.0/speech-transformer-cn.pt" subprocess.check_call(["wget", "-nv", checkpoint_url], cwd=self.repo_dir.name) - def load_model(self, model_name, model_link): + def load_model_impl(self, model_name, model_link): sys.path.append(self.repo_dir.name) from transformer.transformer import Transformer diff --git a/tests/model_hub_tests/torch_tests/test_timm.py b/tests/model_hub_tests/torch_tests/test_timm.py index 5805bfb82dd4bf..406ff6dc9f16a6 100644 --- a/tests/model_hub_tests/torch_tests/test_timm.py +++ b/tests/model_hub_tests/torch_tests/test_timm.py @@ -10,6 +10,9 @@ from models_hub_common.utils import cleanup_dir, get_models_list from torch_utils import TestTorchConvertModel, process_pytest_marks +from openvino import convert_model +from torch.export import export +from packaging import version def filter_timm(timm_list: list) -> list: @@ -47,7 +50,7 @@ def get_all_models() -> list: class TestTimmConvertModel(TestTorchConvertModel): - def load_model(self, model_name, model_link): + def load_model_impl(self, model_name, model_link): m = timm.create_model(model_name, pretrained=True) cfg = timm.get_pretrained_cfg(model_name) shape = [1] + list(cfg.input_size) @@ -78,11 +81,14 @@ def teardown_method(self): "sequencer2d_l.in1k"]) @pytest.mark.precommit def test_convert_model_precommit(self, name, ie_device): + self.mode = "trace" self.run(name, None, ie_device) @pytest.mark.nightly + @pytest.mark.parametrize("mode", ["trace"]) # disable "export" for now @pytest.mark.parametrize("name", get_all_models()) - def test_convert_model_all_models(self, name, ie_device): + def test_convert_model_all_models(self, mode, name, ie_device): + self.mode = mode self.run(name, None, ie_device) @pytest.mark.nightly diff --git a/tests/model_hub_tests/torch_tests/test_torchbench.py b/tests/model_hub_tests/torch_tests/test_torchbench.py index 04c2c96de0ae63..c0fba6b605e0b6 100644 --- a/tests/model_hub_tests/torch_tests/test_torchbench.py +++ b/tests/model_hub_tests/torch_tests/test_torchbench.py @@ -30,7 +30,7 @@ def setup_class(self): subprocess.check_call( ["git", "checkout", "850364ac2678b2363f086b7549254b6cb7df2e4d"], cwd=self.repo_dir.name) - def load_model(self, model_name, model_link): + def load_model_impl(self, model_name, model_link): subprocess.check_call([sys.executable, "install.py"] + [model_name], cwd=self.repo_dir.name) sys.path.append(self.repo_dir.name) from torchbenchmark import load_model_by_name diff --git a/tests/model_hub_tests/torch_tests/test_torchvision_models.py b/tests/model_hub_tests/torch_tests/test_torchvision_models.py index 56ee127c3c701c..eb075baeec0fce 100644 --- a/tests/model_hub_tests/torch_tests/test_torchvision_models.py +++ b/tests/model_hub_tests/torch_tests/test_torchvision_models.py @@ -59,7 +59,7 @@ def setup_class(self): if os.environ.get('USE_SYSTEM_CACHE', 'True') == 'False': torch.hub.set_dir(str(self.cache_dir.name)) - def load_model(self, model_name, model_link): + def load_model_impl(self, model_name, model_link): m = torch.hub.load("pytorch/vision", model_name, weights='DEFAULT', skip_validation=True) m.eval() @@ -105,10 +105,19 @@ def teardown_method(self): @pytest.mark.parametrize("model_name", ["efficientnet_b7", "raft_small", "swin_v2_s"]) @pytest.mark.precommit def test_convert_model_precommit(self, model_name, ie_device): + self.mode = "trace" self.run(model_name, None, ie_device) + @pytest.mark.parametrize("model_name", ["efficientnet_b7"]) + @pytest.mark.precommit + def test_convert_model_precommit_export(self, model_name, ie_device): + self.mode = "export" + self.run(model_name, None, ie_device) + + @pytest.mark.parametrize("mode", ["trace", "export"]) @pytest.mark.parametrize("name", process_pytest_marks(os.path.join(os.path.dirname(__file__), "torchvision_models"))) @pytest.mark.nightly - def test_convert_model_all_models(self, name, ie_device): + def test_convert_model_all_models(self, mode, name, ie_device): + self.mode = mode self.run(name, None, ie_device) diff --git a/tests/model_hub_tests/torch_tests/torch_utils.py b/tests/model_hub_tests/torch_tests/torch_utils.py index 87c9aeb043f596..92bc08ee73e4cf 100644 --- a/tests/model_hub_tests/torch_tests/torch_utils.py +++ b/tests/model_hub_tests/torch_tests/torch_utils.py @@ -45,10 +45,19 @@ def extract_unsupported_ops_from_exception(e: str) -> list: class TestTorchConvertModel(TestConvertModel): + cached_model = None def setup_class(self): torch.set_grad_enabled(False) def load_model(self, model_name, model_link): + if self.cached_model is not None and self.cached_model[0] == model_name and self.cached_model[1] == model_link: + return self.cached_model[2] + else: + res = self.load_model_impl(model_name, model_link) + self.cached_model = (model_name, model_link, res) + return res + + def load_model_impl(self, model_name, model_link): raise "load_model is not implemented" def get_inputs_info(self, model_obj): @@ -61,10 +70,40 @@ def prepare_inputs(self, inputs_info): else: return flattenize_structure(inputs) + def convert_model_impl(self, model_obj): + if hasattr(self, "mode") and self.mode == "export": + from torch.fx.experimental.proxy_tensor import make_fx + from torch.export import export + from packaging import version + from openvino.frontend.pytorch.fx_decoder import TorchFXPythonDecoder + + graph = export(model_obj, self.example) + if version.parse(torch.__version__) >= version.parse("2.2"): + graph = graph.run_decompositions() + + try: + gm = make_fx(graph)(*self.example) + except: + gm = make_fx(graph, tracing_mode='symbolic')(*self.example) + + input_shapes = [] + input_types = [] + for input_data in self.example: + input_types.append(input_data.type()) + input_shapes.append(input_data.size()) + + decoder = TorchFXPythonDecoder(gm, gm, input_shapes=input_shapes, input_types=input_types) + ov_model = convert_model(decoder, example_input=self.example) + else: + ov_model = convert_model(model_obj, + example_input=self.example, + verbose=True + ) + return ov_model + def convert_model(self, model_obj): try: - ov_model = convert_model( - model_obj, example_input=self.example, verbose=True) + ov_model = self.convert_model_impl(model_obj) except Exception as e: report_filename = os.environ.get("OP_REPORT_FILE", None) if report_filename: diff --git a/tests/samples_tests/smoke_tests/README.md b/tests/samples_tests/smoke_tests/README.md index 88e4c91af8a899..b0a56bada5d58a 100644 --- a/tests/samples_tests/smoke_tests/README.md +++ b/tests/samples_tests/smoke_tests/README.md @@ -5,14 +5,16 @@ These tests execute IE samples on pregenerated IR You can run tests not only from the , but in this case you need to remember to adjust the environment variables like as WORKSPACE and SHARE To install smoke tests: - ``` bash - - cd /tests/samples_tests/smoke_tests - - mkdir build && cd build - - cmake ../.. - - cmake -DCOMPONENT=tests -DCMAKE_INSTALL_PREFIX= -P cmake_install.cmake - ``` -1. To run tests from install directory required installing some dependencies: - - pip3 install -r \tests\smoke_tests\requirements.txt +``` bash +cd /tests/samples_tests/smoke_tests +mkdir build && cd build +cmake ../.. +cmake -DCOMPONENT=tests -DCMAKE_INSTALL_PREFIX= -P cmake_install.cmake +``` +1. To run tests from install directory required installing some dependencies: + ``` bash + pip3 install -r \tests\smoke_tests\requirements.txt + ``` 2. Call setupvars script and then set the environment variables: a. Required: - IE_APP_PATH : coomon path to C++ and C samples, e.g. '/samples_bin' @@ -23,10 +25,14 @@ b. Optional: 3. Configure env_config.yml according to your paths: - Set WORKSPACE : working directory, e.g. '' - Set SHARE : path to loaded data with models, e.g. '/tests/smoke_tests/samples_smoke_tests_data/' -4. Run all test via pytest: - - python -m pytest --env_conf env_config.yml -s +4. Run all test via pytest: + ``` bash + python -m pytest --env_conf env_config.yml -s + ``` 5. Run only one sample (for example, classification_sample_async): - - python -m pytest test_classification_sample_async.py --env_conf env_config.yml -s + ``` bash + python -m pytest test_classification_sample_async.py --env_conf env_config.yml -s + ``` 6. To run performance add pytest key: "performance n", where n is number of perf iteration. Test finds in output of sample 'fps', if it exists, then tests rerun that sample adding key 'niter n' with number of perfomance run (that you passed to pytest with '--performance n' keys) diff --git a/tests/time_tests/include/timetests_helper/utils.h b/tests/time_tests/include/timetests_helper/utils.h index fe6da33cd1905f..c7a39a8174a99d 100644 --- a/tests/time_tests/include/timetests_helper/utils.h +++ b/tests/time_tests/include/timetests_helper/utils.h @@ -5,7 +5,6 @@ #pragma once #include -#include #include diff --git a/tests/time_tests/src/timetests/timetest_infer_api_2.cpp b/tests/time_tests/src/timetests/timetest_infer_api_2.cpp index 77b997e0d6ad66..5ee65d192f736c 100644 --- a/tests/time_tests/src/timetests/timetest_infer_api_2.cpp +++ b/tests/time_tests/src/timetests/timetest_infer_api_2.cpp @@ -58,7 +58,7 @@ int runPipeline(const std::string &model, const std::string &device, const bool ie.get_versions(device_prefix); if (isCacheEnabled) - ie.set_property({{CONFIG_KEY(CACHE_DIR), "models_cache"}}); + ie.set_property({ov::cache_dir("models_cache")}); } { SCOPED_TIMER(create_exenetwork); diff --git a/thirdparty/cnpy/CMakeLists.txt b/thirdparty/cnpy/CMakeLists.txt index c10d23301d9113..c418256aed012b 100644 --- a/thirdparty/cnpy/CMakeLists.txt +++ b/thirdparty/cnpy/CMakeLists.txt @@ -4,16 +4,17 @@ project(cnpy) -set(TARGET_NAME "cnpy") +set(TARGET_NAME "openvino_cnpy") add_library(${TARGET_NAME} STATIC cnpy.cpp) +add_library(openvino::cnpy ALIAS ${TARGET_NAME}) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$") target_compile_options(${TARGET_NAME} PUBLIC -Wno-unused-variable PRIVATE -Wno-all) endif() -target_link_libraries(${TARGET_NAME} PUBLIC ZLIB::ZLIB) +target_link_libraries(${TARGET_NAME} PUBLIC openvino::zlib) target_include_directories(${TARGET_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") set_target_properties(${TARGET_NAME} PROPERTIES FOLDER thirdparty) diff --git a/thirdparty/open_model_zoo b/thirdparty/open_model_zoo index e8fb4cd86a516c..126fac1894c806 160000 --- a/thirdparty/open_model_zoo +++ b/thirdparty/open_model_zoo @@ -1 +1 @@ -Subproject commit e8fb4cd86a516ce5765290e9665f8afe87b79b2e +Subproject commit 126fac1894c806190a0e0a9737b5fc692d7f4baa diff --git a/thirdparty/zlib/CMakeLists.txt b/thirdparty/zlib/CMakeLists.txt index f52d7bd027b1e5..53974f8029ad7e 100644 --- a/thirdparty/zlib/CMakeLists.txt +++ b/thirdparty/zlib/CMakeLists.txt @@ -24,7 +24,7 @@ else() endif() endif() -set(TARGET_NAME "zlib") +set(TARGET_NAME "openvino_zlib") set(zlib_srcs zlib/adler32.c @@ -59,7 +59,7 @@ set(zlib_ext_hdrs zlib/zconf.h) add_library(${TARGET_NAME} STATIC ${zlib_srcs} ${zlib_hdrs} ${lib_ext_hdrs}) -add_library(ZLIB::ZLIB ALIAS ${TARGET_NAME}) +add_library(openvino::zlib ALIAS ${TARGET_NAME}) target_include_directories(${TARGET_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/zlib") diff --git a/tools/benchmark_tool/openvino/__init__.py b/tools/benchmark_tool/openvino/__init__.py index 1d75589bd2eceb..9db717409cf327 100644 --- a/tools/benchmark_tool/openvino/__init__.py +++ b/tools/benchmark_tool/openvino/__init__.py @@ -23,7 +23,7 @@ from openvino import helpers as helpers from openvino import preprocess as preprocess from openvino import utils as utils -from openvino.runtime import properties as properties +from openvino import properties as properties # Import most important classes and functions from openvino.runtime from openvino.runtime import Model diff --git a/tools/benchmark_tool/openvino/tools/benchmark/main.py b/tools/benchmark_tool/openvino/tools/benchmark/main.py index b5eff49d6ba7ce..75dc3083e3ed0b 100644 --- a/tools/benchmark_tool/openvino/tools/benchmark/main.py +++ b/tools/benchmark_tool/openvino/tools/benchmark/main.py @@ -447,7 +447,7 @@ def set_nthreads_pin(property_name, property_value): keys = compiled_model.get_property(properties.supported_properties()) logger.info("Model:") for k in keys: - skip_keys = ('SUPPORTED_METRICS', 'SUPPORTED_CONFIG_KEYS', properties.supported_properties()) + skip_keys = (properties.supported_properties()) if k not in skip_keys: value = compiled_model.get_property(k) if k == properties.device.properties(): diff --git a/tools/mo/openvino/__init__.py b/tools/mo/openvino/__init__.py index 635bae28670cc6..9701fe0a9a45a6 100644 --- a/tools/mo/openvino/__init__.py +++ b/tools/mo/openvino/__init__.py @@ -20,7 +20,7 @@ from openvino import helpers as helpers from openvino import preprocess as preprocess from openvino import utils as utils - from openvino.runtime import properties as properties + from openvino import properties as properties # Import most important classes and functions from openvino.runtime from openvino.runtime import Model diff --git a/tools/mo/openvino/tools/mo/front/tf/loader.py b/tools/mo/openvino/tools/mo/front/tf/loader.py index 310cb08f129a54..9bcf87cfa23d35 100644 --- a/tools/mo/openvino/tools/mo/front/tf/loader.py +++ b/tools/mo/openvino/tools/mo/front/tf/loader.py @@ -207,7 +207,7 @@ def prepare_graph_def(model): for node in nodes_to_clear_device: node.device = "" return model, {}, "tf", None - if isinstance(model, tf.keras.Model): + if isinstance(model, tf.keras.Model): # pylint: disable=no-member assert hasattr(model, "inputs") and model.inputs is not None, "Model inputs specification is required." @@ -215,7 +215,7 @@ def prepare_graph_def(model): for inp in model.inputs: if isinstance(inp, tf.Tensor): model_inputs.append(inp) - elif tf.keras.backend.is_keras_tensor(inp): + elif tf.keras.backend.is_keras_tensor(inp): # pylint: disable=no-member model_inputs.append(inp.type_spec) else: raise Error("Unknown input tensor type {}".format(type(input))) @@ -308,7 +308,7 @@ def load_tf_graph_def(graph_file_name: str = "", is_binary: bool = True, checkpo # Code to extract Keras model. # tf.keras.models.load_model function throws TypeError,KeyError or IndexError # for TF 1.x SavedModel format in case TF 1.x installed - imported = tf.keras.models.load_model(model_dir, compile=False) + imported = tf.keras.models.load_model(model_dir, compile=False) # pylint: disable=no-member except: imported = tf.saved_model.load(model_dir, saved_model_tags) # pylint: disable=E1120 diff --git a/tools/mo/openvino/tools/mo/utils/telemetry_utils.py b/tools/mo/openvino/tools/mo/utils/telemetry_utils.py index e2cdd0b53f61d0..7056c861f18fad 100644 --- a/tools/mo/openvino/tools/mo/utils/telemetry_utils.py +++ b/tools/mo/openvino/tools/mo/utils/telemetry_utils.py @@ -22,13 +22,41 @@ def init_mo_telemetry(app_name='Model Optimizer'): - return tm.Telemetry(tid=get_tid(), - app_name=app_name, - app_version=get_rt_version(), - backend='ga4', - enable_opt_in_dialog=False, - disable_in_ci=True - ) + return init_telemetry_class(tid=get_tid(), + app_name=app_name, + app_version=get_rt_version(), + backend='ga4', + enable_opt_in_dialog=False, + disable_in_ci=True + ) + + +def init_telemetry_class(tid, + app_name, + app_version, + backend, + enable_opt_in_dialog, + disable_in_ci): + # Init telemetry class + telemetry = tm.Telemetry(tid=tid, + app_name=app_name, + app_version=app_version, + backend=backend, + enable_opt_in_dialog=enable_opt_in_dialog, + disable_in_ci=disable_in_ci) + + # Telemetry is a singleton class and if it was already initialized in another tool + # some parameters will be incorrect, including app_name. + # In this case we need to force reinitialisation of telemetry. + if hasattr(telemetry, "backend") and telemetry.backend.app_name != app_name: + telemetry.init(tid=tid, + app_name=app_name, + app_version=app_version, + backend=backend, + enable_opt_in_dialog=enable_opt_in_dialog, + disable_in_ci=disable_in_ci) + return telemetry + def send_framework_info(framework: str): """ diff --git a/tools/openvino_dev/src/openvino/__init__.py b/tools/openvino_dev/src/openvino/__init__.py index 635bae28670cc6..9701fe0a9a45a6 100644 --- a/tools/openvino_dev/src/openvino/__init__.py +++ b/tools/openvino_dev/src/openvino/__init__.py @@ -20,7 +20,7 @@ from openvino import helpers as helpers from openvino import preprocess as preprocess from openvino import utils as utils - from openvino.runtime import properties as properties + from openvino import properties as properties # Import most important classes and functions from openvino.runtime from openvino.runtime import Model diff --git a/tools/ovc/openvino/__init__.py b/tools/ovc/openvino/__init__.py index 1d75589bd2eceb..9db717409cf327 100644 --- a/tools/ovc/openvino/__init__.py +++ b/tools/ovc/openvino/__init__.py @@ -23,7 +23,7 @@ from openvino import helpers as helpers from openvino import preprocess as preprocess from openvino import utils as utils -from openvino.runtime import properties as properties +from openvino import properties as properties # Import most important classes and functions from openvino.runtime from openvino.runtime import Model diff --git a/tools/ovc/openvino/tools/ovc/convert_impl.py b/tools/ovc/openvino/tools/ovc/convert_impl.py index dbfb2c440a6ccc..9594b3ae796078 100644 --- a/tools/ovc/openvino/tools/ovc/convert_impl.py +++ b/tools/ovc/openvino/tools/ovc/convert_impl.py @@ -190,12 +190,13 @@ def check_model_object(argv): return "tf" if 'torch' in sys.modules: import torch - if isinstance(model, (torch.nn.Module, torch.jit.ScriptFunction)): + if isinstance(model, (torch.nn.Module, torch.jit.ScriptFunction)) or (hasattr(torch, "export") and isinstance(model, (torch.export.ExportedProgram))): return "pytorch" try: from openvino.frontend.pytorch.ts_decoder import TorchScriptPythonDecoder + from openvino.frontend.pytorch.fx_decoder import TorchFXPythonDecoder - if isinstance(model, TorchScriptPythonDecoder): + if isinstance(model, (TorchScriptPythonDecoder, TorchFXPythonDecoder)): return "pytorch" except Exception as e: pass diff --git a/tools/ovc/openvino/tools/ovc/logger.py b/tools/ovc/openvino/tools/ovc/logger.py index cda6b40085e640..0b96b44672f075 100644 --- a/tools/ovc/openvino/tools/ovc/logger.py +++ b/tools/ovc/openvino/tools/ovc/logger.py @@ -10,7 +10,7 @@ # WA for abseil bug that affects logging while importing TF starting 1.14 version # Link to original issue: https://github.com/abseil/abseil-py/issues/99 if importlib.util.find_spec('absl') is not None: - import absl.logging + import absl.logging # pylint: disable=import-error log.root.removeHandler(absl.logging._absl_handler) diff --git a/tools/ovc/openvino/tools/ovc/moc_frontend/pytorch_frontend_utils.py b/tools/ovc/openvino/tools/ovc/moc_frontend/pytorch_frontend_utils.py index 3a24e84af1ae9a..fa669ba646690d 100644 --- a/tools/ovc/openvino/tools/ovc/moc_frontend/pytorch_frontend_utils.py +++ b/tools/ovc/openvino/tools/ovc/moc_frontend/pytorch_frontend_utils.py @@ -13,6 +13,8 @@ def get_pytorch_decoder(model, example_inputs, args): try: from openvino.frontend.pytorch.ts_decoder import TorchScriptPythonDecoder + from openvino.frontend.pytorch.fx_decoder import TorchFXPythonDecoder + import torch except Exception as e: log.error("PyTorch frontend loading failed") raise e @@ -31,8 +33,11 @@ def get_pytorch_decoder(model, example_inputs, args): raise RuntimeError( "NNCF models produced by nncf<2.6 are not supported directly. Please upgrade nncf or export to ONNX first.") inputs = prepare_torch_inputs(example_inputs) - if not isinstance(model, TorchScriptPythonDecoder): - decoder = TorchScriptPythonDecoder(model, example_input=inputs, shared_memory=args.get("share_weights", True)) + if not isinstance(model, (TorchScriptPythonDecoder, TorchFXPythonDecoder)): + if hasattr(torch, "export") and isinstance(model, (torch.export.ExportedProgram)): + raise RuntimeError("Models received from torch.export are not yet supported by convert_model.") + else: + decoder = TorchScriptPythonDecoder(model, example_input=inputs, shared_memory=args.get("share_weights", True)) else: decoder = model args['input_model'] = decoder diff --git a/tools/ovc/openvino/tools/ovc/moc_frontend/shape_utils.py b/tools/ovc/openvino/tools/ovc/moc_frontend/shape_utils.py index f80157fc4a92dd..2c746ef384e625 100644 --- a/tools/ovc/openvino/tools/ovc/moc_frontend/shape_utils.py +++ b/tools/ovc/openvino/tools/ovc/moc_frontend/shape_utils.py @@ -76,7 +76,7 @@ def tensor_to_int_list(tensor): def to_partial_shape(shape): if 'tensorflow' in sys.modules: - import tensorflow as tf + import tensorflow as tf # pylint: disable=import-error if isinstance(shape, tf.Tensor): return PartialShape(tensor_to_int_list(shape)) if isinstance(shape, tf.TensorShape): @@ -92,7 +92,7 @@ def is_shape_type(value): if isinstance(value, PartialShape): return True if 'tensorflow' in sys.modules: - import tensorflow as tf + import tensorflow as tf # pylint: disable=import-error if isinstance(value, (tf.TensorShape, tf.Tensor)): return True if 'paddle' in sys.modules: diff --git a/tools/ovc/openvino/tools/ovc/moc_frontend/type_utils.py b/tools/ovc/openvino/tools/ovc/moc_frontend/type_utils.py index fba47fa4c06b7e..372dd42542913b 100644 --- a/tools/ovc/openvino/tools/ovc/moc_frontend/type_utils.py +++ b/tools/ovc/openvino/tools/ovc/moc_frontend/type_utils.py @@ -11,7 +11,7 @@ def is_type(val): if isinstance(val, (type, Type)): return True if 'tensorflow' in sys.modules: - import tensorflow as tf + import tensorflow as tf # pylint: disable=import-error if isinstance(val, tf.dtypes.DType): return True if 'torch' in sys.modules: @@ -31,7 +31,7 @@ def to_ov_type(val): if isinstance(val, type): return Type(val) if 'tensorflow' in sys.modules: - import tensorflow as tf + import tensorflow as tf # pylint: disable=import-error if isinstance(val, tf.dtypes.DType): return Type(val.as_numpy_dtype()) if 'torch' in sys.modules: diff --git a/tools/ovc/openvino/tools/ovc/telemetry_utils.py b/tools/ovc/openvino/tools/ovc/telemetry_utils.py index b1d9d05efe1ce0..544ca1fe413687 100644 --- a/tools/ovc/openvino/tools/ovc/telemetry_utils.py +++ b/tools/ovc/openvino/tools/ovc/telemetry_utils.py @@ -17,13 +17,40 @@ def init_mo_telemetry(app_name='Model Conversion API'): - return tm.Telemetry(tid=get_tid(), - app_name=app_name, - app_version=get_rt_version(), - backend='ga4', - enable_opt_in_dialog=False, - disable_in_ci=True - ) + return init_telemetry_class(tid=get_tid(), + app_name=app_name, + app_version=get_rt_version(), + backend='ga4', + enable_opt_in_dialog=False, + disable_in_ci=True + ) + + +def init_telemetry_class(tid, + app_name, + app_version, + backend, + enable_opt_in_dialog, + disable_in_ci): + # Init telemetry class + telemetry = tm.Telemetry(tid=tid, + app_name=app_name, + app_version=app_version, + backend=backend, + enable_opt_in_dialog=enable_opt_in_dialog, + disable_in_ci=disable_in_ci) + + # Telemetry is a singleton class and if it was already initialized in another tool + # some parameters will be incorrect, including app_name. + # In this case we need to force reinitialisation of telemetry. + if hasattr(telemetry, "backend") and telemetry.backend.app_name != app_name: + telemetry.init(tid=tid, + app_name=app_name, + app_version=app_version, + backend=backend, + enable_opt_in_dialog=enable_opt_in_dialog, + disable_in_ci=disable_in_ci) + return telemetry def send_framework_info(framework: str):